mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 06:14:39 +01:00
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. [[email protected]: tweak code layout] Signed-off-by: Daniel Santos <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: David Rientjes <[email protected]> Cc: Joe Perches <[email protected]> Cc: Josh Triplett <[email protected]> Cc: Paul Gortmaker <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
1 parent
ca623c914e
commit
1d6a0d19c8
1 file changed
+4
-3
+4
-3
@@ -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
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user