diff options
author | Filipe Brandenburger <filbranden@google.com> | 2015-08-30 21:00:30 -0700 |
---|---|---|
committer | Filipe Brandenburger <filbranden@google.com> | 2015-08-31 17:33:35 -0700 |
commit | d4ebeb4fb39a03c1ea2be3648dd8aaeade6c5ba2 (patch) | |
tree | d7be162efb201038be01822160cc34f1023c2fa6 /src | |
parent | d4c8dcc47aab8da904b6998c53c457d3d9a7b227 (diff) |
core: Use extract_first_word in config_parse_join_controllers
Related to the TODO item to replace FOREACH_WORD_QUOTED with it.
Tested by setting `JoinControllers=cpu,cpuacct,memory net_cls,blkio' in
/etc/systemd/system.conf, rebooting the system with the patched binaries
and checking that the desired setup was created by inspecting the
entries under /sys/fs/cgroup.
No regressions observed in test cases.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/main.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/core/main.c b/src/core/main.c index e232be88c0..e5d9ec1a4e 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -539,8 +539,6 @@ static int config_parse_join_controllers(const char *unit, void *userdata) { unsigned n = 0; - const char *word, *state; - size_t length; assert(filename); assert(lvalue); @@ -548,16 +546,18 @@ 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) + return r; + if (r == 0) + break; + l = strv_split(word, ","); strv_uniq(l); if (strv_length(l) <= 1) { @@ -617,7 +617,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."); |