Signed-off-by: Martin Kletzander <mklet...@redhat.com>
---
 src/qemu/qemu_agent.c        |  3 +--
 src/qemu/qemu_capabilities.c |  9 +++------
 src/qemu/qemu_cgroup.c       |  6 ++----
 src/qemu/qemu_command.c      |  6 ++----
 src/qemu/qemu_conf.c         |  3 +--
 src/qemu/qemu_domain.c       |  3 +--
 src/qemu/qemu_driver.c       | 45 +++++++++++++++-----------------------------
 src/qemu/qemu_hotplug.c      |  6 ++----
 src/qemu/qemu_migration.c    |  3 +--
 src/qemu/qemu_monitor_json.c | 12 ++++--------
 src/qemu/qemu_monitor_text.c |  6 ++----
 src/qemu/qemu_process.c      | 18 ++++++------------
 12 files changed, 40 insertions(+), 80 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 9f673bf..8df1330 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -381,9 +381,8 @@ static int qemuAgentIOProcessData(qemuAgentPtr mon,
             int got = nl - (data + used);
             for (i = 0; i < strlen(LINE_ENDING); i++)
                 data[used + got + i] = '\0';
-            if (qemuAgentIOProcessLine(mon, data + used, msg) < 0) {
+            if (qemuAgentIOProcessLine(mon, data + used, msg) < 0)
                 return -1;
-            }
             used += got + strlen(LINE_ENDING);
         } else {
             break;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 74a3b24..7ae25f1 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1179,9 +1179,8 @@ virQEMUCapsComputeCmdFlags(const char *help,
     if (is_kvm && (version >= 10000 || kvm_version >= 74))
         virQEMUCapsSet(qemuCaps, QEMU_CAPS_VNET_HDR);

-    if (strstr(help, ",vhost=")) {
+    if (strstr(help, ",vhost="))
         virQEMUCapsSet(qemuCaps, QEMU_CAPS_VHOST_NET);
-    }

     /* Do not use -no-shutdown if qemu doesn't support it or SIGTERM handling
      * is most likely buggy when used with -no-shutdown (which applies for qemu
@@ -1937,9 +1936,8 @@ void virQEMUCapsDispose(void *obj)
     VIR_FREE(qemuCaps->machineAliases);
     VIR_FREE(qemuCaps->machineMaxCpus);

-    for (i = 0; i < qemuCaps->ncpuDefinitions; i++) {
+    for (i = 0; i < qemuCaps->ncpuDefinitions; i++)
         VIR_FREE(qemuCaps->cpuDefinitions[i]);
-    }
     VIR_FREE(qemuCaps->cpuDefinitions);

     virBitmapFree(qemuCaps->flags);
@@ -2827,9 +2825,8 @@ virQEMUCapsReset(virQEMUCapsPtr qemuCaps)
     qemuCaps->arch = VIR_ARCH_NONE;
     qemuCaps->usedQMP = false;

-    for (i = 0; i < qemuCaps->ncpuDefinitions; i++) {
+    for (i = 0; i < qemuCaps->ncpuDefinitions; i++)
         VIR_FREE(qemuCaps->cpuDefinitions[i]);
-    }
     VIR_FREE(qemuCaps->cpuDefinitions);
     qemuCaps->ncpuDefinitions = 0;

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 3b1d16d..0e94cae 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -920,9 +920,8 @@ qemuSetupCgroupVcpuPin(virCgroupPtr cgroup,
     size_t i;

     for (i = 0; i < nvcpupin; i++) {
-        if (vcpuid == vcpupin[i]->vcpuid) {
+        if (vcpuid == vcpupin[i]->vcpuid)
             return qemuSetupCgroupEmulatorPin(cgroup, vcpupin[i]->cpumask);
-        }
     }

     return -1;
@@ -937,9 +936,8 @@ qemuSetupCgroupIOThreadsPin(virCgroupPtr cgroup,
     size_t i;

     for (i = 0; i < niothreadspin; i++) {
-        if (iothreadid == iothreadspin[i]->vcpuid) {
+        if (iothreadid == iothreadspin[i]->vcpuid)
             return qemuSetupCgroupEmulatorPin(cgroup, 
iothreadspin[i]->cpumask);
-        }
     }

     return -1;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f674ba9..6df351f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8862,9 +8862,8 @@ qemuBuildCommandLine(virConnectPtr conn,
                                _("network disks are only supported with 
-drive"));
                 goto error;
             } else {
-                if (VIR_STRDUP(file, disk->src->path) < 0) {
+                if (VIR_STRDUP(file, disk->src->path) < 0)
                     goto error;
-                }
             }

             /* Don't start with source if the tray is open for
@@ -10144,9 +10143,8 @@ static int qemuStringToArgvEnv(const char *args,

         start = curr;
         /* accept a space in CEPH_ARGS */
-        if (STRPREFIX(curr, "CEPH_ARGS=-m ")) {
+        if (STRPREFIX(curr, "CEPH_ARGS=-m "))
             start += strlen("CEPH_ARGS=-m ");
-        }
         if (*start == '\'') {
             if (start == curr)
                 curr++;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 1ae90ff..4764bef 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1018,9 +1018,8 @@ qemuSharedDeviceEntryFree(void *payload, const void *name 
ATTRIBUTE_UNUSED)
     if (!entry)
         return;

-    for (i = 0; i < entry->ref; i++) {
+    for (i = 0; i < entry->ref; i++)
         VIR_FREE(entry->domains[i]);
-    }
     VIR_FREE(entry->domains);
     VIR_FREE(entry);
 }
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 8e91a48..01bf39b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -495,9 +495,8 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
         size_t i;
         virBufferAddLit(buf, "<vcpus>\n");
         virBufferAdjustIndent(buf, 2);
-        for (i = 0; i < priv->nvcpupids; i++) {
+        for (i = 0; i < priv->nvcpupids; i++)
             virBufferAsprintf(buf, "<vcpu pid='%d'/>\n", priv->vcpupids[i]);
-        }
         virBufferAdjustIndent(buf, -2);
         virBufferAddLit(buf, "</vcpus>\n");
     }
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 411179d..7e21ffd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -995,9 +995,8 @@ qemuStateStop(void)
     for (i = 0; i < numDomains; i++) {
         flags[i] = VIR_DOMAIN_SAVE_RUNNING;
         if (virDomainGetState(domains[i], &state, NULL, 0) == 0) {
-            if (state == VIR_DOMAIN_PAUSED) {
+            if (state == VIR_DOMAIN_PAUSED)
                 flags[i] = VIR_DOMAIN_SAVE_PAUSED;
-            }
         }
         virDomainSuspend(domains[i]);
     }
@@ -1840,9 +1839,8 @@ static int qemuDomainSuspend(virDomainPtr dom)
                        "%s", _("domain is pmsuspended"));
         goto endjob;
     } else if (state != VIR_DOMAIN_PAUSED) {
-        if (qemuProcessStopCPUs(driver, vm, reason, QEMU_ASYNC_JOB_NONE) < 0) {
+        if (qemuProcessStopCPUs(driver, vm, reason, QEMU_ASYNC_JOB_NONE) < 0)
             goto endjob;
-        }

         if (eventDetail >= 0) {
             event = virDomainEventLifecycleNewFromObj(vm,
@@ -4043,9 +4041,8 @@ processGuestPanicEvent(virQEMUDriverPtr driver,

     switch (action) {
     case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY:
-        if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0) {
+        if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0)
             goto cleanup;
-        }
         /* fall through */

     case VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY:
@@ -4074,15 +4071,13 @@ processGuestPanicEvent(virQEMUDriverPtr driver,

         virDomainAuditStop(vm, "destroyed");

-        if (!vm->persistent) {
+        if (!vm->persistent)
             qemuDomainRemoveInactive(driver, vm);
-        }
         break;

     case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART:
-        if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0) {
+        if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0)
             goto cleanup;
-        }
         /* fall through */

     case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART:
@@ -4955,9 +4950,8 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
                                         &targetDef) < 0)
         goto cleanup;

