projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ca623c9
)
bug.h: prevent double evaulation of `condition' in BUILD_BUG_ON
author
Daniel Santos
<
[email protected]
>
Fri, 22 Feb 2013 00:41:45 +0000
(16:41 -0800)
committer
Linus Torvalds
<
[email protected]
>
Fri, 22 Feb 2013 01:22:16 +0000
(17:22 -0800)
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]
>
include/linux/bug.h
patch
|
blob
|
history
diff --git
a/include/linux/bug.h
b/include/linux/bug.h
index 27d404f91b3e990a71ad41551669d8bcea8ed3f1..89fb91d0c929d4cc74c8c4971d6f0f67fdd7651d 100644
(file)
--- 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
/**