From: Daniel Santos Date: Wed, 20 Feb 2013 02:13:30 +0000 (+1100) Subject: bug.h: Prevent double evaulation of in BUILD_BUG_ON X-Git-Tag: next-20130220~1^2~682 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=3a27efbe278b4a0e54e9c2a6f1f7c27c1e1327af;p=karo-tx-linux.git bug.h: Prevent double evaulation of in BUILD_BUG_ON When calling BUILD_BUG_ON in an optimized build using gcc 4.3 and later, the condition will be evaulated twice, possibily with side-effects. This patch eliminates that error. Signed-off-by: Daniel Santos Cc: Andi Kleen Cc: Borislav Petkov Cc: David Rientjes Cc: Joe Perches Cc: Josh Triplett Cc: Paul Gortmaker Signed-off-by: Andrew Morton --- diff --git a/include/linux/bug.h b/include/linux/bug.h index 27d404f91b3e..0d75762cd415 100644 --- a/include/linux/bug.h +++ b/include/linux/bug.h @@ -59,8 +59,9 @@ struct pt_regs; extern int __build_bug_on_failed; #define BUILD_BUG_ON(condition) \ do { \ - ((void)sizeof(char[1 - 2*!!(condition)])); \ - if (condition) __build_bug_on_failed = 1; \ + bool __cond = !!(condition); \ + ((void)sizeof(char[1 - 2 * __cond])); \ + if (__cond) __build_bug_on_failed = 1; \ } while(0) #endif