From: Daniel Santos Date: Fri, 22 Feb 2013 00:41:45 +0000 (-0800) Subject: bug.h: prevent double evaulation of `condition' in BUILD_BUG_ON X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1d6a0d19c85587581a364850b77f30446810a560;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git bug.h: prevent double evaulation of `condition' 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. [akpm@linux-foundation.org: tweak code layout] 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 Signed-off-by: Linus Torvalds --- diff --git a/include/linux/bug.h b/include/linux/bug.h index 27d404f91b3e..89fb91d0c929 100644 --- a/include/linux/bug.h +++ b/include/linux/bug.h @@ -59,9 +59,10 @@ 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; \ - } while(0) + bool __cond = !!(condition); \ + ((void)sizeof(char[1 - 2 * __cond])); \ + if (__cond) __build_bug_on_failed = 1; \ + } while (0) #endif /**