These functions can't fail really. Drop checking of their retval then. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/remote/remote_daemon.c | 37 ++++++++++++----------------- src/remote/remote_daemon_config.c | 5 +--- src/remote/remote_daemon_dispatch.c | 20 ++++++---------- src/remote/remote_driver.c | 20 ++++++---------- 4 files changed, 30 insertions(+), 52 deletions(-) diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index 7e63e18034..6977cc36e0 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -225,26 +225,23 @@ daemonUnixSocketPaths(struct daemonConfig *config, char *rundir = NULL; if (config->unix_sock_dir) { - if (virAsprintf(sockfile, "%s/%s-sock", - config->unix_sock_dir, SOCK_PREFIX) < 0) - goto cleanup; + virAsprintf(sockfile, "%s/%s-sock", config->unix_sock_dir, + SOCK_PREFIX); if (privileged) { - if (virAsprintf(rosockfile, "%s/%s-sock-ro", - config->unix_sock_dir, SOCK_PREFIX) < 0 || - virAsprintf(admsockfile, "%s/%s-admin-sock", - config->unix_sock_dir, SOCK_PREFIX) < 0) - goto cleanup; + virAsprintf(rosockfile, "%s/%s-sock-ro", + config->unix_sock_dir, SOCK_PREFIX); + virAsprintf(admsockfile, "%s/%s-admin-sock", + config->unix_sock_dir, SOCK_PREFIX); } } else { if (privileged) { - if (virAsprintf(sockfile, "%s/libvirt/%s-sock", - RUNSTATEDIR, SOCK_PREFIX) < 0 || - virAsprintf(rosockfile, "%s/libvirt/%s-sock-ro", - RUNSTATEDIR, SOCK_PREFIX) < 0 || - virAsprintf(admsockfile, "%s/libvirt/%s-admin-sock", - RUNSTATEDIR, SOCK_PREFIX) < 0) - goto cleanup; + virAsprintf(sockfile, "%s/libvirt/%s-sock", + RUNSTATEDIR, SOCK_PREFIX); + virAsprintf(rosockfile, "%s/libvirt/%s-sock-ro", + RUNSTATEDIR, SOCK_PREFIX); + virAsprintf(admsockfile, "%s/libvirt/%s-admin-sock", + RUNSTATEDIR, SOCK_PREFIX); } else { mode_t old_umask; @@ -258,11 +255,8 @@ daemonUnixSocketPaths(struct daemonConfig *config, } umask(old_umask); - if (virAsprintf(sockfile, "%s/%s-sock", - rundir, SOCK_PREFIX) < 0 || - virAsprintf(admsockfile, "%s/%s-admin-sock", - rundir, SOCK_PREFIX) < 0) - goto cleanup; + virAsprintf(sockfile, "%s/%s-sock", rundir, SOCK_PREFIX); + virAsprintf(admsockfile, "%s/%s-admin-sock", rundir, SOCK_PREFIX); } } @@ -659,8 +653,7 @@ daemonSetupLogging(struct daemonConfig *config, /* Define the default output. This is only applied if there was no setting * from either the config or the environment. */ - if (virLogSetDefaultOutput(DAEMON_NAME, godaemon, privileged) < 0) - return -1; + virLogSetDefaultOutput(DAEMON_NAME, godaemon, privileged); if (virLogGetNbOutputs() == 0) virLogSetOutputs(virLogGetDefaultOutput()); diff --git a/src/remote/remote_daemon_config.c b/src/remote/remote_daemon_config.c index 3187c9acb1..cfc0869747 100644 --- a/src/remote/remote_daemon_config.c +++ b/src/remote/remote_daemon_config.c @@ -84,10 +84,7 @@ daemonConfigFilePath(bool privileged, char **configfile) if (!(configdir = virGetUserConfigDirectory())) goto error; - if (virAsprintf(configfile, "%s/%s.conf", configdir, DAEMON_NAME) < 0) { - VIR_FREE(configdir); - goto error; - } + virAsprintf(configfile, "%s/%s.conf", configdir, DAEMON_NAME); VIR_FREE(configdir); } diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index 203aeff8c3..d12c3c1ed9 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -2174,8 +2174,7 @@ remoteDispatchProbeURI(bool readonly, g_autofree char *daemonname = NULL; g_autofree char *daemonpath = NULL; - if (virAsprintf(&daemonname, "virt%sd", drivers[i]) < 0) - return -1; + virAsprintf(&daemonname, "virt%sd", drivers[i]); if (!(daemonpath = virFileFindResource(daemonname, "src", SBINDIR))) return -1; @@ -2185,8 +2184,7 @@ remoteDispatchProbeURI(bool readonly, continue; } - if (virAsprintf(probeduri, "%s:///session", drivers[i]) < 0) - return -1; + virAsprintf(probeduri, "%s:///session", drivers[i]); VIR_DEBUG("Probed URI %s via daemon %s", *probeduri, daemonpath); return 0; @@ -2219,18 +2217,15 @@ remoteDispatchProbeURI(bool readonly, for (i = 0; i < (ssize_t) G_N_ELEMENTS(drivers) && !*probeduri; i++) { g_autofree char *sockname = NULL; - if (virAsprintf(&sockname, "%s/libvirt/virt%sd-%s", - RUNSTATEDIR, drivers[i], - readonly ? "sock-ro" : "sock") < 0) - return -1; + virAsprintf(&sockname, "%s/libvirt/virt%sd-%s", RUNSTATEDIR, + drivers[i], readonly ? "sock-ro" : "sock"); if (!virFileExists(sockname)) { VIR_DEBUG("Missing sock %s for driver %s", sockname, drivers[i]); continue; } - if (virAsprintf(probeduri, "%s:///system", drivers[i]) < 0) - return -1; + virAsprintf(probeduri, "%s:///system", drivers[i]); VIR_DEBUG("Probed URI %s via sock %s", *probeduri, sockname); return 0; @@ -3844,9 +3839,8 @@ remoteDispatchAuthList(virNetServerPtr server, virResetLastError(); } else if (callerUid == 0) { char *ident; - if (virAsprintf(&ident, "pid:%lld,uid:%d", - (long long) callerPid, (int) callerUid) < 0) - goto cleanup; + virAsprintf(&ident, "pid:%lld,uid:%d", (long long)callerPid, + (int)callerUid); VIR_INFO("Bypass polkit auth for privileged client %s", ident); virNetServerSetClientAuthenticated(server, client); auth = VIR_NET_SERVER_SERVICE_AUTH_NONE; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 83477243fc..4fcf13161c 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -781,9 +781,7 @@ remoteGetUNIXSocketHelper(remoteDriverTransport transport, if (!(userdir = virGetUserRuntimeDirectory())) return NULL; - if (virAsprintf(&sockname, "%s/%s-sock", - userdir, sock_prefix) < 0) - return NULL; + virAsprintf(&sockname, "%s/%s-sock", userdir, sock_prefix); } else { /* Intentionally do *NOT* use RUNSTATEDIR here. We might * be connecting to a remote machine, and cannot assume @@ -791,11 +789,9 @@ remoteGetUNIXSocketHelper(remoteDriverTransport transport, * any machine with /run will have a /var/run symlink. * The portable option is to thus use $LOCALSTATEDIR/run */ - if (virAsprintf(&sockname, "%s/run/libvirt/%s-%s", - LOCALSTATEDIR, sock_prefix, - flags & VIR_DRV_OPEN_REMOTE_RO ? - "sock-ro" : "sock") < 0) - return NULL; + virAsprintf(&sockname, "%s/run/libvirt/%s-%s", LOCALSTATEDIR, + sock_prefix, + flags & VIR_DRV_OPEN_REMOTE_RO ? "sock-ro" : "sock"); } VIR_DEBUG("Built UNIX sockname %s for transport %s prefix %s flags=0x%x", @@ -818,9 +814,8 @@ remoteGetUNIXSocket(remoteDriverTransport transport, g_autofree char *direct_sock_name = NULL; g_autofree char *legacy_sock_name = NULL; - if (driver && - virAsprintf(&direct_daemon, "virt%sd", driver) < 0) - return NULL; + if (driver) + virAsprintf(&direct_daemon, "virt%sd", driver); legacy_daemon = g_strdup("libvirtd"); @@ -1003,8 +998,7 @@ doRemoteOpen(virConnectPtr conn, /* Remote server defaults to "localhost" if not specified. */ if (conn->uri && conn->uri->port != 0) { - if (virAsprintf(&port, "%d", conn->uri->port) < 0) - goto failed; + virAsprintf(&port, "%d", conn->uri->port); } else if (transport == REMOTE_DRIVER_TRANSPORT_TLS) { port = g_strdup(LIBVIRTD_TLS_PORT); } else if (transport == REMOTE_DRIVER_TRANSPORT_TCP) { -- 2.21.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list