From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Colin King (gmail)" <colin.i.king@gmail.com>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Bjorn Helgaas" <bhelgaas@google.com>
Cc: Mahesh J Salgaonkar <mahesh@linux.ibm.com>,
Oliver O'Halloran <oohall@gmail.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
linux-pci@vger.kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: re: PCI: Add TLP Prefix reading to pcie_read_tlp_log()
Date: Thu, 16 Jan 2025 18:18:47 +0200 (EET) [thread overview]
Message-ID: <de2a07a1-ea99-20d7-69c5-8fdf2f432750@linux.intel.com> (raw)
In-Reply-To: <a2f75da3-7065-4592-aa64-5e3590ce5f91@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1300 bytes --]
On Thu, 16 Jan 2025, Colin King (gmail) wrote:
> Hi,
>
> Static analysis shows there is a potential issue in the following commit:
>
> commit 00048c2d5f113bb4e82a0a30dfc4ee12590b81f5
> Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Date: Tue Jan 14 19:08:39 2025 +0200
>
> PCI: Add TLP Prefix reading to pcie_read_tlp_log()
>
>
> The issue is described as follows:
>
> unsigned int aer_tlp_log_len(struct pci_dev *dev, u32 aercc)
> {
> return PCIE_STD_NUM_TLP_HEADERLOG +
> (aercc & PCI_ERR_CAP_PREFIX_LOG_PRESENT) ?
> dev->eetlp_prefix_max : 0;
> }
>
>
> static analysis is warning that the left hand size of the ? operator is always
> true and so dev->eetlp_prefix_max is always being returned and the 0 is never
> returned (dead code).
>
> I suspect the expected behaviour is as follows:
>
> return PCIE_STD_NUM_TLP_HEADERLOG +
> ((aercc & PCI_ERR_CAP_PREFIX_LOG_PRESENT) ?
> dev->eetlp_prefix_max : 0);
>
> ..I'm reluctant to send a fix in case this is not the original intention.
Your fix looks correct, it should have the parenthesis due to operator
precedence rules. The intention is to calculate 4 DWs + optionally n E-E
TLP prefixes.
--
i.
next prev parent reply other threads:[~2025-01-16 16:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 15:57 PCI: Add TLP Prefix reading to pcie_read_tlp_log() Colin King (gmail)
2025-01-16 16:18 ` Ilpo Järvinen [this message]
2025-01-16 16:27 ` Colin King (gmail)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=de2a07a1-ea99-20d7-69c5-8fdf2f432750@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=bhelgaas@google.com \
--cc=colin.i.king@gmail.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mahesh@linux.ibm.com \
--cc=oohall@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox