mirror of https://gitee.com/openkylin/libvirt.git
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];
|
||||
|
||||
if (STRPREFIX(file, QEMU_DEVPREFIX)) {
|
||||
for (i = 0; i < ndevMountsPath; i++) {
|
||||
if (STREQ(devMountsPath[i], "/dev"))
|
||||
GStrv mount;
|
||||
bool inSubmount = false;
|
||||
|
||||
for (mount = devMountsPath; *mount; mount++) {
|
||||
if (STREQ(*mount, "/dev"))
|
||||
continue;
|
||||
if (STRPREFIX(file, devMountsPath[i]))
|
||||
|
||||
if (STRPREFIX(file, *mount)) {
|
||||
inSubmount = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == ndevMountsPath &&
|
||||
if (!inSubmount &&
|
||||
virStringListAdd(&unlinkPaths, file) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue