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