From nobody Mon Feb 9 10:27:36 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=1607477902; cv=none; d=zohomail.com; s=zohoarc; b=Hoa161SRtO3vq5b1J951ihyandln5XdgZKZfxv4CrlH4oZKFx8tg65L4Nol7kulywl21knY/FhocZK8NE4BTzaJQmMJhijff6+MIt0dLEQ2zRP0A6Y5sEBvP0tX57fN3u/pv0RSuM0JfxDKS/hWh1oubczU16HdrGkcGhZhbcIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607477902; 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=NuMdpFC/V+Dyw8ez/m/KfYOwUD2pbure1i7s3wnXcOw=; b=hC0TOgE/wyYsLd19agC8QEXmWNWpiWDSKkT0WgkNRjHvx0qJIxfRO4t451iAIkyYaYLfW05109hxKbrNPQUl66/1xYAaAc6gLf0lElGXxbUw3WRSCkk7q38WN9bLh/7eVK+4o6sbSgMF1e8UTERI5uC5KMv6yjsKT+RXvwaj8+s= 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 1607477901997258.735782073535; Tue, 8 Dec 2020 17:38:21 -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-457-zTJXumyzOviEomGqlcjfag-1; Tue, 08 Dec 2020 20:38:18 -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 4DA845210; Wed, 9 Dec 2020 01:38:12 +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 2A9AE13470; Wed, 9 Dec 2020 01:38:12 +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 B29F71809CA1; Wed, 9 Dec 2020 01:38:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B91bpoM007388 for ; Tue, 8 Dec 2020 20:37:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id A39805D6D5; Wed, 9 Dec 2020 01:37:51 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-50.phx2.redhat.com [10.3.112.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AB145D6AB for ; Wed, 9 Dec 2020 01:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607477901; 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=NuMdpFC/V+Dyw8ez/m/KfYOwUD2pbure1i7s3wnXcOw=; b=TK0OBMjM3Kssb8zL9N/sDpqaje7pd7MQpck4YsJ9fDVL3QPgHXE4RBTh66U7BXTacfg2qk axEcKtRguVzlNQ7N5G2pg0aMhei9q/dVDzmWUnklawGJ0/gOvS+zKv2ef4ipmspvkJ3Dkn EwDLF1dKUhtUsf7nPUMLDZle5W+jfXY= X-MC-Unique: zTJXumyzOviEomGqlcjfag-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 2/7] util: simplify calling of virPCIDeviceDetectFunctionLevelReset() Date: Tue, 8 Dec 2020 20:37:40 -0500 Message-Id: <20201209013745.599662-3-laine@redhat.com> In-Reply-To: <20201209013745.599662-1-laine@redhat.com> References: <20201209013745.599662-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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" This function returned an int, and that int was being checked for < 0 in its solitary caller, but within the function it would only ever return 0 or 1. Change the function itself to return a bool, and the caller to just directly set the flag in the virPCIDevice. Signed-off-by: Laine Stump --- src/util/virpci.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index b63abac8cc..403ef1ec8e 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -549,7 +549,7 @@ virPCIDeviceFindExtendedCapabilityOffset(virPCIDevicePt= r dev, /* detects whether this device has FLR. Returns 0 if the device does * not have FLR, 1 if it does, and -1 on error */ -static int +static bool virPCIDeviceDetectFunctionLevelReset(virPCIDevicePtr dev, int cfgfd) { uint32_t caps; @@ -567,7 +567,7 @@ virPCIDeviceDetectFunctionLevelReset(virPCIDevicePtr de= v, int cfgfd) caps =3D virPCIDeviceRead32(dev, cfgfd, dev->pcie_cap_pos + PCI_EX= P_DEVCAP); if (caps & PCI_EXP_DEVCAP_FLR) { VIR_DEBUG("%s %s: detected PCIe FLR capability", dev->id, dev-= >name); - return 1; + return true; } } =20 @@ -580,7 +580,7 @@ virPCIDeviceDetectFunctionLevelReset(virPCIDevicePtr de= v, int cfgfd) caps =3D virPCIDeviceRead16(dev, cfgfd, pos + PCI_AF_CAP); if (caps & PCI_AF_CAP_FLR) { VIR_DEBUG("%s %s: detected PCI FLR capability", dev->id, dev->= name); - return 1; + return true; } } =20 @@ -596,12 +596,12 @@ virPCIDeviceDetectFunctionLevelReset(virPCIDevicePtr = dev, int cfgfd) if (found) { VIR_DEBUG("%s %s: buggy device didn't advertise FLR, but is a VF; = forcing flr on", dev->id, dev->name); - return 1; + return true; } =20 VIR_DEBUG("%s %s: no FLR capability found", dev->id, dev->name); =20 - return 0; + return false; } =20 /* Require the device has the PCI Power Management capability @@ -885,15 +885,10 @@ virPCIDeviceTryPowerManagementReset(virPCIDevicePtr d= ev, int cfgfd) static int virPCIDeviceInit(virPCIDevicePtr dev, int cfgfd) { - int flr; - dev->pcie_cap_pos =3D virPCIDeviceFindCapabilityOffset(dev, cfgfd, P= CI_CAP_ID_EXP); dev->pci_pm_cap_pos =3D virPCIDeviceFindCapabilityOffset(dev, cfgfd, P= CI_CAP_ID_PM); - flr =3D virPCIDeviceDetectFunctionLevelReset(dev, cfgfd); - if (flr < 0) - return flr; - dev->has_flr =3D !!flr; - dev->has_pm_reset =3D !!virPCIDeviceDetectPowerManagementReset(dev, = cfgfd); + dev->has_flr =3D virPCIDeviceDetectFunctionLevelReset(dev, cfgfd); + dev->has_pm_reset =3D !!virPCIDeviceDetectPowerManagementReset(dev, cf= gfd); =20 return 0; } --=20 2.28.0