]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-remote: port to extract_first_word
authorSusant Sahani <ssahani@gmail.com>
Wed, 28 Oct 2015 17:27:59 +0000 (22:57 +0530)
committerSusant Sahani <ssahani@gmail.com>
Wed, 28 Oct 2015 17:27:59 +0000 (22:57 +0530)
src/journal-remote/journal-remote.c

index a2c49b8b4d1ec7c35be029a76b6cfd6222c244b9..44550532b65bfb2c21abc8f611cbd7c38c9a65c5 100644 (file)
@@ -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