[PATCH master 2/7] include: bitmask: avoid -Wint-in-bool-context warning

Ahmad Fatoum a.fatoum at pengutronix.de
Sun Jun 4 23:29:34 PDT 2023


In case mask is an enum, GCC will complain that an enum is used in a
boolean context. This warning is easily avoided with no functional
change by doing an explicit comparison against 0.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 include/linux/bitfield.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h
index cf2588d81148..44e8cb3a7df3 100644
--- a/include/linux/bitfield.h
+++ b/include/linux/bitfield.h
@@ -53,7 +53,7 @@
 	({								\
 		BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),		\
 				 _pfx "mask is not constant");		\
-		BUILD_BUG_ON_MSG(!(_mask), _pfx "mask is zero");	\
+		BUILD_BUG_ON_MSG(_mask == 0, _pfx "mask is zero");	\
 		BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?		\
 				 ~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \
 				 _pfx "value too large for the field"); \
-- 
2.39.2




More information about the barebox mailing list