]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
proc-cmdline: do assert on flags earlier
authorMike Yuan <me@yhndnzj.com>
Sat, 12 Aug 2023 07:22:06 +0000 (15:22 +0800)
committerMike Yuan <me@yhndnzj.com>
Sun, 13 Aug 2023 04:52:15 +0000 (12:52 +0800)
src/basic/proc-cmdline.c

index c6667366274cde0797cd1b64ad8b0c42ae396a2f..48036b959c3cd3bde8c2a6b5a2a24cbbd3cec5ab 100644 (file)
@@ -197,10 +197,6 @@ static int proc_cmdline_parse_strv(char **args, proc_cmdline_parse_t parse_item,
 
         assert(parse_item);
 
-        /* The PROC_CMDLINE_VALUE_OPTIONAL and PROC_CMDLINE_TRUE_WHEN_MISSING flags don't really make sense
-         * for proc_cmdline_parse(), let's make this clear. */
-        assert(!(flags & (PROC_CMDLINE_VALUE_OPTIONAL|PROC_CMDLINE_TRUE_WHEN_MISSING)));
-
         STRV_FOREACH(word, args) {
                 char *key, *value;
 
@@ -226,6 +222,10 @@ int proc_cmdline_parse(proc_cmdline_parse_t parse_item, void *data, ProcCmdlineF
 
         assert(parse_item);
 
+        /* The PROC_CMDLINE_VALUE_OPTIONAL and PROC_CMDLINE_TRUE_WHEN_MISSING flags don't really make sense
+         * for proc_cmdline_parse(), let's make this clear. */
+        assert(!(flags & (PROC_CMDLINE_VALUE_OPTIONAL|PROC_CMDLINE_TRUE_WHEN_MISSING)));
+
         /* We parse the EFI variable first, because later settings have higher priority. */
 
         if (!FLAGS_SET(flags, PROC_CMDLINE_IGNORE_EFI_OPTIONS)) {