[libvirt] [PATCH 4/6] Remove bogus call to dbus_set_error_from_message

Daniel P. Berrange berrange at redhat.com
Thu Mar 20 12:28:43 UTC 2014


The dbus_connection_send_with_reply_and_block method will
automatically call dbus_set_error_from_message for us. We
mistakenly thought we had todo it because of a flaw in the
systemd unit test mock impl. The latter should have directly
set the error object, instead of creating an error message
object.

Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
 src/util/virdbus.c     |  7 -------
 tests/virsystemdmock.c | 13 +++----------
 2 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index 85f8e29..8a978e5 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -1319,13 +1319,6 @@ int virDBusCall(DBusConnection *conn,
         goto cleanup;
     }
 
-    if (dbus_set_error_from_message(&error,
-                                    reply)) {
-        virReportDBusServiceError(error.message ? error.message : "unknown error",
-                                  error.name);
-        goto cleanup;
-    }
-
     ret = 0;
 
  cleanup:
diff --git a/tests/virsystemdmock.c b/tests/virsystemdmock.c
index b4fcf6e..23167db 100644
--- a/tests/virsystemdmock.c
+++ b/tests/virsystemdmock.c
@@ -70,16 +70,9 @@ DBusMessage *dbus_connection_send_with_reply_and_block(DBusConnection *connectio
 
     if (STREQ(service, "org.freedesktop.machine1")) {
         if (getenv("FAIL_BAD_SERVICE")) {
-            DBusMessageIter iter;
-            const char *error_message = "Something went wrong creating the machine";
-            if (!(reply = dbus_message_new(DBUS_MESSAGE_TYPE_ERROR)))
-                return NULL;
-            dbus_message_set_error_name(reply, "org.freedesktop.systemd.badthing");
-            dbus_message_iter_init_append(reply, &iter);
-            if (!dbus_message_iter_append_basic(&iter,
-                                                DBUS_TYPE_STRING,
-                                                &error_message))
-                goto error;
+            dbus_set_error_const(error,
+                                 "org.freedesktop.systemd.badthing",
+                                 "Something went wrong creating the machine");
         } else {
             reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
         }
-- 
1.8.5.3




More information about the libvir-list mailing list