From b6c9f52545b36b5410b18a67de9a6b71d0219084 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 21 Nov 2017 10:56:56 +0000 Subject: [PATCH 2/8] test/dbus-daemon: Don't leak method call messages if we skip tests Signed-off-by: Simon McVittie --- test/dbus-daemon.c | 72 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index 3d5c147f..ce8edc82 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -1296,8 +1296,7 @@ static void test_get_invalid_path (Fixture *f, gconstpointer context) { - DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, - "/", DBUS_INTERFACE_PROPERTIES, "Get"); + DBusMessage *m = NULL; DBusPendingCall *pc = NULL; DBusError error = DBUS_ERROR_INIT; const char *iface = DBUS_INTERFACE_DBUS; @@ -1306,6 +1305,9 @@ test_get_invalid_path (Fixture *f, if (f->skip) return; + m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, "/", + DBUS_INTERFACE_PROPERTIES, "Get"); + if (m == NULL || !dbus_message_append_args (m, DBUS_TYPE_STRING, &iface, @@ -1342,8 +1344,7 @@ static void test_get_invalid_iface (Fixture *f, gconstpointer context) { - DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Get"); + DBusMessage *m = NULL; DBusPendingCall *pc = NULL; DBusError error = DBUS_ERROR_INIT; const char *iface = "com.example.Nope"; @@ -1352,6 +1353,9 @@ test_get_invalid_iface (Fixture *f, if (f->skip) return; + m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Get"); + if (m == NULL || !dbus_message_append_args (m, DBUS_TYPE_STRING, &iface, @@ -1387,8 +1391,7 @@ static void test_get_invalid (Fixture *f, gconstpointer context) { - DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Get"); + DBusMessage *m = NULL; DBusPendingCall *pc = NULL; DBusError error = DBUS_ERROR_INIT; const char *iface = DBUS_INTERFACE_DBUS; @@ -1397,6 +1400,9 @@ test_get_invalid (Fixture *f, if (f->skip) return; + m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Get"); + if (m == NULL || !dbus_message_append_args (m, DBUS_TYPE_STRING, &iface, @@ -1432,8 +1438,7 @@ static void test_get_all_invalid_iface (Fixture *f, gconstpointer context) { - DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "GetAll"); + DBusMessage *m = NULL; DBusPendingCall *pc = NULL; DBusError error = DBUS_ERROR_INIT; const char *iface = "com.example.Nope"; @@ -1441,6 +1446,9 @@ test_get_all_invalid_iface (Fixture *f, if (f->skip) return; + m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "GetAll"); + if (m == NULL || !dbus_message_append_args (m, DBUS_TYPE_STRING, &iface, @@ -1475,8 +1483,7 @@ static void test_get_all_invalid_path (Fixture *f, gconstpointer context) { - DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, - "/", DBUS_INTERFACE_PROPERTIES, "GetAll"); + DBusMessage *m = NULL; DBusPendingCall *pc = NULL; DBusError error = DBUS_ERROR_INIT; const char *iface = DBUS_INTERFACE_DBUS; @@ -1484,6 +1491,9 @@ test_get_all_invalid_path (Fixture *f, if (f->skip) return; + m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + "/", DBUS_INTERFACE_PROPERTIES, "GetAll"); + if (m == NULL || !dbus_message_append_args (m, DBUS_TYPE_STRING, &iface, @@ -1519,8 +1529,7 @@ static void test_set_invalid_iface (Fixture *f, gconstpointer context) { - DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Set"); + DBusMessage *m = NULL; DBusPendingCall *pc = NULL; DBusError error = DBUS_ERROR_INIT; const char *iface = "com.example.Nope"; @@ -1532,6 +1541,9 @@ test_set_invalid_iface (Fixture *f, if (f->skip) return; + m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Set"); + if (m == NULL || !dbus_message_append_args (m, DBUS_TYPE_STRING, &iface, @@ -1575,8 +1587,7 @@ static void test_set_invalid_path (Fixture *f, gconstpointer context) { - DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, - "/", DBUS_INTERFACE_PROPERTIES, "Set"); + DBusMessage *m = NULL; DBusPendingCall *pc = NULL; DBusError error = DBUS_ERROR_INIT; const char *iface = DBUS_INTERFACE_DBUS; @@ -1588,6 +1599,9 @@ test_set_invalid_path (Fixture *f, if (f->skip) return; + m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + "/", DBUS_INTERFACE_PROPERTIES, "Set"); + if (m == NULL || !dbus_message_append_args (m, DBUS_TYPE_STRING, &iface, @@ -1631,8 +1645,7 @@ static void test_set_invalid (Fixture *f, gconstpointer context) { - DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Set"); + DBusMessage *m = NULL; DBusPendingCall *pc = NULL; DBusError error = DBUS_ERROR_INIT; const char *iface = DBUS_INTERFACE_DBUS; @@ -1644,6 +1657,9 @@ test_set_invalid (Fixture *f, if (f->skip) return; + m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Set"); + if (m == NULL || !dbus_message_append_args (m, DBUS_TYPE_STRING, &iface, @@ -1687,8 +1703,7 @@ static void test_set (Fixture *f, gconstpointer context) { - DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Set"); + DBusMessage *m = NULL; DBusPendingCall *pc = NULL; DBusError error = DBUS_ERROR_INIT; const char *iface = DBUS_INTERFACE_DBUS; @@ -1700,6 +1715,9 @@ test_set (Fixture *f, if (f->skip) return; + m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Set"); + if (m == NULL || !dbus_message_append_args (m, DBUS_TYPE_STRING, &iface, @@ -1781,8 +1799,7 @@ static void test_features (Fixture *f, gconstpointer context) { - DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Get"); + DBusMessage *m = NULL; DBusPendingCall *pc = NULL; DBusMessageIter args_iter; DBusMessageIter var_iter; @@ -1792,6 +1809,9 @@ test_features (Fixture *f, if (f->skip) return; + m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Get"); + if (m == NULL || !dbus_message_append_args (m, DBUS_TYPE_STRING, &iface, @@ -1886,8 +1906,7 @@ static void test_interfaces (Fixture *f, gconstpointer context) { - DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Get"); + DBusMessage *m = NULL; DBusPendingCall *pc = NULL; DBusMessageIter args_iter; DBusMessageIter var_iter; @@ -1897,6 +1916,9 @@ test_interfaces (Fixture *f, if (f->skip) return; + m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Get"); + if (m == NULL || !dbus_message_append_args (m, DBUS_TYPE_STRING, &iface, @@ -1938,8 +1960,7 @@ static void test_get_all (Fixture *f, gconstpointer context) { - DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "GetAll"); + DBusMessage *m = NULL; DBusPendingCall *pc = NULL; DBusMessageIter args_iter; DBusMessageIter arr_iter; @@ -1952,6 +1973,9 @@ test_get_all (Fixture *f, if (f->skip) return; + m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "GetAll"); + if (m == NULL || !dbus_message_append_args (m, DBUS_TYPE_STRING, &iface, -- 2.15.0