x>>32 warning in io.c
jw schultz
jw at pegasys.ws
Fri Mar 21 18:04:02 EST 2003
On Thu, Mar 20, 2003 at 09:37:23PM -0800, Steve Mor Moritsugu wrote:
> I download rsync.2.5.6, configure, make clean, but make gives this warning:
>
> "io.c", line 653: warning: shift count negative or too big: >> 32
> "io.c", line 653: warning: shift count negative or too big: >> 32
> "io.c", line 653: warning: shift count negative or too big: >> 32
> "io.c", line 653: warning: shift count negative or too big: >> 32
>
> Another 32 bit shift (<<32) at line 385 does not cause a warning because
> of this test at line 379:
> #ifdef NO_INT64
> I verified that NO_INT64 is defined on my system in rsync.h
>
> However there is no #ifdef NO_INT64 test protecting line 653.
> Here are lines 652,653, and 654 from io.c in subr write_longint:
>
> SIVAL(b,0,(x&0xFFFFFFFF));
> SIVAL(b,4,((x>>32)&0xFFFFFFFF));
> writefd(f,b,8);
>
> On my system, x>>32 evaluates to the value x, not 0 (since the
> shift count is invalid). This will cause the upper 4 bytes of b to be
> the same as the lower 4 bytes of b, even if x is a small value.
> I am considering using this hack for line 653 to prevent possible problems:
>
> SIVAL(b,4,((0)&0xFFFFFFFF));
>
> I really don't do much C programming so I am fumbling in the dark
> here. Maybe my hack would make things worse. I have not seen any
> problems yet (rsync can copy test files that cmp verifies later). make
> only shows one other warning or error:
> "popt/popt.c", line 910: warning: macro redefined: _ABS
Nice catch. What platform doesn't support 64bit ints?
I've attached a patch. I can't really test it but give it a
try and let us know.
--
________________________________________________________________
J.W. Schultz Pegasystems Technologies
email address: jw at pegasys.ws
Remember Cernan and Schmitt
-------------- next part --------------
Index: io.c
===================================================================
RCS file: /data/cvs/rsync/io.c,v
retrieving revision 1.105
diff -u -b -r1.105 io.c
--- io.c 11 Apr 2002 02:11:50 -0000 1.105
+++ io.c 21 Mar 2003 07:00:54 -0000
@@ -648,11 +648,16 @@
return;
}
+#ifdef NO_INT64
+ rprintf(FERROR,"Integer overflow - attempted 64 bit offset\n");
+ exit_cleanup(RERR_UNSUPPORTED);
+#else
write_int(f, (int32)0xFFFFFFFF);
SIVAL(b,0,(x&0xFFFFFFFF));
SIVAL(b,4,((x>>32)&0xFFFFFFFF));
writefd(f,b,8);
+#endif
}
void write_buf(int f,char *buf,size_t len)
More information about the rsync
mailing list