From: Colin Ian King <colin.i.king@gmail.com>
To: "Bjorn Helgaas" <bhelgaas@google.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
linux-pci@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] PCI: Fix ternary operator that never returns 0
Date: Thu, 16 Jan 2025 17:20:19 +0000 [thread overview]
Message-ID: <20250116172019.88116-1-colin.i.king@gmail.com> (raw)
The left hand size of the ? operator is always true because of the addition
of PCIE_STD_NUM_TLP_HEADERLOG and so dev->eetlp_prefix_max is always being
returned and the 0 is never returned (dead code). Fix this by adding the
required parentheses around the ternary operator.
Fixes: 00048c2d5f11 ("PCI: Add TLP Prefix reading to pcie_read_tlp_log()")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
drivers/pci/pcie/tlp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/pcie/tlp.c b/drivers/pci/pcie/tlp.c
index 9b9e348fb1a0..0860b5da837f 100644
--- a/drivers/pci/pcie/tlp.c
+++ b/drivers/pci/pcie/tlp.c
@@ -22,8 +22,8 @@
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;
+ ((aercc & PCI_ERR_CAP_PREFIX_LOG_PRESENT) ?
+ dev->eetlp_prefix_max : 0);
}
#ifdef CONFIG_PCIE_DPC
--
2.47.1
next reply other threads:[~2025-01-16 17:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 17:20 Colin Ian King [this message]
2025-01-16 18:06 ` [PATCH][next] PCI: Fix ternary operator that never returns 0 Bjorn Helgaas
2025-01-16 22:49 ` David Laight
2025-01-17 5:25 ` Dan Carpenter
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=20250116172019.88116-1-colin.i.king@gmail.com \
--to=colin.i.king@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=bhelgaas@google.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/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