aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bug.h
diff options
context:
space:
mode:
authorDaniel Santos <daniel.santos@pobox.com>2013-02-21 19:41:45 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-21 20:22:16 -0500
commit1d6a0d19c85587581a364850b77f30446810a560 (patch)
treef82e7ac260a7705459c77bd37bf2733047542921 /include/linux/bug.h
parentca623c914e82c3351cd657073fdb24a1df8c27b9 (diff)
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 <daniel.santos@pobox.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Borislav Petkov <bp@alien8.de> Cc: David Rientjes <rientjes@google.com> Cc: Joe Perches <joe@perches.com> Cc: Josh Triplett <josh@joshtriplett.org> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/bug.h')
-rw-r--r--include/linux/bug.h7
1 files changed, 4 insertions, 3 deletions
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;
59extern int __build_bug_on_failed; 59extern int __build_bug_on_failed;
60#define BUILD_BUG_ON(condition) \ 60#define BUILD_BUG_ON(condition) \
61 do { \ 61 do { \
62 ((void)sizeof(char[1 - 2*!!(condition)])); \ 62 bool __cond = !!(condition); \
63 if (condition) __build_bug_on_failed = 1; \ 63 ((void)sizeof(char[1 - 2 * __cond])); \
64 } while(0) 64 if (__cond) __build_bug_on_failed = 1; \
65 } while (0)
65#endif 66#endif
66 67
67/** 68/**