diff options
Diffstat (limited to '')
-rw-r--r-- | src/basic/env-util.c | 8 | ||||
-rw-r--r-- | src/basic/strv.c | 4 | ||||
-rw-r--r-- | src/core/execute.c | 4 | ||||
-rw-r--r-- | src/core/load-dropin.c | 10 | ||||
-rw-r--r-- | src/core/load-fragment.c | 38 | ||||
-rw-r--r-- | src/home/homectl.c | 2 | ||||
-rw-r--r-- | src/libsystemd-network/sd-dhcp6-lease.c | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-varlink/sd-varlink.c | 2 | ||||
-rw-r--r-- | src/modules-load/modules-load.c | 17 | ||||
-rw-r--r-- | src/partition/repart.c | 4 | ||||
-rw-r--r-- | src/portable/portable.c | 8 | ||||
-rw-r--r-- | src/shared/bootspec.c | 2 | ||||
-rw-r--r-- | src/shared/conf-parser.c | 2 | ||||
-rw-r--r-- | src/shared/module-util.c | 21 | ||||
-rw-r--r-- | src/shared/user-record.c | 7 | ||||
-rw-r--r-- | src/systemctl/systemctl-util.c | 4 | ||||
-rw-r--r-- | src/sysupdate/sysupdated.c | 5 | ||||
-rw-r--r-- | src/udev/udevadm-settle.c | 2 | ||||
-rw-r--r-- | src/userdb/userdbctl.c | 10 | ||||
-rw-r--r-- | src/vmspawn/vmspawn.c | 11 |
20 files changed, 52 insertions, 111 deletions
diff --git a/src/basic/env-util.c b/src/basic/env-util.c index cf2c47d214..4c06d1a165 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -796,10 +796,10 @@ int replace_env_full( t = v; } - r = strv_extend_strv(&unset_variables, u, /* filter_duplicates= */ true); + r = strv_extend_strv_consume(&unset_variables, TAKE_PTR(u), /* filter_duplicates= */ true); if (r < 0) return r; - r = strv_extend_strv(&bad_variables, b, /* filter_duplicates= */ true); + r = strv_extend_strv_consume(&bad_variables, TAKE_PTR(b), /* filter_duplicates= */ true); if (r < 0) return r; @@ -931,11 +931,11 @@ int replace_env_argv( return r; n[++k] = NULL; - r = strv_extend_strv(&unset_variables, u, /* filter_duplicates= */ true); + r = strv_extend_strv_consume(&unset_variables, TAKE_PTR(u), /* filter_duplicates= */ true); if (r < 0) return r; - r = strv_extend_strv(&bad_variables, b, /*filter_duplicates= */ true); + r = strv_extend_strv_consume(&bad_variables, TAKE_PTR(b), /* filter_duplicates= */ true); if (r < 0) return r; } diff --git a/src/basic/strv.c b/src/basic/strv.c index 542883ea3f..f962883597 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -405,7 +405,7 @@ int strv_split_full(char ***t, const char *s, const char *separators, ExtractFla } int strv_split_and_extend_full(char ***t, const char *s, const char *separators, bool filter_duplicates, ExtractFlags flags) { - _cleanup_strv_free_ char **l = NULL; + char **l; int r; assert(t); @@ -415,7 +415,7 @@ int strv_split_and_extend_full(char ***t, const char *s, const char *separators, if (r < 0) return r; - r = strv_extend_strv(t, l, filter_duplicates); + r = strv_extend_strv_consume(t, l, filter_duplicates); if (r < 0) return r; diff --git a/src/core/execute.c b/src/core/execute.c index 5e0e0b3a62..30fcffcc5b 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -2046,7 +2046,7 @@ int exec_command_set(ExecCommand *c, const char *path, ...) { } int exec_command_append(ExecCommand *c, const char *path, ...) { - _cleanup_strv_free_ char **l = NULL; + char **l; va_list ap; int r; @@ -2060,7 +2060,7 @@ int exec_command_append(ExecCommand *c, const char *path, ...) { if (!l) return -ENOMEM; - r = strv_extend_strv(&c->argv, l, false); + r = strv_extend_strv_consume(&c->argv, l, /* filter_duplicates = */ false); if (r < 0) return r; diff --git a/src/core/load-dropin.c b/src/core/load-dropin.c index dc9c44e6d6..5c1ccc966f 100644 --- a/src/core/load-dropin.c +++ b/src/core/load-dropin.c @@ -106,13 +106,9 @@ int unit_load_dropin(Unit *u) { if (r <= 0) return 0; - if (!u->dropin_paths) - u->dropin_paths = TAKE_PTR(l); - else { - r = strv_extend_strv(&u->dropin_paths, l, true); - if (r < 0) - return log_oom(); - } + r = strv_extend_strv_consume(&u->dropin_paths, TAKE_PTR(l), /* filter_duplicates = */ true); + if (r < 0) + return log_oom(); u->dropin_mtime = 0; STRV_FOREACH(f, u->dropin_paths) { diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index d8fead1ca5..e49276eae5 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -2779,10 +2779,8 @@ int config_parse_pass_environ( void *data, void *userdata) { - _cleanup_strv_free_ char **n = NULL; + char ***passenv = ASSERT_PTR(data); const Unit *u = userdata; - char*** passenv = ASSERT_PTR(data); - size_t nlen = 0; int r; assert(filename); @@ -2795,6 +2793,8 @@ int config_parse_pass_environ( return 0; } + _cleanup_strv_free_ char **n = NULL; + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *k = NULL; @@ -2825,18 +2825,13 @@ int config_parse_pass_environ( continue; } - if (!GREEDY_REALLOC(n, nlen + 2)) + if (strv_consume(&n, TAKE_PTR(k)) < 0) return log_oom(); - - n[nlen++] = TAKE_PTR(k); - n[nlen] = NULL; } - if (n) { - r = strv_extend_strv(passenv, n, true); - if (r < 0) - return log_oom(); - } + r = strv_extend_strv_consume(passenv, TAKE_PTR(n), /* filter_duplicates = */ true); + if (r < 0) + return log_oom(); return 0; } @@ -2853,10 +2848,8 @@ int config_parse_unset_environ( void *data, void *userdata) { - _cleanup_strv_free_ char **n = NULL; - char*** unsetenv = ASSERT_PTR(data); + char ***unsetenv = ASSERT_PTR(data); const Unit *u = userdata; - size_t nlen = 0; int r; assert(filename); @@ -2869,6 +2862,8 @@ int config_parse_unset_environ( return 0; } + _cleanup_strv_free_ char **n = NULL; + for (const char *p = rvalue;;) { _cleanup_free_ char *word = NULL, *k = NULL; @@ -2899,18 +2894,13 @@ int config_parse_unset_environ( continue; } - if (!GREEDY_REALLOC(n, nlen + 2)) + if (strv_consume(&n, TAKE_PTR(k)) < 0) return log_oom(); - - n[nlen++] = TAKE_PTR(k); - n[nlen] = NULL; } - if (n) { - r = strv_extend_strv(unsetenv, n, true); - if (r < 0) - return log_oom(); - } + r = strv_extend_strv_consume(unsetenv, TAKE_PTR(n), /* filter_duplicates = */ true); + if (r < 0) + return log_oom(); return 0; } diff --git a/src/home/homectl.c b/src/home/homectl.c index a52bc6d464..c193715d96 100644 --- a/src/home/homectl.c +++ b/src/home/homectl.c @@ -3652,7 +3652,7 @@ static int parse_argv(int argc, char *argv[]) { return log_error_errno(r, "Failed to parse SSH authorized keys list: %m"); } - r = strv_extend_strv(&l, add, true); + r = strv_extend_strv_consume(&l, TAKE_PTR(add), /* filter_duplicates = */ true); if (r < 0) return log_oom(); diff --git a/src/libsystemd-network/sd-dhcp6-lease.c b/src/libsystemd-network/sd-dhcp6-lease.c index e5d6547588..c2eb0db87d 100644 --- a/src/libsystemd-network/sd-dhcp6-lease.c +++ b/src/libsystemd-network/sd-dhcp6-lease.c @@ -424,7 +424,7 @@ int dhcp6_lease_add_domains(sd_dhcp6_lease *lease, const uint8_t *optval, size_t if (r < 0) return r; - return strv_extend_strv(&lease->domains, domains, true); + return strv_extend_strv_consume(&lease->domains, TAKE_PTR(domains), /* filter_duplicates = */ true); } int sd_dhcp6_lease_get_domains(sd_dhcp6_lease *lease, char ***ret) { diff --git a/src/libsystemd/sd-varlink/sd-varlink.c b/src/libsystemd/sd-varlink/sd-varlink.c index a0aa12a386..007746f64f 100644 --- a/src/libsystemd/sd-varlink/sd-varlink.c +++ b/src/libsystemd/sd-varlink/sd-varlink.c @@ -410,7 +410,7 @@ static int varlink_connect_ssh_exec(sd_varlink **ret, const char *where) { full_cmdline = strv_new("ssh", "-e", "none", "-T", h, "env", "SYSTEMD_VARLINK_LISTEN=-"); if (!full_cmdline) return log_oom_debug(); - r = strv_extend_strv(&full_cmdline, cmdline, /* filter_duplicates= */ false); + r = strv_extend_strv_consume(&full_cmdline, TAKE_PTR(cmdline), /* filter_duplicates= */ false); if (r < 0) return log_oom_debug(); diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index c1f818320f..59daeb5cb0 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -23,19 +23,6 @@ static const char conf_file_dirs[] = CONF_PATHS_NULSTR("modules-load.d"); STATIC_DESTRUCTOR_REGISTER(arg_proc_cmdline_modules, strv_freep); -static int add_modules(const char *p) { - _cleanup_strv_free_ char **k = NULL; - - k = strv_split(p, ","); - if (!k) - return log_oom(); - - if (strv_extend_strv(&arg_proc_cmdline_modules, k, true) < 0) - return log_oom(); - - return 0; -} - static int parse_proc_cmdline_item(const char *key, const char *value, void *data) { int r; @@ -44,9 +31,9 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat if (proc_cmdline_value_missing(key, value)) return 0; - r = add_modules(value); + r = strv_split_and_extend(&arg_proc_cmdline_modules, value, ",", /* filter_duplicates = */ true); if (r < 0) - return r; + return log_error_errno(r, "Failed to parse modules_load= kernel command line option: %m"); } return 0; diff --git a/src/partition/repart.c b/src/partition/repart.c index 660eef563e..1c7ac5094e 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -5361,13 +5361,13 @@ static int make_subvolumes_strv(const Partition *p, char ***ret) { return log_oom(); if (p->suppressing) { - _cleanup_strv_free_ char **suppressing = NULL; + char **suppressing; r = make_subvolumes_strv(p->suppressing, &suppressing); if (r < 0) return r; - r = strv_extend_strv(&subvolumes, suppressing, /* filter_duplicates= */ true); + r = strv_extend_strv_consume(&subvolumes, suppressing, /* filter_duplicates= */ true); if (r < 0) return log_oom(); } diff --git a/src/portable/portable.c b/src/portable/portable.c index af7d9552da..f0c508c306 100644 --- a/src/portable/portable.c +++ b/src/portable/portable.c @@ -721,13 +721,7 @@ static int extract_image_and_extensions( e = strv_env_pairs_get(extension_release, "PORTABLE_PREFIXES"); if (e) { - _cleanup_strv_free_ char **l = NULL; - - l = strv_split(e, WHITESPACE); - if (!l) - return -ENOMEM; - - r = strv_extend_strv(&valid_prefixes, l, true); + r = strv_split_and_extend(&valid_prefixes, e, WHITESPACE, /* filter_duplicates = */ true); if (r < 0) return r; } diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index 50a07400fe..87aa11ccdf 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -176,7 +176,7 @@ static int parse_path_many( return r; } - return strv_extend_strv(s, f, /* filter_duplicates= */ false); + return strv_extend_strv_consume(s, TAKE_PTR(f), /* filter_duplicates= */ false); } static int parse_tries(const char *fname, const char **p, unsigned *ret) { diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 39e79ef3f6..8b32f2a9bb 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -1343,7 +1343,7 @@ int config_parse_strv( return log_oom(); } - r = strv_extend_strv(sv, strv, /* filter_duplicates = */ ltype); + r = strv_extend_strv_consume(sv, TAKE_PTR(strv), /* filter_duplicates = */ ltype); if (r < 0) return log_oom(); diff --git a/src/shared/module-util.c b/src/shared/module-util.c index 9608b0a671..56e93e8732 100644 --- a/src/shared/module-util.c +++ b/src/shared/module-util.c @@ -49,25 +49,8 @@ int dlopen_libkmod(void) { DLSYM_ARG(kmod_validate_resources)); } -static int denylist_modules(const char *p, char ***denylist) { - _cleanup_strv_free_ char **k = NULL; - int r; - - assert(p); - assert(denylist); - - k = strv_split(p, ","); - if (!k) - return -ENOMEM; - - r = strv_extend_strv(denylist, k, /* filter_duplicates= */ true); - if (r < 0) - return r; - - return 0; -} - static int parse_proc_cmdline_item(const char *key, const char *value, void *data) { + char ***denylist = ASSERT_PTR(data); int r; if (proc_cmdline_key_streq(key, "module_blacklist")) { @@ -75,7 +58,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat if (proc_cmdline_value_missing(key, value)) return 0; - r = denylist_modules(value, data); + r = strv_split_and_extend(denylist, value, ",", /* filter_duplicates = */ true); if (r < 0) return r; } diff --git a/src/shared/user-record.c b/src/shared/user-record.c index d6752f1c7b..0de768cc59 100644 --- a/src/shared/user-record.c +++ b/src/shared/user-record.c @@ -626,16 +626,15 @@ static int json_dispatch_weight(const char *name, sd_json_variant *variant, sd_j } int json_dispatch_user_group_list(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) { + char ***list = ASSERT_PTR(userdata); _cleanup_strv_free_ char **l = NULL; - char ***list = userdata; - sd_json_variant *e; int r; if (!sd_json_variant_is_array(variant)) return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an array of strings.", strna(name)); + sd_json_variant *e; JSON_VARIANT_ARRAY_FOREACH(e, variant) { - if (!sd_json_variant_is_string(e)) return json_log(e, flags, SYNTHETIC_ERRNO(EINVAL), "JSON array element is not a string."); @@ -647,7 +646,7 @@ int json_dispatch_user_group_list(const char *name, sd_json_variant *variant, sd return json_log(e, flags, r, "Failed to append array element: %m"); } - r = strv_extend_strv(list, l, true); + r = strv_extend_strv_consume(list, TAKE_PTR(l), /* filter_duplicates = */ true); if (r < 0) return json_log(variant, flags, r, "Failed to merge user/group arrays: %m"); diff --git a/src/systemctl/systemctl-util.c b/src/systemctl/systemctl-util.c index 848012de66..0b5881ccbb 100644 --- a/src/systemctl/systemctl-util.c +++ b/src/systemctl/systemctl-util.c @@ -739,14 +739,14 @@ int append_unit_dependencies(sd_bus *bus, char **names, char ***ret) { assert(ret); STRV_FOREACH(name, names) { - _cleanup_strv_free_ char **deps = NULL; + char **deps; if (strv_extend(&with_deps, *name) < 0) return log_oom(); (void) unit_get_dependencies(bus, *name, &deps); - if (strv_extend_strv(&with_deps, deps, true) < 0) + if (strv_extend_strv_consume(&with_deps, deps, /* filter_duplicates = */ true) < 0) return log_oom(); } diff --git a/src/sysupdate/sysupdated.c b/src/sysupdate/sysupdated.c index 546f52a96c..f4ff472df1 100644 --- a/src/sysupdate/sysupdated.c +++ b/src/sysupdate/sysupdated.c @@ -1771,12 +1771,13 @@ static int method_list_appstream(sd_bus_message *msg, void *userdata, sd_bus_err return r; HASHMAP_FOREACH(t, m->targets) { - _cleanup_strv_free_ char **target_appstream = NULL; + char **target_appstream; + r = target_get_appstream(t, &target_appstream); if (r < 0) return r; - r = strv_extend_strv(&urls, target_appstream, true); + r = strv_extend_strv_consume(&urls, target_appstream, /* filter_duplicates = */ true); if (r < 0) return r; } diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c index f2b6c58b94..d47a9c3a07 100644 --- a/src/udev/udevadm-settle.c +++ b/src/udev/udevadm-settle.c @@ -128,7 +128,7 @@ static int emit_deprecation_warning(void) { NULL, &b); - r = strv_extend_strv(&a, b, true); + r = strv_extend_strv_consume(&a, TAKE_PTR(b), /* filter_duplicates = */ true); if (r < 0) return r; } diff --git a/src/userdb/userdbctl.c b/src/userdb/userdbctl.c index 1346e2de01..5997f9604f 100644 --- a/src/userdb/userdbctl.c +++ b/src/userdb/userdbctl.c @@ -1220,15 +1220,9 @@ static int parse_argv(int argc, char *argv[]) { if (isempty(optarg)) arg_services = strv_free(arg_services); else { - _cleanup_strv_free_ char **l = NULL; - - l = strv_split(optarg, ":"); - if (!l) - return log_oom(); - - r = strv_extend_strv(&arg_services, l, true); + r = strv_split_and_extend(&arg_services, optarg, ":", /* filter_duplicates = */ true); if (r < 0) - return log_oom(); + return log_error_errno(r, "Failed to parse -s/--service= argument: %m"); } break; diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c index 15418f0742..7474b301f3 100644 --- a/src/vmspawn/vmspawn.c +++ b/src/vmspawn/vmspawn.c @@ -2088,14 +2088,11 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) { const char *e = secure_getenv("SYSTEMD_VMSPAWN_QEMU_EXTRA"); if (e) { - _cleanup_strv_free_ char **extra = NULL; - - r = strv_split_full(&extra, e, /* separator= */ NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE); + r = strv_split_and_extend_full(&cmdline, e, + /* separator = */ NULL, /* filter_duplicates = */ false, + EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE); if (r < 0) - return log_error_errno(r, "Failed to split $SYSTEMD_VMSPAWN_QEMU_EXTRA environment variable: %m"); - - if (strv_extend_strv(&cmdline, extra, /* filter_duplicates= */ false) < 0) - return log_oom(); + return log_error_errno(r, "Failed to parse $SYSTEMD_VMSPAWN_QEMU_EXTRA: %m"); } if (DEBUG_LOGGING) { |