Skip to content

Commit 0d7d303

Browse files
yuwatapull[bot]
authored andcommitted
condition: use proc_cmdline_strv()
1 parent 70542e6 commit 0d7d303

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/shared/condition.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,35 +106,28 @@ Condition* condition_free_list_type(Condition *head, ConditionType type) {
106106
}
107107

108108
static int condition_test_kernel_command_line(Condition *c, char **env) {
109-
_cleanup_free_ char *line = NULL;
109+
_cleanup_strv_free_ char **args = NULL;
110110
int r;
111111

112112
assert(c);
113113
assert(c->parameter);
114114
assert(c->type == CONDITION_KERNEL_COMMAND_LINE);
115115

116-
r = proc_cmdline(&line);
116+
r = proc_cmdline_strv(&args);
117117
if (r < 0)
118118
return r;
119119

120120
bool equal = strchr(c->parameter, '=');
121121

122-
for (const char *p = line;;) {
123-
_cleanup_free_ char *word = NULL;
122+
STRV_FOREACH(word, args) {
124123
bool found;
125124

126-
r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX);
127-
if (r < 0)
128-
return r;
129-
if (r == 0)
130-
break;
131-
132125
if (equal)
133-
found = streq(word, c->parameter);
126+
found = streq(*word, c->parameter);
134127
else {
135128
const char *f;
136129

137-
f = startswith(word, c->parameter);
130+
f = startswith(*word, c->parameter);
138131
found = f && IN_SET(*f, 0, '=');
139132
}
140133

0 commit comments

Comments
 (0)