3cf992
From dce266130a7eef93d3f76940929cc92e1316b0a0 Mon Sep 17 00:00:00 2001
3cf992
Message-Id: <dce266130a7eef93d3f76940929cc92e1316b0a0@dist-git>
3cf992
From: Michal Privoznik <mprivozn@redhat.com>
3cf992
Date: Mon, 8 Mar 2021 12:57:30 +0100
3cf992
Subject: [PATCH] virDevMapperGetTargetsImpl: Use VIR_AUTOSTRINGLIST
3cf992
MIME-Version: 1.0
3cf992
Content-Type: text/plain; charset=UTF-8
3cf992
Content-Transfer-Encoding: 8bit
3cf992
3cf992
Since we have VIR_AUTOSTRINGLIST we can use it to free string
3cf992
lists used in the function automatically.
3cf992
3cf992
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
3cf992
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3cf992
(cherry picked from commit b8ebbe05451fde7ce541564f73437a29ffd5db0d)
3cf992
3cf992
Conflicts:
3cf992
- src/util/virdevmapper.c: Another Glib conflict, but
3cf992
  fortunately, this time it's only in the context - the cherry
3cf992
  picked commit uses g_steal_pointer() because of
3cf992
  a3931b4996e46db409ad031e0230a507fb303287
3cf992
  but the old code still uses VIR_STEAL_PTR().
3cf992
3cf992
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1933557
3cf992
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
3cf992
Message-Id: <c67e2ea85bd93ce5bb2ed136858f66d983403e1b.1615203117.git.mprivozn@redhat.com>
3cf992
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3cf992
---
3cf992
 src/util/virdevmapper.c | 16 +++-------------
3cf992
 1 file changed, 3 insertions(+), 13 deletions(-)
3cf992
3cf992
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
3cf992
index 6aee00112c..50d12ea0f1 100644
3cf992
--- a/src/util/virdevmapper.c
3cf992
+++ b/src/util/virdevmapper.c
3cf992
@@ -72,8 +72,7 @@ virDevMapperGetTargetsImpl(const char *path,
3cf992
     struct dm_task *dmt = NULL;
3cf992
     struct dm_deps *deps;
3cf992
     struct dm_info info;
3cf992
-    char **devPaths = NULL;
3cf992
-    char **recursiveDevPaths = NULL;
3cf992
+    VIR_AUTOSTRINGLIST devPaths = NULL;
3cf992
     size_t i;
3cf992
     int ret = -1;
3cf992
 
3cf992
@@ -139,28 +138,19 @@ virDevMapperGetTargetsImpl(const char *path,
3cf992
             goto cleanup;
3cf992
     }
3cf992
 
3cf992
-    recursiveDevPaths = NULL;
3cf992
     for (i = 0; i < deps->count; i++) {
3cf992
-        char **tmpPaths;
3cf992
+        VIR_AUTOSTRINGLIST tmpPaths = NULL;
3cf992
 
3cf992
         if (virDevMapperGetTargetsImpl(devPaths[i], &tmpPaths, ttl - 1) < 0)
3cf992
             goto cleanup;
3cf992
 
3cf992
-        if (tmpPaths &&
3cf992
-            virStringListMerge(&recursiveDevPaths, &tmpPaths) < 0) {
3cf992
-            virStringListFree(tmpPaths);
3cf992
+        if (virStringListMerge(&devPaths, &tmpPaths) < 0)
3cf992
             goto cleanup;
3cf992
-        }
3cf992
     }
3cf992
 
3cf992
-    if (virStringListMerge(&devPaths, &recursiveDevPaths) < 0)
3cf992
-        goto cleanup;
3cf992
-
3cf992
     VIR_STEAL_PTR(*devPaths_ret, devPaths);
3cf992
     ret = 0;
3cf992
  cleanup:
3cf992
-    virStringListFree(recursiveDevPaths);
3cf992
-    virStringListFree(devPaths);
3cf992
     dm_task_destroy(dmt);
3cf992
     return ret;
3cf992
 }
3cf992
-- 
3cf992
2.31.0
3cf992