diff options
author | Markus Armbruster <armbru@redhat.com> | 2020-05-05 17:29:15 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2020-05-15 07:06:49 +0200 |
commit | 7eecec7d1224890b0d04479dd4736e1eefaa72dc (patch) | |
tree | 58da9dda7cf32c9297f6d710d6dac2f0bf493448 /hw/core | |
parent | 702518877220187a858da1a6ba08d53995dc6e2f (diff) |
qom: Drop object_property_set_description() parameter @errp
object_property_set_description() and
object_class_property_set_description() fail only when property @name
is not found.
There are 85 calls of object_property_set_description() and
object_class_property_set_description(). None of them can fail:
* 84 immediately follow the creation of the property.
* The one in spapr_rng_instance_init() refers to a property created in
spapr_rng_class_init(), from spapr_rng_properties[].
Every one of them still gets to decide what to pass for @errp.
51 calls pass &error_abort, 32 calls pass NULL, one receives the error
and propagates it to &error_abort, and one propagates it to
&error_fatal. I'm actually surprised none of them violates the Error
API.
What are we gaining by letting callers handle the "property not found"
error? Use when the property is not known to exist is simpler: you
don't have to guard the call with a check. We haven't found such a
use in 5+ years. Until we do, let's make life a bit simpler and drop
the @errp parameter.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-8-armbru@redhat.com>
[One semantic rebase conflict resolved]
Diffstat (limited to 'hw/core')
-rw-r--r-- | hw/core/machine.c | 41 | ||||
-rw-r--r-- | hw/core/qdev.c | 6 |
2 files changed, 21 insertions, 26 deletions
diff --git a/hw/core/machine.c b/hw/core/machine.c index 7a50dd518f..0cd2033b1f 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -789,83 +789,82 @@ static void machine_class_init(ObjectClass *oc, void *data) object_class_property_add_str(oc, "kernel", machine_get_kernel, machine_set_kernel, &error_abort); object_class_property_set_description(oc, "kernel", - "Linux kernel image file", &error_abort); + "Linux kernel image file"); object_class_property_add_str(oc, "initrd", machine_get_initrd, machine_set_initrd, &error_abort); object_class_property_set_description(oc, "initrd", - "Linux initial ramdisk file", &error_abort); + "Linux initial ramdisk file"); object_class_property_add_str(oc, "append", machine_get_append, machine_set_append, &error_abort); object_class_property_set_description(oc, "append", - "Linux kernel command line", &error_abort); + "Linux kernel command line"); object_class_property_add_str(oc, "dtb", machine_get_dtb, machine_set_dtb, &error_abort); object_class_property_set_description(oc, "dtb", - "Linux kernel device tree file", &error_abort); + "Linux kernel device tree file"); object_class_property_add_str(oc, "dumpdtb", machine_get_dumpdtb, machine_set_dumpdtb, &error_abort); object_class_property_set_description(oc, "dumpdtb", - "Dump current dtb to a file and quit", &error_abort); + "Dump current dtb to a file and quit"); object_class_property_add(oc, "phandle-start", "int", machine_get_phandle_start, machine_set_phandle_start, NULL, NULL, &error_abort); object_class_property_set_description(oc, "phandle-start", - "The first phandle ID we may generate dynamically", &error_abort); + "The first phandle ID we may generate dynamically"); object_class_property_add_str(oc, "dt-compatible", machine_get_dt_compatible, machine_set_dt_compatible, &error_abort); object_class_property_set_description(oc, "dt-compatible", - "Overrides the \"compatible\" property of the dt root node", - &error_abort); + "Overrides the \"compatible\" property of the dt root node"); object_class_property_add_bool(oc, "dump-guest-core", machine_get_dump_guest_core, machine_set_dump_guest_core, &error_abort); object_class_property_set_description(oc, "dump-guest-core", - "Include guest memory in a core dump", &error_abort); + "Include guest memory in a core dump"); object_class_property_add_bool(oc, "mem-merge", machine_get_mem_merge, machine_set_mem_merge, &error_abort); object_class_property_set_description(oc, "mem-merge", - "Enable/disable memory merge support", &error_abort); + "Enable/disable memory merge support"); object_class_property_add_bool(oc, "usb", machine_get_usb, machine_set_usb, &error_abort); object_class_property_set_description(oc, "usb", - "Set on/off to enable/disable usb", &error_abort); + "Set on/off to enable/disable usb"); object_class_property_add_bool(oc, "graphics", machine_get_graphics, machine_set_graphics, &error_abort); object_class_property_set_description(oc, "graphics", - "Set on/off to enable/disable graphics emulation", &error_abort); + "Set on/off to enable/disable graphics emulation"); object_class_property_add_str(oc, "firmware", machine_get_firmware, machine_set_firmware, &error_abort); object_class_property_set_description(oc, "firmware", - "Firmware image", &error_abort); + "Firmware image"); object_class_property_add_bool(oc, "suppress-vmdesc", machine_get_suppress_vmdesc, machine_set_suppress_vmdesc, &error_abort); object_class_property_set_description(oc, "suppress-vmdesc", - "Set on to disable self-describing migration", &error_abort); + "Set on to disable self-describing migration"); object_class_property_add_bool(oc, "enforce-config-section", machine_get_enforce_config_section, machine_set_enforce_config_section, &error_abort); object_class_property_set_description(oc, "enforce-config-section", - "Set on to enforce configuration section migration", &error_abort); + "Set on to enforce configuration section migration"); object_class_property_add_str(oc, "memory-encryption", machine_get_memory_encryption, machine_set_memory_encryption, &error_abort); object_class_property_set_description(oc, "memory-encryption", - "Set memory encryption object to use", &error_abort); + "Set memory encryption object to use"); } static void machine_class_base_init(ObjectClass *oc, void *data) @@ -898,7 +897,7 @@ static void machine_initfn(Object *obj) &error_abort); object_property_set_description(obj, "nvdimm", "Set on/off to enable/disable " - "NVDIMM instantiation", NULL); + "NVDIMM instantiation"); object_property_add_str(obj, "nvdimm-persistence", machine_get_nvdimm_persistence, @@ -906,8 +905,7 @@ static void machine_initfn(Object *obj) &error_abort); object_property_set_description(obj, "nvdimm-persistence", "Set NVDIMM persistence" - "Valid values are cpu, mem-ctrl", - NULL); + "Valid values are cpu, mem-ctrl"); } if (mc->cpu_index_to_instance_props && mc->get_default_cpu_node_id) { @@ -918,7 +916,7 @@ static void machine_initfn(Object *obj) object_property_set_description(obj, "hmat", "Set on/off to enable/disable " "ACPI Heterogeneous Memory Attribute " - "Table (HMAT)", NULL); + "Table (HMAT)"); } object_property_add_str(obj, "memory-backend", @@ -926,8 +924,7 @@ static void machine_initfn(Object *obj) &error_abort); object_property_set_description(obj, "memory-backend", "Set RAM backend" - "Valid value is ID of hostmem based backend", - &error_abort); + "Valid value is ID of hostmem based backend"); /* Register notifier when init is done for sysbus sanity checks */ ms->sysbus_notifier.notify = machine_init_notify; diff --git a/hw/core/qdev.c b/hw/core/qdev.c index dd77a56067..ea7118ab0e 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -775,8 +775,7 @@ void qdev_property_add_static(DeviceState *dev, Property *prop) prop, &error_abort); object_property_set_description(obj, prop->name, - prop->info->description, - &error_abort); + prop->info->description); if (prop->set_default) { prop->info->set_default_value(op, prop); @@ -805,8 +804,7 @@ static void qdev_class_add_property(DeviceClass *klass, Property *prop) } } object_class_property_set_description(oc, prop->name, - prop->info->description, - &error_abort); + prop->info->description); } /* @qdev_alias_all_properties - Add alias properties to the source object for |