Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/access/viraccessdriverstack.c | 3 +--
src/bhyve/bhyve_driver.c | 3 +--
src/datatypes.c | 6 ++----
src/driver.c | 3 +--
src/interface/interface_backend_udev.c | 12 ++++--------
src/libvirt-lxc.c | 3 +--
src/libvirt-nodedev.c | 3 +--
src/libvirt-storage.c | 6 ++----
src/libxl/libxl_driver.c | 12 ++++--------
src/locking/lock_daemon.c | 3 +--
src/locking/lock_driver_sanlock.c | 6 ++----
src/lxc/lxc_container.c | 9 +++------
src/lxc/lxc_driver.c | 9 +++------
src/lxc/lxc_process.c | 6 ++----
src/network/bridge_driver.c | 6 ++----
src/network/bridge_driver_linux.c | 3 +--
src/nwfilter/nwfilter_dhcpsnoop.c | 3 +--
src/nwfilter/nwfilter_ebiptables_driver.c | 12 ++++--------
src/nwfilter/nwfilter_gentech_driver.c | 9 +++------
src/nwfilter/nwfilter_learnipaddr.c | 3 +--
20 files changed, 40 insertions(+), 80 deletions(-)
diff --git a/src/access/viraccessdriverstack.c b/src/access/viraccessdriverstack.c
index 11ed4f6..b43a743 100644
--- a/src/access/viraccessdriverstack.c
+++ b/src/access/viraccessdriverstack.c
@@ -54,9 +54,8 @@ static void virAccessDriverStackCleanup(virAccessManagerPtr manager)
virAccessDriverStackPrivatePtr priv = virAccessManagerGetPrivateData(manager);
size_t i;
- for (i = 0; i < priv->managersLen; i++) {
+ for (i = 0; i < priv->managersLen; i++)
virObjectUnref(priv->managers[i]);
- }
VIR_FREE(priv->managers);
}
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 331f310..664e631 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -1154,9 +1154,8 @@ bhyveStateInitialize(bool priveleged,
return 0;
}
- if (VIR_ALLOC(bhyve_driver) < 0) {
+ if (VIR_ALLOC(bhyve_driver) < 0)
return -1;
- }
if (virMutexInit(&bhyve_driver->lock) < 0) {
VIR_FREE(bhyve_driver);
diff --git a/src/datatypes.c b/src/datatypes.c
index 87e3550..b4f6765 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -450,9 +450,8 @@ virStoragePoolDispose(void *obj)
virUUIDFormat(pool->uuid, uuidstr);
VIR_DEBUG("release pool %p %s %s", pool, pool->name, uuidstr);
- if (pool->privateDataFreeFunc) {
+ if (pool->privateDataFreeFunc)
pool->privateDataFreeFunc(pool->privateData);
- }
VIR_FREE(pool->name);
virObjectUnref(pool->conn);
@@ -525,9 +524,8 @@ virStorageVolDispose(void *obj)
virStorageVolPtr vol = obj;
VIR_DEBUG("release vol %p %s", vol, vol->name);
- if (vol->privateDataFreeFunc) {
+ if (vol->privateDataFreeFunc)
vol->privateDataFreeFunc(vol->privateData);
- }
VIR_FREE(vol->key);
VIR_FREE(vol->name);
diff --git a/src/driver.c b/src/driver.c
index 71569e6..1be32ef 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -85,9 +85,8 @@ virDriverLoadModule(const char *name)
*tmp = c_toupper(*tmp);
}
- if (virAsprintfQuiet(®func, "%sRegister", fixedname) < 0) {
+ if (virAsprintfQuiet(®func, "%sRegister", fixedname) < 0)
goto cleanup;
- }
regsym = dlsym(handle, regfunc);
if (!regsym) {
diff --git a/src/interface/interface_backend_udev.c
b/src/interface/interface_backend_udev.c
index 1dbbfe7..e9fd941 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -845,9 +845,8 @@ udevGetIfaceDefBond(struct udev *udev,
return 0;
error:
- for (i = 0; slave_count != -1 && i < slave_count; i++) {
+ for (i = 0; slave_count != -1 && i < slave_count; i++)
VIR_FREE(slave_list[i]);
- }
VIR_FREE(slave_list);
return -1;
@@ -952,9 +951,8 @@ udevGetIfaceDefBridge(struct udev *udev,
return 0;
error:
- for (i = 0; member_count != -1 && i < member_count; i++) {
+ for (i = 0; member_count != -1 && i < member_count; i++)
VIR_FREE(member_list[i]);
- }
VIR_FREE(member_list);
return -1;
@@ -1102,14 +1100,12 @@ udevGetIfaceDef(struct udev *udev, const char *name)
* to prevent false positives
*/
vlan_parent_dev = strrchr(name, '.');
- if (vlan_parent_dev) {
+ if (vlan_parent_dev)
ifacedef->type = VIR_INTERFACE_TYPE_VLAN;
- }
/* Fallback check to see if this is a bond device */
- if (udev_device_get_sysattr_value(dev, "bonding/mode")) {
+ if (udev_device_get_sysattr_value(dev, "bonding/mode"))
ifacedef->type = VIR_INTERFACE_TYPE_BOND;
- }
}
switch (ifacedef->type) {
diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c
index 58892df..8553570 100644
--- a/src/libvirt-lxc.c
+++ b/src/libvirt-lxc.c
@@ -145,9 +145,8 @@ virDomainLxcEnterNamespace(virDomainPtr domain,
if (virProcessSetNamespaces(nfdlist, fdlist) < 0) {
if (oldfdlist && noldfdlist) {
- for (i = 0; i < *noldfdlist; i++) {
+ for (i = 0; i < *noldfdlist; i++)
VIR_FORCE_CLOSE((*oldfdlist)[i]);
- }
VIR_FREE(*oldfdlist);
*noldfdlist = 0;
}
diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c
index c19aeef..b6c6d1e 100644
--- a/src/libvirt-nodedev.c
+++ b/src/libvirt-nodedev.c
@@ -741,9 +741,8 @@ virNodeDeviceDestroy(virNodeDevicePtr dev)
if (dev->conn->nodeDeviceDriver &&
dev->conn->nodeDeviceDriver->nodeDeviceDestroy) {
int retval = dev->conn->nodeDeviceDriver->nodeDeviceDestroy(dev);
- if (retval < 0) {
+ if (retval < 0)
goto error;
- }
return 0;
}
diff --git a/src/libvirt-storage.c b/src/libvirt-storage.c
index 190c718..54c7332 100644
--- a/src/libvirt-storage.c
+++ b/src/libvirt-storage.c
@@ -1746,9 +1746,8 @@ virStorageVolWipe(virStorageVolPtr vol,
if (conn->storageDriver && conn->storageDriver->storageVolWipe) {
int ret;
ret = conn->storageDriver->storageVolWipe(vol, flags);
- if (ret < 0) {
+ if (ret < 0)
goto error;
- }
return ret;
}
@@ -1789,9 +1788,8 @@ virStorageVolWipePattern(virStorageVolPtr vol,
if (conn->storageDriver &&
conn->storageDriver->storageVolWipePattern) {
int ret;
ret = conn->storageDriver->storageVolWipePattern(vol, algorithm, flags);
- if (ret < 0) {
+ if (ret < 0)
goto error;
- }
return ret;
}
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index d2c077c..8cbf3c0 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -246,9 +246,8 @@ libxlDriverShouldLoad(bool privileged)
* xenfs to /proc/xen.
*/
status = virFileReadAll(HYPERVISOR_CAPABILITIES, 10, &output);
- if (status >= 0) {
+ if (status >= 0)
status = strncmp(output, "control_d", 9);
- }
VIR_FREE(output);
if (status) {
VIR_INFO("No Xen capabilities detected, probably not running "
@@ -1792,9 +1791,8 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
goto endjob;
}
- if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM) && vm->def->maxvcpus <
max) {
+ if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM) && vm->def->maxvcpus <
max)
max = vm->def->maxvcpus;
- }
if (nvcpus > max) {
virReportError(VIR_ERR_INVALID_ARG,
@@ -1964,9 +1962,8 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu,
&flags, &targetDef) < 0)
goto endjob;
- if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ if (flags & VIR_DOMAIN_AFFECT_LIVE)
targetDef = vm->def;
- }
/* Make sure coverity knows targetDef is valid at this point. */
sa_assert(targetDef);
@@ -2066,9 +2063,8 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int ncpumaps,
&flags, &targetDef) < 0)
goto cleanup;
- if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ if (flags & VIR_DOMAIN_AFFECT_LIVE)
targetDef = vm->def;
- }
/* Make sure coverity knows targetDef is valid at this point. */
sa_assert(targetDef);
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 75244e8..8cc6979 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -1160,9 +1160,8 @@ int main(int argc, char **argv) {
c = getopt_long(argc, argv, "ldf:p:t:vVh", opts, &optidx);
- if (c == -1) {
+ if (c == -1)
break;
- }
switch (c) {
case 0:
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index 0318f25..d84a419 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -1008,9 +1008,8 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
VIR_DEBUG("Acquire completed fd=%d", sock);
if (res_free) {
- for (i = 0; i < res_count; i++) {
+ for (i = 0; i < res_count; i++)
VIR_FREE(res_args[i]);
- }
VIR_FREE(res_args);
}
@@ -1021,9 +1020,8 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
error:
if (res_free) {
- for (i = 0; i < res_count; i++) {
+ for (i = 0; i < res_count; i++)
VIR_FREE(res_args[i]);
- }
VIR_FREE(res_args);
}
VIR_FREE(opt);
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 8aba3ba..db823d6 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -396,9 +396,8 @@ int lxcContainerSendContinue(int control)
VIR_DEBUG("Send continue on fd %d", control);
writeCount = safewrite(control, &msg, sizeof(msg));
- if (writeCount != sizeof(msg)) {
+ if (writeCount != sizeof(msg))
goto error_out;
- }
rc = 0;
error_out:
@@ -858,14 +857,12 @@ static int lxcContainerMountBasicFS(bool userns_enabled,
*/
if (userns_enabled && netns_disabled &&
STREQ(mnt->src, "sysfs")) {
- if (VIR_STRDUP(mnt_src, "/sys") < 0) {
+ if (VIR_STRDUP(mnt_src, "/sys") < 0)
goto cleanup;
- }
mnt_mflags = MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY|MS_BIND;
} else {
- if (VIR_STRDUP(mnt_src, mnt->src) < 0) {
+ if (VIR_STRDUP(mnt_src, mnt->src) < 0)
goto cleanup;
- }
mnt_mflags = mnt->mflags;
}
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index da94cd4..cf2a3c8 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1586,9 +1586,8 @@ static int lxcStateInitialize(bool privileged,
return 0;
}
- if (VIR_ALLOC(lxc_driver) < 0) {
+ if (VIR_ALLOC(lxc_driver) < 0)
return -1;
- }
if (virMutexInit(&lxc_driver->lock) < 0) {
VIR_FREE(lxc_driver);
return -1;
@@ -1972,9 +1971,8 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
vm->def->cputune.period = params[i].value.ul;
}
- if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG)
vmdef->cputune.period = params[i].value.ul;
- }
} else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_QUOTA)) {
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
rc = lxcSetVcpuBWLive(priv->cgroup, 0, params[i].value.l);
@@ -1985,9 +1983,8 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
vm->def->cputune.quota = params[i].value.l;
}
- if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG)
vmdef->cputune.quota = params[i].value.l;
- }
}
}
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 6c83fdb..37ddbbc 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -536,9 +536,8 @@ static void virLXCProcessMonitorEOFNotify(virLXCMonitorPtr mon,
if (vm)
virObjectUnlock(vm);
- if (event) {
+ if (event)
virObjectEventStateQueue(driver->domainEventState, event);
- }
}
static void virLXCProcessMonitorExitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED,
@@ -826,9 +825,8 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
virCommandAddArgFormat(cmd, "%d", handshakefd);
virCommandAddArg(cmd, "--background");
- for (i = 0; i < nveths; i++) {
+ for (i = 0; i < nveths; i++)
virCommandAddArgList(cmd, "--veth", veths[i], NULL);
- }
virCommandPassFD(cmd, handshakefd, 0);
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 12c3b50..6cb421c 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1340,9 +1340,8 @@ networkStartDhcpDaemon(virNetworkObjPtr network)
goto cleanup;
ret = virCommandRun(cmd, NULL);
- if (ret < 0) {
+ if (ret < 0)
goto cleanup;
- }
/*
* There really is no race here - when dnsmasq daemonizes, its
@@ -2016,9 +2015,8 @@ networkStartNetworkVirtual(virNetworkObjPtr network)
v6present = true;
/* Add the IP address/netmask to the bridge */
- if (networkAddAddrToBridge(network, ipdef) < 0) {
+ if (networkAddAddrToBridge(network, ipdef) < 0)
goto err2;
- }
}
/* Bring up the bridge interface */
diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c
index 6b32838..aa2ad10 100644
--- a/src/network/bridge_driver_linux.c
+++ b/src/network/bridge_driver_linux.c
@@ -74,9 +74,8 @@ int networkCheckRouteCollision(virNetworkDefPtr def)
/* NUL-terminate the line, so sscanf doesn't go beyond a newline. */
char *nl = strchr(cur, '\n');
- if (nl) {
+ if (nl)
*nl++ = '\0';
- }
num = sscanf(cur, "%16s %127s %*s %*s %*s %*s %*s %127s",
iface, dest, mask);
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index a2f58ba..6da8983 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -315,9 +315,8 @@ virNWFilterSnoopActivate(virNWFilterSnoopReqPtr req)
virNWFilterSnoopActiveLock();
- if (virHashAddEntry(virNWFilterSnoopState.active, key, (void *)0x1) < 0) {
+ if (virHashAddEntry(virNWFilterSnoopState.active, key, (void *)0x1) < 0)
VIR_FREE(key);
- }
virNWFilterSnoopActiveUnlock();
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c
b/src/nwfilter/nwfilter_ebiptables_driver.c
index 2b89439..377b59b 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -3084,14 +3084,12 @@ virNWFilterRuleInstSort(const void *a, const void *b)
/* ensure root chain commands appear before all others since
we will need them to create the child chains */
if (root_a) {
- if (root_b) {
+ if (root_b)
goto normal;
- }
return -1; /* a before b */
}
- if (root_b) {
+ if (root_b)
return 1; /* b before a */
- }
normal:
/* priorities are limited to range [-1000, 1000] */
return insta->priority - instb->priority;
@@ -3165,9 +3163,8 @@ ebtablesGetProtoIdxByFiltername(const char *filtername)
enum l3_proto_idx idx;
for (idx = 0; idx < L3_PROTO_LAST_IDX; idx++) {
- if (STRPREFIX(filtername, l3_protocols[idx].val)) {
+ if (STRPREFIX(filtername, l3_protocols[idx].val))
return idx;
- }
}
return -1;
@@ -3303,9 +3300,8 @@ ebtablesGetSubChainInsts(virHashTablePtr chains,
cleanup:
VIR_FREE(filter_names);
if (ret < 0) {
- for (i = 0; i < *ninsts; i++) {
+ for (i = 0; i < *ninsts; i++)
VIR_FREE(*insts[i]);
- }
VIR_FREE(*insts);
*ninsts = 0;
}
diff --git a/src/nwfilter/nwfilter_gentech_driver.c
b/src/nwfilter/nwfilter_gentech_driver.c
index 79fc422..701f8d8 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -567,9 +567,8 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
switch (useNewFilter) {
case INSTANTIATE_FOLLOW_NEWFILTER:
- if (obj->newDef) {
+ if (obj->newDef)
next_filter = obj->newDef;
- }
break;
case INSTANTIATE_ALWAYS:
break;
@@ -1139,15 +1138,13 @@ virNWFilterDomainFWUpdateCB(virDomainObjPtr obj,
break;
case STEP_TEAR_NEW:
- if (!virHashLookup(cb->skipInterfaces, net->ifname)) {
+ if (!virHashLookup(cb->skipInterfaces, net->ifname))
ret = virNWFilterRollbackUpdateFilter(net);
- }
break;
case STEP_TEAR_OLD:
- if (!virHashLookup(cb->skipInterfaces, net->ifname)) {
+ if (!virHashLookup(cb->skipInterfaces, net->ifname))
ret = virNWFilterTearOldFilter(net);
- }
break;
case STEP_APPLY_CURRENT:
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index 911079e..1b875c3 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -797,9 +797,8 @@ virNWFilterLearnInit(void)
threadsTerminate = false;
pendingLearnReq = virHashCreate(0, freeLearnReqEntry);
- if (!pendingLearnReq) {
+ if (!pendingLearnReq)
return -1;
- }
ifaceLockMap = virHashCreate(0, virHashValueFree);
if (!ifaceLockMap) {
--
2.1.3