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 /qom | |
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 'qom')
-rw-r--r-- | qom/object.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/qom/object.c b/qom/object.c index 4e5b2ecacd..58a6ec9b1b 100644 --- a/qom/object.c +++ b/qom/object.c @@ -2802,38 +2802,27 @@ object_property_add_alias(Object *obj, const char *name, } object_property_set_description(obj, op->name, - target_prop->description, - &error_abort); + target_prop->description); return op; } void object_property_set_description(Object *obj, const char *name, - const char *description, Error **errp) + const char *description) { ObjectProperty *op; - op = object_property_find(obj, name, errp); - if (!op) { - return; - } - + op = object_property_find(obj, name, &error_abort); g_free(op->description); op->description = g_strdup(description); } void object_class_property_set_description(ObjectClass *klass, const char *name, - const char *description, - Error **errp) + const char *description) { ObjectProperty *op; op = g_hash_table_lookup(klass->properties, name); - if (!op) { - error_setg(errp, "Property '.%s' not found", name); - return; - } - g_free(op->description); op->description = g_strdup(description); } |