From: Willy Tarreau Date: Mon, 18 Mar 2019 15:31:18 +0000 (+0100) Subject: BUILD: tools: fix a build warning on some 32-bit archs X-Git-Tag: v2.0-dev2~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b6be3bbeb40a4e606980f70fe2a8db64c33a44e;p=thirdparty%2Fhaproxy.git BUILD: tools: fix a build warning on some 32-bit archs Some recent versions of gcc apparently can detect that x >> 32 will not work on a 32-bit architecture, but are failing to see that the code will not be built since it's enclosed in "if (sizeof(LONG) > 4)" or equivalent. Just shift right twice by 16 bits in this case, the compiler correctly replaces it by a single 32-bit shift. No backport is needed. --- diff --git a/src/standard.c b/src/standard.c index 2bc4405fb7..03072b96b9 100644 --- a/src/standard.c +++ b/src/standard.c @@ -2672,7 +2672,8 @@ unsigned int mask_find_rank_bit(unsigned int r, unsigned long m) t = 0; s = LONGBITS; if (s > 32) { - t = (d >> 32) + (d >> 48); + unsigned long d2 = (d >> 16) >> 16; + t = d2 + (d2 >> 16); s -= ((t - r) & 256) >> 3; r -= (t & ((t - r) >> 8)); } @@ -2706,7 +2707,8 @@ unsigned int mask_find_rank_bit_fast(unsigned int r, unsigned long m, t = 0; s = LONGBITS; if (s > 32) { - t = (d >> 32) + (d >> 48); + unsigned long d2 = (d >> 16) >> 16; + t = d2 + (d2 >> 16); s -= ((t - r) & 256) >> 3; r -= (t & ((t - r) >> 8)); }