diff options
Diffstat (limited to 'test/name-test/test-privserver.c')
-rw-r--r-- | test/name-test/test-privserver.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/test/name-test/test-privserver.c b/test/name-test/test-privserver.c index 39a98b7f..c6de7348 100644 --- a/test/name-test/test-privserver.c +++ b/test/name-test/test-privserver.c @@ -1,6 +1,9 @@ #include <config.h> #include "../test-utils.h" +static void die (const char *message, + ...) _DBUS_GNUC_NORETURN _DBUS_GNUC_PRINTF (1, 2); + static void die (const char *message, ...) { @@ -42,11 +45,20 @@ filter_session_message (DBusConnection *connection, "GetPrivateAddress")) { DBusMessage *reply; + reply = dbus_message_new_method_return (message); - dbus_message_append_args (reply, DBUS_TYPE_STRING, - &(testdata->private_addr), DBUS_TYPE_INVALID); - dbus_connection_send (connection, reply, NULL); + if (reply == NULL) + die ("OOM"); + if (!dbus_message_append_args (reply, DBUS_TYPE_STRING, + &(testdata->private_addr), + DBUS_TYPE_INVALID)) + die ("OOM"); + + if (!dbus_connection_send (connection, reply, NULL)) + die ("Error sending message"); + dbus_message_unref (reply); + return DBUS_HANDLER_RESULT_HANDLED; } else if (dbus_message_is_method_call (message, @@ -95,9 +107,9 @@ main (int argc, char *argv[]) server = dbus_server_listen ("unix:tmpdir=/tmp", &error); #endif if (!server) - die (error.message); + die ("%s", error.message); testdata->private_addr = dbus_server_get_address (server); - printf ("test server listening on %s\n", testdata->private_addr); + fprintf (stderr, "test server listening on %s\n", testdata->private_addr); dbus_server_set_new_connection_function (server, new_connection_callback, testdata, NULL); |