From nobody Sun Feb 8 17:13:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571752833; cv=none; d=zoho.com; s=zohoarc; b=TO0dciFpwLjRhZCJ7QucPEi9Lln5m+WQrCUXGu1VeGOxKN7qIZSlff2TAjvAT7OK4il2CBd/3i+V1l0gzoxPUSwnKwghS8GJ4DbvkeYDWKmrvj287081Y4i0gktfZB4OPkIn/ojJDDqqxAcvY3fP6Pa+73X4tVd1xYNmGW8rCm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571752833; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0E2dt5n5sqyElrkYbAEAvjrYuF6KiRYGcOT3wwlPQE4=; b=lcBuQoSDHyyWqcgXCKbkzuUSZ0Dz9kL7B+mTFkyjbwMW/fthk29ib4VbruFOlJMAcprs+GLKKx7Bdbc17zEEPEIv8MoW+2OlzfxYuB+OIuI8O6gE5Xc9iosgsW4lpZVMSXNMLzM8obVg0dDyPANnwr0LLJOX7GvtLSqMaC1qjdw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1571752833020428.78728353940494; Tue, 22 Oct 2019 07:00:33 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-142-0k7w_uoBN5m7xKjdU9qeIA-1; Tue, 22 Oct 2019 09:59:12 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73ACD800D53; Tue, 22 Oct 2019 13:59:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4260C60167; Tue, 22 Oct 2019 13:59:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 00D371806B14; Tue, 22 Oct 2019 13:59:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9MDwkM7001707 for ; Tue, 22 Oct 2019 09:58:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 569D76012C; Tue, 22 Oct 2019 13:58:46 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD0DF60167 for ; Tue, 22 Oct 2019 13:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571752831; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0E2dt5n5sqyElrkYbAEAvjrYuF6KiRYGcOT3wwlPQE4=; b=M2BgHPXk4fFpdnRPcEGZaKk96kJMlIFuHiEebp0D11DPmlRLqRsAVgnEIUm+AoL3F5UGrV 0W32Nf1RIfCuHF5Rw9aAp/QYIqUVgWZAkuYDyXbgdxKYlrtOFmjW9xyyDdMwrPRj4PVYFH n1761YnEaRWNb6TK78idDOJcnxmRZ7o= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 22 Oct 2019 15:57:24 +0200 Message-Id: <9d283103c9add428500efab9d8d659e99ff15d1f.1571752582.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 20/75] remote: Drop virAsprintf() and virAsprintfQuiet() retval checking X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: 0k7w_uoBN5m7xKjdU9qeIA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" These functions can't fail really. Drop checking of their retval then. Signed-off-by: Michal Privoznik --- 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 =3D NULL; =20 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); =20 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; =20 @@ -258,11 +255,8 @@ daemonUnixSocketPaths(struct daemonConfig *config, } umask(old_umask); =20 - 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_PREF= IX); } } =20 @@ -659,8 +653,7 @@ daemonSetupLogging(struct daemonConfig *config, /* Define the default output. This is only applied if there was no set= ting * from either the config or the environment. */ - if (virLogSetDefaultOutput(DAEMON_NAME, godaemon, privileged) < 0) - return -1; + virLogSetDefaultOutput(DAEMON_NAME, godaemon, privileged); =20 if (virLogGetNbOutputs() =3D=3D 0) virLogSetOutputs(virLogGetDefaultOutput()); diff --git a/src/remote/remote_daemon_config.c b/src/remote/remote_daemon_c= onfig.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 =3D virGetUserConfigDirectory())) goto error; =20 - 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); } =20 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 =3D NULL; g_autofree char *daemonpath =3D NULL; =20 - if (virAsprintf(&daemonname, "virt%sd", drivers[i]) < 0) - return -1; + virAsprintf(&daemonname, "virt%sd", drivers[i]); =20 if (!(daemonpath =3D virFileFindResource(daemonname, "src", SB= INDIR))) return -1; @@ -2185,8 +2184,7 @@ remoteDispatchProbeURI(bool readonly, continue; } =20 - if (virAsprintf(probeduri, "%s:///session", drivers[i]) < 0) - return -1; + virAsprintf(probeduri, "%s:///session", drivers[i]); =20 VIR_DEBUG("Probed URI %s via daemon %s", *probeduri, daemonpat= h); return 0; @@ -2219,18 +2217,15 @@ remoteDispatchProbeURI(bool readonly, for (i =3D 0; i < (ssize_t) G_N_ELEMENTS(drivers) && !*probeduri; = i++) { g_autofree char *sockname =3D NULL; =20 - 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"); =20 if (!virFileExists(sockname)) { VIR_DEBUG("Missing sock %s for driver %s", sockname, drive= rs[i]); continue; } =20 - if (virAsprintf(probeduri, "%s:///system", drivers[i]) < 0) - return -1; + virAsprintf(probeduri, "%s:///system", drivers[i]); =20 VIR_DEBUG("Probed URI %s via sock %s", *probeduri, sockname); return 0; @@ -3844,9 +3839,8 @@ remoteDispatchAuthList(virNetServerPtr server, virResetLastError(); } else if (callerUid =3D=3D 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 =3D 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 transpo= rt, if (!(userdir =3D virGetUserRuntimeDirectory())) return NULL; =20 - 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 transp= ort, * 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"); } =20 VIR_DEBUG("Built UNIX sockname %s for transport %s prefix %s flags=3D0= x%x", @@ -818,9 +814,8 @@ remoteGetUNIXSocket(remoteDriverTransport transport, g_autofree char *direct_sock_name =3D NULL; g_autofree char *legacy_sock_name =3D NULL; =20 - if (driver && - virAsprintf(&direct_daemon, "virt%sd", driver) < 0) - return NULL; + if (driver) + virAsprintf(&direct_daemon, "virt%sd", driver); =20 legacy_daemon =3D g_strdup("libvirtd"); =20 @@ -1003,8 +998,7 @@ doRemoteOpen(virConnectPtr conn, =20 /* Remote server defaults to "localhost" if not specified. */ if (conn->uri && conn->uri->port !=3D 0) { - if (virAsprintf(&port, "%d", conn->uri->port) < 0) - goto failed; + virAsprintf(&port, "%d", conn->uri->port); } else if (transport =3D=3D REMOTE_DRIVER_TRANSPORT_TLS) { port =3D g_strdup(LIBVIRTD_TLS_PORT); } else if (transport =3D=3D REMOTE_DRIVER_TRANSPORT_TCP) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list