]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
unit-file: use STRV_FOREACH_PAIR() macro at one more place
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 21 Apr 2025 02:02:13 +0000 (11:02 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Apr 2025 01:24:42 +0000 (10:24 +0900)
src/shared/unit-file.c

index e20894216b5acca5ac53333103779fc9a158864a..83a8c45032c93f3017906c8c0e280a81a07238be 100644 (file)
@@ -838,13 +838,14 @@ const char* runlevel_to_target(const char *word) {
                 word = startswith(word, "rd.");
                 if (!word)
                         return NULL;
-        }
 
-        rlmap_ptr = in_initrd() ? rlmap_initrd : rlmap;
+                rlmap_ptr = rlmap_initrd;
+        } else
+                rlmap_ptr = rlmap;
 
-        for (size_t i = 0; rlmap_ptr[i]; i += 2)
-                if (streq(word, rlmap_ptr[i]))
-                        return rlmap_ptr[i+1];
+        STRV_FOREACH_PAIR(rl, target, rlmap_ptr)
+                if (streq(word, *rl))
+                        return *target;
 
         return NULL;
 }