]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
condition: use proc_cmdline_strv()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 22 Mar 2023 16:34:43 +0000 (01:34 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 29 Mar 2023 01:34:41 +0000 (10:34 +0900)
src/shared/condition.c

index d5fdbbf9e07d5c57916112ed21b79388a0059245..e5a80757e095352adcb8027efc571d5ee31f399f 100644 (file)
@@ -106,35 +106,28 @@ Condition* condition_free_list_type(Condition *head, ConditionType type) {
 }
 
 static int condition_test_kernel_command_line(Condition *c, char **env) {
-        _cleanup_free_ char *line = NULL;
+        _cleanup_strv_free_ char **args = NULL;
         int r;
 
         assert(c);
         assert(c->parameter);
         assert(c->type == CONDITION_KERNEL_COMMAND_LINE);
 
-        r = proc_cmdline(&line);
+        r = proc_cmdline_strv(&args);
         if (r < 0)
                 return r;
 
         bool equal = strchr(c->parameter, '=');
 
-        for (const char *p = line;;) {
-                _cleanup_free_ char *word = NULL;
+        STRV_FOREACH(word, args) {
                 bool found;
 
-                r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX);
-                if (r < 0)
-                        return r;
-                if (r == 0)
-                        break;
-
                 if (equal)
-                        found = streq(word, c->parameter);
+                        found = streq(*word, c->parameter);
                 else {
                         const char *f;
 
-                        f = startswith(word, c->parameter);
+                        f = startswith(*word, c->parameter);
                         found = f && IN_SET(*f, 0, '=');
                 }