From 634608db533762805c9b8a4d243a5413f56f1deb Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 17 Aug 2018 16:30:23 +0100 Subject: [PATCH 2/9] bus_connections_foreach, bus_connections_foreach_active: Remove These do not appear in code coverage statistics, and `git grep` reveals that they are unused. Signed-off-by: Simon McVittie --- bus/connection.c | 80 ------------------------------------------------ bus/connection.h | 10 ------ bus/test.h | 3 ++ 3 files changed, 3 insertions(+), 90 deletions(-) diff --git a/bus/connection.c b/bus/connection.c index 35f8e36e..25826b1b 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -1148,86 +1148,6 @@ bus_connection_get_policy (DBusConnection *connection) return d->policy; } -static dbus_bool_t -foreach_active (BusConnections *connections, - BusConnectionForeachFunction function, - void *data) -{ - DBusList *link; - - link = _dbus_list_get_first_link (&connections->completed); - while (link != NULL) - { - DBusConnection *connection = link->data; - DBusList *next = _dbus_list_get_next_link (&connections->completed, link); - - if (!(* function) (connection, data)) - return FALSE; - - link = next; - } - - return TRUE; -} - -static dbus_bool_t -foreach_inactive (BusConnections *connections, - BusConnectionForeachFunction function, - void *data) -{ - DBusList *link; - - link = _dbus_list_get_first_link (&connections->incomplete); - while (link != NULL) - { - DBusConnection *connection = link->data; - DBusList *next = _dbus_list_get_next_link (&connections->incomplete, link); - - if (!(* function) (connection, data)) - return FALSE; - - link = next; - } - - return TRUE; -} - -/** - * Calls function on each active connection; if the function returns - * #FALSE, stops iterating. Active connections are authenticated - * and have sent a Hello message. - * - * @param connections the connections object - * @param function the function - * @param data data to pass to it as a second arg - */ -void -bus_connections_foreach_active (BusConnections *connections, - BusConnectionForeachFunction function, - void *data) -{ - foreach_active (connections, function, data); -} - -/** - * Calls function on each connection; if the function returns - * #FALSE, stops iterating. - * - * @param connections the connections object - * @param function the function - * @param data data to pass to it as a second arg - */ -void -bus_connections_foreach (BusConnections *connections, - BusConnectionForeachFunction function, - void *data) -{ - if (!foreach_active (connections, function, data)) - return; - - foreach_inactive (connections, function, data); -} - BusContext* bus_connections_get_context (BusConnections *connections) { diff --git a/bus/connection.h b/bus/connection.h index 736a3b28..ad3fa8a3 100644 --- a/bus/connection.h +++ b/bus/connection.h @@ -34,21 +34,11 @@ typedef enum BUS_EXTRA_HEADERS_NONE = 0 } BusExtraHeaders; -typedef dbus_bool_t (* BusConnectionForeachFunction) (DBusConnection *connection, - void *data); - - BusConnections* bus_connections_new (BusContext *context); BusConnections* bus_connections_ref (BusConnections *connections); void bus_connections_unref (BusConnections *connections); dbus_bool_t bus_connections_setup_connection (BusConnections *connections, DBusConnection *connection); -void bus_connections_foreach (BusConnections *connections, - BusConnectionForeachFunction function, - void *data); -void bus_connections_foreach_active (BusConnections *connections, - BusConnectionForeachFunction function, - void *data); BusContext* bus_connections_get_context (BusConnections *connections); void bus_connections_increment_stamp (BusConnections *connections); dbus_bool_t bus_connections_reload_policy (BusConnections *connections, diff --git a/bus/test.h b/bus/test.h index 38b74e89..5b0fe085 100644 --- a/bus/test.h +++ b/bus/test.h @@ -30,6 +30,9 @@ #include #include "connection.h" +typedef dbus_bool_t (* BusConnectionForeachFunction) (DBusConnection *connection, + void *data); + dbus_bool_t bus_dispatch_test (const DBusString *test_data_dir); dbus_bool_t bus_dispatch_sha1_test (const DBusString *test_data_dir); dbus_bool_t bus_config_parser_test (const DBusString *test_data_dir); -- 2.19.0.rc1