From 71e7b5d14e65ced795a3d1a63891e94e284f2eb6 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Thu, 23 May 2019 13:15:58 +0000 Subject: [PATCH] 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 --- ctdb/server/ipalloc_lcp2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } -- 2.47.3