mirror of
https://github.com/systemd/systemd.git
synced 2024-10-29 21:55:36 +03:00
Merge pull request #1099 from filbranden/joincontrollers2
Getting rid of FOREACH_WORD_QUOTED in config_parse_join_controllers
This commit is contained in:
commit
332929623a
@ -538,9 +538,8 @@ static int config_parse_join_controllers(const char *unit,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
const char *whole_rvalue = rvalue;
|
||||
unsigned n = 0;
|
||||
const char *word, *state;
|
||||
size_t length;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
@ -548,16 +547,22 @@ static int config_parse_join_controllers(const char *unit,
|
||||
|
||||
free_join_controllers();
|
||||
|
||||
FOREACH_WORD_QUOTED(word, length, rvalue, state) {
|
||||
char *s, **l;
|
||||
for (;;) {
|
||||
_cleanup_free_ char *word = NULL;
|
||||
char **l;
|
||||
int r;
|
||||
|
||||
s = strndup(word, length);
|
||||
if (!s)
|
||||
return log_oom();
|
||||
|
||||
l = strv_split(s, ",");
|
||||
free(s);
|
||||
r = extract_first_word(&rvalue, &word, WHITESPACE, EXTRACT_QUOTES);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid value for %s: %s", lvalue, whole_rvalue);
|
||||
return r;
|
||||
}
|
||||
if (r == 0)
|
||||
break;
|
||||
|
||||
l = strv_split(word, ",");
|
||||
if (!l)
|
||||
log_oom();
|
||||
strv_uniq(l);
|
||||
|
||||
if (strv_length(l) <= 1) {
|
||||
@ -617,7 +622,7 @@ static int config_parse_join_controllers(const char *unit,
|
||||
arg_join_controllers = t;
|
||||
}
|
||||
}
|
||||
if (!isempty(state))
|
||||
if (!isempty(rvalue))
|
||||
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
|
||||
"Trailing garbage, ignoring.");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user