proc-cmdline: minor runlevel_to_target() coding style fixes
authorLennart Poettering <lennart@poettering.net>
Fri, 27 Oct 2017 09:15:20 +0000 (11:15 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 17 Nov 2017 10:13:44 +0000 (11:13 +0100)
Let's not mix function calls and variable declarations, as well as
assignments and comparison in one expression.

src/basic/proc-cmdline.c

index 8592a42..8590133 100644 (file)
@@ -270,17 +270,21 @@ static const char * const rlmap_initrd[] = {
 };
 
 const char* runlevel_to_target(const char *word) {
+        const char * const *rlmap_ptr;
         size_t i;
-        const char * const *rlmap_ptr = in_initrd() ? rlmap_initrd
-                                                    : rlmap;
 
         if (!word)
                 return NULL;
 
-        if (in_initrd() && (word = startswith(word, "rd.")) == NULL)
-                return NULL;
+        if (in_initrd()) {
+                word = startswith(word, "rd.");
+                if (!word)
+                        return NULL;
+        }
+
+        rlmap_ptr = in_initrd() ? rlmap_initrd : rlmap;
 
-        for (i = 0; rlmap_ptr[i] != NULL; i += 2)
+        for (i = 0; rlmap_ptr[i]; i += 2)
                 if (streq(word, rlmap_ptr[i]))
                         return rlmap_ptr[i+1];