rand uniform: fix likely usage
authorPauli <pauli@openssl.org>
Thu, 2 Nov 2023 01:26:50 +0000 (12:26 +1100)
committerTomas Mraz <tomas@openssl.org>
Fri, 3 Nov 2023 10:20:16 +0000 (11:20 +0100)
@mspncp noted that the condition should have been likely not unlikely.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22593)

crypto/rand/rand_uniform.c

index 26ce3ee5605d410dafbcd23f6957ca60fa5bb2d8..b9e263585916eb3a27060ae2c8df0e94dba61153 100644 (file)
@@ -85,7 +85,7 @@ uint32_t ossl_rand_uniform_uint32(OSSL_LIB_CTX *ctx, uint32_t upper, int *err)
         if (f < f2)
             return i + 1;
         /* For not all 1 bits, there is no carry so return the result */
-        if (unlikely(f != 0xffffffff))
+        if (likely(f != 0xffffffff))
             return i;
         /* setup for the next word of randomness */
         f = prod & 0xffffffff;