Skip to contentSkip to conversation

log2: add missing () around n in roundup_pow_of_two()

PATCH Applied Jason Gunthorpe 1 participant 1 message Aug 31, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 log2: add missing () around n in roundup_pow_of_two()

Otherwise gcc generates warnings if the expression is complicated.

Fixes 312a0c170945 ("[PATCH] LOG2: Alter roundup_pow_of_two() so that it can use a ilog2() on a constant")
---
 include/linux/log2.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Hi Andrew, I think this is appropriate for your tree? Thanks

include/linux/log2.h +1 -1
index 83a4a3ca3e8a76..c619ec6eff4aee 100644
@@ -173,7 +173,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
 #define roundup_pow_of_two(n)			\
 (						\
 	__builtin_constant_p(n) ? (		\
-		(n == 1) ? 1 :			\
+		((n) == 1) ? 1 :		\
 		(1UL << (ilog2((n) - 1) + 1))	\
 				   ) :		\
 	__roundup_pow_of_two(n)			\
Signature · 1 line
2.28.0