From: Zbigniew Jędrzejewski-Szmek Date: Thu, 14 Dec 2023 09:41:13 +0000 (+0100) Subject: various: use modern strv helpers X-Git-Tag: v256-rc1~601^2~13 X-Git-Url: http://git-history.diyao.me/?a=commitdiff_plain;h=8f43182847afa56bad6d916d9db1ffe5206fc447;p=systemd%2F.git various: use modern strv helpers If we're building a strv, let's just use strv_new() with the CONF_PATHS macro, which gives as an exploded string set. --- diff --git a/src/analyze/analyze-cat-config.c b/src/analyze/analyze-cat-config.c index 073bc94018..b480d4a009 100644 --- a/src/analyze/analyze-cat-config.c +++ b/src/analyze/analyze-cat-config.c @@ -4,7 +4,6 @@ #include "analyze-cat-config.h" #include "conf-files.h" #include "constants.h" -#include "nulstr-util.h" #include "path-util.h" #include "pretty-print.h" #include "strv.h" @@ -23,7 +22,7 @@ int verb_cat_config(int argc, char *argv[], void *userdata) { print_separator(); if (path_is_absolute(*arg)) { - NULSTR_FOREACH(dir, CONF_PATHS_NULSTR("")) { + FOREACH_STRING(dir, CONF_PATHS("")) { t = path_startswith(*arg, dir); if (t) break; diff --git a/src/basic/strv.c b/src/basic/strv.c index 72cbbfe2f4..37199ebf04 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -252,11 +252,9 @@ int strv_extend_strv_concat(char ***a, char * const *b, const char *suffix) { if (!v) return -ENOMEM; - r = strv_push(a, v); - if (r < 0) { - free(v); + r = strv_consume(a, v); + if (r < 0) return r; - } } return 0; diff --git a/src/environment-d-generator/environment-d-generator.c b/src/environment-d-generator/environment-d-generator.c index fa2c54af31..82fc57f1b1 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"), NULL); + dirs = strv_new(CONF_PATHS_USR("environment.d")); if (!dirs) return -ENOMEM; diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c index f2b3bfb575..c7ea57ab09 100644 --- a/src/shared/tpm2-util.c +++ b/src/shared/tpm2-util.c @@ -7643,7 +7643,7 @@ int tpm2_load_pcr_signature(const char *path, JsonVariant **ret) { /* Tries to load a JSON PCR signature file. Takes an absolute path, a simple file name or NULL. In * the latter two cases searches in /etc/, /usr/lib/, /run/, as usual. */ - search = strv_split_nulstr(CONF_PATHS_NULSTR("systemd")); + search = strv_new(CONF_PATHS("systemd")); if (!search) return log_oom_debug(); diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 75db789f50..958341bc5b 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -49,7 +49,6 @@ #include "mkdir-label.h" #include "mount-util.h" #include "mountpoint-util.h" -#include "nulstr-util.h" #include "offline-passwd.h" #include "pager.h" #include "parse-argument.h" @@ -4580,7 +4579,7 @@ static int run(int argc, char *argv[]) { break; case RUNTIME_SCOPE_SYSTEM: - config_dirs = strv_split_nulstr(CONF_PATHS_NULSTR("tmpfiles.d")); + config_dirs = strv_new(CONF_PATHS("tmpfiles.d")); if (!config_dirs) return log_oom(); break;