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