From b1f48e3c94d09b28a8325eed55f6c3cbb719ce4b Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Wed, 28 Oct 2015 22:57:59 +0530 Subject: journal-remote: port to extract_first_word --- src/journal-remote/journal-remote.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/journal-remote/journal-remote.c') 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 -- cgit v1.2.3-54-g00ecf