]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add checking of dbus_message_iter_append_basic return value
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 20 Sep 2013 10:47:33 +0000 (11:47 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 20 Sep 2013 11:38:24 +0000 (12:38 +0100)
Coverity complains that the test suite did not check the
return value of dbus_message_iter_append_basic() as we did
in most other places.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
tests/virsystemdmock.c

index 59b312daf9950e573f01b16bd69ddcbe425a0a11..b8fc031909d855baaa4f55380e29c9a32746069b 100644 (file)
@@ -82,10 +82,8 @@ DBusMessage *dbus_connection_send_with_reply_and_block(DBusConnection *connectio
             dbus_message_iter_init_append(reply, &iter);
             if (!dbus_message_iter_append_basic(&iter,
                                                 DBUS_TYPE_STRING,
-                                                &error_message)) {
-                dbus_message_unref(reply);
-                return NULL;
-            }
+                                                &error_message))
+                goto error;
         } else {
             reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
         }
@@ -98,19 +96,25 @@ DBusMessage *dbus_connection_send_with_reply_and_block(DBusConnection *connectio
         dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
                                          "s", &sub);
 
-        dbus_message_iter_append_basic(&sub,
+        if (!dbus_message_iter_append_basic(&sub,
                                        DBUS_TYPE_STRING,
-                                       &svc1);
-        if (!getenv("FAIL_NO_SERVICE"))
-            dbus_message_iter_append_basic(&sub,
-                                           DBUS_TYPE_STRING,
-                                           &svc2);
+                                            &svc1))
+            goto error;
+        if (!getenv("FAIL_NO_SERVICE") &&
+            !dbus_message_iter_append_basic(&sub,
+                                            DBUS_TYPE_STRING,
+                                            &svc2))
+            goto error;
         dbus_message_iter_close_container(&iter, &sub);
     } else {
         reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
     }
 
     return reply;
+
+ error:
+    dbus_message_unref(reply);
+    return NULL;
 }
 
 #else