]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
analyze: set SYSTEMD_UNIT_PATH in verify_generate_path()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 23 Nov 2023 20:20:07 +0000 (05:20 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 23 Nov 2023 20:20:13 +0000 (05:20 +0900)
Then, rename verify_generate_path() -> verify_set_unit_path().

src/analyze/analyze-condition.c
src/analyze/analyze-security.c
src/analyze/analyze-verify-util.c
src/analyze/analyze-verify-util.h

index 3b290e032306c54af1987166c661aa9543138a7f..1e9136d7c0751d89f4418ed4539a4b8cc6a6b4a1 100644 (file)
@@ -78,18 +78,9 @@ static int verify_conditions(char **lines, RuntimeScope scope, const char *unit,
         int r, q = 1;
 
         if (unit) {
-                _cleanup_strv_free_ char **filenames = NULL;
-                _cleanup_free_ char *var = NULL;
-
-                filenames = strv_new(unit);
-                if (!filenames)
-                        return log_oom();
-
-                r = verify_generate_path(&var, filenames);
+                r = verify_set_unit_path(STRV_MAKE(unit));
                 if (r < 0)
-                        return log_error_errno(r, "Failed to generate unit load path: %m");
-
-                assert_se(set_unit_path(var) >= 0);
+                        return log_error_errno(r, "Failed to set unit load path: %m");
         }
 
         r = manager_new(scope, MANAGER_TEST_RUN_MINIMAL|MANAGER_TEST_DONT_OPEN_EXECUTOR, &m);
index b119ad735138d364dde2c33f03cc0b8428214896..5f1b5e69705e2df3221c3276e6390b1f2d672ea5 100644 (file)
@@ -2695,19 +2695,15 @@ static int offline_security_checks(
 
         _cleanup_(manager_freep) Manager *m = NULL;
         Unit *units[strv_length(filenames)];
-        _cleanup_free_ char *var = NULL;
         int r, k;
         size_t count = 0;
 
         if (strv_isempty(filenames))
                 return 0;
 
-        /* set the path */
-        r = verify_generate_path(&var, filenames);
+        r = verify_set_unit_path(filenames);
         if (r < 0)
-                return log_error_errno(r, "Failed to generate unit load path: %m");
-
-        assert_se(set_unit_path(var) >= 0);
+                return log_error_errno(r, "Failed to set unit load path: %m");
 
         r = manager_new(scope, flags, &m);
         if (r < 0)
index 54442d06a9e30445e13ef7dd1382410d07478386..cfafbd4d44de03d857488e98f244695cd7097a79 100644 (file)
@@ -72,7 +72,7 @@ int verify_prepare_filename(const char *filename, char **ret) {
         return 0;
 }
 
-int verify_generate_path(char **ret, char **filenames) {
+int verify_set_unit_path(char **filenames) {
         _cleanup_strv_free_ char **ans = NULL;
         _cleanup_free_ char *joined = NULL;
         const char *old;
@@ -107,7 +107,7 @@ int verify_generate_path(char **ret, char **filenames) {
             !strextend_with_separator(&joined, ":", old ?: ""))
                 return -ENOMEM;
 
-        *ret = TAKE_PTR(joined);
+        assert_se(set_unit_path(joined) >= 0);
         return 0;
 }
 
@@ -242,7 +242,6 @@ int verify_units(
         _cleanup_(set_destroy_ignore_pointer_max) Set *s = NULL;
         _unused_ _cleanup_(clear_log_syntax_callback) dummy_t dummy;
         Unit *units[strv_length(filenames)];
-        _cleanup_free_ char *var = NULL;
         int r, k, count = 0;
 
         if (strv_isempty(filenames))
@@ -254,11 +253,9 @@ int verify_units(
         set_log_syntax_callback(log_syntax_callback, &s);
 
         /* set the path */
-        r = verify_generate_path(&var, filenames);
+        r = verify_set_unit_path(filenames);
         if (r < 0)
-                return log_error_errno(r, "Failed to generate unit load path: %m");
-
-        assert_se(set_unit_path(var) >= 0);
+                return log_error_errno(r, "Failed to set unit load path: %m");
 
         r = manager_new(scope, flags, &m);
         if (r < 0)
index 2e3b0604c31540f82d69c3c32d3565fcaaf6b301..0834c59c576cff87cd312871182ee051dbfe785d 100644 (file)
@@ -14,7 +14,7 @@ typedef enum RecursiveErrors {
         _RECURSIVE_ERRORS_INVALID = -EINVAL,
 } RecursiveErrors;
 
-int verify_generate_path(char **var, char **filenames);
+int verify_set_unit_path(char **filenames);
 int verify_prepare_filename(const char *filename, char **ret);
 int verify_executable(Unit *u, const ExecCommand *exec, const char *root);
 int verify_units(char **filenames, RuntimeScope scope, bool check_man, bool run_generators, RecursiveErrors recursive_errors, const char *root);