From 10a8defecc7804247ae6bc0bfae8b650e87df3c4 Mon Sep 17 00:00:00 2001 From: Olivia Lee Date: Thu, 9 Oct 2025 11:16:51 -0700 Subject: [PATCH] util/macros: coerce likely/unlikely to bool even without __builtin_expect Coercing the argument to a bool when we have __builtin_expect but leaving it unmodified otherwise is a recipe for really subtle bugs. I don't know if any bugs like that exist currently, but I almost introduced one in panfrost. Signed-off-by: Olivia Lee Reviewed-by: Alyssa Rosenzweig Part-of: --- src/util/macros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/macros.h b/src/util/macros.h index d9487688900..007006744ed 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -66,8 +66,8 @@ # define likely(x) __builtin_expect(!!(x), 1) # define unlikely(x) __builtin_expect(!!(x), 0) # else -# define likely(x) (x) -# define unlikely(x) (x) +# define likely(x) (!!(x)) +# define unlikely(x) (!!(x)) # endif #endif