[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/7] qdev: Don't register unreadable legacy properties
From: |
Eduardo Habkost |
Subject: |
[PATCH 3/7] qdev: Don't register unreadable legacy properties |
Date: |
Wed, 4 Nov 2020 12:25:08 -0500 |
The existing code at qdev_class_add_legacy_property() will
register a property if both .print and .get are NULL, which is
useless as it will register a property that can't be read or
written.
The only PropertyInfo struct in the whole tree that has both
.print and .get set to NULL is qdev_prop_link. This means every
link property in the code had a useless "legacy-" property being
registered.
Fix this by only registering legacy properties if a .print method
exists.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org
---
hw/core/qdev-properties.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 5bb4ff5f46..73884a212a 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -264,13 +264,13 @@ static void qdev_class_add_legacy_property(DeviceClass
*dc, Property *prop)
g_autofree char *name = NULL;
/* Register pointer properties as legacy properties */
- if (!prop->info->print && prop->info->get) {
+ if (!prop->info->print) {
return;
}
name = g_strdup_printf("legacy-%s", prop->qdev_prop_name);
object_class_property_add(OBJECT_CLASS(dc), name, "str",
- prop->info->print ? qdev_get_legacy_property : prop->info->get,
+ qdev_get_legacy_property,
NULL, NULL, prop);
}
--
2.28.0
- [PATCH 0/7] qom: Field properties type safety, Eduardo Habkost, 2020/11/04
- [PATCH 1/7] sparc: Fix property/field size mismatch for iu-version, Eduardo Habkost, 2020/11/04
- [PATCH 2/7] qom: Save size of struct field in Property struct, Eduardo Habkost, 2020/11/04
- [PATCH 3/7] qdev: Don't register unreadable legacy properties,
Eduardo Habkost <=
- [PATCH 5/7] qom: Replace void* parameter with Property* on PropertyInfo.release, Eduardo Habkost, 2020/11/04
- [PATCH 4/7] qom: Replace void* parameter with Property* on field getters/setters, Eduardo Habkost, 2020/11/04
- [PATCH 6/7] qom: Add FIELD_PTR, a type-safe wrapper for object_field_prop_ptr(), Eduardo Habkost, 2020/11/04
- [PATCH 7/7] sparc: Use FIELD_PTR at nwindows getter/setter, Eduardo Habkost, 2020/11/04