[PATCH] Drop needless ret variable

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

 



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@xxxxxxxxxx>
---
 src/bhyve/bhyve_driver.c            | 38 +++++++++---------------
 src/conf/checkpoint_conf.c          |  5 +---
 src/conf/domain_conf.c              | 12 ++------
 src/conf/snapshot_conf.c            |  5 +---
 src/conf/storage_conf.c             | 17 ++++-------
 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             | 19 ++++--------
 src/qemu/qemu_driver.c              | 19 ++++--------
 src/qemu/qemu_firmware.c            |  4 +--
 src/qemu/qemu_monitor_json.c        |  4 +--
 src/qemu/qemu_process.c             | 16 ++++------
 src/qemu/qemu_vhost_user.c          |  4 +--
 src/remote/remote_daemon_dispatch.c |  5 +---
 src/storage/storage_backend_iscsi.c |  5 +---
 src/test/test_driver.c              | 34 ++++++----------------
 src/util/vircgroupv1.c              |  6 +---
 src/util/vircgroupv2.c              |  6 +---
 src/util/virdbus.c                  |  5 +---
 src/util/virjson.c                  |  5 +---
 src/util/virmdev.c                  |  5 +---
 src/util/virscsi.c                  |  4 +--
 src/util/virscsivhost.c             |  5 +---
 src/util/virstoragefile.c           | 23 ++++-----------
 src/vbox/vbox_storage.c             | 18 ++++--------
 src/vz/vz_driver.c                  | 45 ++++++++++-------------------
 tests/qemuxml2argvmock.c            |  5 +---
 tests/virstoragetest.c              |  4 +--
 tools/virsh-completer-domain.c      | 20 ++++---------
 tools/virsh-completer-host.c        |  8 ++---
 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 +---
 41 files changed, 143 insertions(+), 367 deletions(-)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index e3d984f69a..a2c8185c45 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 4fa743e0b0..90cb565d70 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 9ee9b44a5e..6aeef3e5c5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8322,7 +8322,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;
@@ -8374,8 +8373,7 @@ virDomainNetIPParseXML(xmlNodePtr node)
         return NULL;
     }
 
-    ret = g_steal_pointer(&ip);
-    return ret;
+    return g_steal_pointer(&ip);
 }
 
 
@@ -9239,7 +9237,6 @@ virDomainStorageSourceParseBase(const char *type,
                                 const char *index)
 {
     g_autoptr(virStorageSource) src = NULL;
-    virStorageSourcePtr ret = NULL;
 
     if (!(src = virStorageSourceNew()))
         return NULL;
@@ -9267,8 +9264,7 @@ virDomainStorageSourceParseBase(const char *type,
         return NULL;
     }
 
-    ret = g_steal_pointer(&src);
-    return ret;
+    return g_steal_pointer(&src);
 }
 
 
@@ -18368,7 +18364,6 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node,
 static virBitmapPtr
 virDomainEmulatorPinDefParseXML(xmlNodePtr node)
 {
-    virBitmapPtr ret = NULL;
     g_autofree char *tmp = NULL;
     g_autoptr(virBitmap) def = NULL;
 
@@ -18387,8 +18382,7 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node)
         return NULL;
     }
 
-    ret = g_steal_pointer(&def);
-    return ret;
+    return g_steal_pointer(&def);
 }
 
 
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index f9fbca3c07..9f08965aab 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 f212eefe25..d493109b7d 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -846,7 +846,6 @@ virStoragePoolDefPtr
 virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
 {
     virStoragePoolOptionsPtr options;
-    virStoragePoolDefPtr ret = NULL;
     xmlNodePtr source_node;
     g_autoptr(virStoragePoolDef) def = NULL;
     g_autofree char *type = NULL;
@@ -995,8 +994,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
             return NULL;
     }
 
-    ret = g_steal_pointer(&def);
-    return ret;
+    return g_steal_pointer(&def);
 }
 
 
@@ -1270,7 +1268,6 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
                          xmlXPathContextPtr ctxt,
                          unsigned int flags)
 {
-    virStorageVolDefPtr ret = NULL;
     virStorageVolOptionsPtr options;
     xmlNodePtr node;
     size_t i;
@@ -1430,8 +1427,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
         VIR_FREE(nodes);
     }
 
