[PATCH v2 13/20] Move BUILD_BUG_ON_ZERO to <linux/must_be.h>

From: Alejandro Colomar
Date: Sat Nov 20 2021 - 08:01:45 EST


Signed-off-by: Alejandro Colomar <alx.manpages@xxxxxxxxx>
---
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