[PATCH 25/39] storage: zfs: Use g_strsplit instead of virStringSplitCount

Peter Krempa pkrempa at redhat.com
Thu Apr 1 13:52:24 UTC 2021


Both instances just check the length once. Replicate that faithfully.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/storage/storage_backend_zfs.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
index 6fed25cf4d..c36deb9dac 100644
--- a/src/storage/storage_backend_zfs.c
+++ b/src/storage/storage_backend_zfs.c
@@ -96,7 +96,6 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool,
                              const char *volume_string)
 {
     int ret = -1;
-    size_t count;
     char *vol_name;
     bool is_new_vol = false;
     virStorageVolDefPtr volume = NULL;
@@ -104,10 +103,10 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool,
     g_auto(GStrv) tokens = NULL;
     char *tmp;

-    if (!(tokens = virStringSplitCount(volume_string, "\t", 0, &count)))
+    if (!(tokens = g_strsplit(volume_string, "\t", 0)))
         return -1;

-    if (count != 3)
+    if (g_strv_length(tokens) != 3)
         goto cleanup;

     vol_name = tokens[0];
@@ -246,16 +245,15 @@ virStorageBackendZFSRefreshPool(virStoragePoolObjPtr pool G_GNUC_UNUSED)

     for (i = 0; lines[i]; i++) {
         g_auto(GStrv) tokens = NULL;
-        size_t count;
         char *prop_name;

         if (STREQ(lines[i], ""))
             continue;

-        if (!(tokens = virStringSplitCount(lines[i], "\t", 0, &count)))
+        if (!(tokens = g_strsplit(lines[i], "\t", 0)))
             goto cleanup;

-        if (count != 4)
+        if (g_strv_length(tokens) != 4)
             continue;

         prop_name = tokens[1];
-- 
2.29.2




More information about the libvir-list mailing list