]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
proc-cmdline: use FLAGS_SET() where appropriate
authorLennart Poettering <lennart@poettering.net>
Fri, 26 Oct 2018 10:00:37 +0000 (12:00 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 26 Oct 2018 10:00:37 +0000 (12:00 +0200)
This was mostly prompted by seeing the expression "in_initrd() && flags
& PROC_CMDLINE_RD_STRICT", which uses & and && without any brackets.
Let's make that a bit more readable and hide all doubts about operator
precedence.

src/basic/proc-cmdline.c

index 647c61ce739c049f4e8d36d5876d37a7eab09da3..b8839ef52cb546aeff4b13e2d27a2e7087e577ad 100644 (file)
@@ -64,10 +64,11 @@ int proc_cmdline_parse_given(const char *line, proc_cmdline_parse_t parse_item,
                         if (!in_initrd())
                                 continue;
 
-                        if (flags & PROC_CMDLINE_STRIP_RD_PREFIX)
+                        if (FLAGS_SET(flags, PROC_CMDLINE_STRIP_RD_PREFIX))
                                 key = q;
-                } else if (in_initrd() && flags & PROC_CMDLINE_RD_STRICT)
-                        continue;
+
+                } else if (FLAGS_SET(flags, PROC_CMDLINE_RD_STRICT) && in_initrd())
+                        continue; /* And optionally filter out arguments that are intended only for the host */
 
                 value = strchr(key, '=');
                 if (value)
@@ -148,7 +149,7 @@ int proc_cmdline_get_key(const char *key, unsigned flags, char **value) {
         if (isempty(key))
                 return -EINVAL;
 
-        if ((flags & PROC_CMDLINE_VALUE_OPTIONAL) && !value)
+        if (FLAGS_SET(flags, PROC_CMDLINE_VALUE_OPTIONAL) && !value)
                 return -EINVAL;
 
         r = proc_cmdline(&line);
@@ -183,7 +184,7 @@ int proc_cmdline_get_key(const char *key, unsigned flags, char **value) {
 
                                 found = true;
 
-                        } else if (*e == 0 && (flags & PROC_CMDLINE_VALUE_OPTIONAL))
+                        } else if (*e == 0 && FLAGS_SET(flags, PROC_CMDLINE_VALUE_OPTIONAL))
                                 found = true;
 
                 } else {