[PATCH 2/3] remote: remove unnecessary return value and if branch

Jiacheng Jiang jiangjiacheng at huawei.com
Tue Sep 6 13:48:30 UTC 2022


From: jiangjiacheng <jiangjiacheng at huawei.com>

Function daemonConfigFilePath() will assign a path to
remote_config_file definitely and the path will be validated
in following codes. So, it's unnecessary to return value
from daemonConfigFilePath() and check the returned value.

Signed-off-by: jiangjiacheng <jiangjiacheng at huawei.com>
---
 src/remote/remote_daemon.c        | 6 +-----
 src/remote/remote_daemon_config.c | 4 +---
 src/remote/remote_daemon_config.h | 2 +-
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index 23a5eeb200..36d95de83d 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -903,11 +903,7 @@ int main(int argc, char **argv) {
     /* No explicit config, so try and find a default one */
     if (remote_config_file == NULL) {
         implicit_conf = true;
-        if (daemonConfigFilePath(privileged,
-                                 &remote_config_file) < 0) {
-            VIR_ERROR(_("Can't determine config path"));
-            exit(EXIT_FAILURE);
-        }
+        daemonConfigFilePath(privileged, &remote_config_file);
     }
 
     /* Read the config file if it exists */
diff --git a/src/remote/remote_daemon_config.c b/src/remote/remote_daemon_config.c
index 330db54651..3567e337c4 100644
--- a/src/remote/remote_daemon_config.c
+++ b/src/remote/remote_daemon_config.c
@@ -72,7 +72,7 @@ remoteConfigGetAuth(virConf *conf,
     return 0;
 }
 
-int
+void
 daemonConfigFilePath(bool privileged, char **configfile)
 {
     if (privileged) {
@@ -84,8 +84,6 @@ daemonConfigFilePath(bool privileged, char **configfile)
 
         *configfile = g_strdup_printf("%s/%s.conf", configdir, DAEMON_NAME);
     }
-
-    return 0;
 }
 
 struct daemonConfig*
diff --git a/src/remote/remote_daemon_config.h b/src/remote/remote_daemon_config.h
index 47839271d3..9f9e54e838 100644
--- a/src/remote/remote_daemon_config.h
+++ b/src/remote/remote_daemon_config.h
@@ -99,7 +99,7 @@ struct daemonConfig {
 };
 
 
-int daemonConfigFilePath(bool privileged, char **configfile);
+void daemonConfigFilePath(bool privileged, char **configfile);
 struct daemonConfig* daemonConfigNew(bool privileged);
 void daemonConfigFree(struct daemonConfig *data);
 int daemonConfigLoadFile(struct daemonConfig *data,
-- 
2.33.0



More information about the libvir-list mailing list