]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
config-parser: Eliminate duplicate functionality
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 13 Feb 2017 19:31:39 +0000 (19:31 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 17 Feb 2017 12:16:32 +0000 (12:16 +0000)
We had two ways to append a path to the list of service directories.
Collapse them into one.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99825
Reviewed-by: Philip Withnall <withnall@endlessm.com>
bus/config-parser.c

index b776a2d0935c8de42107c5e696f0e71fd2911eb6..cc5690dd84bb18708463f1bec96c40110667eb15 100644 (file)
@@ -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;