Skip to content

Commit

Permalink
qom: Drop @errp parameter of object_property_del()
Browse files Browse the repository at this point in the history
Same story as for object_property_add(): the only way
object_property_del() can fail is when the property with this name
does not exist.  Since our property names are all hardcoded, failure
is a programming error, and the appropriate way to handle it is
passing &error_abort.  Most callers do that, the commit before
previous fixed one that didn't (and got the error handling wrong), and
the two remaining exceptions ignore errors.

Drop the @errp parameter.

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
  • Loading branch information
Markus Armbruster committed May 15, 2020
1 parent 7ef1553 commit df4fe0b
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion hw/core/qdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static void bus_remove_child(BusState *bus, DeviceState *child)
bus->num_children--;

/* This gives back ownership of kid->child back to us. */
object_property_del(OBJECT(bus), name, NULL);
object_property_del(OBJECT(bus), name);
object_unref(OBJECT(kid->child));
g_free(kid);
return;
Expand Down
2 changes: 1 addition & 1 deletion hw/i386/pc_sysfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static void pc_system_flash_cleanup_unused(PCMachineState *pcms)
dev_obj = OBJECT(pcms->flash[i]);
if (!object_property_get_bool(dev_obj, "realized", &error_abort)) {
prop_name = g_strdup_printf("pflash%d", i);
object_property_del(OBJECT(pcms), prop_name, &error_abort);
object_property_del(OBJECT(pcms), prop_name);
g_free(prop_name);
object_unparent(dev_obj);
pcms->flash[i] = NULL;
Expand Down
4 changes: 2 additions & 2 deletions hw/ppc/spapr_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ static void spapr_drc_release(SpaprDrc *drc)
g_free(drc->fdt);
drc->fdt = NULL;
drc->fdt_start_offset = 0;
object_property_del(OBJECT(drc), "device", &error_abort);
object_property_del(OBJECT(drc), "device");
drc->dev = NULL;
}

Expand Down Expand Up @@ -551,7 +551,7 @@ static void unrealize(DeviceState *d)
vmstate_unregister(VMSTATE_IF(drc), &vmstate_spapr_drc, drc);
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
name = g_strdup_printf("%x", spapr_drc_index(drc));
object_property_del(root_container, name, &error_abort);
object_property_del(root_container, name);
g_free(name);
}

Expand Down
2 changes: 1 addition & 1 deletion include/qom/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ ObjectProperty *object_property_add(Object *obj, const char *name,
ObjectPropertyRelease *release,
void *opaque);

void object_property_del(Object *obj, const char *name, Error **errp);
void object_property_del(Object *obj, const char *name);

ObjectProperty *object_class_property_add(ObjectClass *klass, const char *name,
const char *type,
Expand Down
7 changes: 1 addition & 6 deletions qom/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,15 +1280,10 @@ ObjectProperty *object_class_property_find(ObjectClass *klass, const char *name,
return prop;
}

void object_property_del(Object *obj, const char *name, Error **errp)
void object_property_del(Object *obj, const char *name)
{
ObjectProperty *prop = g_hash_table_lookup(obj->properties, name);

if (!prop) {
error_setg(errp, "Property '.%s' not found", name);
return;
}

if (prop->release) {
prop->release(obj, name, prop->opaque);
}
Expand Down
3 changes: 1 addition & 2 deletions qom/object_interfaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ Object *user_creatable_add_type(const char *type, const char *id,
user_creatable_complete(USER_CREATABLE(obj), &local_err);
if (local_err) {
if (id != NULL) {
object_property_del(object_get_objects_root(),
id, &error_abort);
object_property_del(object_get_objects_root(), id);
}
goto out;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/check-qom-proplist.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static void dummy_bus_init(Object *obj)
static void dummy_bus_unparent(Object *obj)
{
DummyBus *bus = DUMMY_BUS(obj);
object_property_del(obj->parent, "backend", NULL);
object_property_del(obj->parent, "backend");
object_unparent(OBJECT(bus->backend));
}

Expand Down

0 comments on commit df4fe0b

Please sign in to comment.