From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4EE6C77B7A for ; Thu, 1 Jun 2023 16:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zcXSNt0sHyhKgGUwQYhhz8+kU4ez1AVFZ76m0WrAjz8=; b=ks+4bA4VcGCWiz dKSxBUaj9LpJh/9OxA1PgJ5LFSa4wY58AXYI/8z+ErsTitT3apzV9l3+yNm2Uk4ULIrKUU+36YLXN G4Rp7TYsqH8l2irUlsHSgnm/mNYU9bjDaVjRZ8KHxg9BlGbFz0aa2b1h5HsGSi3mvMr4wAwH85hwM yaH0mUXUgSuXdmWupz2/d79Jm5sQNrRIht4pEXEst0c9EqDRw9PG+MgbYQ1ubjjp9U5KwevjxtGAs xZKyWv/mi7Ky8uuyUMRtMy+WDbymm3NlnYZrzFvtg2M6hQJ4KBaeWGGb0InLAOBkAXAyBVUTLB/Io xORaDfH7gA8PBWGdux8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4l7p-004Env-1w; Thu, 01 Jun 2023 16:26:09 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4l7k-004EkT-2J for linux-arm-kernel@lists.infradead.org; Thu, 01 Jun 2023 16:26:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685636764; x=1717172764; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=q1NNNfNs1qkINp4+7F0o+S22gLPh78FVwhQOR7EmNDk=; b=A650K9DDlM7WKsXZBUfBswm99ZyRhlvbRXT3+irw74KBNDtJWSEUHG4W OE7gWS6+F1yJ6nge2hhrT3+Cr5zOEW36gr6vPKaNa1sxhLaAoNWyVt+0M 8rz+72PUT/+uX6UZGvlI8sO3ZCNFKbsckV81Nd87ZMil1fenkiMlDRXHd nto/1LJ2mE/QnazX9t0ZHLQub3zNZt8hcwbwJe0Sq1tjn4t0NyOesAnqL G4Qg9Q+wZLejsyQxnBQHHN/i0fWTMuSeH40gtqdRniBKqs/8FOviZNiQ5 zJcioT6nN2n1tiDhxPrTa8Ec48Ukn/jwEstGeDLQCEFJ/KUiYtExuvEPq A==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="353103099" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="353103099" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 09:26:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="740424758" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="740424758" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga001.jf.intel.com with ESMTP; 01 Jun 2023 09:25:50 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1q4l7S-000SYH-2G; Thu, 01 Jun 2023 19:25:46 +0300 Date: Thu, 1 Jun 2023 19:25:46 +0300 From: Andy Shevchenko To: Jonas Gorski Cc: Bjorn Helgaas , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rich Felker , linux-sh@vger.kernel.org, linux-pci@vger.kernel.org, Dominik Brodowski , linux-kernel@vger.kernel.org, =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= , Andrew Lunn , sparclinux@vger.kernel.org, Stefano Stabellini , Yoshinori Sato , Gregory Clement , "Rafael J. Wysocki" , Russell King , linux-acpi@vger.kernel.org, Miguel Ojeda , xen-devel@lists.xenproject.org, Matt Turner , Anatolij Gustschin , Sebastian Hesselbarth , Arnd Bergmann , Niklas Schnelle , Richard Henderson , Nicholas Piggin , Ivan Kokshaysky , John Paul Adrian Glaubitz , Bjorn Helgaas , Mika Westerberg , linux-arm-kernel@lists.infradead.org, Juergen Gross , Thomas Bogendoerfer , Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= , linuxppc-dev@lists.ozlabs.org, Randy Dunlap , linux-mips@vger.kernel.org, Oleksandr Tyshchenko , linux-alpha@vger.kernel.org, Pali =?iso-8859-1?Q?Roh=E1r?= , "David S. Miller" , "Maciej W. Rozycki" Subject: Re: [PATCH v8 0/7] Add pci_dev_for_each_resource() helper and update users Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230601_092604_833880_581271C9 X-CRM114-Status: GOOD ( 36.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, May 31, 2023 at 08:48:35PM +0200, Jonas Gorski wrote: > On Tue, 30 May 2023 at 23:34, Bjorn Helgaas wrote: > > On Fri, May 12, 2023 at 02:48:51PM -0500, Bjorn Helgaas wrote: > > > On Fri, May 12, 2023 at 01:56:29PM +0300, Andy Shevchenko wrote: > > > > On Tue, May 09, 2023 at 01:21:22PM -0500, Bjorn Helgaas wrote: > > > > > On Tue, Apr 04, 2023 at 11:11:01AM -0500, Bjorn Helgaas wrote: > > > > > > On Thu, Mar 30, 2023 at 07:24:27PM +0300, Andy Shevchenko wrote: > > > > > > > Provide two new helper macros to iterate over PCI device resources and > > > > > > > convert users. > > > > > > > > > > > Applied 2-7 to pci/resource for v6.4, thanks, I really like this! > > > > > > > > > > This is 09cc90063240 ("PCI: Introduce pci_dev_for_each_resource()") > > > > > upstream now. > > > > > > > > > > Coverity complains about each use, > > > > > > > > It needs more clarification here. Use of reduced variant of the > > > > macro or all of them? If the former one, then I can speculate that > > > > Coverity (famous for false positives) simply doesn't understand `for > > > > (type var; var ...)` code. > > > > > > True, Coverity finds false positives. It flagged every use in > > > drivers/pci and drivers/pnp. It didn't mention the arch/alpha, arm, > > > mips, powerpc, sh, or sparc uses, but I think it just didn't look at > > > those. > > > > > > It flagged both: > > > > > > pbus_size_io pci_dev_for_each_resource(dev, r) > > > pbus_size_mem pci_dev_for_each_resource(dev, r, i) > > > > > > Here's a spreadsheet with a few more details (unfortunately I don't > > > know how to make it dump the actual line numbers or analysis like I > > > pasted below, so "pci_dev_for_each_resource" doesn't appear). These > > > are mostly in the "Drivers-PCI" component. > > > > > > https://docs.google.com/spreadsheets/d/1ohOJwxqXXoDUA0gwopgk-z-6ArLvhN7AZn4mIlDkHhQ/edit?usp=sharing > > > > > > These particular reports are in the "High Impact Outstanding" tab. > > > > Where are we at? Are we going to ignore this because some Coverity > > reports are false positives? > > Looking at the code I understand where coverity is coming from: > > #define __pci_dev_for_each_res0(dev, res, ...) \ > for (unsigned int __b = 0; \ > res = pci_resource_n(dev, __b), __b < PCI_NUM_RESOURCES; \ > __b++) > > res will be assigned before __b is checked for being less than > PCI_NUM_RESOURCES, making it point to behind the array at the end of > the last loop iteration. Which is fine and you stumbled over the same mistake I made, that's why the documentation has been added to describe why the heck this macro is written the way it's written. Coverity sucks. > Rewriting the test expression as > > __b < PCI_NUM_RESOURCES && (res = pci_resource_n(dev, __b)); > > should avoid the (coverity) warning by making use of lazy evaluation. Obviously NAK. > It probably makes the code slightly less performant as res will now be > checked for being not NULL (which will always be true), but I doubt it > will be significant (or in any hot paths). -- With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel