From: Noel Power Date: Thu, 23 May 2019 13:15:58 +0000 (+0000) Subject: ctdb/server: cppcheck: fix shiftTooManyBitsSigned error X-Git-Tag: ldb-2.0.5~498 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=71e7b5d14e65ced795a3d1a63891e94e284f2eb6;p=thirdparty%2Fsamba.git ctdb/server: cppcheck: fix shiftTooManyBitsSigned error Fixes ctdb/server/ipalloc_lcp2.c:61: error: shiftTooManyBitsSigned: Shifting signed 32-bit value by 31 bits is undefined behaviour <--[cppcheck] Signed-off-by: Noel Power Reviewed-by: Andreas Schneider --- diff --git a/ctdb/server/ipalloc_lcp2.c b/ctdb/server/ipalloc_lcp2.c index 565b58c9a0c..1146bb60f16 100644 --- a/ctdb/server/ipalloc_lcp2.c +++ b/ctdb/server/ipalloc_lcp2.c @@ -58,7 +58,7 @@ static uint32_t ip_distance(ctdb_sock_addr *ip1, ctdb_sock_addr *ip2) /* Count number of leading zeroes. * FIXME? This could be optimised... */ - while ((x & (1 << 31)) == 0) { + while ((x & ((uint32_t)1 << 31)) == 0) { x <<= 1; distance += 1; }