From nobody Mon Apr 29 07:34:09 2024 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=1603247194; cv=none; d=zohomail.com; s=zohoarc; b=Izb4VhpDukQK8NRqPYO8Be0dX8C7edu1Fp9Z2oL01LH8Cl9+EXMNjB1J99ls6O8TffDS/uCTY3XTYWKdZ9xSgLQKUxLcS1tSXQmwxt/e+trgC6Xk0bch0SGAS3IW1qXoYG4avnboM7yWz/ioNqunob5H/cp0tA699tUrFd8XK1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603247194; 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=7vuey1XVDagr8qpqZJ320xNIbclm+65s7L/OnBY9vUY=; b=XWuVZpJ1GLQjN5SNfhNkbZxfQK0Iy+hm0qVI5zdpfi/yLUhWcW/0DjCISAr7ISnMSIx3ZebFHCtiK8QppKnCyk+LFk0X1RK8E/0gc1AwirjT41YJMHTcDIXjfvWm98U4mM2H8IzxxngypHpSv1akp9nMgnY7MVYoYpkPcqJ06WQ= 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 160324719488840.93619101674415; Tue, 20 Oct 2020 19:26:34 -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-131-UZBN_4DbOgCTXCjE0URxIQ-1; Tue, 20 Oct 2020 22:26:31 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D94A41006716; Wed, 21 Oct 2020 02:26:25 +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 7260027BDC; Wed, 21 Oct 2020 02:26:25 +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 5BE108C7CB; Wed, 21 Oct 2020 02:26:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09L2QJcN003904 for ; Tue, 20 Oct 2020 22:26:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0DC665C1C2; Wed, 21 Oct 2020 02:26:19 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-130.phx2.redhat.com [10.3.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC1B25C1BB for ; Wed, 21 Oct 2020 02:26:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603247194; 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=7vuey1XVDagr8qpqZJ320xNIbclm+65s7L/OnBY9vUY=; b=Le3S7ndw3mVg9A1WUw9aZaKXbXPo95mQjBXIIoOmDBIPX6HcrAjQeIZ8DH7DGHkLi2POJD 8zXUMCp2mzkqgqNfrAAmx7dNZehxoPfJRG7coOKOrOL31ggFRxAwD/SCIXnUEuMcljr2l2 5JMDLhQJSbOMDTNUTPTvCyPlj0/B958= X-MC-Unique: UZBN_4DbOgCTXCjE0URxIQ-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 1/9] util: simplify virHostdevPCISysfsPath() Date: Tue, 20 Oct 2020 22:26:01 -0400 Message-Id: <20201021022609.2318322-2-laine@redhat.com> In-Reply-To: <20201021022609.2318322-1-laine@redhat.com> References: <20201021022609.2318322-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.84 on 10.5.11.23 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" Apparently at some point in the past, when there were multiple types to represent PCI addresses, the function virPCIDeviceAddressGetSysfsFile() used one of those types, while virDomainHostDevDef used another. It's been quite awhile since we reduced the number of different representations of PCI address, but this function was still creating a temporary virPCIDeviceAddress, then copying the individual elements into this temporary object from the same type of object in the virDomainHostDevDef. This patch just eliminates that pointless copy. Signed-off-by: Laine Stump Reviewed-by: Erik Skultety Reviewed-by: Peter Krempa --- src/hypervisor/virhostdev.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 69102b8ebf..120187b07a 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -285,18 +285,12 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr= *hostdevs, int nhostdevs) return g_steal_pointer(&pcidevs); } =20 + static int virHostdevPCISysfsPath(virDomainHostdevDefPtr hostdev, char **sysfs_path) { - virPCIDeviceAddress config_address; - - config_address.domain =3D hostdev->source.subsys.u.pci.addr.domain; - config_address.bus =3D hostdev->source.subsys.u.pci.addr.bus; - config_address.slot =3D hostdev->source.subsys.u.pci.addr.slot; - config_address.function =3D hostdev->source.subsys.u.pci.addr.function; - - return virPCIDeviceAddressGetSysfsFile(&config_address, sysfs_path); + return virPCIDeviceAddressGetSysfsFile(&hostdev->source.subsys.u.pci.a= ddr, sysfs_path); } =20 =20 --=20 2.26.2 From nobody Mon Apr 29 07:34:09 2024 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=1603247194; cv=none; d=zohomail.com; s=zohoarc; b=dyxtEjXhEmEGiJ2TElnIMoQUT6xFDZLBJLpoRqFwLjZLn1edasI6+bRX27uooC1+Okidr5Q/rmgmuBZkIralwT/z9mUW0fmy+U+ZJg65f9n4G0lLpqwjBpI8RxO6HS7nlU3ltTryUHESiQek2vEEDAEr2XeUXQ8GYWdi4JBz6HE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603247194; 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=FfYvoAe31rQEWABtCuwjBYJCXMnM+EPk8EL54ClggcY=; b=WStxu0+6exd7wcYcclxnRUGFe/Hwr0XbNolLT+RHU7p7xl9EbocwIEGszPyhrci12AiDq1H7xNT0zMUy5ye7SOpo0b3gAZC/l+2BiTx/FILLZ6faFEOMVXykYJUe2P9kQY3VerCwtSIVSREmOcwjedA50SFymoUM96R8+/T76uU= 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 1603247194487308.0721465683646; Tue, 20 Oct 2020 19:26:34 -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-19-wu0na1ACOU-0of9JDAl13g-1; Tue, 20 Oct 2020 22:26:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0D8564093; Wed, 21 Oct 2020 02:26:25 +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 B77A75D9EF; Wed, 21 Oct 2020 02:26:25 +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 E717F180B658; Wed, 21 Oct 2020 02:26:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09L2QJbh003909 for ; Tue, 20 Oct 2020 22:26:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 81D425C1C7; Wed, 21 Oct 2020 02:26:19 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-130.phx2.redhat.com [10.3.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3AD935C1BB for ; Wed, 21 Oct 2020 02:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603247193; 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=FfYvoAe31rQEWABtCuwjBYJCXMnM+EPk8EL54ClggcY=; b=ScQ83jolLmnRr2+mIhVbFVynpOjmzUbgzdbYKYQ7Q24GE/D2J+J7W9D8WzhEyjsZy4fzUI cdaLwybA1ewDT8LhVhPQNRtLPDQQQZylDgu6inhWyX0ncqsHjnoga3aDzqLfQsgRBb5zP7 xdASf5MxE2hKKfN6D2TIGFxHQg0Nizg= X-MC-Unique: wu0na1ACOU-0of9JDAl13g-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 2/9] util: simplify virPCIFile() and its callers Date: Tue, 20 Oct 2020 22:26:02 -0400 Message-Id: <20201021022609.2318322-3-laine@redhat.com> In-Reply-To: <20201021022609.2318322-1-laine@redhat.com> References: <20201021022609.2318322-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.14 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" There is no need for a temporary variable in this function, and ever since we switched to glib for memory allocation, there is no possibility it can return NULL, so callers don't need to check for it. Signed-off-by: Laine Stump Reviewed-by: Erik Skultety Reviewed-by: Peter Krempa --- src/util/virpci.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index 6fa8acd246..0786ddd478 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -219,10 +219,7 @@ virPCIDriverDir(const char *driver) static char * virPCIFile(const char *device, const char *file) { - char *buffer; - - buffer =3D g_strdup_printf(PCI_SYSFS "devices/%s/%s", device, file); - return buffer; + return g_strdup_printf(PCI_SYSFS "devices/%s/%s", device, file); } =20 =20 @@ -240,9 +237,9 @@ virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev, c= har **path, char **name) g_autofree char *drvlink =3D NULL; =20 *path =3D *name =3D NULL; + /* drvlink =3D "/sys/bus/pci/dddd:bb:ss.ff/driver" */ - if (!(drvlink =3D virPCIFile(dev->name, "driver"))) - goto cleanup; + drvlink =3D virPCIFile(dev->name, "driver"); =20 if (!virFileExists(drvlink)) { ret =3D 0; @@ -376,8 +373,7 @@ virPCIDeviceReadClass(virPCIDevicePtr dev, uint16_t *de= vice_class) g_autofree char *id_str =3D NULL; unsigned int value; =20 - if (!(path =3D virPCIFile(dev->name, "class"))) - return -1; + path =3D virPCIFile(dev->name, "class"); =20 /* class string is '0xNNNNNN\n' ... i.e. 9 bytes */ if (virFileReadAll(path, 9, &id_str) < 0) @@ -1054,8 +1050,7 @@ virPCIDeviceUnbind(virPCIDevicePtr dev) /* The device is not bound to any driver */ return 0; =20 - if (!(path =3D virPCIFile(dev->name, "driver/unbind"))) - return -1; + path =3D virPCIFile(dev->name, "driver/unbind"); =20 if (virFileExists(path)) { if (virFileWriteStr(path, dev->name, 0) < 0) { @@ -1111,8 +1106,7 @@ virPCIDeviceBindWithDriverOverride(virPCIDevicePtr de= v, { g_autofree char *path =3D NULL; =20 - if (!(path =3D virPCIFile(dev->name, "driver_override"))) - return -1; + path =3D virPCIFile(dev->name, "driver_override"); =20 if (virFileWriteStr(path, driverName, 0) < 0) { virReportSystemError(errno, @@ -1159,10 +1153,11 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev) return -1; } =20 - if (!(stubDriverPath =3D virPCIDriverDir(stubDriverName)) || - !(driverLink =3D virPCIFile(dev->name, "driver"))) + if (!(stubDriverPath =3D virPCIDriverDir(stubDriverName))) return -1; =20 + driverLink =3D virPCIFile(dev->name, "driver"); + if (virFileExists(driverLink)) { if (virFileLinkPointsTo(driverLink, stubDriverPath)) { /* The device is already bound to the correct driver */ @@ -1259,8 +1254,7 @@ virPCIDeviceReadID(virPCIDevicePtr dev, const char *i= d_name) g_autofree char *path =3D NULL; char *id_str; =20 - if (!(path =3D virPCIFile(dev->name, id_name))) - return NULL; + path =3D virPCIFile(dev->name, id_name); =20 /* ID string is '0xNNNN\n' ... i.e. 7 bytes */ if (virFileReadAll(path, 7, &id_str) < 0) @@ -1924,8 +1918,8 @@ virPCIDeviceAddressGetIOMMUGroupNum(virPCIDeviceAddre= ssPtr addr) devName =3D g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT, addr->domain, = addr->bus, addr->slot, addr->function); =20 - if (!(devPath =3D virPCIFile(devName, "iommu_group"))) - return -1; + devPath =3D virPCIFile(devName, "iommu_group"); + if (virFileIsLink(devPath) !=3D 1) return -2; if (virFileResolveLink(devPath, &groupPath) < 0) { @@ -1973,8 +1967,8 @@ virPCIDeviceGetIOMMUGroupDev(virPCIDevicePtr dev) g_autofree char *groupPath =3D NULL; g_autofree char *groupFile =3D NULL; =20 - if (!(devPath =3D virPCIFile(dev->name, "iommu_group"))) - return NULL; + devPath =3D virPCIFile(dev->name, "iommu_group"); + if (virFileIsLink(devPath) !=3D 1) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid device %s iommu_group file %s is not a s= ymlink"), --=20 2.26.2 From nobody Mon Apr 29 07:34:09 2024 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=1603247211; cv=none; d=zohomail.com; s=zohoarc; b=ghjumt4T17EDVzWzCW4U4ra5TBQKfhgsFo4xgAMw91NfcHs3rV0Bhp2isPmetqJZG9fsUf+r3kPWkG4VccBle7FGDnAu+d/CLmTQnlxqRILfn0jscmIteyo3z+uUHSwosXGjPeOAJa5TuP5wv2uQsG2nnZ8u0l8sVdu+oweRR6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603247211; 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=Usxwvb0mD8FoAOgKcc76uTk+ilVTaXD4ZYo3pCwCDsk=; b=fMwKKNZmHiC4ww0Nk4XPEYlTibr15Wtr0uA04zlhXiCIzUfYlMMTf8YVDrig2efhhhsRCeGN93wKVP771nYjmseSOX/jV9O02cK7tJu+W948JpP8FSeP10G8qe7SiTUPcftAdvgJBfiORG2V6TI+awtSliAM5EoHQOqrLd9sa9s= 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 1603247211222417.9562839147801; Tue, 20 Oct 2020 19:26:51 -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-317-PYetxedaMiOSXKH9SkW2yQ-1; Tue, 20 Oct 2020 22:26:48 -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 973A38049E6; Wed, 21 Oct 2020 02:26:42 +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 7610776642; Wed, 21 Oct 2020 02:26:42 +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 42B5D8C7D3; Wed, 21 Oct 2020 02:26:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09L2QMHR003936 for ; Tue, 20 Oct 2020 22:26:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9CDB85C1C7; Wed, 21 Oct 2020 02:26:22 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-130.phx2.redhat.com [10.3.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57ABE5C1BB for ; Wed, 21 Oct 2020 02:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603247210; 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=Usxwvb0mD8FoAOgKcc76uTk+ilVTaXD4ZYo3pCwCDsk=; b=e+3Rh53jF6GYgQOjSU2c8gibT/KUdy/Tibb6vMvuiNjeaUaod58bR2h4bqK16W4hHVSGUY cuSntRXXyfD0uVRiFhq5VwDXpCXN4iRwf8HxxGWEcShgycVRUpSssbXlY2MUPFzksCOc/h IBHVVI5POSV9UF6iUO2VttSHPvqH6Ok= X-MC-Unique: PYetxedaMiOSXKH9SkW2yQ-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 3/9] util: simplify virPCIDriverDir() and its callers Date: Tue, 20 Oct 2020 22:26:03 -0400 Message-Id: <20201021022609.2318322-4-laine@redhat.com> In-Reply-To: <20201021022609.2318322-1-laine@redhat.com> References: <20201021022609.2318322-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" There is no need for a temporary variable in this function, and since it can't return NULL, no need for callers to check for it. Signed-off-by: Laine Stump Reviewed-by: Erik Skultety Reviewed-by: Peter Krempa --- src/util/virpci.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index 0786ddd478..ac37a60576 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -209,10 +209,7 @@ VIR_ONCE_GLOBAL_INIT(virPCI); static char * virPCIDriverDir(const char *driver) { - char *buffer; - - buffer =3D g_strdup_printf(PCI_SYSFS "drivers/%s", driver); - return buffer; + return g_strdup_printf(PCI_SYSFS "drivers/%s", driver); } =20 =20 @@ -1002,7 +999,9 @@ virPCIProbeStubDriver(virPCIStubDriver driver) } =20 recheck: - if ((drvpath =3D virPCIDriverDir(drvname)) && virFileExists(drvpath)) + drvpath =3D virPCIDriverDir(drvname); + + if (virFileExists(drvpath)) /* driver already loaded, return */ return 0; =20 @@ -1153,9 +1152,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev) return -1; } =20 - if (!(stubDriverPath =3D virPCIDriverDir(stubDriverName))) - return -1; - + stubDriverPath =3D virPCIDriverDir(stubDriverName); driverLink =3D virPCIFile(dev->name, "driver"); =20 if (virFileExists(driverLink)) { --=20 2.26.2 From nobody Mon Apr 29 07:34:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1603247289; cv=none; d=zohomail.com; s=zohoarc; b=FFVzgQJ2toQPdKD3UoRapdTXM8Hm2ChDrp1tmvuTcV+MjiEPQF735PIQYljMmHESjtm47To4dPfGbqZsmJhRFUfIAV++JtfHjXZVd2Pn/g47LaH/HGVB/MvA0l/8uN5HRrTdYG2iDs/rW15JNyzjPmQryEuItlYJpOlADG3bP64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603247289; 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=7b39pMsDv1/iF4jWxBZmk9LZY6bLH7U8aWimRINFu+I=; b=b94Jg7MAPDNyNHAP9Fl7hVwgxUQ2gnK1kL9B3+R0OCsL1Rlm1jYFH0BzIEZIWCpOkYLWdXgcwsHLllGBtb9uRYEzwhWfhBQQBKuUV9XVv4O9H2ySX/uf1djjBoFWr0Es0TQYKH6qMjQic+2S9goT5CvdozS14oFwml0zpI0da08= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603247289922187.7137305700287; Tue, 20 Oct 2020 19:28:09 -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-389-w3Dm_gnNNWKfUADVfsDsRA-1; Tue, 20 Oct 2020 22:26:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 61C94803F4E; Wed, 21 Oct 2020 02:26:45 +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 424D76EF69; Wed, 21 Oct 2020 02:26:45 +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 10D7B1826D39; Wed, 21 Oct 2020 02:26:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09L2QPpD003953 for ; Tue, 20 Oct 2020 22:26:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 80E445C1C2; Wed, 21 Oct 2020 02:26:25 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-130.phx2.redhat.com [10.3.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38C455C1BB for ; Wed, 21 Oct 2020 02:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603247289; 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=7b39pMsDv1/iF4jWxBZmk9LZY6bLH7U8aWimRINFu+I=; b=ioAAFotHeSQq8lXF2txyVSsKR/984HtS7+2odLJiWaG+Zdgmm6PEDuq4MRo9zTgKTpm/Yu sNJSOdypLByVpvHfZiHlkpO5q1H3RUgRAvf3JEohqROt0N1VsA5xhW5cTQiJ+IZCYxffGc 6GV4eoau1Lo7xvMO2cN3nLRLUcYa/rs= X-MC-Unique: w3Dm_gnNNWKfUADVfsDsRA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 4/9] util: simplify virPCIProbeStubDriver() Date: Tue, 20 Oct 2020 22:26:04 -0400 Message-Id: <20201021022609.2318322-5-laine@redhat.com> In-Reply-To: <20201021022609.2318322-1-laine@redhat.com> References: <20201021022609.2318322-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.13 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" This function had a loop that was only executed twice; it was artificially constructed with a label, a goto, and a boolean to tell that it had already been executed once. Aside from that, the body of the loop contained only two lines that needed to be repeated (the second time through, everything beyond those two lines would be skipped). One side effect of this strange loop was that a g_autofree string was manually freed and re-initialized; I've been told that manually freeing a g_auto_free object is highly discouraged. This patch refactors the function to simply repeat the 2 lines that might possibly be executed twice, thus eliminating the ugly use of goto to construct a loop, and also takes advantage of the fact that virPCIDriverDir() was previously returning *exactly* the same string both times it was called to eliminate the manual VIR_FREE of drvpath. Signed-off-by: Laine Stump Reviewed-by: Erik Skultety Reviewed-by: Peter Krempa --- src/util/virpci.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index ac37a60576..045121c453 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -988,7 +988,7 @@ virPCIProbeStubDriver(virPCIStubDriver driver) { const char *drvname =3D NULL; g_autofree char *drvpath =3D NULL; - bool probed =3D false; + g_autofree char *errbuf =3D NULL; =20 if (driver =3D=3D VIR_PCI_STUB_DRIVER_NONE || !(drvname =3D virPCIStubDriverTypeToString(driver))) { @@ -998,25 +998,21 @@ virPCIProbeStubDriver(virPCIStubDriver driver) return -1; } =20 - recheck: drvpath =3D virPCIDriverDir(drvname); =20 + /* driver previously loaded, return */ if (virFileExists(drvpath)) - /* driver already loaded, return */ return 0; =20 - if (!probed) { - g_autofree char *errbuf =3D NULL; - probed =3D true; - if ((errbuf =3D virKModLoad(drvname))) { - VIR_WARN("failed to load driver %s: %s", drvname, errbuf); - goto cleanup; - } - - VIR_FREE(drvpath); - goto recheck; + if ((errbuf =3D virKModLoad(drvname))) { + VIR_WARN("failed to load driver %s: %s", drvname, errbuf); + goto cleanup; } =20 + /* driver loaded after probing */ + if (virFileExists(drvpath)) + return 0; + cleanup: /* If we know failure was because of admin config, let's report that; * otherwise, report a more generic failure message --=20 2.26.2 From nobody Mon Apr 29 07:34:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1603247211; cv=none; d=zohomail.com; s=zohoarc; b=QqOZ4dYLCDMunDz8Ou7JUG6keDnc3ALsF+8xgbr+YDOq6r8X2eoXxzAOslMeoBN+RvQJ6XUMgEPcurd4XQ58OqxAlzPr1vgXEHxW05DjuVUxgZ++fKAjFBMF2OHaGfBd1hEKuYro8Obc3qFcDe3QfbSEbILVO0WOslpDDfe/bZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603247211; 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=8dXtZNWcr8riL/Ef5N00GJu0gzs4t4xBpaxW6CttBRQ=; b=Oe9Qh3/OB6U8SOi90JPGirGudRn4W1a60BkYyaNCCAzEpAZbaFHFbcFcnjKPEOCAZy9ToyQtC6TxUZsj+32Q7MTd5BVTFwX15qLKfSaktljHggMcfXitv8Qo5Zc4pH6XIrnQQa8+BFYUy08KDoupj54ze1uS6ULDUFHRlUOBJ7A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603247211329858.0746717444347; Tue, 20 Oct 2020 19:26:51 -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-324-YsPgZ81mMBWOg2-Rp9Sr_w-1; Tue, 20 Oct 2020 22:26:47 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BF7FD18A076A; Wed, 21 Oct 2020 02:26:42 +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 97D8A5C1C7; Wed, 21 Oct 2020 02:26:42 +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 3C6D3180610F; Wed, 21 Oct 2020 02:26:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09L2QQvL003959 for ; Tue, 20 Oct 2020 22:26:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id F2B0D5C1C2; Wed, 21 Oct 2020 02:26:25 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-130.phx2.redhat.com [10.3.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC1E45C1BB for ; Wed, 21 Oct 2020 02:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603247210; 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=8dXtZNWcr8riL/Ef5N00GJu0gzs4t4xBpaxW6CttBRQ=; b=QK0v85R5rDzqm9komnrARIeZZdiLSsteEj2lfLsFRkXVRweKIPryHZCXscbXNEQTDQo3UT OZZ5YdKGJHfmwKrTA8ANGRPwTch1TqbGbitkyvRGY7gKk1kbXAwz75a53qWMU1ptJ8XfPa 2kSaBn2czJel1qtMGKSbdw8tztZQSIs= X-MC-Unique: YsPgZ81mMBWOg2-Rp9Sr_w-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 5/9] util: avoid manual VIR_FREE of a g_autofree pointer in virPCIGetName() Date: Tue, 20 Oct 2020 22:26:05 -0400 Message-Id: <20201021022609.2318322-6-laine@redhat.com> In-Reply-To: <20201021022609.2318322-1-laine@redhat.com> References: <20201021022609.2318322-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.16 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" thisPhysPortID is only used inside a conditional, so reduce its scope to just the body of that conditional, which will eliminate the need for the undesirable manual VIR_FREE(). Signed-off-by: Laine Stump Reviewed-by: Erik Skultety Reviewed-by: Peter Krempa --- src/util/virpci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index 045121c453..3ca513702e 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2408,7 +2408,6 @@ virPCIGetNetName(const char *device_link_sysfs_path, { g_autofree char *pcidev_sysfs_net_path =3D NULL; g_autofree char *firstEntryName =3D NULL; - g_autofree char *thisPhysPortID =3D NULL; int ret =3D -1; DIR *dir =3D NULL; struct dirent *entry =3D NULL; @@ -2433,12 +2432,13 @@ virPCIGetNetName(const char *device_link_sysfs_path, * physportID of this netdev. If not, look for entry[idx]. */ if (physPortID) { + g_autofree char *thisPhysPortID =3D NULL; + if (virNetDevGetPhysPortID(entry->d_name, &thisPhysPortID) < 0) goto cleanup; =20 /* if this one doesn't match, keep looking */ if (STRNEQ_NULLABLE(physPortID, thisPhysPortID)) { - VIR_FREE(thisPhysPortID); /* save the first entry we find to use as a failsafe * in case we don't match the phys_port_id. This is * needed because some NIC drivers (e.g. i40e) --=20 2.26.2 From nobody Mon Apr 29 07:34:09 2024 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=1603247277; cv=none; d=zohomail.com; s=zohoarc; b=bQcohu/kPpkbXQSN7iLqzaIkgvEhX1T603nry2KbkQfL9FRmRoQUebevLMoic6TO2D1XDL+lgQWLfton74uw3Qgg8wngBardwazyBLMGf4H7hFKyFQLfIBdWGufe6LPMuUQLY6AK4q+YlmHhZJTjJ0jmBdeyJrxfag4gTy7G8d8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603247277; 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=+5i4LQgOwfDPicxWr8AFuaVJSFs51CvriQFSPlDXHRs=; b=k4ZmWZFOSbH/bl5frhs6DhMA6NY/uzqbmd1l6MLvJYEKge0vtfBBHEAuPgHSi3BReAkt92nFiC0XJ7hKokNFlJtq9kh3TKlIBIWcQuANRCeISm9YpOlNRdQXAbPA/6xa2+aZUqkBBoorwJoTsxbOdlbHR0yLCYuhqMEqZnB1dxE= 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 1603247277065434.2634435815978; Tue, 20 Oct 2020 19:27:57 -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-501-t7NdZALOMaKJfySjX0qfzg-1; Tue, 20 Oct 2020 22:26:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 60E646409A; Wed, 21 Oct 2020 02:26:45 +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 3CA955C1C2; Wed, 21 Oct 2020 02:26:45 +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 094AB8C7D8; Wed, 21 Oct 2020 02:26:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09L2QQI3003965 for ; Tue, 20 Oct 2020 22:26:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 713575C1C2; Wed, 21 Oct 2020 02:26:26 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-130.phx2.redhat.com [10.3.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B8025C1BB for ; Wed, 21 Oct 2020 02:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603247276; 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=+5i4LQgOwfDPicxWr8AFuaVJSFs51CvriQFSPlDXHRs=; b=aJ9WKEDjAUStYU23x4xAejR0Otic4MUh105sbDz5z36W/0F5LyPzdejOFdSrk9cQsaDe9X AOBgkvdUwKAKsmAcDUULA5wLHNe59/E9lZXjENs09X3LnUxaPUYZqJpe3AixAzmUedHWs2 9O8AZ8fD0f1kesvQ3x+EFcLKq2b00c4= X-MC-Unique: t7NdZALOMaKJfySjX0qfzg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 6/9] util: use more g_autofree in virpci.c Date: Tue, 20 Oct 2020 22:26:06 -0400 Message-Id: <20201021022609.2318322-7-laine@redhat.com> In-Reply-To: <20201021022609.2318322-1-laine@redhat.com> References: <20201021022609.2318322-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.16 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" Signed-off-by: Laine Stump Reviewed-by: Erik Skultety Reviewed-by: Peter Krempa --- src/util/virpci.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index 3ca513702e..c7ee259e29 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1245,7 +1245,7 @@ static char * virPCIDeviceReadID(virPCIDevicePtr dev, const char *id_name) { g_autofree char *path =3D NULL; - char *id_str; + g_autofree char *id_str =3D NULL; =20 path =3D virPCIFile(dev->name, id_name); =20 @@ -1254,15 +1254,13 @@ virPCIDeviceReadID(virPCIDevicePtr dev, const char = *id_name) return NULL; =20 /* Check for 0x suffix */ - if (id_str[0] !=3D '0' || id_str[1] !=3D 'x') { - VIR_FREE(id_str); + if (id_str[0] !=3D '0' || id_str[1] !=3D 'x') return NULL; - } =20 /* Chop off the newline; we know the string is 7 bytes */ id_str[6] =3D '\0'; =20 - return id_str; + return g_steal_pointer(&id_str); } =20 bool @@ -1853,7 +1851,7 @@ virPCIGetIOMMUGroupAddressesAddOne(virPCIDeviceAddres= sPtr newDevAddr, void *opaq { int ret =3D -1; virPCIDeviceAddressListPtr addrList =3D opaque; - virPCIDeviceAddressPtr copyAddr; + g_autofree virPCIDeviceAddressPtr copyAddr =3D NULL; =20 /* make a copy to insert onto the list */ copyAddr =3D g_new0(virPCIDeviceAddress, 1); @@ -1866,7 +1864,6 @@ virPCIGetIOMMUGroupAddressesAddOne(virPCIDeviceAddres= sPtr newDevAddr, void *opaq =20 ret =3D 0; cleanup: - VIR_FREE(copyAddr); return ret; } =20 @@ -2170,7 +2167,7 @@ virZPCIDeviceAddressIsPresent(const virZPCIDeviceAddr= ess *addr) virPCIDeviceAddressPtr virPCIGetDeviceAddressFromSysfsLink(const char *device_link) { - virPCIDeviceAddressPtr bdf =3D NULL; + g_autofree virPCIDeviceAddressPtr bdf =3D NULL; g_autofree char *config_address =3D NULL; g_autofree char *device_path =3D NULL; =20 @@ -2194,11 +2191,10 @@ virPCIGetDeviceAddressFromSysfsLink(const char *dev= ice_link) virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to parse PCI config address '%s'"), config_address); - VIR_FREE(bdf); return NULL; } =20 - return bdf; + return g_steal_pointer(&bdf); } =20 /** @@ -2251,7 +2247,7 @@ virPCIGetVirtualFunctions(const char *sysfs_path, size_t i; g_autofree char *totalvfs_file =3D NULL; g_autofree char *totalvfs_str =3D NULL; - virPCIDeviceAddressPtr config_addr =3D NULL; + g_autofree virPCIDeviceAddressPtr config_addr =3D NULL; =20 *virtual_functions =3D NULL; *num_virtual_functions =3D 0; @@ -2296,7 +2292,6 @@ virPCIGetVirtualFunctions(const char *sysfs_path, *num_virtual_functions, sysfs_path); ret =3D 0; cleanup: - VIR_FREE(config_addr); return ret; =20 error: @@ -2333,7 +2328,7 @@ virPCIGetVirtualFunctionIndex(const char *pf_sysfs_de= vice_link, size_t i; size_t num_virt_fns =3D 0; unsigned int max_virt_fns =3D 0; - virPCIDeviceAddressPtr vf_bdf =3D NULL; + g_autofree virPCIDeviceAddressPtr vf_bdf =3D NULL; virPCIDeviceAddressPtr *virt_fns =3D NULL; =20 if (!(vf_bdf =3D virPCIGetDeviceAddressFromSysfsLink(vf_sysfs_device_l= ink))) @@ -2362,8 +2357,6 @@ virPCIGetVirtualFunctionIndex(const char *pf_sysfs_de= vice_link, VIR_FREE(virt_fns[i]); =20 VIR_FREE(virt_fns); - VIR_FREE(vf_bdf); - return ret; } =20 @@ -2492,7 +2485,7 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_dev= ice_path, char **pfname, int *vf_index) { - virPCIDeviceAddressPtr pf_config_address =3D NULL; + g_autofree virPCIDeviceAddressPtr pf_config_address =3D NULL; g_autofree char *pf_sysfs_device_path =3D NULL; g_autofree char *vfname =3D NULL; g_autofree char *vfPhysPortID =3D NULL; @@ -2549,8 +2542,6 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_dev= ice_path, =20 ret =3D 0; cleanup: - VIR_FREE(pf_config_address); - return ret; } =20 --=20 2.26.2 From nobody Mon Apr 29 07:34:09 2024 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=1603247215; cv=none; d=zohomail.com; s=zohoarc; b=Xd5pV4NbPGW+y8JQ1oTm02QWyijlyKzaHQTrfOqClPKkgAxZcHrVZBkPkZOrK7mU/OODsrqLDCqKR2YijbJlMWguc9mseJi/EcIphoSr9JnTd7numLqMTRgwf3nVpu5UQ3Qb+yfbIbHHxyxBozLtGrLOTVYjzXzF6x+QWNOjCuc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603247215; 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=YwBWVss0ozaHfB9xOwFOaIzFEto5XBV+a1nK9gzDkec=; b=DgZpmedf1mGcPsQ/g4TFozlRsdw4RpS+xFKu38UugTqzXiDSyNyFiq/Ug58+8E2a3bnZhPvOw4W51dYyUh0A+O7YMMJKQTptSY7cyffpBAtVO3X7dLNovRyik0zkOcsQLrsBFBEZJ9kz/gTPLH3MvhxF9gqaCW8y+P3EJiZhSbc= 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 160324721500467.53614270996331; Tue, 20 Oct 2020 19:26:55 -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-75--I4lqt4RPXeUY0Y1UL0rIA-1; Tue, 20 Oct 2020 22:26:52 -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 4286F64090; Wed, 21 Oct 2020 02:26:45 +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 265DF5B4C3; Wed, 21 Oct 2020 02:26:45 +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 E58F91800B6C; Wed, 21 Oct 2020 02:26:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09L2QQOa003971 for ; Tue, 20 Oct 2020 22:26:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id E1E005C1C2; Wed, 21 Oct 2020 02:26:26 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-130.phx2.redhat.com [10.3.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C4F45C1BB for ; Wed, 21 Oct 2020 02:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603247214; 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=YwBWVss0ozaHfB9xOwFOaIzFEto5XBV+a1nK9gzDkec=; b=LvYFv+SiU4zszQtwwsOtRQMtf6Q4nJ3u/cKyjaNxq0Ki7Ir1PYqfJRP61p28/t6l73YaZ+ BKSrTrYhNdnlCt52hlJztjTqq+JKM/OOYp4jtePAfCHzzFmj0i1BNEHf/hv0e3y3iWnU3Z ara73cy6LBRUPgmrqYzZTeKaShNTdAs= X-MC-Unique: -I4lqt4RPXeUY0Y1UL0rIA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 7/9] util: remove unneeded cleanup:/ret in virpci.c Date: Tue, 20 Oct 2020 22:26:07 -0400 Message-Id: <20201021022609.2318322-8-laine@redhat.com> In-Reply-To: <20201021022609.2318322-1-laine@redhat.com> References: <20201021022609.2318322-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" These were nops once enough cleanup was g_auto'd. Signed-off-by: Laine Stump Reviewed-by: Erik Skultety Reviewed-by: Peter Krempa --- src/util/virpci.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index c7ee259e29..855872031e 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1849,7 +1849,6 @@ typedef virPCIDeviceAddressList *virPCIDeviceAddressL= istPtr; static int virPCIGetIOMMUGroupAddressesAddOne(virPCIDeviceAddressPtr newDevAddr, void= *opaque) { - int ret =3D -1; virPCIDeviceAddressListPtr addrList =3D opaque; g_autofree virPCIDeviceAddressPtr copyAddr =3D NULL; =20 @@ -1860,11 +1859,9 @@ virPCIGetIOMMUGroupAddressesAddOne(virPCIDeviceAddre= ssPtr newDevAddr, void *opaq =20 if (VIR_APPEND_ELEMENT(*addrList->iommuGroupDevices, *addrList->nIommuGroupDevices, copyAddr) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -2243,7 +2240,6 @@ virPCIGetVirtualFunctions(const char *sysfs_path, size_t *num_virtual_functions, unsigned int *max_virtual_functions) { - int ret =3D -1; size_t i; g_autofree char *totalvfs_file =3D NULL; g_autofree char *totalvfs_str =3D NULL; @@ -2290,16 +2286,14 @@ virPCIGetVirtualFunctions(const char *sysfs_path, =20 VIR_DEBUG("Found %zu virtual functions for %s", *num_virtual_functions, sysfs_path); - ret =3D 0; - cleanup: - return ret; + return 0; =20 error: for (i =3D 0; i < *num_virtual_functions; i++) VIR_FREE((*virtual_functions)[i]); VIR_FREE(*virtual_functions); *num_virtual_functions =3D 0; - goto cleanup; + return -1; } =20 =20 @@ -2489,22 +2483,21 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_d= evice_path, g_autofree char *pf_sysfs_device_path =3D NULL; g_autofree char *vfname =3D NULL; g_autofree char *vfPhysPortID =3D NULL; - int ret =3D -1; =20 if (virPCIGetPhysicalFunction(vf_sysfs_device_path, &pf_config_address= ) < 0) - goto cleanup; + return -1; =20 if (!pf_config_address) - goto cleanup; + return -1; =20 if (virPCIDeviceAddressGetSysfsFile(pf_config_address, &pf_sysfs_device_path) < 0) { - goto cleanup; + return -1; } =20 if (virPCIGetVirtualFunctionIndex(pf_sysfs_device_path, vf_sysfs_device_path, vf_index) < 0)= { - goto cleanup; + return -1; } =20 /* If the caller hasn't asked for a specific pfNetDevIdx, and VF @@ -2516,18 +2509,18 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_d= evice_path, */ if (pfNetDevIdx =3D=3D -1) { if (virPCIGetNetName(vf_sysfs_device_path, 0, NULL, &vfname) < 0) - goto cleanup; + return -1; =20 if (vfname) { if (virNetDevGetPhysPortID(vfname, &vfPhysPortID) < 0) - goto cleanup; + return -1; } pfNetDevIdx =3D 0; } =20 if (virPCIGetNetName(pf_sysfs_device_path, pfNetDevIdx, vfPhysPortID, pfname) < 0) { - goto cleanup; + return -1; } =20 if (!*pfname) { @@ -2537,12 +2530,10 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_d= evice_path, virReportError(VIR_ERR_INTERNAL_ERROR, _("The PF device for VF %s has no network device na= me"), vf_sysfs_device_path); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 --=20 2.26.2 From nobody Mon Apr 29 07:34:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1603247217; cv=none; d=zohomail.com; s=zohoarc; b=f/coAZdtCejaPV2uaPW8swBtWeVQ2b9Ce2BSuYn+PKYzs280Xy5NpmGHz1dXaFvt5rkGk8K2+0DuZc8f8ygYTMz3bBCRxsbdlaTicofwkNTcmY28WeO/cpMdgyeRNxx8NEPoiF+hlgVdZFqZmxLt1PvhIaitPzG9uKhOI7qrnD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603247217; 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=y4DgFQrpUVsRM1R/mKlY0i6Eo8oJmnxr7ged2Vq6PE8=; b=YqU2f9UIyM3D3zKbkRWEHXXufzeMxwf5QZWUQWjdic4fO910npygkXyvX4s8u2ts+cNe899Jo1lM4I8d2J8AyF6yd3T9C/SMA9CzTgSMawd6B47GUJ8lrF2fw0BQPdwOHw6EGLufAsxytbbiwYSg+/KLRHlzjkjtqAMobi8GfsQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 160324721721781.72708420785318; Tue, 20 Oct 2020 19:26:57 -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-196-HtoJeMIcNVCtB9AcSIhPYg-1; Tue, 20 Oct 2020 22:26:54 -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 F003318A076E; Wed, 21 Oct 2020 02:26:47 +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 D2A6F5B4AE; Wed, 21 Oct 2020 02:26:47 +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 9C9DE8C7DA; Wed, 21 Oct 2020 02:26:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09L2QRLv003977 for ; Tue, 20 Oct 2020 22:26:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 600CE5C1C2; Wed, 21 Oct 2020 02:26:27 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-130.phx2.redhat.com [10.3.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B80B5C1BB for ; Wed, 21 Oct 2020 02:26:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603247216; 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=y4DgFQrpUVsRM1R/mKlY0i6Eo8oJmnxr7ged2Vq6PE8=; b=NuLbvL5ISKp85HDaQBbGqPKz443I4fkI3k3+IRHb6Jfs9iiso/k7mPucfRiK0dvBx3ThL5 NpA5QnNXBADAkbzx+OGVjQayssAbjJeQ4s0Z7Z7h9qRHh/f2DXH6aqisR+mp357YyBcqx/ 6ce2/OFBMQHKIMhmNka2GL40nzLMz50= X-MC-Unique: HtoJeMIcNVCtB9AcSIhPYg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 8/9] util: don't use virPCIGetSysfsFile() Date: Tue, 20 Oct 2020 22:26:08 -0400 Message-Id: <20201021022609.2318322-9-laine@redhat.com> In-Reply-To: <20201021022609.2318322-1-laine@redhat.com> References: <20201021022609.2318322-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" virPCIDeviceAddressGetSysfsFile() is simpler to call. Signed-off-by: Laine Stump Reviewed-by: Erik Skultety Reviewed-by: Peter Krempa --- src/util/virnetdev.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 088f35621d..e284d62233 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1212,13 +1212,9 @@ virNetDevGetVirtualFunctions(const char *pfname, *vfname =3D g_new0(char *, *n_vfname); =20 for (i =3D 0; i < *n_vfname; i++) { - g_autofree char *pciConfigAddr =3D NULL; g_autofree char *pci_sysfs_device_link =3D NULL; =20 - if (!(pciConfigAddr =3D virPCIDeviceAddressAsString((*virt_fns)[i]= ))) - goto cleanup; - - if (virPCIGetSysfsFile(pciConfigAddr, &pci_sysfs_device_link) < 0)= { + if (virPCIDeviceAddressGetSysfsFile((*virt_fns)[i], &pci_sysfs_dev= ice_link) < 0) { virReportSystemError(ENOSYS, "%s", _("Failed to get PCI SYSFS file")); goto cleanup; --=20 2.26.2 From nobody Mon Apr 29 07:34:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1603247300; cv=none; d=zohomail.com; s=zohoarc; b=GalYUuD+474wMtp1E4yB9lsYrOxoiT9pFDiXLmbZEGWJss6P6LF89PUKw20KsHRzZM5ycvMSET1hjlzW13XkENjrE7YpHCnTgBKGhSmTgyW3Lp+PfsSq7n3MzBdgMQFDm9rcOY8VPiTh0OTePSO/aQ2CuSjNrNUf6j67ZaFUkhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603247300; 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=faL8KwGzEEgtAeF9pQ2GcSXnjLcich2SxQeV8+NgXJ0=; b=IESa+zmwrILWCkSoTnu/e6qNaoTVQSftx3/Yt0bRpEG3500OME7WtQ+5WUehCM5/vrK/kIjxkWF2q6boXrQSjWq/4uCCf/l4yI7SLtcKGA/nRb95tWUUQgvZ/NHahAEjOS2/92NoyCkRBxCKI6/ZPq3rpbXWfnWOXTfQV4sT5+w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603247300454658.5002438221732; Tue, 20 Oct 2020 19:28:20 -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-354-20x6zkYOMu287tIhu1YMGw-1; Tue, 20 Oct 2020 22:26:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 12539107AFB7; Wed, 21 Oct 2020 02:26:48 +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 DECC05C1C7; Wed, 21 Oct 2020 02:26:47 +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 AD4A68C7DC; Wed, 21 Oct 2020 02:26:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09L2QRr9003987 for ; Tue, 20 Oct 2020 22:26:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id CEADC5C1C2; Wed, 21 Oct 2020 02:26:27 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-130.phx2.redhat.com [10.3.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B20A5C1BB for ; Wed, 21 Oct 2020 02:26:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603247295; 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=faL8KwGzEEgtAeF9pQ2GcSXnjLcich2SxQeV8+NgXJ0=; b=PDcqPLoQoD0f4HGX5ZehUfvfkuZpx0f4ccU5UYplhtcKXrjSaveyg4S97vjPepudC5oD0N ly+xv7DKxBEqmakDtk5BdgqhSum92rVNg8nyeYxXnnDqf3MZmWXdXRt0jNfE8xQ7mSDbG/ LSvHdelSwfp063XUa/zdL5anc1QBToc= X-MC-Unique: 20x6zkYOMu287tIhu1YMGw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 9/9] util: remove unused function virPCIGetSysfsFile() Date: Tue, 20 Oct 2020 22:26:09 -0400 Message-Id: <20201021022609.2318322-10-laine@redhat.com> In-Reply-To: <20201021022609.2318322-1-laine@redhat.com> References: <20201021022609.2318322-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.16 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" Signed-off-by: Laine Stump Reviewed-by: Erik Skultety Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 1 - src/util/virpci.c | 15 --------------- src/util/virpci.h | 4 ---- 3 files changed, 20 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ae543589f1..b2d786409b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2849,7 +2849,6 @@ virPCIGetHeaderType; virPCIGetMdevTypes; virPCIGetNetName; virPCIGetPhysicalFunction; -virPCIGetSysfsFile; virPCIGetVirtualFunctionIndex; virPCIGetVirtualFunctionInfo; virPCIGetVirtualFunctions; diff --git a/src/util/virpci.c b/src/util/virpci.c index 855872031e..1f679a7b45 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2358,14 +2358,6 @@ virPCIGetVirtualFunctionIndex(const char *pf_sysfs_d= evice_link, * Returns a path to the PCI sysfs file given the BDF of the PCI function */ =20 -int -virPCIGetSysfsFile(char *virPCIDeviceName, char **pci_sysfs_device_link) -{ - *pci_sysfs_device_link =3D g_strdup_printf(PCI_SYSFS "devices/%s", - virPCIDeviceName); - return 0; -} - int virPCIDeviceAddressGetSysfsFile(virPCIDeviceAddressPtr addr, char **pci_sysfs_device_link) @@ -2633,13 +2625,6 @@ virPCIGetVirtualFunctionIndex(const char *pf_sysfs_d= evice_link G_GNUC_UNUSED, =20 } =20 -int -virPCIGetSysfsFile(char *virPCIDeviceName G_GNUC_UNUSED, - char **pci_sysfs_device_link G_GNUC_UNUSED) -{ - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported)); - return -1; -} =20 int virPCIDeviceAddressGetSysfsFile(virPCIDeviceAddressPtr dev G_GNUC_UNUSED, diff --git a/src/util/virpci.h b/src/util/virpci.h index b3322ba61b..1f896ca481 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -234,10 +234,6 @@ int virPCIGetNetName(const char *device_link_sysfs_pat= h, char *physPortID, char **netname); =20 -int virPCIGetSysfsFile(char *virPCIDeviceName, - char **pci_sysfs_device_link) - G_GNUC_WARN_UNUSED_RESULT; - bool virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr, bool report); bool virPCIDeviceAddressIsEmpty(const virPCIDeviceAddress *addr); --=20 2.26.2