From e9fcffd089739a21dd42cf20922c09ff4590c0fe Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Wed, 19 Jul 2023 15:42:19 +0100 Subject: [PATCH] Robustness fix to MBEDTLS_LIKELY Signed-off-by: Dave Rodgman --- library/common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/common.h b/library/common.h index 839b7d119c..2d358143b9 100644 --- a/library/common.h +++ b/library/common.h @@ -291,8 +291,8 @@ static inline void mbedtls_xor_no_simd(unsigned char *r, /* Define compiler branch hints */ #if defined(__has_builtin) #if __has_builtin(__builtin_expect) -#define MBEDTLS_LIKELY(x) __builtin_expect((x), 1) -#define MBEDTLS_UNLIKELY(x) __builtin_expect((x), 0) +#define MBEDTLS_LIKELY(x) __builtin_expect(!!(x), 1) +#define MBEDTLS_UNLIKELY(x) __builtin_expect(!!(x), 0) #endif #endif #if !defined(MBEDTLS_LIKELY)