summaryrefslogtreecommitdiff
path: root/src/core/main.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-01 19:10:45 +0200
committerLennart Poettering <lennart@poettering.net>2015-09-01 19:10:45 +0200
commit332929623af07716530fb0d0a30e792b564ea486 (patch)
tree46f1ce7bcf6175c443dd18c15af6f568e9d5dce2 /src/core/main.c
parentaa3e5246ba08dbaa23509d8fbbfe963129a70eff (diff)
parent1592ec21b3c302c29e42d35e48159d1e3361f117 (diff)
Merge pull request #1099 from filbranden/joincontrollers2
Getting rid of FOREACH_WORD_QUOTED in config_parse_join_controllers
Diffstat (limited to 'src/core/main.c')
-rw-r--r--src/core/main.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/core/main.c b/src/core/main.c
index e232be88c0..833fd74d87 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -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;
-
- s = strndup(word, length);
- if (!s)
- return log_oom();
+ for (;;) {
+ _cleanup_free_ char *word = NULL;
+ char **l;
+ int r;
- 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.");