render / rpms / libvirt

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