From 71264627d6f083082da553b96300390506c90ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Thu, 23 Jun 2016 12:26:45 +0000 Subject: [PATCH] Use dbus_set_error_from_message() to check for an error Do not rely on dbus_message_get_args() to turn an ERROR message into DBusError. https://bugs.freedesktop.org/show_bug.cgi?id=96653 --- test/dbus-daemon.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index 72bcd08..99d2bc6 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -526,7 +526,18 @@ test_processid (Fixture *f, while (m == NULL) test_main_context_iterate (f->ctx, TRUE); - if (dbus_message_get_args (m, &error, + if (dbus_set_error_from_message (&error, m)) + { + g_assert_cmpstr (error.name, ==, DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN); + +#ifdef PID_SHOULD_WORK + g_error ("Expected pid to be passed, but got %s: %s", + error.name, error.message); +#endif + + dbus_error_free (&error); + } + else if (dbus_message_get_args (m, &error, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID)) { @@ -545,14 +556,7 @@ test_processid (Fixture *f, } else { - g_assert_cmpstr (error.name, ==, DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN); - -#ifdef PID_SHOULD_WORK - g_error ("Expected pid to be passed, but got %s: %s", - error.name, error.message); -#endif - - dbus_error_free (&error); + g_error ("Unexpected error: %s: %s", error.name, error.message); } } -- 2.4.0