]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test: Remove an unnecessary NULL check in sd-activation
authorPhilip Withnall <withnall@endlessm.com>
Tue, 28 Feb 2017 08:56:25 +0000 (08:56 +0000)
committerSimon McVittie <smcv@debian.org>
Mon, 20 Mar 2017 14:54:40 +0000 (14:54 +0000)
test_transient_services() was checking whether (config == NULL), then
shortly afterwards dereferencing config->bus_name (which is in fact
dereferenced on all branches of the function). Remove the check and add
some assertions to ensure a Config struct is always passed into the test
(which it currently is).

Coverity ID: 141877

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99999
Reviewed-by: Simon McVittie <smcv@collabora.com>
test/sd-activation.c

index cb5a7c7f026aff65e92f523887fe70dcc035ac34..8e0b2af6e8abf76bbe83335f1af9efe32b956c3b 100644 (file)
@@ -742,6 +742,9 @@ test_deny_receive (Fixture *f,
   DBusMessage *m;
   const Config *config = context;
 
+  g_assert (config != NULL);
+  g_assert (config->bus_name != NULL);
+
   if (f->address == NULL)
     return;
 
@@ -852,6 +855,9 @@ test_transient_services (Fixture *f,
   DBusMessage *reply = NULL;
   DBusPendingCall *pc;
 
+  g_assert (config != NULL);
+  g_assert (config->bus_name != NULL);
+
   if (f->address == NULL)
     return;
 
@@ -863,7 +869,7 @@ test_transient_services (Fixture *f,
   f->systemd_name = dbus_bus_get_unique_name (f->systemd);
   take_well_known_name (f, f->systemd, "org.freedesktop.systemd1");
 
-  if (config == NULL || (config->flags & FLAG_EARLY_TRANSIENT_SERVICE) == 0)
+  if ((config->flags & FLAG_EARLY_TRANSIENT_SERVICE) == 0)
     {
       /* Try to activate a service that isn't there. */
       m = dbus_message_new_method_call (config->bus_name,