xdiff: avoid more compiler warnings with XDL_FAST_HASH on 32-bit machines

Hide literals that can cause compiler warnings for 32-bit architectures in expressions that evaluate to small numbers there. Some compilers warn that 0x0001020304050608 won't fit into a 32-bit long, others that shifting right by 56 bits clears a 32-bit value completely. The correct values are calculated in the 64-bit case, which is all that matters in this if-branch. Reported-by: Øyvind A. Holm <sunny@sunbase.org> Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Acked-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed May 22, 2012 at 22:36 UTC 7e356a979459092d10450e66d8512381e89c2570
1 file changed +7 -1
xdiff/xutils.c
+7 -1
@@ -301,7 +301,13 @@ static inline long count_masked_bytes(unsigned long mask)
301 * that works for the bytemasks without having to
302 * mask them first.
303 */
304 - return mask * 0x0001020304050608 >> 56;
304 + /*
305 + * return mask * 0x0001020304050608 >> 56;
306 + *
307 + * Doing it like this avoids warnings on 32-bit machines.
308 + */
309 + long a = (REPEAT_BYTE(0x01) / 0xff + 1);
310 + return mask * a >> (sizeof(long) * 7);
311 } else {
312 /*
313 * Modified Carl Chatfield G+ version for 32-bit *