]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-json: use strv_env_get_merged()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 25 Oct 2024 17:07:02 +0000 (02:07 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 31 Oct 2024 02:02:35 +0000 (11:02 +0900)
src/libsystemd/sd-json/sd-json.c

index 5e9c1ba15bed40379f1a05ff3304f11737ab245d..293df301a295c056b6e7676d7d3a48b5cce6c8ae 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "alloc-util.h"
 #include "ansi-color.h"
+#include "env-util.h"
 #include "errno-util.h"
 #include "escape.h"
 #include "ether-addr-util.h"
@@ -3867,22 +3868,13 @@ _public_ int sd_json_buildv(sd_json_variant **ret, va_list ap) {
 
                         l = va_arg(ap, char **);
 
-                        _cleanup_strv_free_ char **el = NULL;
-                        STRV_FOREACH_PAIR(x, y, l) {
-                                char *n = NULL;
-
-                                n = strjoin(*x, "=", *y);
-                                if (!n) {
-                                        r = -ENOMEM;
-                                        goto finish;
-                                }
+                        if (current->n_suppress == 0) {
+                                _cleanup_strv_free_ char **el = NULL;
 
-                                r = strv_consume(&el, n);
+                                r = strv_env_get_merged(l, &el);
                                 if (r < 0)
                                         goto finish;
-                        }
 
-                        if (current->n_suppress == 0) {
                                 r = sd_json_variant_new_array_strv(&add, el);
                                 if (r < 0)
                                         goto finish;