In few places we have the following code pattern:
int ret;
... /* @ret is not accessed here */
ret = f(...);
return ret;
This pattern can be written less verbose:
...
return f(...);
This patch was generated with following coccinelle spatch:
@@
type T;
constant C;
expression f;
identifier ret;
@@
-T ret = C;
... when != ret
-ret = f;
-return ret;
+return f;
Afterwards I needed to fix a few places, e.g. comment in
virDomainNetIPParseXML() was removed too because coccinelle
thinks it refers to @ret while in fact it doesn't. Also in few
places it replaced @ret declaration with a few spaces instead of
removing the line. But nothing terribly wrong.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/bhyve/bhyve_driver.c | 38 +++++++++---------------
src/conf/checkpoint_conf.c | 5 +---
src/conf/domain_conf.c | 4 +--
src/conf/snapshot_conf.c | 5 +---
src/conf/storage_conf.c | 9 ++----
src/conf/virnwfilterbindingobj.c | 5 +---
src/libvirt-stream.c | 7 ++---
src/libxl/libxl_driver.c | 36 ++++++++---------------
src/lxc/lxc_driver.c | 36 ++++++++---------------
src/lxc/lxc_native.c | 5 +---
src/network/bridge_driver.c | 38 +++++++-----------------
src/nwfilter/nwfilter_driver.c | 10 ++-----
src/phyp/phyp_driver.c | 5 +---
src/qemu/qemu_command.c | 14 ++++-----
src/qemu/qemu_driver.c | 14 +++------
src/qemu/qemu_process.c | 16 ++++------
src/remote/remote_daemon_dispatch.c | 5 +---
src/storage/storage_backend_iscsi.c | 5 +---
src/test/test_driver.c | 28 +++++-------------
src/util/vircgroupv1.c | 6 +---
src/util/vircgroupv2.c | 6 +---
src/util/virdbus.c | 5 +---
src/vbox/vbox_storage.c | 18 ++++--------
src/vz/vz_driver.c | 45 ++++++++++-------------------
tools/virsh-completer-domain.c | 4 +--
tools/virsh-completer-nodedev.c | 4 +--
tools/virsh-completer-pool.c | 4 +--
tools/virsh-completer-secret.c | 4 +--
tools/virsh-network.c | 5 +---
tools/vsh.c | 5 +---
30 files changed, 115 insertions(+), 276 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 52e1895052..2e4f03d841 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -630,30 +630,24 @@ static int
bhyveConnectListDomains(virConnectPtr conn, int *ids, int maxids)
{
bhyveConnPtr privconn = conn->privateData;
- int n;
if (virConnectListDomainsEnsureACL(conn) < 0)
return -1;
- n = virDomainObjListGetActiveIDs(privconn->domains, ids, maxids,
- virConnectListDomainsCheckACL, conn);
-
- return n;
+ return virDomainObjListGetActiveIDs(privconn->domains, ids, maxids,
+ virConnectListDomainsCheckACL, conn);
}
static int
bhyveConnectNumOfDomains(virConnectPtr conn)
{
bhyveConnPtr privconn = conn->privateData;
- int count;
if (virConnectNumOfDomainsEnsureACL(conn) < 0)
return -1;
- count = virDomainObjListNumOfDomains(privconn->domains, true,
- virConnectNumOfDomainsCheckACL, conn);
-
- return count;
+ return virDomainObjListNumOfDomains(privconn->domains, true,
+ virConnectNumOfDomainsCheckACL, conn);
}
static int
@@ -661,31 +655,28 @@ bhyveConnectListDefinedDomains(virConnectPtr conn, char **const
names,
int maxnames)
{
bhyveConnPtr privconn = conn->privateData;
- int n;
if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
return -1;
memset(names, 0, sizeof(*names) * maxnames);
- n = virDomainObjListGetInactiveNames(privconn->domains, names,
- maxnames, virConnectListDefinedDomainsCheckACL,
conn);
-
- return n;
+ return virDomainObjListGetInactiveNames(privconn->domains, names,
+ maxnames,
+ virConnectListDefinedDomainsCheckACL,
+ conn);
}
static int
bhyveConnectNumOfDefinedDomains(virConnectPtr conn)
{
bhyveConnPtr privconn = conn->privateData;
- int count;
if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
return -1;
- count = virDomainObjListNumOfDomains(privconn->domains, false,
- virConnectNumOfDefinedDomainsCheckACL, conn);
-
- return count;
+ return virDomainObjListNumOfDomains(privconn->domains, false,
+ virConnectNumOfDefinedDomainsCheckACL,
+ conn);
}
static char *
@@ -771,17 +762,14 @@ bhyveConnectListAllDomains(virConnectPtr conn,
unsigned int flags)
{
bhyveConnPtr privconn = conn->privateData;
- int ret = -1;
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
if (virConnectListAllDomainsEnsureACL(conn) < 0)
return -1;
- ret = virDomainObjListExport(privconn->domains, conn, domains,
- virConnectListAllDomainsCheckACL, flags);
-
- return ret;
+ return virDomainObjListExport(privconn->domains, conn, domains,
+ virConnectListAllDomainsCheckACL, flags);
}
static virDomainPtr
diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c
index b254dce7fd..586528a974 100644
--- a/src/conf/checkpoint_conf.c
+++ b/src/conf/checkpoint_conf.c
@@ -73,13 +73,10 @@ virDomainCheckpointDiskDefClear(virDomainCheckpointDiskDefPtr disk)
virDomainCheckpointDefPtr
virDomainCheckpointDefNew(void)
{
- virDomainCheckpointDefPtr def;
-
if (virDomainCheckpointInitialize() < 0)
return NULL;
- def = virObjectNew(virDomainCheckpointDefClass);
- return def;
+ return virObjectNew(virDomainCheckpointDefClass);
}
static void
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2e6a113de3..d1c2ad5484 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8306,7 +8306,6 @@ static virNetDevIPAddrPtr
virDomainNetIPParseXML(xmlNodePtr node)
{
/* Parse the prefix in every case */
- virNetDevIPAddrPtr ret = NULL;
unsigned int prefixValue = 0;
int family = AF_UNSPEC;
g_autofree virNetDevIPAddrPtr ip = NULL;
@@ -8358,8 +8357,7 @@ virDomainNetIPParseXML(xmlNodePtr node)
return NULL;
}
- ret = g_steal_pointer(&ip);
- return ret;
+ return g_steal_pointer(&ip);
}
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 0e9d307321..1992cc1b08 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -113,13 +113,10 @@ virDomainSnapshotDiskDefFree(virDomainSnapshotDiskDefPtr disk)
virDomainSnapshotDefPtr
virDomainSnapshotDefNew(void)
{
- virDomainSnapshotDefPtr def;
-
if (virDomainSnapshotInitialize() < 0)
return NULL;
- def = virObjectNew(virDomainSnapshotDefClass);
- return def;
+ return virObjectNew(virDomainSnapshotDefClass);
}
static void
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 9e4978b560..c115729ec7 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1692,14 +1692,11 @@ virStoragePoolSaveXML(const char *path,
const char *xml)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
- int ret = -1;
virUUIDFormat(def->uuid, uuidstr);
- ret = virXMLSaveFile(path,
- virXMLPickShellSafeComment(def->name, uuidstr),
- "pool-edit", xml);
-
- return ret;
+ return virXMLSaveFile(path,
+ virXMLPickShellSafeComment(def->name, uuidstr),
+ "pool-edit", xml);
}
diff --git a/src/conf/virnwfilterbindingobj.c b/src/conf/virnwfilterbindingobj.c
index 48d53fafb1..24aafa99c3 100644
--- a/src/conf/virnwfilterbindingobj.c
+++ b/src/conf/virnwfilterbindingobj.c
@@ -91,10 +91,7 @@ virNWFilterBindingObjSetDef(virNWFilterBindingObjPtr obj,
virNWFilterBindingDefPtr
virNWFilterBindingObjStealDef(virNWFilterBindingObjPtr obj)
{
- virNWFilterBindingDefPtr def;
-
- def = g_steal_pointer(&obj->def);
- return def;
+ return g_steal_pointer(&obj->def);
}
diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c
index fb646d0aef..6f6bb5df0b 100644
--- a/src/libvirt-stream.c
+++ b/src/libvirt-stream.c
@@ -520,11 +520,8 @@ virStreamInData(virStreamPtr stream,
virCheckNonNullArgReturn(data, -1);
virCheckNonNullArgReturn(length, -1);
- if (stream->driver->streamInData) {
- int ret;
- ret = (stream->driver->streamInData)(stream, data, length);
- return ret;
- }
+ if (stream->driver->streamInData)
+ return (stream->driver->streamInData)(stream, data, length);
virReportUnsupportedError();
return -1;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 64b21f2073..a1c752c25b 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1009,30 +1009,24 @@ static int
libxlConnectListDomains(virConnectPtr conn, int *ids, int nids)
{
libxlDriverPrivatePtr driver = conn->privateData;
- int n;
if (virConnectListDomainsEnsureACL(conn) < 0)
return -1;
- n = virDomainObjListGetActiveIDs(driver->domains, ids, nids,
- virConnectListDomainsCheckACL, conn);
-
- return n;
+ return virDomainObjListGetActiveIDs(driver->domains, ids, nids,
+ virConnectListDomainsCheckACL, conn);
}
static int
libxlConnectNumOfDomains(virConnectPtr conn)
{
libxlDriverPrivatePtr driver = conn->privateData;
- int n;
if (virConnectNumOfDomainsEnsureACL(conn) < 0)
return -1;
- n = virDomainObjListNumOfDomains(driver->domains, true,
- virConnectNumOfDomainsCheckACL, conn);
-
- return n;
+ return virDomainObjListNumOfDomains(driver->domains, true,
+ virConnectNumOfDomainsCheckACL, conn);
}
static virDomainPtr
@@ -2777,29 +2771,26 @@ libxlConnectListDefinedDomains(virConnectPtr conn,
char **const names, int nnames)
{
libxlDriverPrivatePtr driver = conn->privateData;
- int n;
if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
return -1;
- n = virDomainObjListGetInactiveNames(driver->domains, names, nnames,
- virConnectListDefinedDomainsCheckACL, conn);
- return n;
+ return virDomainObjListGetInactiveNames(driver->domains, names, nnames,
+ virConnectListDefinedDomainsCheckACL,
+ conn);
}
static int
libxlConnectNumOfDefinedDomains(virConnectPtr conn)
{
libxlDriverPrivatePtr driver = conn->privateData;
- int n;
if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
return -1;
- n = virDomainObjListNumOfDomains(driver->domains, false,
- virConnectNumOfDefinedDomainsCheckACL,
- conn);
- return n;
+ return virDomainObjListNumOfDomains(driver->domains, false,
+ virConnectNumOfDefinedDomainsCheckACL,
+ conn);
}
static int
@@ -5717,17 +5708,14 @@ libxlConnectListAllDomains(virConnectPtr conn,
unsigned int flags)
{
libxlDriverPrivatePtr driver = conn->privateData;
- int ret = -1;
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
if (virConnectListAllDomainsEnsureACL(conn) < 0)
return -1;
- ret = virDomainObjListExport(driver->domains, conn, domains,
- virConnectListAllDomainsCheckACL, flags);
-
- return ret;
+ return virDomainObjListExport(driver->domains, conn, domains,
+ virConnectListAllDomainsCheckACL, flags);
}
/* Which features are supported by this driver? */
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 204a3ed522..4edbe6e299 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -347,59 +347,49 @@ static int lxcDomainIsUpdated(virDomainPtr dom)
static int lxcConnectListDomains(virConnectPtr conn, int *ids, int nids)
{
virLXCDriverPtr driver = conn->privateData;
- int n;
if (virConnectListDomainsEnsureACL(conn) < 0)
return -1;
- n = virDomainObjListGetActiveIDs(driver->domains, ids, nids,
- virConnectListDomainsCheckACL, conn);
-
- return n;
+ return virDomainObjListGetActiveIDs(driver->domains, ids, nids,
+ virConnectListDomainsCheckACL, conn);
}
static int lxcConnectNumOfDomains(virConnectPtr conn)
{
virLXCDriverPtr driver = conn->privateData;
- int n;
if (virConnectNumOfDomainsEnsureACL(conn) < 0)
return -1;
- n = virDomainObjListNumOfDomains(driver->domains, true,
- virConnectNumOfDomainsCheckACL, conn);
-
- return n;
+ return virDomainObjListNumOfDomains(driver->domains, true,
+ virConnectNumOfDomainsCheckACL, conn);
}
static int lxcConnectListDefinedDomains(virConnectPtr conn,
char **const names, int nnames)
{
virLXCDriverPtr driver = conn->privateData;
- int n;
if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
return -1;
- n = virDomainObjListGetInactiveNames(driver->domains, names, nnames,
- virConnectListDefinedDomainsCheckACL, conn);
-
- return n;
+ return virDomainObjListGetInactiveNames(driver->domains, names, nnames,
+ virConnectListDefinedDomainsCheckACL,
+ conn);
}
static int lxcConnectNumOfDefinedDomains(virConnectPtr conn)
{
virLXCDriverPtr driver = conn->privateData;
- int n;
if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
return -1;
- n = virDomainObjListNumOfDomains(driver->domains, false,
- virConnectNumOfDefinedDomainsCheckACL, conn);
-
- return n;
+ return virDomainObjListNumOfDomains(driver->domains, false,
+ virConnectNumOfDefinedDomainsCheckACL,
+ conn);
}
@@ -3254,16 +3244,14 @@ lxcConnectListAllDomains(virConnectPtr conn,
unsigned int flags)
{
virLXCDriverPtr driver = conn->privateData;
- int ret = -1;
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
if (virConnectListAllDomainsEnsureACL(conn) < 0)
return -1;
- ret = virDomainObjListExport(driver->domains, conn, domains,
- virConnectListAllDomainsCheckACL, flags);
- return ret;
+ return virDomainObjListExport(driver->domains, conn, domains,
+ virConnectListAllDomainsCheckACL, flags);
}
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 8ae3c7b006..3ac5e34ee1 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -718,7 +718,6 @@ static int
lxcConvertNetworkSettings(virDomainDefPtr def, virConfPtr properties)
{
int status;
- int result = -1;
size_t i;
lxcNetworkParseData data = {def, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, 0,
@@ -742,9 +741,7 @@ lxcConvertNetworkSettings(virDomainDefPtr def, virConfPtr properties)
/* When no network type is provided LXC only adds loopback */
def->features[VIR_DOMAIN_FEATURE_PRIVNET] = VIR_TRISTATE_SWITCH_ON;
}
- result = 0;
-
- return result;
+ return 0;
error:
for (i = 0; i < data.nips; i++)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 6862818698..e6881965c1 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -3136,17 +3136,13 @@ static int
networkConnectNumOfNetworks(virConnectPtr conn)
{
virNetworkDriverStatePtr driver = networkGetDriver();
- int nactive;
if (virConnectNumOfNetworksEnsureACL(conn) < 0)
return -1;
- nactive = virNetworkObjListNumOfNetworks(driver->networks,
- true,
- virConnectNumOfNetworksCheckACL,
- conn);
-
- return nactive;
+ return virNetworkObjListNumOfNetworks(driver->networks, true,
+ virConnectNumOfNetworksCheckACL,
+ conn);
}
@@ -3156,17 +3152,12 @@ networkConnectListNetworks(virConnectPtr conn,
int maxnames)
{
virNetworkDriverStatePtr driver = networkGetDriver();
- int got = 0;
if (virConnectListNetworksEnsureACL(conn) < 0)
return -1;
- got = virNetworkObjListGetNames(driver->networks,
- true, names, maxnames,
- virConnectListNetworksCheckACL,
- conn);
-
- return got;
+ return virNetworkObjListGetNames(driver->networks, true, names, maxnames,
+ virConnectListNetworksCheckACL, conn);
}
@@ -3174,17 +3165,13 @@ static int
networkConnectNumOfDefinedNetworks(virConnectPtr conn)
{
virNetworkDriverStatePtr driver = networkGetDriver();
- int ninactive = 0;
if (virConnectNumOfDefinedNetworksEnsureACL(conn) < 0)
return -1;
- ninactive = virNetworkObjListNumOfNetworks(driver->networks,
- false,
- virConnectNumOfDefinedNetworksCheckACL,
- conn);
-
- return ninactive;
+ return virNetworkObjListNumOfNetworks(driver->networks, false,
+ virConnectNumOfDefinedNetworksCheckACL,
+ conn);
}
@@ -3194,16 +3181,13 @@ networkConnectListDefinedNetworks(virConnectPtr conn,
int maxnames)
{
virNetworkDriverStatePtr driver = networkGetDriver();
- int got = 0;
if (virConnectListDefinedNetworksEnsureACL(conn) < 0)
return -1;
- got = virNetworkObjListGetNames(driver->networks,
- false, names, maxnames,
- virConnectListDefinedNetworksCheckACL,
- conn);
- return got;
+ return virNetworkObjListGetNames(driver->networks, false, names, maxnames,
+ virConnectListDefinedNetworksCheckACL,
+ conn);
}
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index fbdf250934..2e906555b9 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -707,19 +707,13 @@ nwfilterConnectListAllNWFilterBindings(virConnectPtr conn,
virNWFilterBindingPtr **bindings,
unsigned int flags)
{
- int ret;
-
virCheckFlags(0, -1);
if (virConnectListAllNWFilterBindingsEnsureACL(conn) < 0)
return -1;
- ret = virNWFilterBindingObjListExport(driver->bindings,
- conn,
- bindings,
- virConnectListAllNWFilterBindingsCheckACL);
-
- return ret;
+ return virNWFilterBindingObjListExport(driver->bindings, conn, bindings,
+ virConnectListAllNWFilterBindingsCheckACL);
}
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 4527adc670..67193d6359 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3174,7 +3174,6 @@ phypDomainLookupByName(virConnectPtr conn, const char *lpar_name)
{
phyp_driverPtr phyp_driver = conn->privateData;
LIBSSH2_SESSION *session = phyp_driver->session;
- virDomainPtr dom = NULL;
int lpar_id = 0;
char *managed_system = phyp_driver->managed_system;
unsigned char lpar_uuid[VIR_UUID_BUFLEN];
@@ -3186,9 +3185,7 @@ phypDomainLookupByName(virConnectPtr conn, const char *lpar_name)
if (phypGetLparUUID(lpar_uuid, lpar_id, conn) == -1)
return NULL;
- dom = virGetDomain(conn, lpar_name, lpar_uuid, lpar_id);
-
- return dom;
+ return virGetDomain(conn, lpar_name, lpar_uuid, lpar_id);
}
static virDomainPtr
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e98195b1d7..6886a07154 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -697,20 +697,16 @@ int
qemuBuildSecretInfoProps(qemuDomainSecretInfoPtr secinfo,
virJSONValuePtr *propsret)
{
- int ret = -1;
g_autofree char *keyid = NULL;
if (!(keyid = qemuDomainGetMasterKeyAlias()))
return -1;
- ret = qemuMonitorCreateObjectProps(propsret,
- "secret", secinfo->s.aes.alias,
- "s:data", secinfo->s.aes.ciphertext,
- "s:keyid", keyid,
- "s:iv", secinfo->s.aes.iv,
- "s:format", "base64", NULL);
-
- return ret;
+ return qemuMonitorCreateObjectProps(propsret, "secret",
+ secinfo->s.aes.alias, "s:data",
+ secinfo->s.aes.ciphertext,
"s:keyid",
+ keyid, "s:iv", secinfo->s.aes.iv,
+ "s:format", "base64", NULL);
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index cafd5c0fc7..f93f987833 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1761,29 +1761,23 @@ static char *qemuConnectGetHostname(virConnectPtr conn)
static int qemuConnectListDomains(virConnectPtr conn, int *ids, int nids)
{
virQEMUDriverPtr driver = conn->privateData;
- int n;
if (virConnectListDomainsEnsureACL(conn) < 0)
return -1;
- n = virDomainObjListGetActiveIDs(driver->domains, ids, nids,
- virConnectListDomainsCheckACL, conn);
-
- return n;
+ return virDomainObjListGetActiveIDs(driver->domains, ids, nids,
+ virConnectListDomainsCheckACL, conn);
}
static int qemuConnectNumOfDomains(virConnectPtr conn)
{
virQEMUDriverPtr driver = conn->privateData;
- int n;
if (virConnectNumOfDomainsEnsureACL(conn) < 0)
return -1;
- n = virDomainObjListNumOfDomains(driver->domains, true,
- virConnectNumOfDomainsCheckACL, conn);
-
- return n;
+ return virDomainObjListNumOfDomains(driver->domains, true,
+ virConnectNumOfDomainsCheckACL, conn);
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index aaca2fc7d6..b10fdc0379 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7316,8 +7316,6 @@ qemuProcessCreatePretendCmd(virQEMUDriverPtr driver,
int
qemuProcessKill(virDomainObjPtr vm, unsigned int flags)
{
- int ret;
-
VIR_DEBUG("vm=%p name=%s pid=%lld flags=0x%x",
vm, vm->def->name,
(long long)vm->pid, flags);
@@ -7338,11 +7336,9 @@ qemuProcessKill(virDomainObjPtr vm, unsigned int flags)
/* Request an extra delay of two seconds per current nhostdevs
* to be safe against stalls by the kernel freeing up the resources */
- ret = virProcessKillPainfullyDelay(vm->pid,
- !!(flags & VIR_QEMU_PROCESS_KILL_FORCE),
- vm->def->nhostdevs * 2);
-
- return ret;
+ return virProcessKillPainfullyDelay(vm->pid,
+ !!(flags & VIR_QEMU_PROCESS_KILL_FORCE),
+ vm->def->nhostdevs * 2);
}
@@ -7764,11 +7760,9 @@ int qemuProcessAutoDestroyAdd(virQEMUDriverPtr driver,
int qemuProcessAutoDestroyRemove(virQEMUDriverPtr driver,
virDomainObjPtr vm)
{
- int ret;
VIR_DEBUG("vm=%s", vm->def->name);
- ret = virCloseCallbacksUnset(driver->closeCallbacks, vm,
- qemuProcessAutoDestroy);
- return ret;
+ return virCloseCallbacksUnset(driver->closeCallbacks, vm,
+ qemuProcessAutoDestroy);
}
bool qemuProcessAutoDestroyActive(virQEMUDriverPtr driver,
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index 56a46a13be..18b2e16a8f 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -7512,10 +7512,7 @@ get_nonnull_storage_pool(virConnectPtr conn,
remote_nonnull_storage_pool pool)
static virStorageVolPtr
get_nonnull_storage_vol(virConnectPtr conn, remote_nonnull_storage_vol vol)
{
- virStorageVolPtr ret;
- ret = virGetStorageVol(conn, vol.pool, vol.name, vol.key,
- NULL, NULL);
- return ret;
+ return virGetStorageVol(conn, vol.pool, vol.name, vol.key, NULL, NULL);
}
static virSecretPtr
diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index b11d1d6622..c754b5958c 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -227,7 +227,6 @@ virStorageBackendISCSICheckPool(virStoragePoolObjPtr pool,
bool *isActive)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
- int ret = -1;
g_autofree char *session = NULL;
*isActive = false;
@@ -253,9 +252,7 @@ virStorageBackendISCSICheckPool(virStoragePoolObjPtr pool,
if ((session = virStorageBackendISCSISession(pool, true)))
*isActive = true;
- ret = 0;
-
- return ret;
+ return 0;
}
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index ab7e5fc02a..f81af5d629 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -5270,11 +5270,8 @@ static int
testConnectNumOfNetworks(virConnectPtr conn)
{
testDriverPtr privconn = conn->privateData;
- int numActive;
-
- numActive = virNetworkObjListNumOfNetworks(privconn->networks,
- true, NULL, conn);
- return numActive;
+ return virNetworkObjListNumOfNetworks(privconn->networks, true, NULL,
+ conn);
}
@@ -5284,11 +5281,8 @@ testConnectListNetworks(virConnectPtr conn,
int maxnames)
{
testDriverPtr privconn = conn->privateData;
- int n;
-
- n = virNetworkObjListGetNames(privconn->networks,
- true, names, maxnames, NULL, conn);
- return n;
+ return virNetworkObjListGetNames(privconn->networks, true, names,
+ maxnames, NULL, conn);
}
@@ -5296,11 +5290,8 @@ static int
testConnectNumOfDefinedNetworks(virConnectPtr conn)
{
testDriverPtr privconn = conn->privateData;
- int numInactive;
-
- numInactive = virNetworkObjListNumOfNetworks(privconn->networks,
- false, NULL, conn);
- return numInactive;
+ return virNetworkObjListNumOfNetworks(privconn->networks, false, NULL,
+ conn);
}
@@ -5310,11 +5301,8 @@ testConnectListDefinedNetworks(virConnectPtr conn,
int maxnames)
{
testDriverPtr privconn = conn->privateData;
- int n;
-
- n = virNetworkObjListGetNames(privconn->networks,
- false, names, maxnames, NULL, conn);
- return n;
+ return virNetworkObjListGetNames(privconn->networks, false, names,
+ maxnames, NULL, conn);
}
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 6ab79a1897..4d09d84274 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -410,11 +410,7 @@ virCgroupV1ValidatePlacement(virCgroupPtr group,
static char *
virCgroupV1StealPlacement(virCgroupPtr group)
{
- char *ret = NULL;
-
- ret =
g_steal_pointer(&group->legacy[VIR_CGROUP_CONTROLLER_SYSTEMD].placement);
-
- return ret;
+ return
g_steal_pointer(&group->legacy[VIR_CGROUP_CONTROLLER_SYSTEMD].placement);
}
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 621ab71eb5..c89158d5d5 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -242,11 +242,7 @@ virCgroupV2ValidatePlacement(virCgroupPtr group,
static char *
virCgroupV2StealPlacement(virCgroupPtr group)
{
- char *ret;
-
- ret = g_steal_pointer(&group->unified.placement);
-
- return ret;
+ return g_steal_pointer(&group->unified.placement);
}
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index f54c917c03..50a6bea05e 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -1178,15 +1178,12 @@ virDBusMessageEncodeArgs(DBusMessage* msg,
va_list args)
{
DBusMessageIter iter;
- int ret = -1;
memset(&iter, 0, sizeof(iter));
dbus_message_iter_init_append(msg, &iter);
- ret = virDBusMessageIterEncode(&iter, types, args);
-
- return ret;
+ return virDBusMessageIterEncode(&iter, types, args);
}
diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c
index ba5b876ffb..3d221fa8d9 100644
--- a/src/vbox/vbox_storage.c
+++ b/src/vbox/vbox_storage.c
@@ -90,10 +90,9 @@ static int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
PRUint32 hardDiskAccessible = 0;
nsresult rc;
size_t i;
- int ret = -1;
if (!data->vboxObj)
- return ret;
+ return -1;
rc = gVBoxAPI.UArray.vboxArrayGet(&hardDisks, data->vboxObj,
gVBoxAPI.UArray.handleGetHardDisks(data->vboxObj));
@@ -101,7 +100,7 @@ static int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not get number of volumes in the pool: %s,
rc=%08x"),
pool->name, (unsigned)rc);
- return ret;
+ return -1;
}
for (i = 0; i < hardDisks.count; ++i) {
@@ -118,9 +117,7 @@ static int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
gVBoxAPI.UArray.vboxArrayRelease(&hardDisks);
- ret = hardDiskAccessible;
-
- return ret;
+ return hardDiskAccessible;
}
static int
@@ -131,10 +128,9 @@ vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const
names, int nname
PRUint32 numActive = 0;
nsresult rc;
size_t i;
- int ret = -1;
if (!data->vboxObj)
- return ret;
+ return -1;
rc = gVBoxAPI.UArray.vboxArrayGet(&hardDisks, data->vboxObj,
gVBoxAPI.UArray.handleGetHardDisks(data->vboxObj));
@@ -142,7 +138,7 @@ vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
int nname
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not get the volume list in the pool: %s,
rc=%08x"),
pool->name, (unsigned)rc);
- return ret;
+ return -1;
}
for (i = 0; i < hardDisks.count && numActive < nnames; ++i) {
@@ -174,9 +170,7 @@ vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
int nname
}
gVBoxAPI.UArray.vboxArrayRelease(&hardDisks);
- ret = numActive;
-
- return ret;
+ return numActive;
}
static virStorageVolPtr
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 21425346ac..69ec1a5377 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -210,13 +210,11 @@ static char *
vzConnectGetCapabilities(virConnectPtr conn)
{
vzConnPtr privconn = conn->privateData;
- char *xml;
if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
return NULL;
- xml = virCapabilitiesFormatXML(privconn->driver->caps);
- return xml;
+ return virCapabilitiesFormatXML(privconn->driver->caps);
}
static int
@@ -470,63 +468,53 @@ static int
vzConnectListDomains(virConnectPtr conn, int *ids, int maxids)
{
vzConnPtr privconn = conn->privateData;
- int n;
if (virConnectListDomainsEnsureACL(conn) < 0)
return -1;
- n = virDomainObjListGetActiveIDs(privconn->driver->domains, ids, maxids,
- virConnectListDomainsCheckACL, conn);
-
- return n;
+ return virDomainObjListGetActiveIDs(privconn->driver->domains, ids,
+ maxids, virConnectListDomainsCheckACL,
+ conn);
}
static int
vzConnectNumOfDomains(virConnectPtr conn)
{
vzConnPtr privconn = conn->privateData;
- int count;
if (virConnectNumOfDomainsEnsureACL(conn) < 0)
return -1;
- count = virDomainObjListNumOfDomains(privconn->driver->domains, true,
- virConnectNumOfDomainsCheckACL, conn);
-
- return count;
+ return virDomainObjListNumOfDomains(privconn->driver->domains, true,
+ virConnectNumOfDomainsCheckACL, conn);
}
static int
vzConnectListDefinedDomains(virConnectPtr conn, char **const names, int maxnames)
{
vzConnPtr privconn = conn->privateData;
- int n;
if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
return -1;
memset(names, 0, sizeof(*names) * maxnames);
- n = virDomainObjListGetInactiveNames(privconn->driver->domains, names,
- maxnames,
- virConnectListDefinedDomainsCheckACL,
- conn);
-
- return n;
+ return virDomainObjListGetInactiveNames(privconn->driver->domains, names,
+ maxnames,
+ virConnectListDefinedDomainsCheckACL,
+ conn);
}
static int
vzConnectNumOfDefinedDomains(virConnectPtr conn)
{
vzConnPtr privconn = conn->privateData;
- int count;
if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
return -1;
- count = virDomainObjListNumOfDomains(privconn->driver->domains, false,
- virConnectNumOfDefinedDomainsCheckACL,
- conn);
- return count;
+ return virDomainObjListNumOfDomains(privconn->driver->domains, false,
+ virConnectNumOfDefinedDomainsCheckACL,
+ conn);
}
static int
@@ -535,17 +523,14 @@ vzConnectListAllDomains(virConnectPtr conn,
unsigned int flags)
{
vzConnPtr privconn = conn->privateData;
- int ret = -1;
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
if (virConnectListAllDomainsEnsureACL(conn) < 0)
return -1;
- ret = virDomainObjListExport(privconn->driver->domains, conn, domains,
- virConnectListAllDomainsCheckACL, flags);
-
- return ret;
+ return virDomainObjListExport(privconn->driver->domains, conn, domains,
+ virConnectListAllDomainsCheckACL, flags);
}
static virDomainPtr
diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c
index bb06f468d7..641b26d2c5 100644
--- a/tools/virsh-completer-domain.c
+++ b/tools/virsh-completer-domain.c
@@ -173,7 +173,6 @@ virshDomainEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
unsigned int flags)
{
size_t i = 0;
- char **ret = NULL;
VIR_AUTOSTRINGLIST tmp = NULL;
virCheckFlags(0, NULL);
@@ -186,8 +185,7 @@ virshDomainEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
return NULL;
}
- ret = g_steal_pointer(&tmp);
- return ret;
+ return g_steal_pointer(&tmp);
}
diff --git a/tools/virsh-completer-nodedev.c b/tools/virsh-completer-nodedev.c
index 899c199902..83f6d415a7 100644
--- a/tools/virsh-completer-nodedev.c
+++ b/tools/virsh-completer-nodedev.c
@@ -73,7 +73,6 @@ virshNodeDeviceEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
unsigned int flags)
{
size_t i = 0;
- char **ret = NULL;
VIR_AUTOSTRINGLIST tmp = NULL;
virCheckFlags(0, NULL);
@@ -86,8 +85,7 @@ virshNodeDeviceEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
return NULL;
}
- ret = g_steal_pointer(&tmp);
- return ret;
+ return g_steal_pointer(&tmp);
}
diff --git a/tools/virsh-completer-pool.c b/tools/virsh-completer-pool.c
index ceb73eed06..def2b95b6d 100644
--- a/tools/virsh-completer-pool.c
+++ b/tools/virsh-completer-pool.c
@@ -76,7 +76,6 @@ virshPoolEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
unsigned int flags)
{
size_t i = 0;
- char **ret = NULL;
VIR_AUTOSTRINGLIST tmp = NULL;
virCheckFlags(0, NULL);
@@ -89,8 +88,7 @@ virshPoolEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
return NULL;
}
- ret = g_steal_pointer(&tmp);
- return ret;
+ return g_steal_pointer(&tmp);
}
diff --git a/tools/virsh-completer-secret.c b/tools/virsh-completer-secret.c
index a533ac178f..4ebeaeeb65 100644
--- a/tools/virsh-completer-secret.c
+++ b/tools/virsh-completer-secret.c
@@ -73,7 +73,6 @@ virshSecretEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
unsigned int flags)
{
size_t i;
- char **ret = NULL;
VIR_AUTOSTRINGLIST tmp = NULL;
virCheckFlags(0, NULL);
@@ -86,6 +85,5 @@ virshSecretEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
return NULL;
}
- ret = g_steal_pointer(&tmp);
- return ret;
+ return g_steal_pointer(&tmp);
}
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 64b733adcc..edd61f3217 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -1384,8 +1384,6 @@ static const vshCmdOptDef opts_network_dhcp_leases[] = {
static int
virshNetworkDHCPLeaseSorter(const void *a, const void *b)
{
- int rv = -1;
-
virNetworkDHCPLeasePtr *lease1 = (virNetworkDHCPLeasePtr *) a;
virNetworkDHCPLeasePtr *lease2 = (virNetworkDHCPLeasePtr *) b;
@@ -1395,8 +1393,7 @@ virshNetworkDHCPLeaseSorter(const void *a, const void *b)
if (!*lease1)
return *lease2 != NULL;
- rv = vshStrcasecmp((*lease1)->mac, (*lease2)->mac);
- return rv;
+ return vshStrcasecmp((*lease1)->mac, (*lease2)->mac);
}
static bool
diff --git a/tools/vsh.c b/tools/vsh.c
index ee675a63cc..ae94a724df 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2910,10 +2910,7 @@ vshReadlineCompletion(const char *text,
int start G_GNUC_UNUSED,
int end G_GNUC_UNUSED)
{
- char **matches = (char **) NULL;
-
- matches = rl_completion_matches(text, vshReadlineParse);
- return matches;
+ return rl_completion_matches(text, vshReadlineParse);
}
--
2.21.0