]> Git Repo - linux.git/commitdiff
PCI: Fix BUILD_BUG_ON usage for old gcc
authorAlex Williamson <[email protected]>
Wed, 12 Feb 2025 18:53:32 +0000 (11:53 -0700)
committerBjorn Helgaas <[email protected]>
Wed, 12 Feb 2025 22:16:21 +0000 (16:16 -0600)
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 enforce this sanity check and older
compilers can still work.  Add __always_inline attribute to give the
compiler an even better chance to know the inputs.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 4453f360862e ("PCI: Batch BAR sizing operations")
Reported-by: Oleg Nesterov <[email protected]>
Link: https://lore.kernel.org/all/[email protected]
Signed-off-by: Alex Williamson <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Tested-by: Oleg Nesterov <[email protected]>
Tested-by: Mitchell Augustin <[email protected]>
drivers/pci/probe.c

index b6536ed599c3727ebfc92697ee8d0906e8167902..246744d8d268a2f386b8dd259c3563653849f79d 100644 (file)
@@ -339,13 +339,14 @@ out:
        return (res->flags & IORESOURCE_MEM_64) ? 1 : 0;
 }
 
-static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
+static __always_inline void pci_read_bases(struct pci_dev *dev,
+                                          unsigned int howmany, int rom)
 {
        u32 rombar, stdbars[PCI_STD_NUM_BARS];
        unsigned int pos, reg;
        u16 orig_cmd;
 
-       BUILD_BUG_ON(howmany > PCI_STD_NUM_BARS);
+       BUILD_BUG_ON(statically_true(howmany > PCI_STD_NUM_BARS));
 
        if (dev->non_compliant_bars)
                return;
This page took 0.060309 seconds and 4 git commands to generate.