diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-03-16 22:32:23 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-03-19 08:33:33 +0900 |
commit | de010b0b2e50cf0b3837ce350b116bc92605f67a (patch) | |
tree | 226685fbb97461692562035501ebc21a314f718c /src/core/dbus-execute.c | |
parent | 80a226b26b5e00a2ef9e85d1321da44cd14d051b (diff) | |
download | systemd-de010b0b2e50cf0b3837ce350b116bc92605f67a.tar.gz |
strv: make iterator in STRV_FOREACH() declaread in the loop
This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
Diffstat (limited to 'src/core/dbus-execute.c')
-rw-r--r-- | src/core/dbus-execute.c | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index 3967abbafb..65eec8f6b7 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -74,7 +74,6 @@ static int property_get_environment_files( sd_bus_error *error) { ExecContext *c = userdata; - char **j; int r; assert(bus); @@ -1138,15 +1137,12 @@ static int bus_property_get_exec_dir_symlink( if (r < 0) return r; - for (size_t i = 0; i < d->n_items; i++) { - char **dst; - + for (size_t i = 0; i < d->n_items; i++) STRV_FOREACH(dst, d->items[i].symlinks) { r = sd_bus_message_append(reply, "(sst)", d->items[i].path, *dst, 0 /* flags, unused for now */); if (r < 0) return r; } - } return sd_bus_message_close_container(reply); } @@ -2016,7 +2012,6 @@ int bus_exec_context_set_transient_property( if (!UNIT_WRITE_FLAGS_NOOP(flags)) { _cleanup_free_ char *joined = NULL; FilesystemParseFlags invert_flag = allow_list ? 0 : FILESYSTEM_PARSE_INVERT; - char **s; if (strv_isempty(l)) { c->restrict_filesystems_allow_list = false; @@ -2062,7 +2057,6 @@ int bus_exec_context_set_transient_property( if (streq(name, "SupplementaryGroups")) { _cleanup_strv_free_ char **l = NULL; - char **p; r = sd_bus_message_read_strv(message, &l); if (r < 0) @@ -2427,7 +2421,6 @@ int bus_exec_context_set_transient_property( if (!UNIT_WRITE_FLAGS_NOOP(flags)) { _cleanup_free_ char *joined = NULL; SeccompParseFlags invert_flag = allow_list ? 0 : SECCOMP_PARSE_INVERT; - char **s; if (strv_isempty(l)) { c->syscall_allow_list = false; @@ -2512,7 +2505,6 @@ int bus_exec_context_set_transient_property( if (!UNIT_WRITE_FLAGS_NOOP(flags)) { _cleanup_free_ char *joined = NULL; SeccompParseFlags invert_flag = allow_list ? 0 : SECCOMP_PARSE_INVERT; - char **s; if (strv_isempty(l)) { c->syscall_log_allow_list = false; @@ -2564,9 +2556,7 @@ int bus_exec_context_set_transient_property( if (strv_isempty(l)) c->syscall_archs = set_free(c->syscall_archs); - else { - char **s; - + else STRV_FOREACH(s, l) { uint32_t a; @@ -2579,8 +2569,6 @@ int bus_exec_context_set_transient_property( return r; } - } - joined = strv_join(l, " "); if (!joined) return -ENOMEM; @@ -2612,7 +2600,6 @@ int bus_exec_context_set_transient_property( if (!UNIT_WRITE_FLAGS_NOOP(flags)) { _cleanup_free_ char *joined = NULL; - char **s; if (strv_isempty(l)) { c->address_families_allow_list = allow_list; @@ -3141,7 +3128,6 @@ int bus_exec_context_set_transient_property( _cleanup_fclose_ FILE *f = NULL; _cleanup_strv_free_ char **l = NULL; size_t size = 0; - char **i; r = sd_bus_message_enter_container(message, 'a', "(sb)"); if (r < 0) @@ -3260,7 +3246,6 @@ int bus_exec_context_set_transient_property( "ExtensionDirectories")) { _cleanup_strv_free_ char **l = NULL; char ***dirs; - char **p; r = sd_bus_message_read_strv(message, &l); if (r < 0) @@ -3314,16 +3299,15 @@ int bus_exec_context_set_transient_property( } else if (streq(name, "ExecSearchPath")) { _cleanup_strv_free_ char **l = NULL; - char **p; r = sd_bus_message_read_strv(message, &l); if (r < 0) return r; - STRV_FOREACH(p, l) { + STRV_FOREACH(p, l) if (!path_is_absolute(*p) || !path_is_normalized(*p) || strchr(*p, ':')) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid %s", name); - } + if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (strv_isempty(l)) { c->exec_search_path = strv_free(c->exec_search_path); @@ -3344,7 +3328,6 @@ int bus_exec_context_set_transient_property( } else if (STR_IN_SET(name, "RuntimeDirectory", "StateDirectory", "CacheDirectory", "LogsDirectory", "ConfigurationDirectory")) { _cleanup_strv_free_ char **l = NULL; - char **p; r = sd_bus_message_read_strv(message, &l); if (r < 0) @@ -3373,7 +3356,6 @@ int bus_exec_context_set_transient_property( unit_write_settingf(u, flags, name, "%s=", name); } else { _cleanup_free_ char *joined = NULL; - char **source; STRV_FOREACH(source, l) { r = exec_directory_add(&d->items, &d->n_items, *source, NULL); |