提交 7e356a97 编写于 作者: R René Scharfe 提交者: Junio C Hamano

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: NØyvind A. Holm <sunny@sunbase.org>
Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
Acked-by: NThomas Rast <trast@student.ethz.ch>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 9322ce21
......@@ -301,7 +301,13 @@ static inline long count_masked_bytes(unsigned long mask)
* that works for the bytemasks without having to
* mask them first.
*/
return mask * 0x0001020304050608 >> 56;
/*
* return mask * 0x0001020304050608 >> 56;
*
* Doing it like this avoids warnings on 32-bit machines.
*/
long a = (REPEAT_BYTE(0x01) / 0xff + 1);
return mask * a >> (sizeof(long) * 7);
} else {
/*
* Modified Carl Chatfield G+ version for 32-bit *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册