From: Marco Bettini Date: Fri, 26 Nov 2021 14:48:04 +0000 (+0100) Subject: lib: switch i_rand_limit() - Replace signed expression with UNSIGNED_MINUS() X-Git-Tag: 2.3.18~99 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5297d4862f504b0363ca5aeb6f5585c46fd50951;p=thirdparty%2Fdovecot%2Fcore.git lib: switch i_rand_limit() - Replace signed expression with UNSIGNED_MINUS() Found by code analysis tool --- diff --git a/src/lib/rand.c b/src/lib/rand.c index 69f769a9ad..12c9686b60 100644 --- a/src/lib/rand.c +++ b/src/lib/rand.c @@ -94,7 +94,7 @@ uint32_t i_rand_limit(uint32_t upper_bound) i_assert(upper_bound > 0); uint32_t val; - uint32_t min = ~(upper_bound - 1) % upper_bound; + uint32_t min = UNSIGNED_MINUS(upper_bound) % upper_bound; while((val = i_rand()) < min); return val % upper_bound; }