-    if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+    if (flags & VIR_DOMAIN_AFFECT_LIVE)
         targetDef = vm->def;
-    }

     /* Coverity didn't realize that targetDef must be set if we got here.  */
     sa_assert(targetDef);
@@ -4973,9 +4967,8 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
     if (ncpumaps > targetDef->vcpus)
         ncpumaps = targetDef->vcpus;

-    if (ncpumaps < 1) {
+    if (ncpumaps < 1)
         goto cleanup;
-    }

     /* initialize cpumaps */
     memset(cpumaps, 0xff, maplen * ncpumaps);
@@ -5233,9 +5226,8 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom,

     /* initialize cpumaps */
     memset(cpumaps, 0xff, maplen);
-    if (maxcpu % 8) {
+    if (maxcpu % 8)
         cpumaps[maplen - 1] &= (1 << maxcpu % 8) - 1;
-    }

     if (targetDef->cputune.emulatorpin) {
         cpumask = targetDef->cputune.emulatorpin->cpumask;
@@ -9532,9 +9524,8 @@ qemuSetEmulatorBandwidthLive(virDomainObjPtr vm, 
virCgroupPtr cgroup,
     if (period == 0 && quota == 0)
         return 0;

-    if (priv->nvcpupids == 0 || priv->vcpupids[0] == vm->pid) {
+    if (priv->nvcpupids == 0 || priv->vcpupids[0] == vm->pid)
         return 0;
-    }

     if (virCgroupNewEmulator(cgroup, false, &cgroup_emulator) < 0)
         goto cleanup;
@@ -10510,12 +10501,10 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
     /* average is mandatory, peak and burst are optional. So if no
      * average is given, we free inbound/outbound here which causes
      * inbound/outbound to not be set. */
-    if (!bandwidth->in->average) {
+    if (!bandwidth->in->average)
         VIR_FREE(bandwidth->in);
-    }
-    if (!bandwidth->out->average) {
+    if (!bandwidth->out->average)
         VIR_FREE(bandwidth->out);
-    }

     if (flags & VIR_DOMAIN_AFFECT_LIVE) {
         if (VIR_ALLOC(newBandwidth) < 0)
@@ -14860,9 +14849,8 @@ qemuDomainSnapshotReparentChildren(void *payload,
     virDomainSnapshotObjPtr snap = payload;
     virQEMUSnapReparentPtr rep = data;

-    if (rep->err < 0) {
+    if (rep->err < 0)
         return;
-    }

     VIR_FREE(snap->def->parent);
     snap->parent = rep->parent;
@@ -15036,9 +15024,8 @@ static int qemuDomainQemuMonitorCommand(virDomainPtr 
domain, const char *cmd,
     qemuDomainObjExitMonitor(driver, vm);

  endjob:
-    if (!qemuDomainObjEndJob(driver, vm)) {
+    if (!qemuDomainObjEndJob(driver, vm))
         vm = NULL;
-    }

  cleanup:
     if (vm)
@@ -15905,9 +15892,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
     }

     device = qemuDiskPathToAlias(vm, path, &idx);
-    if (!device) {
+    if (!device)
         goto endjob;
-    }
     disk = vm->def->disks[idx];
     if (disk->mirror) {
         virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
@@ -17032,9 +17018,8 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
     }

     device = qemuDiskPathToAlias(vm, disk, NULL);
-    if (!device) {
+    if (!device)
         goto endjob;
-    }

     if (flags & VIR_DOMAIN_AFFECT_LIVE) {
         qemuDomainObjEnterMonitor(driver, vm);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 13bcd88..b9a0cee 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -468,9 +468,8 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr 
driver,
             goto cleanup;
         }

-        if (!(devstr = qemuBuildControllerDevStr(vm->def, controller, 
priv->qemuCaps, NULL))) {
+        if (!(devstr = qemuBuildControllerDevStr(vm->def, controller, 
priv->qemuCaps, NULL)))
             goto cleanup;
-        }
     }

     if (VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers+1) < 0)
@@ -3095,9 +3094,8 @@ qemuFindDisk(virDomainDefPtr def, const char *dst)
     size_t i;

     for (i = 0; i < def->ndisks; i++) {
-        if (STREQ(def->disks[i]->dst, dst)) {
+        if (STREQ(def->disks[i]->dst, dst))
             return i;
-        }
     }

     return -1;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index bef5b94..b0e1024 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2837,9 +2837,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
     qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0);

  endjob:
-    if (!qemuMigrationJobFinish(driver, vm)) {
+    if (!qemuMigrationJobFinish(driver, vm))
         vm = NULL;
-    }
     goto cleanup;
 }

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 91a7aba..744a862 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -565,9 +565,8 @@ static void qemuMonitorJSONHandleWatchdog(qemuMonitorPtr 
mon, virJSONValuePtr da
 {
     const char *action;
     int actionID;
-    if (!(action = virJSONValueObjectGetString(data, "action"))) {
+    if (!(action = virJSONValueObjectGetString(data, "action")))
         VIR_WARN("missing action in watchdog event");
-    }
     if (action) {
         if ((actionID = qemuMonitorWatchdogActionTypeFromString(action)) < 0) {
             VIR_WARN("unknown action %s in watchdog event", action);
@@ -602,9 +601,8 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, 
virJSONValuePtr data)
         action = "ignore";
     }

-    if ((device = virJSONValueObjectGetString(data, "device")) == NULL) {
+    if ((device = virJSONValueObjectGetString(data, "device")) == NULL)
         VIR_WARN("missing device in disk io error event");
-    }

     if (virJSONValueObjectGetBoolean(data, "nospace", &nospc) == 0 && nospc)
         reason = "enospc";
@@ -4451,9 +4449,8 @@ int qemuMonitorJSONGetBlockIoThrottle(qemuMonitorPtr mon,
     virJSONValuePtr result = NULL;

     cmd = qemuMonitorJSONMakeCommand("query-block", NULL);
-    if (!cmd) {
+    if (!cmd)
         return -1;
-    }

     ret = qemuMonitorJSONCommand(mon, cmd, &result);

@@ -4485,9 +4482,8 @@ int qemuMonitorJSONSystemWakeup(qemuMonitorPtr mon)
     virJSONValuePtr reply = NULL;

     cmd = qemuMonitorJSONMakeCommand("system_wakeup", NULL);
-    if (!cmd) {
+    if (!cmd)
         return -1;
-    }

     ret = qemuMonitorJSONCommand(mon, cmd, &reply);

diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 46d2782..e40c676 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -123,9 +123,8 @@ int qemuMonitorTextIOProcess(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
          */
         if (msg->txLength > 0) {
             char *tmp;
-            if ((tmp = strchr(msg->txBuffer, '\r'))) {
+            if ((tmp = strchr(msg->txBuffer, '\r')))
                 *tmp = '\0';
-            }
         }

         /* QEMU echos the command back to us, full of control
@@ -144,9 +143,8 @@ int qemuMonitorTextIOProcess(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
         skip = strstr(data + used, msg->txBuffer);

         /* After the junk we should have a line ending... */
-        if (skip) {
+        if (skip)
             start = strstr(skip + strlen(msg->txBuffer), LINE_ENDING);
-        }

         /* ... then our command reply data, following by a (qemu) prompt */
         if (start) {
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 6350bfa..7518138 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -627,9 +627,8 @@ qemuProcessFakeReboot(void *opaque)

  cleanup:
     if (vm) {
-        if (ret == -1) {
+        if (ret == -1)
             ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_FORCE));
-        }
         if (virObjectUnref(vm))
             virObjectUnlock(vm);
     }
@@ -1830,9 +1829,8 @@ qemuProcessExtractTTYPath(const char *haystack,

     VIR_FREE(*path);
     /* First look for our magic string */
-    if (!(tmp = strstr(haystack + *offset, needle))) {
+    if (!(tmp = strstr(haystack + *offset, needle)))
         return 1;
-    }
     tmp += sizeof(needle);
     dev = tmp;

@@ -3470,9 +3468,8 @@ qemuProcessReconnect(void *opaque)
         priv->agentError = true;
     }

-    if (qemuUpdateActivePCIHostdevs(driver, obj->def) < 0) {
+    if (qemuUpdateActivePCIHostdevs(driver, obj->def) < 0)
         goto error;
-    }

     if (qemuUpdateActiveUSBHostdevs(driver, obj->def) < 0)
         goto error;
@@ -4511,9 +4508,8 @@ int qemuProcessStart(virConnectPtr conn,
     }

     VIR_DEBUG("Writing early domain status to disk");
-    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) {
+    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
         goto cleanup;
-    }

     VIR_DEBUG("Waiting for handshake from child");
     if (virCommandHandshakeWait(cmd) < 0) {
@@ -4562,9 +4558,8 @@ int qemuProcessStart(virConnectPtr conn,
     }

     VIR_DEBUG("Labelling done, completing handshake to child");
-    if (virCommandHandshakeNotify(cmd) < 0) {
+    if (virCommandHandshakeNotify(cmd) < 0)
         goto cleanup;
-    }
     VIR_DEBUG("Handshake complete, child running");

     if (migrateFrom)
@@ -4929,9 +4924,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,

     /* Clear out dynamically assigned labels */
     for (i = 0; i < vm->def->nseclabels; i++) {
-        if (vm->def->seclabels[i]->type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
+        if (vm->def->seclabels[i]->type == VIR_DOMAIN_SECLABEL_DYNAMIC)
             VIR_FREE(vm->def->seclabels[i]->label);
-        }
         VIR_FREE(vm->def->seclabels[i]->imagelabel);
     }

-- 
2.1.3

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

Reply via email to