From: Alex Williamson <alex.williamson@redhat.com>
To: bhelgaas@google.com
Cc: Alex Williamson <alex.williamson@redhat.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
mitchell.augustin@canonical.com, ilpo.jarvinen@linux.intel.com,
Oleg Nesterov <oleg@redhat.com>
Subject: [PATCH] PCI: Fix BUILD_BUG_ON usage for old gcc
Date: Mon, 10 Feb 2025 14:01:04 -0700 [thread overview]
Message-ID: <20250210210109.3673582-1-alex.williamson@redhat.com> (raw)
As reported in the below link, it seems older versions of gcc cannot
determine that the howmany variable is known for all callers. Include
a test so that newer compilers can still enforce this sanity check and
older compilers can still work.
Fixes: 4453f360862e ("PCI: Batch BAR sizing operations")
Link: https://lore.kernel.org/all/20250209154512.GA18688@redhat.com
Reported-by: Oleg Nesterov <oleg@redhat.com>
Suggested-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
Verified against gcc 14.2.1 to still trigger a build error if called
with a constant value greater than 6, Oleg to confirm build issue is
resolved for gcc 5.3.1.
drivers/pci/probe.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index b6536ed599c3..1bde89d0dc0d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -345,7 +345,8 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
unsigned int pos, reg;
u16 orig_cmd;
- BUILD_BUG_ON(howmany > PCI_STD_NUM_BARS);
+ BUILD_BUG_ON(__builtin_constant_p(howmany) &&
+ howmany > PCI_STD_NUM_BARS);
if (dev->non_compliant_bars)
return;
--
2.47.1
next reply other threads:[~2025-02-10 21:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 21:01 Alex Williamson [this message]
2025-02-10 22:00 ` [PATCH] PCI: Fix BUILD_BUG_ON usage for old gcc Oleg Nesterov
2025-02-11 10:05 ` Oleg Nesterov
2025-02-11 22:38 ` Mitchell Augustin
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=20250210210109.3673582-1-alex.williamson@redhat.com \
--to=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mitchell.augustin@canonical.com \
--cc=oleg@redhat.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