From e7c01bef72bd4b14d8af78e3e84206bf9cf97b1c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 23 Jul 2018 18:02:42 +0100 Subject: [PATCH 7/7] 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 --- test/dbus-daemon.c | 6 +++++- test/header-fields.c | 6 +++++- test/monitor.c | 10 ++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index e18a42ed..47d2c70d 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -1937,6 +1937,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); @@ -1949,7 +1951,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); test_connection_shutdown (f->ctx, f->right_conn); diff --git a/test/header-fields.c b/test/header-fields.c index 54e25798..b0d89d61 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 6f6e9212..eb11eb81 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); @@ -1942,10 +1944,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); -- 2.18.0