summary refs log tree commit diff stats
path: root/include/hw/qdev-core.h
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2024-12-18 07:42:45 -0600
committerPaolo Bonzini <pbonzini@redhat.com>2024-12-19 19:35:49 +0100
commit1088d41795101479e2d88f1e6140071732f9bdb3 (patch)
tree8c992af56bd4302efdce5fec32e5a74a9fa07b09 /include/hw/qdev-core.h
parent5f9976486970b0fec50ff4c07da7af620cd7d0a0 (diff)
downloadfocaccia-qemu-1088d41795101479e2d88f1e6140071732f9bdb3.tar.gz
focaccia-qemu-1088d41795101479e2d88f1e6140071732f9bdb3.zip
hw/core: Remove device_class_set_props function
All uses of device_class_set_props() are now using arrays.
Validate this compile-time in the device_class_set_props macro and
call device_class_set_props_n using the known size of the array.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-19-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/hw/qdev-core.h')
-rw-r--r--include/hw/qdev-core.h16
1 files changed, 6 insertions, 10 deletions
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index e9b4891f55..afa667b68f 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -948,22 +948,18 @@ char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev);
  * To modify an inherited property you need to use????
  *
  * Validate that @props has at least one Property plus the terminator.
+ * Validate that @props is an array, not a pointer, via ARRAY_SIZE.
  * Validate that the array is terminated at compile-time (with -O2),
  * which requires the array to be const.
  */
-void device_class_set_props(DeviceClass *dc, const Property *props);
-
 #define device_class_set_props(dc, props) \
     do {                                                                \
-        QEMU_BUILD_BUG_ON(sizeof(props) != sizeof(const Property *) &&  \
-                          sizeof(props) < 2 * sizeof(Property));        \
-        if (sizeof(props) != sizeof(const Property *)) {                \
-            size_t props_count_ = sizeof(props) / sizeof(Property) - 1; \
-            if ((props)[props_count_].name != NULL) {                   \
-                qemu_build_not_reached();                               \
-            }                                                           \
+        QEMU_BUILD_BUG_ON(sizeof(props) == 0);                          \
+        size_t props_count_ = ARRAY_SIZE(props) - 1;                    \
+        if ((props)[props_count_].name != NULL) {                       \
+            qemu_build_not_reached();                                   \
         }                                                               \
-        (device_class_set_props)((dc), (props));                        \
+        device_class_set_props_n((dc), (props), props_count_);          \
     } while (0)
 
 /**