diff options
author | Peter Krempa <pkrempa@redhat.com> | 2021-03-23 09:12:19 +0100 |
---|---|---|
committer | Peter Krempa <pkrempa@redhat.com> | 2021-04-12 15:55:09 +0200 |
commit | 7f5c2ad88fc672676c7b84a98126c3f9afa059de (patch) | |
tree | b5bf2a9d6036d1c8154812d1b3af30bf1055d463 /src/storage_file | |
parent | def579e88a14c8d30bc7bae211a60c174b896db7 (diff) | |
download | libvirt-7f5c2ad88fc672676c7b84a98126c3f9afa059de.tar.gz |
virStorageSourceParseBackingJSONUriCookies: Use g_strsplit instead of virStringSplitCount
Count the elements after splitting the string.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Diffstat (limited to 'src/storage_file')
-rw-r--r-- | src/storage_file/storage_source_backingstore.c | 9 |
1 files 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; |