[PATCH] lib: Drop intermediary return variables

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

 



In a few places we declare a variable (which is optionally
followed by a code not touching it) then set the variable to a
value and return the variable immediately. It's obvious that the
variable is needless and the value can be returned directly
instead.

This patch was generated using this semantic patch:

  @@
  type T;
  identifier ret;
  expression E;
  @@
  - T ret;
  ... when != ret
      when strict
  - ret = E;
  - return ret;
  + return E;

After that I fixed couple of formatting issues because coccinelle
formatted some lines differently than our coding style.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/bhyve/bhyve_domain.c            |  6 +-----
 src/conf/domain_addr.c              |  6 +-----
 src/conf/domain_conf.c              |  5 +----
 src/conf/virnetworkobj.c            |  4 +---
 src/conf/virnwfilterbindingobj.c    |  5 +----
 src/conf/virnwfilterobj.c           |  5 +----
 src/esx/esx_driver.c                |  5 +----
 src/esx/esx_storage_backend_iscsi.c |  5 +----
 src/esx/esx_storage_backend_vmfs.c  |  5 +----
 src/hyperv/hyperv_driver.c          |  5 +----
 src/locking/lock_daemon.c           |  5 +----
 src/locking/lock_driver_sanlock.c   |  6 ++----
 src/logging/log_daemon.c            |  5 +----
 src/network/bridge_driver.c         | 27 +++++----------------------
 src/qemu/qemu_alias.c               | 24 ++++--------------------
 src/qemu/qemu_command.c             | 15 ++++++---------
 src/qemu/qemu_domain.c              | 10 +++-------
 src/qemu/qemu_monitor.c             |  5 +----
 src/security/security_apparmor.c    |  5 +----
 src/security/security_nop.c         |  5 +----
 src/test/test_driver.c              |  9 ++-------
 src/util/viraudit.c                 |  4 +---
 src/util/virfirewall.c              |  6 +-----
 src/util/virmacmap.c                |  6 +-----
 src/util/virnetdev.c                |  5 +----
 src/util/virpci.c                   | 10 ++--------
 src/vbox/vbox_common.c              |  7 +++----
 tests/bhyvexml2argvmock.c           |  5 +----
 tests/qemumonitortestutils.c        |  5 +----
 tests/qemusecuritymock.c            |  6 +-----
 tests/qemuxml2argvmock.c            |  5 +----
 tests/virnetserverclienttest.c      |  6 +-----
 tests/virpcimock.c                  |  8 ++------
 tests/virusbmock.c                  |  4 +---
 34 files changed, 54 insertions(+), 190 deletions(-)

diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index 33e74e2e25..b526235a4e 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -36,11 +36,7 @@ VIR_LOG_INIT("bhyve.bhyve_domain");
 static void *
 bhyveDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED)
 {
-    bhyveDomainObjPrivate *priv;
-
-    priv = g_new0(bhyveDomainObjPrivate, 1);
-
-    return priv;
+    return g_new0(bhyveDomainObjPrivate, 1);
 }
 
 static void
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index fe6520cf3a..a06721c35d 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1862,11 +1862,7 @@ virDomainUSBAddressPortFormat(unsigned int *port)
 virDomainUSBAddressSet *
 virDomainUSBAddressSetCreate(void)
 {
-    virDomainUSBAddressSet *addrs;
-
-    addrs = g_new0(virDomainUSBAddressSet, 1);
-
-    return addrs;
+    return g_new0(virDomainUSBAddressSet, 1);
 }
 
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 15228d1e38..1b36699761 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -28879,10 +28879,7 @@ char
 *virDomainConfigFile(const char *dir,
                      const char *name)
 {
-    char *ret;
-
-    ret = g_strdup_printf("%s/%s.xml", dir, name);
-    return ret;
+    return g_strdup_printf("%s/%s.xml", dir, name);
 }
 
 /* Translates a device name of the form (regex) "[fhv]d[a-z]+" into
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index aa629af6f6..f1baffc516 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -1601,9 +1601,7 @@ char *
 virNetworkObjGetPortStatusDir(virNetworkObj *net,
                               const char *stateDir)
 {
-    char *ret;
-    ret = g_strdup_printf("%s/%s/ports", stateDir, net->def->name);
-    return ret;
+    return g_strdup_printf("%s/%s/ports", stateDir, net->def->name);
 }
 
 int
diff --git a/src/conf/virnwfilterbindingobj.c b/src/conf/virnwfilterbindingobj.c
index 29fbb63b5f..acea240b5d 100644
--- a/src/conf/virnwfilterbindingobj.c
+++ b/src/conf/virnwfilterbindingobj.c
@@ -138,10 +138,7 @@ char *
 virNWFilterBindingObjConfigFile(const char *dir,
                                 const char *name)
 {
-    char *ret;
-
-    ret = g_strdup_printf("%s/%s.xml", dir, name);
-    return ret;
+    return g_strdup_printf("%s/%s.xml", dir, name);
 }
 
 
diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c
index c3b2eb048c..6bbdf6e6fa 100644
--- a/src/conf/virnwfilterobj.c
+++ b/src/conf/virnwfilterobj.c
@@ -117,10 +117,7 @@ virNWFilterObjListFree(virNWFilterObjList *nwfilters)
 virNWFilterObjList *
 virNWFilterObjListNew(void)
 {
-    virNWFilterObjList *nwfilters;
-
-    nwfilters = g_new0(virNWFilterObjList, 1);
-    return nwfilters;
+    return g_new0(virNWFilterObjList, 1);
 }
 
 
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 5d9687733f..ee752662ec 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -1800,10 +1800,7 @@ esxDomainDestroy(virDomainPtr dom)
 static char *
 esxDomainGetOSType(virDomainPtr domain G_GNUC_UNUSED)
 {
-    char *osType;
-
-    osType = g_strdup("hvm");
-    return osType;
+    return g_strdup("hvm");
 }
 
 
diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_backend_iscsi.c
index d89b5a4ba8..043de1690d 100644
--- a/src/esx/esx_storage_backend_iscsi.c
+++ b/src/esx/esx_storage_backend_iscsi.c
@@ -766,10 +766,7 @@ esxStorageVolWipe(virStorageVolPtr volume G_GNUC_UNUSED,
 static char *
 esxStorageVolGetPath(virStorageVolPtr volume)
 {
-    char *path;
-
-    path = g_strdup(volume->name);
-    return path;
+    return g_strdup(volume->name);
 }
 
 
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index cb2be59a33..5dba813111 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -1392,10 +1392,7 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
 static char *
 esxStorageVolGetPath(virStorageVolPtr volume)
 {
-    char *path;
-
-    path = g_strdup_printf("[%s] %s", volume->pool, volume->name);
-    return path;
+    return g_strdup_printf("[%s] %s", volume->pool, volume->name);
 }
 
 
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index a672901a81..3e6360f2a7 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -2234,10 +2234,7 @@ hypervDomainDestroy(virDomainPtr domain)
 static char *
 hypervDomainGetOSType(virDomainPtr domain G_GNUC_UNUSED)
 {
-    char *osType;
-
-    osType = g_strdup("hvm");
-    return osType;
+    return g_strdup("hvm");
 }
 
 
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index fa08acbc76..faca4a2485 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -616,10 +616,7 @@ virLockDaemonExecRestartStatePath(bool privileged,
 static char *
 virLockDaemonGetExecRestartMagic(void)
 {
-    char *ret;
-
-    ret = g_strdup_printf("%lld", (long long int)getpid());
-    return ret;
+    return g_strdup_printf("%lld", (long long int)getpid());
 }
 
 
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index 46e2cbc4f0..2dceb1eefc 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -174,13 +174,11 @@ static int
 virLockManagerSanlockInitLockspace(virLockManagerSanlockDriver *driver,
                                    struct sanlk_lockspace *ls)
 {
-    int ret;
-
     const int max_hosts = 0; /* defaults used in sanlock_init() implementation */
     const unsigned int lockspaceFlags = 0;
 
