[PATCH 4/6] qemu: domain: Return early in qemuDomainObjPrivateXMLFormatJob

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

 



Remove one level of nesting by returing early.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 54 ++++++++++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e5b494fa2a..b7fb9f264d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2045,36 +2045,38 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf,
     if (!qemuDomainTrackJob(job))
         job = QEMU_JOB_NONE;

-    if (job || priv->job.asyncJob) {
-        virBufferAsprintf(buf, "<job type='%s' async='%s'",
-                          qemuDomainJobTypeToString(job),
-                          qemuDomainAsyncJobTypeToString(priv->job.asyncJob));
-        if (priv->job.phase) {
-            virBufferAsprintf(buf, " phase='%s'",
-                              qemuDomainAsyncJobPhaseToString(
-                                    priv->job.asyncJob, priv->job.phase));
-        }
-        if (priv->job.asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT) {
-            virBufferAddLit(buf, "/>\n");
-        } else {
-            size_t i;
-            virDomainDiskDefPtr disk;
-            qemuDomainDiskPrivatePtr diskPriv;
+    if (job == QEMU_JOB_NONE &&
+        priv->job.asyncJob == QEMU_ASYNC_JOB_NONE)
+        return;

-            virBufferAddLit(buf, ">\n");
-            virBufferAdjustIndent(buf, 2);
+    virBufferAsprintf(buf, "<job type='%s' async='%s'",
+                      qemuDomainJobTypeToString(job),
+                      qemuDomainAsyncJobTypeToString(priv->job.asyncJob));
+    if (priv->job.phase) {
+        virBufferAsprintf(buf, " phase='%s'",
+                          qemuDomainAsyncJobPhaseToString(priv->job.asyncJob,
+                                                          priv->job.phase));
+    }
+    if (priv->job.asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT) {
+        virBufferAddLit(buf, "/>\n");
+    } else {
+        size_t i;
+        virDomainDiskDefPtr disk;
+        qemuDomainDiskPrivatePtr diskPriv;

-            for (i = 0; i < vm->def->ndisks; i++) {
-                disk = vm->def->disks[i];
-                diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
-                virBufferAsprintf(buf, "<disk dev='%s' migrating='%s'/>\n",
-                                  disk->dst,
-                                  diskPriv->migrating ? "yes" : "no");
-            }
+        virBufferAddLit(buf, ">\n");
+        virBufferAdjustIndent(buf, 2);

-            virBufferAdjustIndent(buf, -2);
-            virBufferAddLit(buf, "</job>\n");
+        for (i = 0; i < vm->def->ndisks; i++) {
+            disk = vm->def->disks[i];
+            diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+            virBufferAsprintf(buf, "<disk dev='%s' migrating='%s'/>\n",
+                              disk->dst,
+                              diskPriv->migrating ? "yes" : "no");
         }
+
+        virBufferAdjustIndent(buf, -2);
+        virBufferAddLit(buf, "</job>\n");
     }
 }

-- 
2.16.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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