From 07e0ffc8234b8212a6509fe6dbc1811be03fc3ae Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Fri, 27 Jan 2023 11:32:27 +0100 Subject: conf: replace config_parse_many_nulstr() with config_parse_config_file() All daemons use a similar scheme to read their main config files and theirs drop-ins. The main config files are always stored in /etc/systemd directory and it's easy enough to construct the name of the drop-in directories based on the name of the main config file. Hence the new helper does that internally, which allows to reduce and simplify the args passed previously to config_parse_many_nulstr(). Besides the overall code simplification it results: 16 files changed, 87 insertions(+), 159 deletions(-) it allows to identify clearly the locations in the code where configuration files are parsed. --- src/core/main.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src/core/main.c') diff --git a/src/core/main.c b/src/core/main.c index 3f63150f31..5f8f251e9a 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -704,33 +704,32 @@ static int parse_config_file(void) { {} }; - _cleanup_strv_free_ char **files = NULL, **dirs = NULL; - const char *suffix; - int r; - if (arg_runtime_scope == RUNTIME_SCOPE_SYSTEM) - suffix = "system.conf.d"; + (void) config_parse_config_file("system.conf", + "Manager\0", + config_item_table_lookup, items, + CONFIG_PARSE_WARN, + NULL); else { + _cleanup_strv_free_ char **files = NULL, **dirs = NULL; + int r; + assert(arg_runtime_scope == RUNTIME_SCOPE_USER); r = manager_find_user_config_paths(&files, &dirs); if (r < 0) return log_error_errno(r, "Failed to determine config file paths: %m"); - suffix = "user.conf.d"; + (void) config_parse_many( + (const char* const*) files, + (const char* const*) dirs, + "user.conf.d", + "Manager\0", + config_item_table_lookup, items, + CONFIG_PARSE_WARN, + NULL, NULL, NULL); } - (void) config_parse_many( - (const char* const*) (files ?: STRV_MAKE(PKGSYSCONFDIR "/system.conf")), - (const char* const*) (dirs ?: CONF_PATHS_STRV("systemd")), - suffix, - "Manager\0", - config_item_table_lookup, items, - CONFIG_PARSE_WARN, - NULL, - NULL, - NULL); - /* Traditionally "0" was used to turn off the default unit timeouts. Fix this up so that we use * USEC_INFINITY like everywhere else. */ if (arg_default_timeout_start_usec <= 0) -- cgit v1.2.1