diff options
author | Susant Sahani <ssahani@gmail.com> | 2015-10-28 22:57:59 +0530 |
---|---|---|
committer | Susant Sahani <ssahani@gmail.com> | 2015-10-28 22:57:59 +0530 |
commit | b1f48e3c94d09b28a8325eed55f6c3cbb719ce4b (patch) | |
tree | 84ff3d8a2eb31e84f889496854387f7061267ebe /src | |
parent | dc1e811ebd80d1659d1476c4ae733d212d6aa946 (diff) |
journal-remote: port to extract_first_word
Diffstat (limited to 'src')
-rw-r--r-- | src/journal-remote/journal-remote.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index a2c49b8b4d..44550532b6 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -1255,6 +1255,7 @@ static int parse_argv(int argc, char *argv[]) { }; int c, r; + const char *p; bool type_a, type_b; assert(argc >= 0); @@ -1415,18 +1416,21 @@ static int parse_argv(int argc, char *argv[]) { case ARG_GNUTLS_LOG: { #ifdef HAVE_GNUTLS - const char *word, *state; - size_t size; + p = optarg; + for (;;) { + _cleanup_free_ char *word = NULL; - FOREACH_WORD_SEPARATOR(word, size, optarg, ",", state) { - char *cat; + r = extract_first_word(&p, &word, ",", 0); + if (r < 0) + return log_error_errno(r, "Failed to parse --gnutls-log= argument: %m"); - cat = strndup(word, size); - if (!cat) - return log_oom(); + if (r == 0) + break; - if (strv_consume(&arg_gnutls_log, cat) < 0) + if (strv_push(&arg_gnutls_log, word) < 0) return log_oom(); + + word = NULL; } break; #else |