lkml.org 
[lkml]   [2021]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 12/20] linux/must_be.h: Add must_be() to improve readability of BUILD_BUG_ON_ZERO()
Date
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@gmail.com>
---
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
\
 
 \ /
  Last update: 2021-11-20 14:03    [W:1.581 / U:0.520 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site