diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2021-11-19 21:25:51 +0100 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2021-11-20 13:22:21 +0100 |
commit | cd025a02d17c353f5a5f9545a1bfa2df3c8974ef (patch) | |
tree | edb268f82dd89db4dc5fe8883b62145e790fc3f3 | |
parent | 54f38f52a7384222be20b927a8cab3bf7ac6ea55 (diff) |
linux/must_be.h: Add must_be() to improve readability of BUILD_BUG_ON_ZERO()
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>
-rw-r--r-- | include/linux/must_be.h | 9 |
1 files changed, 9 insertions, 0 deletions
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 */ |