-    ret = sanlock_write_lockspace(ls, max_hosts, lockspaceFlags, driver->io_timeout);
-    return ret;
+    return sanlock_write_lockspace(ls, max_hosts, lockspaceFlags,
+                                   driver->io_timeout);
 }
 
 /* How many times try adding a lockspace? */
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index 1b04fbdae8..cc7889399b 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -423,10 +423,7 @@ virLogDaemonExecRestartStatePath(bool privileged,
 static char *
 virLogDaemonGetExecRestartMagic(void)
 {
-    char *ret;
-
-    ret = g_strdup_printf("%lld", (long long int)getpid());
-    return ret;
+    return g_strdup_printf("%lld", (long long int)getpid());
 }
 
 
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 7027dc636c..498c45d0a7 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -365,10 +365,7 @@ static char *
 networkDnsmasqLeaseFileNameDefault(virNetworkDriverState *driver,
                                    const char *netname)
 {
-    char *leasefile;
-
-    leasefile = g_strdup_printf("%s/%s.leases", driver->dnsmasqStateDir, netname);
-    return leasefile;
+    return g_strdup_printf("%s/%s.leases", driver->dnsmasqStateDir, netname);
 }
 
 
@@ -376,10 +373,7 @@ static char *
 networkDnsmasqLeaseFileNameCustom(virNetworkDriverState *driver,
                                   const char *bridge)
 {
-    char *leasefile;
-
-    leasefile = g_strdup_printf("%s/%s.status", driver->dnsmasqStateDir, bridge);
-    return leasefile;
+    return g_strdup_printf("%s/%s.status", driver->dnsmasqStateDir, bridge);
 }
 
 
@@ -387,21 +381,13 @@ static char *
 networkDnsmasqConfigFileName(virNetworkDriverState *driver,
                              const char *netname)
 {
-    char *conffile;
-
-    conffile = g_strdup_printf("%s/%s.conf", driver->dnsmasqStateDir, netname);
-    return conffile;
+    return g_strdup_printf("%s/%s.conf", driver->dnsmasqStateDir, netname);
 }
 
 
 static char *
 networkRadvdPidfileBasename(const char *netname)
-{
-    /* this is simple but we want to be sure it's consistently done */
-    char *pidfilebase;
-
-    pidfilebase = g_strdup_printf("%s-radvd", netname);
-    return pidfilebase;
+{return g_strdup_printf("%s-radvd", netname);
 }
 
 
@@ -409,10 +395,7 @@ static char *
 networkRadvdConfigFileName(virNetworkDriverState *driver,
                            const char *netname)
 {
-    char *configfile;
-
-    configfile = g_strdup_printf("%s/%s-radvd.conf", driver->radvdStateDir, netname);
-    return configfile;
+    return g_strdup_printf("%s/%s-radvd.conf", driver->radvdStateDir, netname);
 }
 
 
diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index 276a03cb56..a36f346592 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -804,11 +804,7 @@ qemuAliasFromHostdev(const virDomainHostdevDef *hostdev)
 char *
 qemuDomainGetMasterKeyAlias(void)
 {
-    char *alias;
-
-    alias = g_strdup("masterKey0");
-
-    return alias;
+    return g_strdup("masterKey0");
 }
 
 
@@ -837,11 +833,7 @@ qemuAliasForSecret(const char *parentalias,
 char *
 qemuAliasTLSObjFromSrcAlias(const char *srcAlias)
 {
-    char *ret;
-
-    ret = g_strdup_printf("obj%s_tls0", srcAlias);
-
-    return ret;
+    return g_strdup_printf("obj%s_tls0", srcAlias);
 }
 
 
@@ -853,11 +845,7 @@ qemuAliasTLSObjFromSrcAlias(const char *srcAlias)
 char *
 qemuAliasChardevFromDevAlias(const char *devAlias)
 {
-    char *ret;
-
-    ret = g_strdup_printf("char%s", devAlias);
-
-    return ret;
+    return g_strdup_printf("char%s", devAlias);
 }
 
 
@@ -871,11 +859,7 @@ qemuDomainGetManagedPRAlias(void)
 char *
 qemuDomainGetUnmanagedPRAlias(const char *parentalias)
 {
-    char *ret;
-
-    ret = g_strdup_printf("pr-helper-%s", parentalias);
-
-    return ret;
+    return g_strdup_printf("pr-helper-%s", parentalias);
 }
 
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d6df50ec73..335bad5616 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3811,18 +3811,15 @@ qemuBuildMemoryDeviceProps(const virDomainDef *def,
 static char *
 qemuBuildLegacyNicStr(virDomainNetDef *net)
 {
-    char *str;
     char macaddr[VIR_MAC_STRING_BUFLEN];
     const char *netmodel = virDomainNetGetModelString(net);
 
-    str = g_strdup_printf("nic,macaddr=%s,netdev=host%s%s%s%s%s",
-                          virMacAddrFormat(&net->mac, macaddr),
-                          net->info.alias,
-                          netmodel ? ",model=" : "",
-                          NULLSTR_EMPTY(netmodel),
-                          (net->info.alias ? ",id=" : ""),
-                          NULLSTR_EMPTY(net->info.alias));
-    return str;
+    return g_strdup_printf("nic,macaddr=%s,netdev=host%s%s%s%s%s",
+                           virMacAddrFormat(&net->mac, macaddr),
+                           net->info.alias, netmodel ? ",model=" : "",
+                           NULLSTR_EMPTY(netmodel),
+                           (net->info.alias ? ",id=" : ""),
+                           NULLSTR_EMPTY(net->info.alias));
 }
 
 
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e719c7b8c7..d0cb2eebed 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5944,13 +5944,9 @@ qemuDomainDefFromXML(virQEMUDriver *driver,
                      virQEMUCaps *qemuCaps,
                      const char *xml)
 {
-    virDomainDef *def;
-
-    def = virDomainDefParseString(xml, driver->xmlopt, qemuCaps,
-                                  VIR_DOMAIN_DEF_PARSE_INACTIVE |
-                                  VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
-
-    return def;
+    return virDomainDefParseString(xml, driver->xmlopt, qemuCaps,
+                                   VIR_DOMAIN_DEF_PARSE_INACTIVE |
+                                   VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
 }
 
 
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 6b6d6cd613..81d9087839 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -920,10 +920,7 @@ qemuMonitorClose(qemuMonitor *mon)
 char *
 qemuMonitorNextCommandID(qemuMonitor *mon)
 {
-    char *id;
-
-    id = g_strdup_printf("libvirt-%d", ++mon->nextSerial);
-    return id;
+    return g_strdup_printf("libvirt-%d", ++mon->nextSerial);
 }
 
 
diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index 2cc15ba6af..dadcfd67db 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -1169,10 +1169,7 @@ static char *
 AppArmorGetMountOptions(virSecurityManager *mgr G_GNUC_UNUSED,
                         virDomainDef *vm G_GNUC_UNUSED)
 {
-    char *opts;
-
-    opts = g_strdup("");
-    return opts;
+    return g_strdup("");
 }
 
 static const char *
diff --git a/src/security/security_nop.c b/src/security/security_nop.c
index a634e7f3fe..0b3d37142a 100644
--- a/src/security/security_nop.c
+++ b/src/security/security_nop.c
@@ -178,10 +178,7 @@ static char *
 virSecurityDomainGetMountOptionsNop(virSecurityManager *mgr G_GNUC_UNUSED,
                                     virDomainDef *vm G_GNUC_UNUSED)
 {
-    char *opts;
-
-    opts = g_strdup("");
-    return opts;
+    return g_strdup("");
 }
 
 static const char *
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index b5413cc03d..fd7486b8ca 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1666,7 +1666,6 @@ static char *
 testConnectGetSysinfo(virConnectPtr conn G_GNUC_UNUSED,
                       unsigned int flags)
 {
-    char *ret;
     const char *sysinfo = "<sysinfo type='smbios'>\n"
            "  <bios>\n"
            "    <entry name='vendor'>LENOVO</entry>\n"
@@ -1678,8 +1677,7 @@ testConnectGetSysinfo(virConnectPtr conn G_GNUC_UNUSED,
 
     virCheckFlags(0, NULL);
 
-    ret = g_strdup(sysinfo);
-    return ret;
+    return g_strdup(sysinfo);
 }
 
 static const char *
@@ -2706,10 +2704,7 @@ testDomainCoreDump(virDomainPtr domain,
 static char *
 testDomainGetOSType(virDomainPtr dom G_GNUC_UNUSED)
 {
-    char *ret;
-
-    ret = g_strdup("linux");
-    return ret;
+    return g_strdup("linux");
 }
 
 
diff --git a/src/util/viraudit.c b/src/util/viraudit.c
index bbd2462897..76ad3a73ed 100644
--- a/src/util/viraudit.c
+++ b/src/util/viraudit.c
@@ -140,8 +140,6 @@ char *virAuditEncode(const char *key, const char *value)
 #if WITH_AUDIT
     return audit_encode_nv_string(key, value, 0);
 #else
-    char *str;
-    str = g_strdup_printf("%s=%s", key, value);
-    return str;
+    return g_strdup_printf("%s=%s", key, value);
 #endif
 }
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index fb02992912..1a546335f6 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -157,11 +157,7 @@ virFirewallSetBackend(virFirewallBackend backend)
 static virFirewallGroup *
 virFirewallGroupNew(void)
 {
-    virFirewallGroup *group;
-
-    group = g_new0(virFirewallGroup, 1);
-
-    return group;
+    return g_new0(virFirewallGroup, 1);
 }
 
 
diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c
index 297d57a931..fb16062cd1 100644
--- a/src/util/virmacmap.c
+++ b/src/util/virmacmap.c
@@ -267,11 +267,7 @@ char *
 virMacMapFileName(const char *dnsmasqStateDir,
                   const char *bridge)
 {
-    char *filename;
-
-    filename = g_strdup_printf("%s/%s.macs", dnsmasqStateDir, bridge);
-
-    return filename;
+    return g_strdup_printf("%s/%s.macs", dnsmasqStateDir, bridge);
 }
 
 
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 5b4c585716..58f7360a0f 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -2803,10 +2803,7 @@ static int virNetDevGetMulticastTable(const char *ifname,
 virNetDevRxFilter *
 virNetDevRxFilterNew(void)
 {
-    virNetDevRxFilter *filter;
-
-    filter = g_new0(virNetDevRxFilter, 1);
-    return filter;
+    return g_new0(virNetDevRxFilter, 1);
 }
 
 
diff --git a/src/util/virpci.c b/src/util/virpci.c
index e746a2b25b..2d12e28004 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1438,14 +1438,8 @@ void virPCIDeviceAddressCopy(virPCIDeviceAddress *dst,
 char *
 virPCIDeviceAddressAsString(const virPCIDeviceAddress *addr)
 {
-    char *str;
-
-    str = g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT,
-                          addr->domain,
-                          addr->bus,
-                          addr->slot,
-                          addr->function);
-    return str;
+    return g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT, addr->domain,
+                           addr->bus, addr->slot, addr->function);
 }
 
 bool
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 7334254a36..45e7225ae1 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -2699,16 +2699,15 @@ static int vboxDomainDestroy(virDomainPtr dom)
     return vboxDomainDestroyFlags(dom, 0);
 }
 
-static char *vboxDomainGetOSType(virDomainPtr dom G_GNUC_UNUSED) {
+static char *vboxDomainGetOSType(virDomainPtr dom G_GNUC_UNUSED)
+{
     /* Returning "hvm" always as suggested on list, cause
      * this functions seems to be badly named and it
      * is supposed to pass the ABI name and not the domain
      * operating system driver as I had imagined ;)
      */
-    char *osType;
 
-    osType = g_strdup("hvm");
-    return osType;
+    return g_strdup("hvm");
 }
 
 static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory)
diff --git a/tests/bhyvexml2argvmock.c b/tests/bhyvexml2argvmock.c
index f3820ef032..9b77f97e5f 100644
--- a/tests/bhyvexml2argvmock.c
+++ b/tests/bhyvexml2argvmock.c
@@ -74,10 +74,7 @@ int virNetDevTapCreateInBridgePort(const char *brname G_GNUC_UNUSED,
 
 char *virNetDevTapGetRealDeviceName(char *name G_GNUC_UNUSED)
 {
-    char *fakename;
-
-    fakename = g_strdup("faketapdev");
-    return fakename;
+    return g_strdup("faketapdev");
 }
 
 int virNetDevSetOnline(const char *ifname G_GNUC_UNUSED,
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 35a1bce071..75a6a76b92 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -1282,13 +1282,10 @@ qemuMonitorTestFullAddItem(qemuMonitorTest *test,
                            size_t line)
 {
     g_autofree char *cmderr = NULL;
-    int ret;
 
     cmderr = g_strdup_printf("wrong expected command in %s:%zu: ", filename, line);
 
-    ret = qemuMonitorTestAddItemVerbatim(test, command, cmderr, response);
-
-    return ret;
+    return qemuMonitorTestAddItemVerbatim(test, command, cmderr, response);
 }
 
 
diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c
index 87aadf564e..f092383b62 100644
--- a/tests/qemusecuritymock.c
+++ b/tests/qemusecuritymock.c
@@ -128,11 +128,7 @@ static char *
 get_key(const char *path,
         const char *name)
 {
-    char *ret;
-
-    ret = g_strdup_printf("%s:%s", path, name);
-
-    return ret;
+    return g_strdup_printf("%s:%s", path, name);
 }
 
 
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index 2265492f1e..f4e2f52680 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -107,12 +107,9 @@ virNumaNodesetIsAvailable(virBitmap *nodeset)
 char *
 virTPMCreateCancelPath(const char *devpath)
 {
-    char *path;
     (void)devpath;
 
-    path = g_strdup("/sys/class/misc/tpm0/device/cancel");
-
-    return path;
+    return g_strdup("/sys/class/misc/tpm0/device/cancel");
 }
 
 /**
diff --git a/tests/virnetserverclienttest.c b/tests/virnetserverclienttest.c
index 942901bf60..d3c817f70d 100644
--- a/tests/virnetserverclienttest.c
+++ b/tests/virnetserverclienttest.c
@@ -30,11 +30,7 @@ static void *
 testClientNew(virNetServerClient *client G_GNUC_UNUSED,
               void *opaque G_GNUC_UNUSED)
 {
-    char *dummy;
-
-    dummy = g_new0(char, 1);
-
-    return dummy;
+    return g_new0(char, 1);
 }
 
 
diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 0f8d5ad54f..f65ae7c0c5 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -351,12 +351,8 @@ remove_fd(int fd)
 static char *
 pci_address_format(struct pciDeviceAddress const *addr)
 {
-    char *ret;
-
-    ret = g_strdup_printf(ADDR_STR_FMT,
-                          addr->domain, addr->bus,
-                          addr->device, addr->function);
-    return ret;
+    return g_strdup_printf(ADDR_STR_FMT, addr->domain, addr->bus,
+                           addr->device, addr->function);
 }
 
 static int
diff --git a/tests/virusbmock.c b/tests/virusbmock.c
index a1f539b8b1..5b09895197 100644
--- a/tests/virusbmock.c
+++ b/tests/virusbmock.c
@@ -64,14 +64,12 @@ static char *get_fake_path(const char *real_path)
 DIR *opendir(const char *name)
 {
     g_autofree char *path = NULL;
-    DIR* ret;
 
     init_syms();
 
     path = get_fake_path(name);
 
-    ret = realopendir(path);
-    return ret;
+    return realopendir(path);
 }
 
 int open(const char *pathname, int flags, ...)
-- 
2.32.0




[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