]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virStorageFileParseBackingStoreStr: use g_strsplit instead of virStringSplitCount
authorPeter Krempa <pkrempa@redhat.com>
Mon, 22 Mar 2021 16:00:41 +0000 (17:00 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 12 Apr 2021 13:55:09 +0000 (15:55 +0200)
The presence of the second element can be checked by looking at it
directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virstoragefile.c

index e6bc723d1eea62c5147c2e91013a975bb1813277..e3ec64486e92e818d96f7307c218ca4f34bea1b1 100644 (file)
@@ -192,17 +192,16 @@ virStorageFileParseBackingStoreStr(const char *str,
                                    char **target,
                                    unsigned int *chainIndex)
 {
-    size_t nstrings;
     unsigned int idx = 0;
     char *suffix;
     g_auto(GStrv) strings = NULL;
 
     *chainIndex = 0;
 
-    if (!(strings = virStringSplitCount(str, "[", 2, &nstrings)))
+    if (!(strings = g_strsplit(str, "[", 2)))
         return -1;
 
-    if (nstrings == 2) {
+    if (strings[0] && strings[1]) {
         if (virStrToLong_uip(strings[1], &suffix, 10, &idx) < 0 ||
             STRNEQ(suffix, "]"))
             return -1;