From b90ae4294d4a6c6dd548e7c2ee0c6402cece7b74 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 28 Feb 2017 08:56:25 +0000 Subject: [PATCH] test: Remove an unnecessary NULL check in sd-activation 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 https://bugs.freedesktop.org/show_bug.cgi?id=99999 --- test/sd-activation.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/sd-activation.c b/test/sd-activation.c index cb5a7c7..8e0b2af 100644 --- a/test/sd-activation.c +++ b/test/sd-activation.c @@ -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, -- 2.9.3