-    ret = g_steal_pointer(&def);
-    return ret;
+    return g_steal_pointer(&def);
 }
 
 
@@ -1689,14 +1685,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 5cc6b87b8c..c0e070d214 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
@@ -2776,29 +2770,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
@@ -5715,17 +5706,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 41a6a446bd..75c8c030c5 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -348,59 +348,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 5df09a849e..fec3b4454c 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -703,7 +703,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,
@@ -727,9 +726,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 fcaa6a48ae..5c212a2969 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -3128,17 +3128,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);
 }
 
 
@@ -3148,17 +3144,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);
 }
 
 
@@ -3166,17 +3157,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);
 }
 
 
@@ -3186,16 +3173,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 41e0a1d5d9..cc3ce98cc5 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -704,19 +704,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 8b1d804233..7fe7745279 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3165,7 +3165,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];
@@ -3177,9 +3176,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 0160507737..4358734279 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -698,20 +698,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);
 }
 
 
@@ -10743,7 +10739,6 @@ qemuBuildStorageSourceAttachPrepareDrive(virDomainDiskDefPtr disk,
                                          virQEMUCapsPtr qemuCaps)
 {
     g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
-    qemuBlockStorageSourceAttachDataPtr ret = NULL;
 
     if (VIR_ALLOC(data) < 0)
         return NULL;
@@ -10752,9 +10747,7 @@ qemuBuildStorageSourceAttachPrepareDrive(virDomainDiskDefPtr disk,
         !(data->driveAlias = qemuAliasDiskDriveFromDisk(disk)))
         return NULL;
 
-    ret = g_steal_pointer(&data);
-
-    return ret;
+    return g_steal_pointer(&data);
 }
 
 
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index af8cbf40f4..33a8c53d24 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1711,29 +1711,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);
 }
 
 
@@ -4079,7 +4073,6 @@ static char *
 getAutoDumpPath(virQEMUDriverPtr driver,
                 virDomainObjPtr vm)
 {
-    char *dumpfile = NULL;
     g_autofree char *domname = virDomainDefGetShortName(vm->def);
     char timestr[100];
     struct tm time_info;
@@ -4094,9 +4087,7 @@ getAutoDumpPath(virQEMUDriverPtr driver,
     localtime_r(&curtime, &time_info);
     strftime(timestr, sizeof(timestr), "%Y-%m-%d-%H:%M:%S", &time_info);
 
-    dumpfile = g_strdup_printf("%s/%s-%s", cfg->autoDumpPath, domname, timestr);
-
-    return dumpfile;
+    return g_strdup_printf("%s/%s-%s", cfg->autoDumpPath, domname, timestr);
 }
 
 static void
diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
index 670662fd4b..be4a10689e 100644
--- a/src/qemu/qemu_firmware.c
+++ b/src/qemu/qemu_firmware.c
@@ -616,7 +616,6 @@ qemuFirmwareParse(const char *path)
     g_autofree char *cont = NULL;
     g_autoptr(virJSONValue) doc = NULL;
     g_autoptr(qemuFirmware) fw = NULL;
-    qemuFirmwarePtr ret = NULL;
 
     if (virFileReadAll(path, DOCUMENT_SIZE, &cont) < 0)
         return NULL;
@@ -643,8 +642,7 @@ qemuFirmwareParse(const char *path)
     if (qemuFirmwareFeatureParse(path, doc, fw) < 0)
         return NULL;
 
-    ret = g_steal_pointer(&fw);
-    return ret;
+    return g_steal_pointer(&fw);
 }
 
 
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 99f55c420a..4bdc4d5569 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -9325,7 +9325,6 @@ qemuMonitorJSONGetJobInfoOne(virJSONValuePtr data)
     const char *errmsg = virJSONValueObjectGetString(data, "error");
     int tmp;
     g_autoptr(qemuMonitorJobInfo) job = NULL;
-    qemuMonitorJobInfoPtr ret = NULL;
 
     if (VIR_ALLOC(job) < 0)
         return NULL;
@@ -9343,8 +9342,7 @@ qemuMonitorJSONGetJobInfoOne(virJSONValuePtr data)
     job->id = g_strdup(id);
     job->error = g_strdup(errmsg);
 
