Re: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE

From: Arnd Bergmann
Date: Wed Apr 21 2021 - 07:58:12 EST


On Wed, Apr 21, 2021 at 1:50 PM Niklas Schnelle <schnelle@xxxxxxxxxxxxx> wrote:
> On Wed, 2021-04-21 at 11:24 +0000, David Laight wrote:
> >
> > I suspect that this might be better not inlined
> > when PCI_IOBASE is undefined.
> >
> > Otherwise you get quite a lot of bloat from all the
> > WARN_ONCE() calls.
>
> Hmm, I was wondering if we should rather have a large ifdef block of
> all these functions stubbed to WARN_ONCE rather than in each function.
> As I understand it this would be necessary if we want the inline gone.
> They would still be static though so we still get a copy per
> compilation unit that uses it or am I misunderstanding?

I wouldn't worry too much about the size of known broken drivers during
compile testing. Also, since the functions are marked 'inline' and not
'__always_inline', the compiler is free to decide not to inline them if
the contents are excessively big, and since the strings are all identical,
they should be constant-folded.

If you want to make this a little smaller, using pr_warn_once()
would be a little smaller, but also give less information.

Arnd