[PATCH 13/39] virLogParseOutputs: Refactor string list handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rewrite the code to remove the need to calculate the string list count.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/util/virlog.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/util/virlog.c b/src/util/virlog.c
index 004792db01..56059f62f1 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -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++) {
+    for (next = strings; *next; next++) {
         /* virStringSplit may return empty strings */
-        if (STREQ(strings[i], ""))
+        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
-- 
2.29.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux