From 73ed4874e9e65e1c15850752ccb9db611e7c8b77 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 2 Apr 2023 21:22:17 +0200 Subject: [PATCH] shared/exec-util: reduce scope of iterator variables --- src/shared/exec-util.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/shared/exec-util.c b/src/shared/exec-util.c index a2e8f428e69..56f16188e1b 100644 --- a/src/shared/exec-util.c +++ b/src/shared/exec-util.c @@ -427,14 +427,14 @@ int exec_command_flags_to_strv(ExecCommandFlags flags, char ***ex_opts) { _cleanup_strv_free_ char **ret_opts = NULL; ExecCommandFlags it = flags; const char *str; - int i, r; + int r; assert(ex_opts); if (flags < 0) return flags; - for (i = 0; it != 0; it &= ~(1 << i), i++) { + for (unsigned i = 0; it != 0; it &= ~(1 << i), i++) if (FLAGS_SET(flags, (1 << i))) { str = exec_command_flags_to_string(1 << i); if (!str) @@ -444,7 +444,6 @@ int exec_command_flags_to_strv(ExecCommandFlags flags, char ***ex_opts) { if (r < 0) return r; } - } *ex_opts = TAKE_PTR(ret_opts); @@ -466,9 +465,7 @@ static const char* const exec_command_strings[] = { }; const char* exec_command_flags_to_string(ExecCommandFlags i) { - size_t idx; - - for (idx = 0; idx < ELEMENTSOF(exec_command_strings); idx++) + for (size_t idx = 0; idx < ELEMENTSOF(exec_command_strings); idx++) if (i == (1 << idx)) return exec_command_strings[idx]; -- 2.47.3