From: Simon McVittie Date: Mon, 23 Jul 2018 17:02:42 +0000 (+0100) Subject: test: Avoid g_queue_foreach X-Git-Tag: dbus-1.13.6~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=963ce92f687f15efb25226fc022ce3a9bc9d386b;p=thirdparty%2Fdbus.git test: Avoid g_queue_foreach In gcc 8, -Wall -Wextra includes -Wcast-function-type, which warns about passing an extra (unwanted) parameter to callbacks. Instead of using g_list_foreach(), open-code the equivalent. Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107349 Reviewed-by: Thiago Macieira --- diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index 222b1028c..d25267ae0 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -1930,6 +1930,8 @@ teardown (Fixture *f, if (f->right_conn != NULL) { + GList *link; + if (f->right_conn_echo) { dbus_connection_remove_filter (f->right_conn, echo_filter, f); @@ -1942,7 +1944,9 @@ teardown (Fixture *f, f->right_conn_hold = FALSE; } - g_queue_foreach (&f->held_messages, (GFunc) dbus_message_unref, NULL); + for (link = f->held_messages.head; link != NULL; link = link->next) + dbus_message_unref (link->data); + g_queue_clear (&f->held_messages); dbus_connection_close (f->right_conn); diff --git a/test/header-fields.c b/test/header-fields.c index 088953bfc..019ff2181 100644 --- a/test/header-fields.c +++ b/test/header-fields.c @@ -719,10 +719,14 @@ out: if (f->right_conn != NULL) { + GList *link; + if (added_hold_filter) dbus_connection_remove_filter (f->right_conn, hold_filter, f); - g_queue_foreach (&f->held_messages, (GFunc) dbus_message_unref, NULL); + for (link = f->held_messages.head; link != NULL; link = link->next) + dbus_message_unref (link->data); + g_queue_clear (&f->held_messages); dbus_connection_close (f->right_conn); diff --git a/test/monitor.c b/test/monitor.c index 57f13af85..95b394bf3 100644 --- a/test/monitor.c +++ b/test/monitor.c @@ -1882,6 +1882,8 @@ static void teardown (Fixture *f, gconstpointer context G_GNUC_UNUSED) { + GList *link; + dbus_error_free (&f->e); g_clear_error (&f->ge); @@ -1936,10 +1938,14 @@ teardown (Fixture *f, test_main_context_unref (f->ctx); - g_queue_foreach (&f->monitored, (GFunc) dbus_message_unref, NULL); + for (link = f->monitored.head; link != NULL; link = link->next) + dbus_message_unref (link->data); + g_queue_clear (&f->monitored); - g_queue_foreach (&f->received, (GFunc) dbus_message_unref, NULL); + for (link = f->received.head; link != NULL; link = link->next) + dbus_message_unref (link->data); + g_queue_clear (&f->received); g_free (f->address);