diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-07-31 11:23:44 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-09-09 09:34:54 +0200 |
commit | dd2fff3a189a956170978ddeda6618b0f84ab2a0 (patch) | |
tree | c18e1948063478b830ae6f17e268e25ed40eebc8 | |
parent | core/load-fragment: use extract_first_word() (diff) | |
download | systemd-dd2fff3a189a956170978ddeda6618b0f84ab2a0.tar.xz systemd-dd2fff3a189a956170978ddeda6618b0f84ab2a0.zip |
cryptsetup: use extract_first_word()
-rw-r--r-- | src/cryptsetup/cryptsetup.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index f9e627da46..7d0571f147 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -288,19 +288,19 @@ static int parse_one_option(const char *option) { } static int parse_options(const char *options) { - const char *word, *state; - size_t l; - int r; - assert(options); - FOREACH_WORD_SEPARATOR(word, l, options, ",", state) { - _cleanup_free_ char *o; + for (;;) { + _cleanup_free_ char *word = NULL; + int r; + + r = extract_first_word(&options, &word, ",", EXTRACT_DONT_COALESCE_SEPARATORS); + if (r < 0) + return log_debug_errno(r, "Failed to parse options: %m"); + if (r == 0) + break; - o = strndup(word, l); - if (!o) - return -ENOMEM; - r = parse_one_option(o); + r = parse_one_option(word); if (r < 0) return r; } |