]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
various: use modern strv helpers
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 14 Dec 2023 09:41:13 +0000 (10:41 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 28 Feb 2024 10:10:34 +0000 (11:10 +0100)
If we're building a strv, let's just use strv_new() with the CONF_PATHS macro,
which gives as an exploded string set.

src/analyze/analyze-cat-config.c
src/basic/strv.c
src/environment-d-generator/environment-d-generator.c
src/shared/tpm2-util.c
src/tmpfiles/tmpfiles.c

index 073bc940185619f268b8b4e2a5c597f521b0d74e..b480d4a0097085f51066e9e15087c5ef5efec624 100644 (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;
index 72cbbfe2f4e3bc77ccce969d4aabc4aecd22d786..37199ebf045d7f4193a6684573dbfde1ee9d9587 100644 (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;
index fa2c54af31d6a992bef9e20c226043dfee1a1401..82fc57f1b106dba6633ff1f02974162ba5711788 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"), NULL);
+        dirs = strv_new(CONF_PATHS_USR("environment.d"));
         if (!dirs)
                 return -ENOMEM;
 
index f2b3bfb57594ad6eff6490ebf93e131c99442abc..c7ea57ab09f61c60de6c6a25381e6001e4ae3ef5 100644 (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();
 
index 75db789f5013be30b3ee027d3118be8482b39af3..958341bc5b8bbae5e4664805c9231015c5889d55 100644 (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;