delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/06/20/13:04:21

From: Martin Str|mberg <ams AT ludd DOT luth DOT se>
Message-Id: <200106201703.TAA22756@father.ludd.luth.se>
Subject: Re: Casting left side to unsigned or right side to signed?
In-Reply-To: <8361-Wed20Jun2001110123+0300-eliz@is.elta.co.il> from Eli Zaretskii at "Jun 20, 2001 11:01:23 am"
To: djgpp-workers AT delorie DOT com
Date: Wed, 20 Jun 2001 19:03:03 +0200 (MET DST)
X-Mailer: ELM [version 2.4ME+ PL54 (25)]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

According to Eli Zaretskii:
> > Which way is best to go? Casting left side to unsigned or right side
> > to signed?
> 
> I think we should simply declare exe_start as off_t.  (Please leave
> the cast of header[4] in place, though.)

1. Ok. But why should I keep the cast of the header? It's still there
but in another place I have:

diff -p -u -r1.3 chkv2prg.c
--- src/libc/dos/process/chkv2prg.c     2000/12/25 20:34:54     1.3
+++ src/libc/dos/process/chkv2prg.c     2001/06/20 16:57:03
@@ -75,9 +75,9 @@ const _v2_prog_type *_check_v2_prog_inte
   else if (header[0] == 0x5a4d)        /* "MZ" */
   {
     char go32stub[9];
-    unsigned long coff_start = (unsigned long)header[2]*512L;
-    unsigned long exe_start;
-    unsigned long real_exe_start;
+    off_t coff_start = header[2]*512L;
+    off_t exe_start;
+    off_t real_exe_start;
     type.exec_format = _V2_EXEC_FORMAT_EXE;

Should I keep the cast here too?

2. If we decided to do the cast (theoretically speaking) which way is
best to cast? signed -> unsigned or unsigned -> signed?


Right,

						MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019