From cb447ff5cc99e8c122a88fa78d7b80e4c572529b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 26 Oct 2018 12:00:37 +0200 Subject: [PATCH] proc-cmdline: use FLAGS_SET() where appropriate 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 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/basic/proc-cmdline.c b/src/basic/proc-cmdline.c index 647c61ce739..b8839ef52cb 100644 --- a/src/basic/proc-cmdline.c +++ b/src/basic/proc-cmdline.c @@ -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 {