[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48BD64C1.8000504@panasas.com>
Date: Tue, 02 Sep 2008 19:07:29 +0300
From: Boaz Harrosh <bharrosh@...asas.com>
To: Ingo Molnar <mingo@...e.hu>, Rusty Russell <rusty@...tcorp.com.au>,
"David S. Miller" <davem@...emloft.net>,
Ivo van Doorn <IvDoorn@...il.com>,
"John W. Linville" <linville@...driver.com>
CC: Alexey Dobriyan <adobriyan@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Theodore Tso <tytso@....edu>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Jan Beulich <jbeulich@...ell.com>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 5/5 ver3] debug: BUILD_BUG_ON: error on non-const expressions
Fix BUILD_BUG_ON to not silently drop non-compile-time
visible expressions. It will now produce a compilation
error if so.
The code to BUILD_BUG_ON_ZERO was done by:
Jan Beulich <jbeulich@...ell.com>
The code to BUILD_BUG_ON is a small variation to Jan's
code inspired by Rusty Russell. Which gives me better
compilations semantics, and makes BUILD_BUG_ON behave
more like BUG_ON.
Signed-off-by: Boaz Harrosh <bharrosh@...asas.com>
TO: Jan Beulich <jbeulich@...ell.com>
CC: Ingo Molnar <mingo@...e.hu>
CC: Rusty Russell <rusty@...tcorp.com.au>
CC: Alexey Dobriyan <adobriyan@...il.com>
CC: Andrew Morton <akpm@...ux-foundation.org>
CC: Theodore Tso <tytso@....edu>
CC: David S. Miller <davem@...emloft.net>
---
include/linux/compiler.h | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 90fa975..f882410 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -194,14 +194,15 @@ extern void __chk_io_ptr(const volatile void __iomem *);
*/
#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
-/* Force a compilation error if condition is true */
-#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
-
/* Force a compilation error if condition is true, but also produce a
result (of value 0 and type size_t), so the expression can be used
- e.g. in a structure initializer (or where-ever else comma expressions
+ e.g. in a structure initializer (or where-ever full statements
aren't permitted). */
-#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
+#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int: -!!(e); }))
+
+/* Force a compilation error if condition is true */
+#define BUILD_BUG_ON(e) \
+ do { struct {int: -!!(e); } x __maybe_unused; } while (0)
/* Trap pasters of __FUNCTION__ at compile-time */
#define __FUNCTION__ (__func__)
--
1.5.6.rc1.5.gadf6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists