mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemuNamespaceUnlinkPaths: Fix wrong use of iterator variable
'i' is used in both outer and inner loop. Since 'devMountsPath' is now a
NULL-terminated list, we can use a GStrv to iterate it;
Additionally rewrite the conditional of adding to the 'unlinkPaths'
array so that it's more clear what's happening.
Fixes: 5c86fbb72d
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
5ab8342e64
commit
e310900e50
@ -1362,14 +1362,20 @@ qemuNamespaceUnlinkPaths(virDomainObjPtr vm,
|
|||||||
const char *file = paths[i];
|
const char *file = paths[i];
|
||||||
|
|
||||||
if (STRPREFIX(file, QEMU_DEVPREFIX)) {
|
if (STRPREFIX(file, QEMU_DEVPREFIX)) {
|
||||||
for (i = 0; i < ndevMountsPath; i++) {
|
GStrv mount;
|
||||||
if (STREQ(devMountsPath[i], "/dev"))
|
bool inSubmount = false;
|
||||||
|
|
||||||
|
for (mount = devMountsPath; *mount; mount++) {
|
||||||
|
if (STREQ(*mount, "/dev"))
|
||||||
continue;
|
continue;
|
||||||
if (STRPREFIX(file, devMountsPath[i]))
|
|
||||||
|
if (STRPREFIX(file, *mount)) {
|
||||||
|
inSubmount = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == ndevMountsPath &&
|
if (!inSubmount &&
|
||||||
virStringListAdd(&unlinkPaths, file) < 0)
|
virStringListAdd(&unlinkPaths, file) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user