[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/24] include/hw/qdev-core: Detect most empty Property lists at
From: |
Richard Henderson |
Subject: |
[PATCH 12/24] include/hw/qdev-core: Detect most empty Property lists at compile time |
Date: |
Sun, 15 Dec 2024 21:50:57 -0600 |
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/hw/qdev-core.h | 8 ++++++++
hw/core/qdev-properties.c | 2 +-
migration/migration.c | 2 +-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 5be9844412..b2859d1e39 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -943,6 +943,14 @@ char *qdev_get_own_fw_dev_path_from_handler(BusState *bus,
DeviceState *dev);
*/
void device_class_set_props(DeviceClass *dc, const Property *props);
+/* Validate at least one Property, plus the terminator. */
+#define device_class_set_props(DC, PROPS) \
+ do { \
+ QEMU_BUILD_BUG_ON(sizeof(PROPS) != sizeof(const Property *) && \
+ sizeof(PROPS) < 2 * sizeof(Property)); \
+ (device_class_set_props)(DC, PROPS); \
+ } while (0)
+
/**
* device_class_set_parent_realize() - set up for chaining realize fns
* @dc: The device class
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 315196bd85..de618a964a 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1061,7 +1061,7 @@ static void qdev_class_add_legacy_property(DeviceClass
*dc, const Property *prop
NULL, NULL, (Property *)prop);
}
-void device_class_set_props(DeviceClass *dc, const Property *props)
+void (device_class_set_props)(DeviceClass *dc, const Property *props)
{
const Property *prop;
diff --git a/migration/migration.c b/migration/migration.c
index 8c5bd0a75c..6b3b85d31e 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -3822,7 +3822,7 @@ static void migration_class_init(ObjectClass *klass, void
*data)
DeviceClass *dc = DEVICE_CLASS(klass);
dc->user_creatable = false;
- device_class_set_props(dc, migration_properties);
+ (device_class_set_props)(dc, migration_properties);
}
static void migration_instance_finalize(Object *obj)
--
2.43.0
- [PATCH 02/24] hw/ide: Constify sysbus_ahci_properties, (continued)
- [PATCH 02/24] hw/ide: Constify sysbus_ahci_properties, Richard Henderson, 2024/12/15
- [PATCH 07/24] hw/tricore: Remove empty Property lists, Richard Henderson, 2024/12/15
- [PATCH 04/24] target/s390x: Use s390x_cpu_properties for system mode only, Richard Henderson, 2024/12/15
- [PATCH 06/24] hw/ppc: Only register spapr_nvdimm_properties if CONFIG_LIBPMEM, Richard Henderson, 2024/12/15
- [PATCH 10/24] hw/sparc: Remove empty Property lists, Richard Henderson, 2024/12/15
- [PATCH 08/24] hw/s390x: Remove empty Property lists, Richard Henderson, 2024/12/15
- [PATCH 09/24] hw/xen: Remove empty Property lists, Richard Henderson, 2024/12/15
- [PATCH 12/24] include/hw/qdev-core: Detect most empty Property lists at compile time,
Richard Henderson <=
- [PATCH 13/24] hw/core: Introduce device_class_set_props_n, Richard Henderson, 2024/12/15
- [PATCH 11/24] hw/virtio: Remove empty Property lists, Richard Henderson, 2024/12/15
- [PATCH 15/24] hw/scsi/megasas: Use device_class_set_props_n, Richard Henderson, 2024/12/15
- [PATCH 16/24] hw/arm/armsse: Use device_class_set_props_n, Richard Henderson, 2024/12/15
- [PATCH 17/24] rust/qemu-api: Use device_class_set_props_n, Richard Henderson, 2024/12/15
- [PATCH 14/24] migration: Use device_class_set_props_n, Richard Henderson, 2024/12/15
- [PATCH 19/24] target/riscv: Do not abuse DEFINE_PROP_END_OF_LIST, Richard Henderson, 2024/12/15
- [PATCH 18/24] hw/core: Replace device_class_set_props with a macro, Richard Henderson, 2024/12/15
- [PATCH 21/24] include/hw/qdev-properties: Shrink struct Property, Richard Henderson, 2024/12/15