summaryrefslogtreecommitdiff
path: root/test/sd-activation.c
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2017-11-21 11:59:20 +0000
committerSimon McVittie <smcv@collabora.com>2017-11-24 12:19:12 +0000
commit9baff7044e58fa70f89737b632960cfc3f5efbdf (patch)
tree61e6497933649ad88579e66140603dde5ceee6ff /test/sd-activation.c
parentdaf9b7dab99308d2925b3527ea7d1d519c850f78 (diff)
downloaddbus-9baff7044e58fa70f89737b632960cfc3f5efbdf.tar.gz
tests: Don't use the same variable for call and reply
It seemed like a nice idea at the time, but I now think it's more confusing than it's worth. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103600
Diffstat (limited to 'test/sd-activation.c')
-rw-r--r--test/sd-activation.c53
1 files changed, 23 insertions, 30 deletions
diff --git a/test/sd-activation.c b/test/sd-activation.c
index bf6f8b6f..c8e41225 100644
--- a/test/sd-activation.c
+++ b/test/sd-activation.c
@@ -522,8 +522,9 @@ static void
test_uae (Fixture *f,
gconstpointer context)
{
- DBusMessage *m;
- DBusPendingCall *pc;
+ DBusMessage *m = NULL;
+ DBusMessage *reply = NULL;
+ DBusPendingCall *pc = NULL;
DBusMessageIter args_iter, arr_iter, entry_iter;
const char *s;
@@ -548,21 +549,19 @@ test_uae (Fixture *f,
DBUS_TIMEOUT_USE_DEFAULT) || pc == NULL)
g_error ("OOM");
- dbus_message_unref (m);
- m = NULL;
-
if (dbus_pending_call_get_completed (pc))
- test_pending_call_store_reply (pc, &m);
+ test_pending_call_store_reply (pc, &reply);
else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply,
- &m, NULL))
+ &reply, NULL))
g_error ("OOM");
- while (m == NULL)
+ while (reply == NULL)
test_main_context_iterate (f->ctx, TRUE);
- assert_method_reply (m, DBUS_SERVICE_DBUS, f->caller_name, "");
+ assert_method_reply (reply, DBUS_SERVICE_DBUS, f->caller_name, "");
dbus_clear_pending_call (&pc);
+ dbus_clear_message (&reply);
dbus_clear_message (&m);
/* The fake systemd connects to the bus. */
@@ -635,21 +634,19 @@ test_uae (Fixture *f,
DBUS_TIMEOUT_USE_DEFAULT) || pc == NULL)
g_error ("OOM");
- dbus_message_unref (m);
- m = NULL;
-
if (dbus_pending_call_get_completed (pc))
- test_pending_call_store_reply (pc, &m);
+ test_pending_call_store_reply (pc, &reply);
else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply,
- &m, NULL))
+ &reply, NULL))
g_error ("OOM");
- while (m == NULL)
+ while (reply == NULL)
test_main_context_iterate (f->ctx, TRUE);
- assert_method_reply (m, DBUS_SERVICE_DBUS, f->caller_name, "");
+ assert_method_reply (reply, DBUS_SERVICE_DBUS, f->caller_name, "");
dbus_clear_pending_call (&pc);
+ dbus_clear_message (&reply);
dbus_clear_message (&m);
while (f->systemd_message == NULL)
@@ -884,24 +881,22 @@ test_transient_services (Fixture *f,
DBUS_TIMEOUT_USE_DEFAULT) || pc == NULL)
g_error ("OOM");
- dbus_message_unref (m);
- m = NULL;
-
/* It fails. */
if (dbus_pending_call_get_completed (pc))
- test_pending_call_store_reply (pc, &m);
+ test_pending_call_store_reply (pc, &reply);
else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply,
- &m, NULL))
+ &reply, NULL))
g_error ("OOM");
- while (m == NULL)
+ while (reply == NULL)
test_main_context_iterate (f->ctx, TRUE);
- assert_error_reply (m, DBUS_SERVICE_DBUS, f->caller_name,
+ assert_error_reply (reply, DBUS_SERVICE_DBUS, f->caller_name,
DBUS_ERROR_SERVICE_UNKNOWN);
dbus_clear_pending_call (&pc);
+ dbus_clear_message (&reply);
dbus_clear_message (&m);
/* Now generate a transient D-Bus service file for it. The directory
@@ -919,21 +914,19 @@ test_transient_services (Fixture *f,
DBUS_TIMEOUT_USE_DEFAULT) || pc == NULL)
g_error ("OOM");
- dbus_message_unref (m);
- m = NULL;
-
if (dbus_pending_call_get_completed (pc))
- test_pending_call_store_reply (pc, &m);
+ test_pending_call_store_reply (pc, &reply);
else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply,
- &m, NULL))
+ &reply, NULL))
g_error ("OOM");
- while (m == NULL)
+ while (reply == NULL)
test_main_context_iterate (f->ctx, TRUE);
- assert_method_reply (m, DBUS_SERVICE_DBUS, f->caller_name, "");
+ assert_method_reply (reply, DBUS_SERVICE_DBUS, f->caller_name, "");
dbus_clear_pending_call (&pc);
+ dbus_clear_message (&reply);
dbus_clear_message (&m);
}