79b470
From 318beaace7890f3ccf2d09c1afcdde40f4f0284f Mon Sep 17 00:00:00 2001
79b470
Message-Id: <318beaace7890f3ccf2d09c1afcdde40f4f0284f@dist-git>
79b470
From: Michal Privoznik <mprivozn@redhat.com>
79b470
Date: Mon, 27 Jul 2020 12:36:51 +0200
79b470
Subject: [PATCH] virDevMapperGetTargetsImpl: Use VIR_AUTOSTRINGLIST
79b470
MIME-Version: 1.0
79b470
Content-Type: text/plain; charset=UTF-8
79b470
Content-Transfer-Encoding: 8bit
79b470
79b470
Since we have VIR_AUTOSTRINGLIST we can use it to free string
79b470
lists used in the function automatically.
79b470
79b470
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
79b470
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
79b470
(cherry picked from commit b8ebbe05451fde7ce541564f73437a29ffd5db0d)
79b470
79b470
https://bugzilla.redhat.com/show_bug.cgi?id=1860421
79b470
79b470
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
79b470
Message-Id: <c93475780b29c50e19492521e3b9cd19498f119b.1595846084.git.mprivozn@redhat.com>
79b470
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
79b470
---
79b470
 src/util/virdevmapper.c | 16 +++-------------
79b470
 1 file changed, 3 insertions(+), 13 deletions(-)
79b470
79b470
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
79b470
index 118dc82e94..44c4731fb4 100644
79b470
--- a/src/util/virdevmapper.c
79b470
+++ b/src/util/virdevmapper.c
79b470
@@ -67,8 +67,7 @@ virDevMapperGetTargetsImpl(const char *path,
79b470
     struct dm_task *dmt = NULL;
79b470
     struct dm_deps *deps;
79b470
     struct dm_info info;
79b470
-    char **devPaths = NULL;
79b470
-    char **recursiveDevPaths = NULL;
79b470
+    VIR_AUTOSTRINGLIST devPaths = NULL;
79b470
     size_t i;
79b470
     int ret = -1;
79b470
 
79b470
@@ -133,28 +132,19 @@ virDevMapperGetTargetsImpl(const char *path,
79b470
                                       minor(deps->device[i]));
79b470
     }
79b470
 
79b470
-    recursiveDevPaths = NULL;
79b470
     for (i = 0; i < deps->count; i++) {
79b470
-        char **tmpPaths;
79b470
+        VIR_AUTOSTRINGLIST tmpPaths = NULL;
79b470
 
79b470
         if (virDevMapperGetTargetsImpl(devPaths[i], &tmpPaths, ttl - 1) < 0)
79b470
             goto cleanup;
79b470
 
79b470
-        if (tmpPaths &&
79b470
-            virStringListMerge(&recursiveDevPaths, &tmpPaths) < 0) {
79b470
-            virStringListFree(tmpPaths);
79b470
+        if (virStringListMerge(&devPaths, &tmpPaths) < 0)
79b470
             goto cleanup;
79b470
-        }
79b470
     }
79b470
 
79b470
-    if (virStringListMerge(&devPaths, &recursiveDevPaths) < 0)
79b470
-        goto cleanup;
79b470
-
79b470
     *devPaths_ret = g_steal_pointer(&devPaths);
79b470
     ret = 0;
79b470
  cleanup:
79b470
-    virStringListFree(recursiveDevPaths);
79b470
-    virStringListFree(devPaths);
79b470
     dm_task_destroy(dmt);
79b470
     return ret;
79b470
 }
79b470
-- 
79b470
2.28.0
79b470