From: Yu Watanabe Date: Thu, 23 Nov 2023 20:20:07 +0000 (+0900) Subject: analyze: set SYSTEMD_UNIT_PATH in verify_generate_path() X-Git-Tag: v255-rc4~59^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ff7af46edb51c6548876e139c89389a388694051;p=thirdparty%2Fsystemd.git analyze: set SYSTEMD_UNIT_PATH in verify_generate_path() Then, rename verify_generate_path() -> verify_set_unit_path(). --- diff --git a/src/analyze/analyze-condition.c b/src/analyze/analyze-condition.c index 3b290e03230..1e9136d7c07 100644 --- a/src/analyze/analyze-condition.c +++ b/src/analyze/analyze-condition.c @@ -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); diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c index b119ad73513..5f1b5e69705 100644 --- a/src/analyze/analyze-security.c +++ b/src/analyze/analyze-security.c @@ -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) diff --git a/src/analyze/analyze-verify-util.c b/src/analyze/analyze-verify-util.c index 54442d06a9e..cfafbd4d44d 100644 --- a/src/analyze/analyze-verify-util.c +++ b/src/analyze/analyze-verify-util.c @@ -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) diff --git a/src/analyze/analyze-verify-util.h b/src/analyze/analyze-verify-util.h index 2e3b0604c31..0834c59c576 100644 --- a/src/analyze/analyze-verify-util.h +++ b/src/analyze/analyze-verify-util.h @@ -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);