1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-09 20:58:33 +03:00

qemuNamespaceUnlinkPaths: Fix inconsistent cleanup handling

Some code paths return -1 directly while others jump to 'cleanup' which
cleans the list of mounts. Since qemuDomainGetPreservedMounts now
returns a NULL-terminated list, convert devMountsPath to g_auto(GStrv)
and remove the cleanup altoghether.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2021-02-04 15:12:57 +01:00
parent e310900e50
commit b020663381

View File

@ -1341,11 +1341,9 @@ qemuNamespaceUnlinkPaths(virDomainObjPtr vm,
virQEMUDriverPtr driver = priv->driver;
g_autoptr(virQEMUDriverConfig) cfg = NULL;
g_auto(GStrv) unlinkPaths = NULL;
char **devMountsPath = NULL;
size_t ndevMountsPath = 0;
g_auto(GStrv) devMountsPath = NULL;
size_t npaths;
size_t i;
int ret = -1;
npaths = virStringListLength(paths);
if (!npaths)
@ -1353,10 +1351,8 @@ qemuNamespaceUnlinkPaths(virDomainObjPtr vm,
cfg = virQEMUDriverGetConfig(driver);
if (qemuDomainGetPreservedMounts(cfg, vm,
&devMountsPath, NULL,
&ndevMountsPath) < 0)
goto cleanup;
if (qemuDomainGetPreservedMounts(cfg, vm, &devMountsPath, NULL, NULL) < 0)
return -1;
for (i = 0; i < npaths; i++) {
const char *file = paths[i];
@ -1387,10 +1383,7 @@ qemuNamespaceUnlinkPaths(virDomainObjPtr vm,
unlinkPaths) < 0)
return -1;
ret = 0;
cleanup:
virStringListFreeCount(devMountsPath, ndevMountsPath);
return ret;
return 0;
}