[PATCH 08/13] qemuNamespacePrepareOneItem: Restructure code to avoid temporary variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux