| From | Alejandro Colomar <> | Subject | [PATCH v2 12/20] linux/must_be.h: Add must_be() to improve readability of BUILD_BUG_ON_ZERO() | Date | Sat, 20 Nov 2021 14:00:55 +0100 |
| |
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
|