diff options
author | Evgeny Vereshchagin <evvers@ya.ru> | 2015-10-30 09:25:12 +0300 |
---|---|---|
committer | Evgeny Vereshchagin <evvers@ya.ru> | 2015-10-30 20:55:56 +0300 |
commit | 9ef57298cc57b105c62e2f1dab9ef5837d910604 (patch) | |
tree | 3f54b684ba37765182b0655e99792bd85a675823 /src | |
parent | 4b03af4a97b959e1220f1e7c92cc40bf2ebc5169 (diff) |
core: port config_parse_bounding_set to extract_first_word
Diffstat (limited to 'src')
-rw-r--r-- | src/core/load-fragment.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 333fca46c4..a30cd0967d 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -983,10 +983,10 @@ int config_parse_bounding_set(const char *unit, uint64_t *capability_bounding_set_drop = data; uint64_t capability_bounding_set; - const char *word, *state; - size_t l; bool invert = false; uint64_t sum = 0; + const char *prev; + const char *cur; assert(filename); assert(lvalue); @@ -1003,24 +1003,32 @@ int config_parse_bounding_set(const char *unit, * non-inverted everywhere to have a fully normalized * interface. */ - FOREACH_WORD_QUOTED(word, l, rvalue, state) { - _cleanup_free_ char *t = NULL; + prev = cur = rvalue; + for (;;) { + _cleanup_free_ char *word = NULL; int cap; + int r; - t = strndup(word, l); - if (!t) + r = extract_first_word(&cur, &word, NULL, EXTRACT_QUOTES); + if (r == 0) + break; + if (r == -ENOMEM) return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, "Trailing garbage in bounding set, ignoring: %s", prev); + break; + } - cap = capability_from_name(t); + cap = capability_from_name(word); if (cap < 0) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse capability in bounding set, ignoring: %s", t); + log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse capability in bounding set, ignoring: %s", word); + prev = cur; continue; } sum |= ((uint64_t) 1ULL) << (uint64_t) cap; + prev = cur; } - if (!isempty(state)) - log_syntax(unit, LOG_ERR, filename, line, 0, "Trailing garbage, ignoring."); capability_bounding_set = invert ? ~sum : sum; if (*capability_bounding_set_drop && capability_bounding_set) |