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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2024-02-28 11:10:34 +01:00
parent eafadb91ce
commit 8f43182847
5 changed files with 6 additions and 10 deletions
+1 -2
View File
@@ -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;
+2 -4
View File
@@ -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;
@@ -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;
+1 -1
View File
@@ -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();
+1 -2
View File
@@ -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;