proc-cmdline: minor runlevel_to_target() coding style fixes

Let's not mix function calls and variable declarations, as well as
assignments and comparison in one expression.
This commit is contained in:
Lennart Poettering
2017-11-17 11:13:44 +01:00
parent a3ab8f2a99
commit 11f5d82507
+9 -5
View 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;
}
for (i = 0; rlmap_ptr[i] != NULL; i += 2)
rlmap_ptr = in_initrd() ? rlmap_initrd : rlmap;
for (i = 0; rlmap_ptr[i]; i += 2)
if (streq(word, rlmap_ptr[i]))
return rlmap_ptr[i+1];