-    ret = g_steal_pointer(&job);
-    return ret;
+    return g_steal_pointer(&job);
 }
 
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 7e0dc26658..ed8666e9d1 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7304,8 +7304,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);
@@ -7326,11 +7324,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);
 }
 
 
@@ -7752,11 +7748,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/qemu/qemu_vhost_user.c b/src/qemu/qemu_vhost_user.c
index 789d29ce43..4c25b30664 100644
--- a/src/qemu/qemu_vhost_user.c
+++ b/src/qemu/qemu_vhost_user.c
@@ -184,7 +184,6 @@ qemuVhostUserParse(const char *path)
     g_autofree char *cont = NULL;
     g_autoptr(virJSONValue) doc = NULL;
     g_autoptr(qemuVhostUser) vu = NULL;
-    qemuVhostUserPtr ret = NULL;
 
     if (virFileReadAll(path, DOCUMENT_SIZE, &cont) < 0)
         return NULL;
@@ -205,8 +204,7 @@ qemuVhostUserParse(const char *path)
     if (qemuVhostUserBinaryParse(path, doc, vu) < 0)
         return NULL;
 
-    ret = g_steal_pointer(&vu);
-    return ret;
+    return g_steal_pointer(&vu);
 }
 
 
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index 203aeff8c3..40d97e944a 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -7492,10 +7492,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 e00a65d8bb..79320e6093 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -4880,14 +4880,10 @@ testDomainGetPerfEvents(virDomainPtr dom,
 static char *testDomainGetSchedulerType(virDomainPtr domain G_GNUC_UNUSED,
                                         int *nparams)
 {
-    char *type = NULL;
-
     if (nparams)
         *nparams = 1;
 
-    type = g_strdup("fair");
-
-    return type;
+    return g_strdup("fair");
 }
 
 static int
@@ -5264,11 +5260,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);
 }
 
 
@@ -5278,11 +5271,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);
 }
 
 
@@ -5290,11 +5280,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);
 }
 
 
@@ -5304,11 +5291,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 0820c5d638..3f10d8d127 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -401,11 +401,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 e976a8d241..e0362990ab 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -243,11 +243,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 89c9cb3e24..9afc5af194 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -1177,15 +1177,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/util/virjson.c b/src/util/virjson.c
index eb6207f13f..d8e80b6c64 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -2138,7 +2138,6 @@ virJSONValuePtr
 virJSONValueObjectDeflatten(virJSONValuePtr json)
 {
     g_autoptr(virJSONValue) deflattened = NULL;
-    virJSONValuePtr ret = NULL;
 
     if (!(deflattened = virJSONValueNewObject()))
         return NULL;
@@ -2148,7 +2147,5 @@ virJSONValueObjectDeflatten(virJSONValuePtr json)
                                           deflattened) < 0)
         return NULL;
 
-    ret = g_steal_pointer(&deflattened);
-
-    return ret;
+    return g_steal_pointer(&deflattened);
 }
