[PATCH 3/4] lib: Drop needless ret variables

Michal Privoznik mprivozn at redhat.com
Tue May 5 10:10:07 UTC 2020


There are few places where a return variable is introduced (ret
or retval), but then is never changed and is then passed to
return. Well, we can return the value that the variable is
initialized to directly.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/locking/lock_daemon.c           | 3 +--
 src/logging/log_daemon.c            | 3 +--
 src/storage/storage_backend_mpath.c | 3 +--
 tools/virt-host-validate-bhyve.c    | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 4eff63014a..b0cd89375b 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -720,7 +720,6 @@ virLockDaemonPreExecRestart(const char *state_file,
 {
     virJSONValuePtr child;
     char *state = NULL;
-    int ret = -1;
     virJSONValuePtr object = virJSONValueNewObject();
     char *magic;
     virHashKeyValuePairPtr pairs = NULL, tmp;
@@ -800,7 +799,7 @@ virLockDaemonPreExecRestart(const char *state_file,
     VIR_FREE(pairs);
     VIR_FREE(state);
     virJSONValueFree(object);
-    return ret;
+    return -1;
 }
 
 
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index f37054706e..7017db2dcc 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -524,7 +524,6 @@ virLogDaemonPreExecRestart(const char *state_file,
 {
     virJSONValuePtr child;
     char *state = NULL;
-    int ret = -1;
     virJSONValuePtr object = virJSONValueNewObject();
     char *magic;
     virHashKeyValuePairPtr pairs = NULL;
@@ -581,7 +580,7 @@ virLogDaemonPreExecRestart(const char *state_file,
     VIR_FREE(pairs);
     VIR_FREE(state);
     virJSONValueFree(object);
-    return ret;
+    return -1;
 }
 
 
diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c
index 7cb084b2d6..fffc0f86b7 100644
--- a/src/storage/storage_backend_mpath.c
+++ b/src/storage/storage_backend_mpath.c
@@ -243,7 +243,6 @@ virStorageBackendMpathCheckPool(virStoragePoolObjPtr pool G_GNUC_UNUSED,
 static int
 virStorageBackendMpathRefreshPool(virStoragePoolObjPtr pool)
 {
-    int retval = 0;
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
 
     VIR_DEBUG("pool=%p", pool);
@@ -254,7 +253,7 @@ virStorageBackendMpathRefreshPool(virStoragePoolObjPtr pool)
 
     virStorageBackendGetMaps(pool);
 
-    return retval;
+    return 0;
 }
 
 
diff --git a/tools/virt-host-validate-bhyve.c b/tools/virt-host-validate-bhyve.c
index 2f0ec1e36c..3e8cc59a38 100644
--- a/tools/virt-host-validate-bhyve.c
+++ b/tools/virt-host-validate-bhyve.c
@@ -47,7 +47,6 @@
 
 int virHostValidateBhyve(void)
 {
-    int ret = 0;
     int fileid = 0;
     struct kld_file_stat stat;
     bool vmm_loaded = false, if_tap_loaded = false;
@@ -73,5 +72,5 @@ int virHostValidateBhyve(void)
     MODULE_STATUS_WARN(if_bridge, "bridged networking will not work");
     MODULE_STATUS_WARN(nmdm, "nmdm console will not work");
 
-    return ret;
+    return 0;
 }
-- 
2.26.2




More information about the libvir-list mailing list