[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-sparse
Subject: [PATCH v8 6/9] bug.h: Prevent double evaulation of in BUILD_BUG_ON
From: danielfsantos () att ! net
Date: 2013-01-01 22:54:08
Message-ID: 1357080851-30938-7-git-send-email-daniel.santos () pobox ! com
[Download RAW message or body]
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 <daniel.santos@pobox.com>
---
include/linux/bug.h | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/linux/bug.h b/include/linux/bug.h
index 27d404f..0d75762 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
--
1.7.8.6
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic