Re: [PATCH] PCI: Fix BUILD_BUG_ON usage for old gcc

From: Oleg Nesterov
Date: Tue Feb 11 2025 - 05:05:47 EST


On 02/10, Oleg Nesterov wrote:
>
> On 02/10, Alex Williamson wrote:
> >
> > @@ -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);
>
> Thanks!
>
> Tested-by: Oleg Nesterov <oleg@xxxxxxxxxx>

Just in case... I agree with David, statically_true() looks a bit
better and

BUILD_BUG_ON(statically_true(howmany > PCI_STD_NUM_BARS));

also works for me, so if you decide to update this patch feel free
to keep my Tested-by.

Oleg.