Remove one level of nesting by returing early.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
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