From fdd182d400ac0129141f19c5a4c7b9cf574e9ef5 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 13 Feb 2017 19:31:39 +0000 Subject: [PATCH 01/11] config-parser: Eliminate duplicate functionality We had two ways to append a path to the list of service directories. Collapse them into one. Signed-off-by: Simon McVittie --- bus/config-parser.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/bus/config-parser.c b/bus/config-parser.c index b776a2d0..cc5690dd 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -252,17 +252,6 @@ service_dirs_find_dir (DBusList **service_dirs, return FALSE; } -static dbus_bool_t -service_dirs_append_unique_or_free (DBusList **service_dirs, - char *dir) -{ - if (!service_dirs_find_dir (service_dirs, dir)) - return _dbus_list_append (service_dirs, dir); - - dbus_free (dir); - return TRUE; -} - static void service_dirs_append_link_unique_or_free (DBusList **service_dirs, DBusList *dir_link) @@ -2601,7 +2590,8 @@ bus_config_parser_content (BusConfigParser *parser, { char *s; DBusString full_path; - + DBusList *link; + e->had_content = TRUE; if (!_dbus_string_init (&full_path)) @@ -2619,14 +2609,17 @@ bus_config_parser_content (BusConfigParser *parser, goto nomem; } - /* _only_ extra session directories can be specified */ - if (!service_dirs_append_unique_or_free (&parser->service_dirs, s)) + link = _dbus_list_alloc_link (s); + + if (link == NULL) { _dbus_string_free (&full_path); dbus_free (s); goto nomem; } + /* cannot fail */ + service_dirs_append_link_unique_or_free (&parser->service_dirs, link); _dbus_string_free (&full_path); } break; -- 2.11.0