From nobody Mon Feb 9 00:02:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1614183474; cv=none; d=zohomail.com; s=zohoarc; b=gy2KDyUI++SWCCTnoOtf+L/bQvdYTcBSkU/YiY8JrAw9OERbeSB2CSHiTn7CxI5fOxYlKJr7Vb74wDSJ3iuBV2M4H13/cTXR3yEOnHWurHhtaH5i/foEoCWlheFGIhjBuQGZvRGX6NjmpXB9UH9nJKTFBYqqXJi6/RK0VUA7g9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183474; 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=kxnjZTHqbWGI776astVs1WbWZcQW1SVm+s3NVqJw0e4=; b=cGQvKT1LrDbAd4hyn4CHu04stCvNf2xCBlV/OPdlhhELvExx/knKxEiivJ+kX46fTeMYhio2VQlbJuuIcpHkdOIqSOELDcOzKnYeAtFA6fUsW0ILXHutjS0znCI03fgFAbrtvFcNZGeFl3mN3CjKY0GhAylJibQoRlstbLab6Xg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 161418347424279.37783140577619; Wed, 24 Feb 2021 08:17:54 -0800 (PST) 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-361-QAXrS-a2MNqtmI3J2eYJFA-1; Wed, 24 Feb 2021 11:17:48 -0500 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 BA484801989; Wed, 24 Feb 2021 16:17:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9189E2BFC7; Wed, 24 Feb 2021 16:17:39 +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 26EA358080; Wed, 24 Feb 2021 16:17:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHWS6015566 for ; Wed, 24 Feb 2021 11:17:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7BE5C60CE7; Wed, 24 Feb 2021 16:17:32 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id D141960D79 for ; Wed, 24 Feb 2021 16:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183471; 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=kxnjZTHqbWGI776astVs1WbWZcQW1SVm+s3NVqJw0e4=; b=Am7ROTgLB28u+yHLeFl4ZBBhVzbp2BUDQ4bbR3cPFHL1K1JU1DKTCasCZ8jvHamZAxMYS0 ah85GxhCXLXRNKssx3datFEqNbuhXtvJvIROANEaHsCu9Mavmvxhz1UTCwRB6PQseBUkoL brX4e+/f/1HrUvf8Dx8yQJE0iNdecRA= X-MC-Unique: QAXrS-a2MNqtmI3J2eYJFA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/33] virBuildPath: Remove return value Date: Wed, 24 Feb 2021 17:16:43 +0100 Message-Id: <82427e5ea3589d0ae519a4b06bb1e0decde01eee.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function can't fail nowadays, remove the return value and adjust callers. Signed-off-by: Peter Krempa --- docs/internals/command.html.in | 8 +------- src/util/virfcp.c | 3 +-- src/util/virfile.c | 7 +------ src/util/virfile.h | 2 +- src/util/virhook.c | 14 ++------------ src/util/virpci.c | 11 ++--------- 6 files changed, 8 insertions(+), 37 deletions(-) diff --git a/docs/internals/command.html.in b/docs/internals/command.html.in index 823d89cc71..634afdc937 100644 --- a/docs/internals/command.html.in +++ b/docs/internals/command.html.in @@ -568,13 +568,7 @@ int runhook(const char *drvstr, const char *id, char *path; virCommandPtr cmd; - ret =3D virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr); - if ((ret < 0) || (path =3D=3D NULL)) { - virHookReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to build path for %s hook"), - drvstr); - return -1; - } + virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr); cmd =3D virCommandNew(path); VIR_FREE(path); diff --git a/src/util/virfcp.c b/src/util/virfcp.c index 80773c7c5d..5e8fe72fec 100644 --- a/src/util/virfcp.c +++ b/src/util/virfcp.c @@ -40,8 +40,7 @@ virFCIsCapableRport(const char *rport) { g_autofree char *path =3D NULL; - if (virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport) < 0) - return false; + virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport); return virFileExists(path); } diff --git a/src/util/virfile.c b/src/util/virfile.c index 5710495bbf..27a647d1d0 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1308,13 +1308,12 @@ virFileFindMountPoint(const char *type G_GNUC_UNUSE= D) #endif /* defined WITH_MNTENT_H && defined WITH_GETMNTENT_R */ -int +void virBuildPathInternal(char **path, ...) { char *path_component =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; va_list ap; - int ret =3D 0; va_start(ap, path); @@ -1329,10 +1328,6 @@ virBuildPathInternal(char **path, ...) va_end(ap); *path =3D virBufferContentAndReset(&buf); - if (*path =3D=3D NULL) - ret =3D -1; - - return ret; } /* Read no more than the specified maximum number of bytes. */ diff --git a/src/util/virfile.h b/src/util/virfile.h index 733d652ac9..f237e98290 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -300,7 +300,7 @@ char *virFileFindMountPoint(const char *type); /* NB: this should be combined with virFileBuildPath */ #define virBuildPath(path, ...) \ virBuildPathInternal(path, __VA_ARGS__, NULL) -int virBuildPathInternal(char **path, ...) G_GNUC_NULL_TERMINATED; +void virBuildPathInternal(char **path, ...) G_GNUC_NULL_TERMINATED; typedef struct _virHugeTLBFS virHugeTLBFS; typedef virHugeTLBFS *virHugeTLBFSPtr; diff --git a/src/util/virhook.c b/src/util/virhook.c index e4e1945225..b52e2cd814 100644 --- a/src/util/virhook.c +++ b/src/util/virhook.c @@ -155,12 +155,7 @@ virHookCheck(int no, const char *driver) return -1; } - if (virBuildPath(&path, LIBVIRT_HOOK_DIR, driver) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to build path for %s hook"), - driver); - return -1; - } + virBuildPath(&path, LIBVIRT_HOOK_DIR, driver); if (!virFileExists(path)) { VIR_DEBUG("No hook script %s", path); @@ -405,12 +400,7 @@ virHookCall(int driver, if (extra =3D=3D NULL) extra =3D "-"; - if (virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to build path for %s hook"), - drvstr); - return -1; - } + virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr); script_ret =3D 1; diff --git a/src/util/virpci.c b/src/util/virpci.c index 3df4199532..515b642db4 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2293,10 +2293,7 @@ virPCIGetPhysicalFunction(const char *vf_sysfs_path, *pf =3D NULL; - if (virBuildPath(&device_link, vf_sysfs_path, "physfn") =3D=3D -1) { - virReportOOMError(); - return -1; - } + virBuildPath(&device_link, vf_sysfs_path, "physfn"); if ((*pf =3D virPCIGetDeviceAddressFromSysfsLink(device_link))) { VIR_DEBUG("PF for VF device '%s': " VIR_PCI_DEVICE_ADDRESS_FMT, @@ -2470,11 +2467,7 @@ virPCIGetNetName(const char *device_link_sysfs_path, *netname =3D NULL; - if (virBuildPath(&pcidev_sysfs_net_path, device_link_sysfs_path, - "net") =3D=3D -1) { - virReportOOMError(); - return -1; - } + virBuildPath(&pcidev_sysfs_net_path, device_link_sysfs_path, "net"); if (virDirOpenQuiet(&dir, pcidev_sysfs_net_path) < 0) { /* this *isn't* an error - caller needs to check for netname =3D= =3D NULL */ --=20 2.29.2