[PATCH 22/39] virStorageSourceParseBackingJSONUriCookies: Use g_strsplit instead of virStringSplitCount

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

 



Count the elements after splitting the string.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/storage_file/storage_source_backingstore.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/storage_file/storage_source_backingstore.c b/src/storage_file/storage_source_backingstore.c
index bac5a043e5..9a67d64fd6 100644
--- a/src/storage_file/storage_source_backingstore.c
+++ b/src/storage_file/storage_source_backingstore.c
@@ -483,7 +483,6 @@ virStorageSourceParseBackingJSONUriCookies(virStorageSourcePtr src,
 {
     const char *cookiestr;
     g_auto(GStrv) cookies = NULL;
-    size_t ncookies = 0;
     size_t i;

     if (!virJSONValueObjectHasKey(json, "cookie"))
@@ -496,13 +495,13 @@ virStorageSourceParseBackingJSONUriCookies(virStorageSourcePtr src,
         return -1;
     }

-    if (!(cookies = virStringSplitCount(cookiestr, ";", 0, &ncookies)))
+    if (!(cookies = g_strsplit(cookiestr, ";", 0)))
         return -1;

-    src->cookies = g_new0(virStorageNetCookieDefPtr, ncookies);
-    src->ncookies = ncookies;
+    src->ncookies = g_strv_length(cookies);
+    src->cookies = g_new0(virStorageNetCookieDefPtr, src->ncookies);

-    for (i = 0; i < ncookies; i++) {
+    for (i = 0; i < src->ncookies; i++) {
         char *cookiename = cookies[i];
         char *cookievalue;

-- 
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