[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211120130104.185699-14-alx.manpages@gmail.com>
Date: Sat, 20 Nov 2021 14:00:56 +0100
From: Alejandro Colomar <alx.manpages@...il.com>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Alejandro Colomar <alx.manpages@...il.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Arnd Bergmann <arnd@...db.de>,
Alexey Dobriyan <adobriyan@...il.com>,
Jani Nikula <jani.nikula@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Kees Cook <keescook@...omium.org>,
Joe Perches <joe@...ches.com>
Subject: [PATCH v2 13/20] Move BUILD_BUG_ON_ZERO to <linux/must_be.h>
Signed-off-by: Alejandro Colomar <alx.manpages@...il.com>
---
include/linux/build_bug.h | 13 ++-----------
include/linux/must_be.h | 12 ++++++++++++
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/include/linux/build_bug.h b/include/linux/build_bug.h
index e3a0be2c90ad..539e3d5df027 100644
--- a/include/linux/build_bug.h
+++ b/include/linux/build_bug.h
@@ -2,19 +2,10 @@
#ifndef _LINUX_BUILD_BUG_H
#define _LINUX_BUILD_BUG_H
+
#include <linux/compiler.h>
+#include <linux/must_be.h>
-#ifdef __CHECKER__
-#define BUILD_BUG_ON_ZERO(e) (0)
-#else /* __CHECKER__ */
-/*
- * Force a compilation error if condition is true, but also produce a
- * result (of value 0 and type int), so the expression can be used
- * e.g. in a structure initializer (or where-ever else comma expressions
- * aren't permitted).
- */
-#define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
-#endif /* __CHECKER__ */
/* Force a compilation error if a constant expression is not a power of 2 */
#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) \
diff --git a/include/linux/must_be.h b/include/linux/must_be.h
index a2e0b0c890a6..d1ebeaca9cf8 100644
--- a/include/linux/must_be.h
+++ b/include/linux/must_be.h
@@ -3,6 +3,18 @@
#define _LINUX_MUST_BE_H
+#ifdef __CHECKER__
+#define BUILD_BUG_ON_ZERO(e) (0)
+#else /* __CHECKER__ */
+/*
+ * Force a compilation error if condition is true, but also produce a
+ * result (of value 0 and type int), so the expression can be used
+ * e.g. in a structure initializer (or where-ever else comma expressions
+ * aren't permitted).
+ */
+#define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
+#endif /* __CHECKER__ */
+
#define __must_be(e) BUILD_BUG_ON_ZERO(!(e))
--
2.33.1
Powered by blists - more mailing lists