diff --git a/src/util/virmdev.c b/src/util/virmdev.c
index 9f8cb95423..f18a6dc2d0 100644
--- a/src/util/virmdev.c
+++ b/src/util/virmdev.c
@@ -140,7 +140,6 @@ virMediatedDeviceCheckModel(virMediatedDevicePtr dev,
 virMediatedDevicePtr
 virMediatedDeviceNew(const char *uuidstr, virMediatedDeviceModelType model)
 {
-    virMediatedDevicePtr ret = NULL;
     g_autoptr(virMediatedDevice) dev = NULL;
     g_autofree char *sysfspath = NULL;
 
@@ -165,9 +164,7 @@ virMediatedDeviceNew(const char *uuidstr, virMediatedDeviceModelType model)
         return NULL;
 
     dev->model = model;
-    ret = g_steal_pointer(&dev);
-
-    return ret;
+    return g_steal_pointer(&dev);
 }
 
 #else
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 705571f8ec..22360c91b9 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -184,7 +184,6 @@ virSCSIDeviceNew(const char *sysfs_prefix,
                  bool shareable)
 {
     g_autoptr(virSCSIDevice) dev = NULL;
-    virSCSIDevicePtr ret = NULL;
     g_autofree char *sg = NULL;
     g_autofree char *vendor_path = NULL;
     g_autofree char *model_path = NULL;
@@ -238,8 +237,7 @@ virSCSIDeviceNew(const char *sysfs_prefix,
     if (virAsprintf(&dev->id, "%s:%s", vendor, model) < 0)
         return NULL;
 
-    ret = g_steal_pointer(&dev);
-    return ret;
+    return g_steal_pointer(&dev);
 }
 
 static void
diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c
index 5f523636be..4feef827b5 100644
--- a/src/util/virscsivhost.c
+++ b/src/util/virscsivhost.c
@@ -249,7 +249,6 @@ virSCSIVHostDevicePtr
 virSCSIVHostDeviceNew(const char *name)
 {
     g_autoptr(virSCSIVHostDevice) dev = NULL;
-    virSCSIVHostDevicePtr ret = NULL;
 
     if (VIR_ALLOC(dev) < 0)
         return NULL;
@@ -262,9 +261,7 @@ virSCSIVHostDeviceNew(const char *name)
 
     VIR_DEBUG("%s: initialized", dev->name);
 
-    ret = g_steal_pointer(&dev);
-
-    return ret;
+    return g_steal_pointer(&dev);
 }
 
 
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index be2b5479bb..f083eead3f 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1128,7 +1128,6 @@ virStorageFileMetadataNew(const char *path,
                           int format)
 {
     g_autoptr(virStorageSource) def = NULL;
-    virStorageSourcePtr ret = NULL;
 
     if (!(def = virStorageSourceNew()))
         return NULL;
@@ -1138,8 +1137,7 @@ virStorageFileMetadataNew(const char *path,
 
     def->path = g_strdup(path);
 
-    ret = g_steal_pointer(&def);
-    return ret;
+    return g_steal_pointer(&def);
 }
 
 
@@ -1211,7 +1209,6 @@ virStorageFileGetMetadataFromFD(const char *path,
                                 int *backingFormat)
 
 {
-    virStorageSourcePtr ret = NULL;
     ssize_t len = VIR_STORAGE_MAX_HEADER;
     struct stat sb;
     int dummy;
@@ -1237,8 +1234,7 @@ virStorageFileGetMetadataFromFD(const char *path,
          * update the metadata.*/
         meta->type = VIR_STORAGE_TYPE_DIR;
         meta->format = VIR_STORAGE_FILE_DIR;
-        ret = g_steal_pointer(&meta);
-        return ret;
+        return g_steal_pointer(&meta);
     }
 
     if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
@@ -1259,8 +1255,7 @@ virStorageFileGetMetadataFromFD(const char *path,
     else if (S_ISBLK(sb.st_mode))
         meta->type = VIR_STORAGE_TYPE_BLOCK;
 
-    ret = g_steal_pointer(&meta);
-    return ret;
+    return g_steal_pointer(&meta);
 }
 
 
@@ -1843,7 +1838,6 @@ virStorageAuthDefFree(virStorageAuthDefPtr authdef)
 virStorageAuthDefPtr
 virStorageAuthDefCopy(const virStorageAuthDef *src)
 {
-    virStorageAuthDefPtr ret = NULL;
     g_autoptr(virStorageAuthDef) authdef = NULL;
 
     if (VIR_ALLOC(authdef) < 0)
@@ -1857,8 +1851,7 @@ virStorageAuthDefCopy(const virStorageAuthDef *src)
     if (virSecretLookupDefCopy(&authdef->seclookupdef, &src->seclookupdef) < 0)
         return NULL;
 
-    ret = g_steal_pointer(&authdef);
-    return ret;
+    return g_steal_pointer(&authdef);
 }
 
 
@@ -2228,7 +2221,6 @@ virStorageSourcePtr
 virStorageSourceCopy(const virStorageSource *src,
                      bool backingChain)
 {
-    virStorageSourcePtr ret = NULL;
     g_autoptr(virStorageSource) def = NULL;
 
     if (!(def = virStorageSourceNew()))
@@ -2323,8 +2315,7 @@ virStorageSourceCopy(const virStorageSource *src,
             return NULL;
     }
 
-    ret = g_steal_pointer(&def);
-    return ret;
+    return g_steal_pointer(&def);
 }
 
 
@@ -2604,7 +2595,6 @@ static virStorageSourcePtr
 virStorageSourceNewFromBackingRelative(virStorageSourcePtr parent,
                                        const char *rel)
 {
-    virStorageSourcePtr ret = NULL;
     g_autofree char *dirname = NULL;
     g_autoptr(virStorageSource) def = NULL;
 
@@ -2646,8 +2636,7 @@ virStorageSourceNewFromBackingRelative(virStorageSourcePtr parent,
         def->type = VIR_STORAGE_TYPE_FILE;
     }
 
-    ret = g_steal_pointer(&def);
-    return ret;
+    return g_steal_pointer(&def);
 }
 
 
diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c
index c7bea2c219..9bb3da4c57 100644
--- a/src/vbox/vbox_storage.c
+++ b/src/vbox/vbox_storage.c
@@ -91,10 +91,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));
@@ -102,7 +101,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) {
@@ -119,9 +118,7 @@ static int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
 
     gVBoxAPI.UArray.vboxArrayRelease(&hardDisks);
 
-    ret = hardDiskAccessible;
-
-    return ret;
+    return hardDiskAccessible;
 }
 
 static int
@@ -132,10 +129,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));
@@ -143,7 +139,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) {
@@ -175,9 +171,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 5b54f83b22..70084cc79e 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/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index 34e0eb91a6..914d2bcf9f 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -198,10 +198,7 @@ virNetDevRunEthernetScript(const char *ifname G_GNUC_UNUSED,
 char *
 virHostGetDRMRenderNode(void)
 {
-    char *dst = NULL;
-
-    dst = g_strdup("/dev/dri/foo");
-    return dst;
+    return g_strdup("/dev/dri/foo");
 }
 
 static void (*real_virCommandPassFD)(virCommandPtr cmd, int fd, unsigned int flags);
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index 8f1d93fa5a..32d12fd778 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -85,7 +85,6 @@ testStorageFileGetMetadata(const char *path,
                            uid_t uid, gid_t gid)
 {
     struct stat st;
-    virStorageSourcePtr ret = NULL;
     g_autoptr(virStorageSource) def = NULL;
 
     if (!(def = virStorageSourceNew()))
@@ -107,8 +106,7 @@ testStorageFileGetMetadata(const char *path,
     if (virStorageFileGetMetadata(def, uid, gid, false) < 0)
         return NULL;
 
-    ret = g_steal_pointer(&def);
-    return ret;
+    return g_steal_pointer(&def);
 }
 
 static int
diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c
index 6bfa3ab58c..7df08211b0 100644
--- a/tools/virsh-completer-domain.c
+++ b/tools/virsh-completer-domain.c
@@ -87,7 +87,6 @@ virshDomainInterfaceCompleter(vshControl *ctl,
     g_autofree xmlNodePtr *interfaces = NULL;
     size_t i;
     unsigned int domainXMLFlags = 0;
-    char **ret = NULL;
     VIR_AUTOSTRINGLIST tmp = NULL;
 
     virCheckFlags(VIRSH_DOMAIN_INTERFACE_COMPLETER_MAC, NULL);
@@ -121,8 +120,7 @@ virshDomainInterfaceCompleter(vshControl *ctl,
             return NULL;
     }
 
-    ret = g_steal_pointer(&tmp);
-    return ret;
+    return g_steal_pointer(&tmp);
 }
 
 
@@ -138,7 +136,6 @@ virshDomainDiskTargetCompleter(vshControl *ctl,
     int ndisks;
     size_t i;
     VIR_AUTOSTRINGLIST tmp = NULL;
-    char **ret = NULL;
 
     virCheckFlags(0, NULL);
 
@@ -161,8 +158,7 @@ virshDomainDiskTargetCompleter(vshControl *ctl,
             return NULL;
     }
 
-    ret = g_steal_pointer(&tmp);
-    return ret;
+    return g_steal_pointer(&tmp);
 }
 
 
@@ -172,7 +168,6 @@ virshDomainEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
                               unsigned int flags)
 {
     size_t i = 0;
-    char **ret = NULL;
     VIR_AUTOSTRINGLIST tmp = NULL;
 
     virCheckFlags(0, NULL);
@@ -183,8 +178,7 @@ virshDomainEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
     for (i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++)
         tmp[i] = g_strdup(virshDomainEventCallbacks[i].name);
 
-    ret = g_steal_pointer(&tmp);
-    return ret;
+    return g_steal_pointer(&tmp);
 }
 
 
@@ -195,7 +189,6 @@ virshDomainInterfaceStateCompleter(vshControl *ctl,
 {
     virshControlPtr priv = ctl->privData;
     const char *iface = NULL;
-    char **ret = NULL;
     g_autoptr(xmlDoc) xml = NULL;
     g_autoptr(xmlXPathContext) ctxt = NULL;
     virMacAddr macaddr;
@@ -244,8 +237,7 @@ virshDomainInterfaceStateCompleter(vshControl *ctl,
         tmp[0] = g_strdup("down");
     }
 
-    ret = g_steal_pointer(&tmp);
-    return ret;
+    return g_steal_pointer(&tmp);
 }
 
 
@@ -261,7 +253,6 @@ virshDomainDeviceAliasCompleter(vshControl *ctl,
     g_autofree xmlNodePtr *aliases = NULL;
     size_t i;
     unsigned int domainXMLFlags = 0;
-    char **ret = NULL;
     VIR_AUTOSTRINGLIST tmp = NULL;
 
     virCheckFlags(0, NULL);
@@ -287,8 +278,7 @@ virshDomainDeviceAliasCompleter(vshControl *ctl,
             return NULL;
     }
 
-    ret = g_steal_pointer(&tmp);
-    return ret;
+    return g_steal_pointer(&tmp);
 }
 
 
diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c
index 42e59a6656..f795a2a826 100644
--- a/tools/virsh-completer-host.c
+++ b/tools/virsh-completer-host.c
@@ -64,7 +64,6 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
     bool cellno = vshCommandOptBool(cmd, "cellno");
     g_autofree char *path = NULL;
     g_autofree char *cap_xml = NULL;
-    char **ret = NULL;
     VIR_AUTOSTRINGLIST tmp = NULL;
 
     virCheckFlags(0, NULL);
@@ -100,8 +99,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
             return NULL;
     }
 
-    ret = g_steal_pointer(&tmp);
-    return ret;
+    return g_steal_pointer(&tmp);
 }
 
 
@@ -117,7 +115,6 @@ virshCellnoCompleter(vshControl *ctl,
     g_autoptr(xmlDoc) doc = NULL;
     size_t i = 0;
     g_autofree char *cap_xml = NULL;
-    char **ret = NULL;
     VIR_AUTOSTRINGLIST tmp = NULL;
 
     virCheckFlags(0, NULL);
@@ -143,6 +140,5 @@ virshCellnoCompleter(vshControl *ctl,
             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 6b01941911..5425f11262 100644
--- a/tools/virsh-completer-nodedev.c
+++ b/tools/virsh-completer-nodedev.c
@@ -72,7 +72,6 @@ virshNodeDeviceEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
                                   unsigned int flags)
 {
     size_t i = 0;
-    char **ret = NULL;
     VIR_AUTOSTRINGLIST tmp = NULL;
 
     virCheckFlags(0, NULL);
@@ -83,8 +82,7 @@ virshNodeDeviceEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
     for (i = 0; i < VIR_NODE_DEVICE_EVENT_ID_LAST; i++)
         tmp[i] = g_strdup(virshNodeDeviceEventCallbacks[i].name);
 
-    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 bd9d9a9802..ed3b1e35ff 100644
--- a/tools/virsh-completer-pool.c
+++ b/tools/virsh-completer-pool.c
@@ -75,7 +75,6 @@ virshPoolEventNameCompleter(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 @@ virshPoolEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
     for (i = 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++)
         tmp[i] = g_strdup(virshPoolEventCallbacks[i].name);
 
-    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 bb02577c82..a90fdb399f 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);
@@ -84,6 +83,5 @@ virshSecretEventNameCompleter(vshControl *ctl G_GNUC_UNUSED,
     for (i = 0; i < VIR_SECRET_EVENT_ID_LAST; i++)
         tmp[i] = g_strdup(virshSecretEventCallbacks[i].name);
 
-    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 3f8b7f2186..ec46b822c5 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2898,10 +2898,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

--
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