[PATCH 10/39] virStorageFileParseBackingStoreStr: use g_strsplit instead of virStringSplitCount

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


The presence of the second element can be checked by looking at it
directly.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/util/virstoragefile.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index e6bc723d1e..e3ec64486e 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -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;
-- 
2.29.2




More information about the libvir-list mailing list