]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virLogParseOutputs: Refactor string list handling
authorPeter Krempa <pkrempa@redhat.com>
Mon, 22 Mar 2021 16:38:24 +0000 (17:38 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 12 Apr 2021 13:55:09 +0000 (15:55 +0200)
Rewrite the code to remove the need to calculate the string list count.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virlog.c

index 004792db012a64e4ff3ac8fb06dc60058fa96e0d..3fadf7fc4a59ba608302c8014599663bd773a5ea 100644 (file)
@@ -1612,22 +1612,22 @@ virLogParseOutputs(const char *src, virLogOutputPtr **outputs)
 {
     int at = -1;
     size_t noutputs = 0;
-    size_t i, count;
     g_auto(GStrv) strings = NULL;
+    GStrv next;
     virLogOutputPtr output = NULL;
     virLogOutputPtr *list = NULL;
 
     VIR_DEBUG("outputs=%s", src);
 
-    if (!(strings = virStringSplitCount(src, " ", 0, &count)))
+    if (!(strings = g_strsplit(src, " ", 0)))
         return -1;
 
-    for (i = 0; i < count; i++) {
-        /* virStringSplit may return empty strings */
-        if (STREQ(strings[i], ""))
+    for (next = strings; *next; next++) {
+        /* g_strsplit may return empty strings */
+        if (STREQ(*next, ""))
             continue;
 
-        if (!(output = virLogParseOutput(strings[i])))
+        if (!(output = virLogParseOutput(*next)))
             return -1;
 
         /* let's check if a duplicate output does not already exist in which