]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/exec-util: reduce scope of iterator variables 27114/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 2 Apr 2023 19:22:17 +0000 (21:22 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 3 Apr 2023 13:28:53 +0000 (15:28 +0200)
src/shared/exec-util.c

index a2e8f428e691cedbca9e725c08a381e262485a61..56f16188e1b7d10ea6f7881995db3af59134de0b 100644 (file)
@@ -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];