'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: 5c86fbb72d6e90025481db7
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_namespace.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c
index 27a78c86e4..03cc6379fe 100644
--- a/src/qemu/qemu_namespace.c
+++ b/src/qemu/qemu_namespace.c
@@ -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;
}
--
2.29.2