[PATCH v2 12/20] linux/must_be.h: Add must_be() to improve readability of BUILD_BUG_ON_ZERO()

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


Historically, BUILD_BUG_ON_ZERO() has been hard to read.
__must_be_array() is based on BUILD_BUG_ON_ZERO(),
and unlike BUILD_BUG_ON_*(),
it has a pretty readable name.

Let's generalize it with this kind of usage:

#define __must_be_array(a) must_be(__is_array(a))

So next step is to create macros of the kind:
__is_array(a)

Signed-off-by: Alejandro Colomar <alx.manpages@xxxxxxxxx>
---
include/linux/must_be.h | 9 +++++++++
1 file changed, 9 insertions(+)
create mode 100644 include/linux/must_be.h

diff --git a/include/linux/must_be.h b/include/linux/must_be.h
new file mode 100644
index 000000000000..a2e0b0c890a6
--- /dev/null
+++ b/include/linux/must_be.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_MUST_BE_H
+#define _LINUX_MUST_BE_H
+
+
+#define __must_be(e) BUILD_BUG_ON_ZERO(!(e))
+
+
+#endif /* _LINUX_MUST_BE_H */
--
2.33.1