From: Zbigniew Jędrzejewski-Szmek Date: Thu, 14 Dec 2023 09:52:34 +0000 (+0100) Subject: constants: drop duplicated CONF_PATHS defines X-Git-Tag: v256-rc1~601^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76d75d8b7b6b19fa1709471ff17e56daf2cb4d04;p=thirdparty%2Fsystemd.git constants: drop duplicated CONF_PATHS defines Follow-up for b0d3095fd6cc1791a38f57a1982116b4475244ba. --- diff --git a/src/basic/constants.h b/src/basic/constants.h index 6bb5f3c2812..b86337405c6 100644 --- a/src/basic/constants.h +++ b/src/basic/constants.h @@ -67,18 +67,12 @@ "/usr/local/lib/" n "\0" \ "/usr/lib/" n "\0" -#define CONF_PATHS_USR(n) \ +#define CONF_PATHS(n) \ "/etc/" n, \ "/run/" n, \ "/usr/local/lib/" n, \ "/usr/lib/" n -#define CONF_PATHS(n) \ - CONF_PATHS_USR(n) - -#define CONF_PATHS_USR_STRV(n) \ - STRV_MAKE(CONF_PATHS_USR(n)) - #define CONF_PATHS_STRV(n) \ STRV_MAKE(CONF_PATHS(n)) diff --git a/src/environment-d-generator/environment-d-generator.c b/src/environment-d-generator/environment-d-generator.c index 82fc57f1b10..236cf385976 100644 --- a/src/environment-d-generator/environment-d-generator.c +++ b/src/environment-d-generator/environment-d-generator.c @@ -17,7 +17,7 @@ static int environment_dirs(char ***ret) { _cleanup_free_ char *c = NULL; int r; - dirs = strv_new(CONF_PATHS_USR("environment.d")); + dirs = strv_new(CONF_PATHS("environment.d")); if (!dirs) return -ENOMEM; diff --git a/src/partition/repart.c b/src/partition/repart.c index 7735bd458af..44a785a7ed2 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -7997,7 +7997,7 @@ static int run(int argc, char *argv[]) { if (!d) return log_oom(); - r = search_and_access(d, F_OK, NULL, CONF_PATHS_USR_STRV("systemd/repart/definitions"), &dp); + r = search_and_access(d, F_OK, NULL, CONF_PATHS_STRV("systemd/repart/definitions"), &dp); if (r < 0) return log_error_errno(r, "DDI type '%s' is not defined: %m", arg_make_ddi); diff --git a/src/shared/install.c b/src/shared/install.c index fabf5db7ed2..7191f846a9c 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -3218,8 +3218,8 @@ static int split_pattern_into_name_and_instances(const char *pattern, char **out } static int presets_find_config(RuntimeScope scope, const char *root_dir, char ***files) { - static const char* const system_dirs[] = {CONF_PATHS("systemd/system-preset"), NULL}; - static const char* const user_dirs[] = {CONF_PATHS_USR("systemd/user-preset"), NULL}; + static const char* const system_dirs[] = { CONF_PATHS("systemd/system-preset"), NULL }; + static const char* const user_dirs[] = { CONF_PATHS("systemd/user-preset"), NULL }; const char* const* dirs; assert(scope >= 0); diff --git a/src/shared/pretty-print.c b/src/shared/pretty-print.c index 946da5f42dd..3de193e2642 100644 --- a/src/shared/pretty-print.c +++ b/src/shared/pretty-print.c @@ -316,11 +316,10 @@ static int guess_type(const char **name, char ***prefixes, bool *is_collection, */ _cleanup_free_ char *n = NULL; - bool usr = false, run = false, coll = false; + bool run = false, coll = false; const char *ext = ".conf"; /* This is static so that the array doesn't get deallocated when we exit the function */ static const char* const std_prefixes[] = { CONF_PATHS(""), NULL }; - static const char* const usr_prefixes[] = { CONF_PATHS_USR(""), NULL }; static const char* const run_prefixes[] = { "/run/", NULL }; if (path_equal(*name, "environment.d")) @@ -332,20 +331,13 @@ static int guess_type(const char **name, char ***prefixes, bool *is_collection, if (!n) return log_oom(); - /* All systemd-style config files should support the /usr-/etc-/run split and - * dropins. Let's add a blanket rule that allows us to support them without keeping - * an explicit list. */ - if (path_startswith(n, "systemd") && endswith(n, ".conf")) - usr = true; - delete_trailing_chars(n, "/"); + /* We assume systemd-style config files support the /usr-/run-/etc split and dropins. */ + if (endswith(n, ".d")) coll = true; - if (path_equal(n, "environment")) - usr = true; - if (path_equal(n, "udev/hwdb.d")) ext = ".hwdb"; else if (path_equal(n, "udev/rules.d")) @@ -363,10 +355,7 @@ static int guess_type(const char **name, char ***prefixes, bool *is_collection, ext = ".preset"; } - if (path_equal(n, "systemd/user-preset")) - usr = true; - - *prefixes = (char**) (usr ? usr_prefixes : run ? run_prefixes : std_prefixes); + *prefixes = (char**) (run ? run_prefixes : std_prefixes); *is_collection = coll; *extension = ext; return 0;