Since commit ed63ec0d22c ("ARRAY_SIZE: check that argument is an
array"), passing a pointer to ARRAY_SIZE() is a build error.
Document that.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
 include/qemu/osdep.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 1ec5b42230b..5d5695ade28 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -528,6 +528,12 @@ void QEMU_ERROR("code path is reachable")
  */
 #define QEMU_IS_ARRAY(x) (!__builtin_types_compatible_p(typeof(x), \
                                                         typeof(&(x)[0])))
+/**
+ * ARRAY_SIZE() - Return the number of elements of an array
+ * @x: the array
+ *
+ * Note: fails to build if @x is a pointer.
+ */
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(x) ((sizeof(x) / sizeof((x)[0])) + \
                        QEMU_BUILD_BUG_ON_ZERO(!QEMU_IS_ARRAY(x)))
-- 
2.55.0


Reply via email to