[PATCH 19/39] virHostValidateGetCPUFlags: Use g_strsplit instead of virStringSplitCount

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

 



We don't need the count of elements to iterate the list.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tools/virt-host-validate-common.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c
index fc43b2ddc8..7e9f5a667c 100644
--- a/tools/virt-host-validate-common.c
+++ b/tools/virt-host-validate-common.c
@@ -201,9 +201,8 @@ virBitmapPtr virHostValidateGetCPUFlags(void)
     do {
         char line[1024];
         char *start;
-        char **tokens;
-        size_t ntokens;
-        size_t i;
+        g_auto(GStrv) tokens = NULL;
+        GStrv next;

         if (!fgets(line, sizeof(line), fp))
             break;
@@ -228,20 +227,18 @@ virBitmapPtr virHostValidateGetCPUFlags(void)

         /* Split the line using " " as a delimiter. The first token
          * will always be ":", but that's okay */
-        if (!(tokens = virStringSplitCount(start, " ", 0, &ntokens)))
+        if (!(tokens = g_strsplit(start, " ", 0)))
             continue;

         /* Go through all flags and check whether one of those we
          * might want to check for later on is present; if that's
          * the case, set the relevant bit in the bitmap */
-        for (i = 0; i < ntokens; i++) {
+        for (next = tokens; *next; next++) {
             int value;

-            if ((value = virHostValidateCPUFlagTypeFromString(tokens[i])) >= 0)
+            if ((value = virHostValidateCPUFlagTypeFromString(*next)) >= 0)
                 ignore_value(virBitmapSetBit(flags, value));
         }
-
-        virStringListFreeCount(tokens, ntokens);
     } while (1);

     VIR_FORCE_FCLOSE(fp);
-- 
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