diff options
author | Markus Armbruster <armbru@redhat.com> | 2020-07-07 18:05:53 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2020-07-10 15:18:08 +0200 |
commit | 1c94a351644fb2555f34e63c8ddc29f70bd4803a (patch) | |
tree | 1b514b71f4fd62bb48cbf7f26d8c16f1285319e2 /qom/object.c | |
parent | 4d21fcd52404ff4bac1f94d8054dfb745f1b2ad6 (diff) |
qom: Use return values to check for error where that's simpler
When using the Error object to check for error, we need to receive it
into a local variable, then propagate() it to @errp.
Using the return value permits allows receiving it straight to @errp.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200707160613.848843-26-armbru@redhat.com>
Diffstat (limited to 'qom/object.c')
-rw-r--r-- | qom/object.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/qom/object.c b/qom/object.c index e062ac5c82..be8fed6688 100644 --- a/qom/object.c +++ b/qom/object.c @@ -549,8 +549,7 @@ void object_initialize_child_with_propsv(Object *parentobj, object_initialize(childobj, size, type); obj = OBJECT(childobj); - object_set_propv(obj, &local_err, vargs); - if (local_err) { + if (object_set_propv(obj, errp, vargs) < 0) { goto out; } @@ -743,7 +742,7 @@ Object *object_new_with_propv(const char *typename, } obj = object_new_with_type(klass->type); - if (object_set_propv(obj, &local_err, vargs) < 0) { + if (object_set_propv(obj, errp, vargs) < 0) { goto error; } @@ -1777,20 +1776,24 @@ static void object_set_link_property(Object *obj, Visitor *v, LinkProperty *prop = opaque; Object **targetp = object_link_get_targetp(obj, prop); Object *old_target = *targetp; - Object *new_target = NULL; + Object *new_target; char *path = NULL; - visit_type_str(v, name, &path, &local_err); + if (!visit_type_str(v, name, &path, errp)) { + return; + } - if (!local_err && strcmp(path, "") != 0) { - new_target = object_resolve_link(obj, name, path, &local_err); + if (*path) { + new_target = object_resolve_link(obj, name, path, errp); + if (!new_target) { + g_free(path); + return; + } + } else { + new_target = NULL; } g_free(path); - if (local_err) { - error_propagate(errp, local_err); - return; - } prop->check(obj, name, new_target, &local_err); if (local_err) { |