diff mbox series

[35/46] qom: Use return values to check for error where that's simpler

Message ID 20200624164344.3778251-36-armbru@redhat.com
State New
Headers show
Series [01/46] error: Improve examples in error.h's big comment | expand

Commit Message

Markus Armbruster June 24, 2020, 4:43 p.m. UTC
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>
---
 qom/object.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/qom/object.c b/qom/object.c
index f6e9f0e413..326a8de91e 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;
     }
 
@@ -1771,12 +1770,11 @@  static void object_set_link_property(Object *obj, Visitor *v,
     }
 
     if (strcmp(path, "") != 0) {
-        new_target = object_resolve_link(obj, name, path, &local_err);
+        new_target = object_resolve_link(obj, name, path, errp);
     }
 
     g_free(path);
-    if (local_err) {
-        error_propagate(errp, local_err);
+    if (!new_target) {
         return;
     }