]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
constants: drop duplicated CONF_PATHS defines
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 14 Dec 2023 09:52:34 +0000 (10:52 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 7 Mar 2024 17:47:50 +0000 (18:47 +0100)
Follow-up for b0d3095fd6cc1791a38f57a1982116b4475244ba.

src/basic/constants.h
src/environment-d-generator/environment-d-generator.c
src/partition/repart.c
src/shared/install.c
src/shared/pretty-print.c

index 6bb5f3c28127ea394859b7411e907bc3a1103c94..b86337405c679f55358f49aa99a9369e4fe6e1c6 100644 (file)
         "/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))
 
index 82fc57f1b106dba6633ff1f02974162ba5711788..236cf3859765819ec11778a53dc4f67195591d5a 100644 (file)
@@ -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;
 
index 7735bd458af33b78c7dd1bd67f231b06600041e3..44a785a7ed2c328565dce315f080d01d652c917e 100644 (file)
@@ -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);
 
index fabf5db7ed2e139548ff30073c96cf9addd442ac..7191f846a9cde3e8c15f1f76ed9adca0d7e3c3dc 100644 (file)
@@ -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);
index 946da5f42ddc752561be42726ca83cfb8010c481..3de193e264242a87a7f68049000c635c227ee64a 100644 (file)
@@ -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;