Message ID | 20201104172512.2381656-4-ehabkost@redhat.com |
---|---|
State | New |
Headers | show |
Series | qom: Field properties type safety | expand |
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); }
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(-)