The value of 'next' is copied into 'item.file' so we can move the update
to the 'next' pointer earlier and move the VIR_APPEND_ELEMENT call to
where we figure out that we need to append the value.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_namespace.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c
index ca59b5d95b..01a5edc585 100644
--- a/src/qemu/qemu_namespace.c
+++ b/src/qemu/qemu_namespace.c
@@ -1197,7 +1197,6 @@ qemuNamespacePrepareOneItem(qemuNamespaceMknodData *data,
while (1) {
g_auto(qemuNamespaceMknodItem) item = { 0 };
bool isLink;
- bool addToData = false;
int rc;
rc = qemuNamespaceMknodItemInit(&item, cfg, vm, next);
@@ -1210,25 +1209,21 @@ qemuNamespacePrepareOneItem(qemuNamespaceMknodData *data,
}
isLink = S_ISLNK(item.sb.st_mode);
+ g_free(next);
+ next = g_strdup(item.target);
- if (STRPREFIX(next, QEMU_DEVPREFIX)) {
+ if (STRPREFIX(item.file, QEMU_DEVPREFIX)) {
for (i = 0; i < ndevMountsPath; i++) {
if (STREQ(devMountsPath[i], "/dev"))
continue;
- if (STRPREFIX(next, devMountsPath[i]))
+ if (STRPREFIX(item.file, devMountsPath[i]))
break;
}
if (i == ndevMountsPath)
- addToData = true;
+ VIR_APPEND_ELEMENT(data->items, data->nitems, item);
}
- g_free(next);
- next = g_strdup(item.target);
-
- if (addToData)
- VIR_APPEND_ELEMENT(data->items, data->nitems, item);
-
if (!isLink)
break;
--
2.31.1