|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] xen/compat: use BUILD_BUG_ON in CHECK_SIZE macros
commit ab9558ef5eea50339f2aaeb946f5e3e3aadd68ab
Author: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
AuthorDate: Fri Oct 27 15:34:15 2023 +0200
Commit: Stefano Stabellini <stefano.stabellini@xxxxxxx>
CommitDate: Fri Nov 17 18:04:52 2023 -0800
xen/compat: use BUILD_BUG_ON in CHECK_SIZE macros
BUILD_BUG_ON is the preferred way to induce a build error
upon statically determined incorrect conditions.
This also fixes a MISRA C:2012 Rule 10.1 violation in the
previous formulation.
Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
xen/include/xen/compat.h | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/xen/include/xen/compat.h b/xen/include/xen/compat.h
index f2ce5bb358..41a5d61eef 100644
--- a/xen/include/xen/compat.h
+++ b/xen/include/xen/compat.h
@@ -151,12 +151,18 @@ CHECK_NAME_(k, n, T)(k xen_ ## n *x, \
return x == c; \
}
-#define CHECK_SIZE(name) \
- typedef int CHECK_NAME(name, S)[1 - (sizeof(xen_ ## name ## _t) != \
- sizeof(compat_ ## name ## _t)) * 2]
+#define CHECK_SIZE(name) \
+static inline void __maybe_unused CHECK_SIZE_##name(void) \
+{ \
+ BUILD_BUG_ON(sizeof(xen_ ## name ## _t) != \
+ sizeof(compat_ ## name ## _t)); \
+}
#define CHECK_SIZE_(k, n) \
- typedef int CHECK_NAME_(k, n, S)[1 - (sizeof(k xen_ ## n) != \
- sizeof(k compat_ ## n)) * 2]
+static inline void __maybe_unused CHECK_SIZE_##k_##n(void) \
+{ \
+ BUILD_BUG_ON(sizeof(k xen_ ## n) != \
+ sizeof(k compat_ ## n)); \
+}
#define CHECK_FIELD_COMMON(name, t, f) \
static inline int __maybe_unused name(xen_ ## t ## _t *x, compat_ ## t ## _t
*c) \
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |