Re: [PATCH] m68k: atari: Make Atari ROM port I/O write macros return void

From: Geert Uytterhoeven
Date: Fri May 20 2022 - 11:08:37 EST


Hi Günter,

On Fri, May 20, 2022 at 4:52 PM Guenter Roeck <linux@xxxxxxxxxxxx> wrote:
> On 5/20/22 07:32, Geert Uytterhoeven wrote:
> > The macros implementing Atari ROM port I/O writes do not cast away their
> > output, unlike similar implementations for other I/O buses.
> > When they are combined using conditional expressions in the definitions of
> > outb() and friends, this triggers sparse warnings like:
> >
> > drivers/net/appletalk/cops.c:382:17: error: incompatible types in conditional expression (different base types):
> > drivers/net/appletalk/cops.c:382:17: unsigned char
> > drivers/net/appletalk/cops.c:382:17: void
> >
> > Fix this by adding casts to "void".
> >
> > Reported-by: kernel test robot <lkp@xxxxxxxxx>
> > Reported-by: Guenter Roeck <linux@xxxxxxxxxxxx>
> > Signed-off-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
>
> Reviewed-by: Guenter Roeck <linux@xxxxxxxxxxxx>

Thanks!

> > Removing the casts instead causes issues with functions propagating void
> > return values (return expression in void function), which BTW sparse
> > complains about, too.
>
> We live and learn. I didn't even know that this was valid syntax.

I knew about the syntax, but didn't realize immediately why it was
done that way.

Initially I thought it was some relic from the "always cast to void
to make it clear you do not care about the return value"-frenzy, which
are inside Linux visible mostly in the various "(void)acpi_<foo>(...);"
calls. AFAIK these are checked by some external tools.
In Linux, we have __must_check to annotate the important cases.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds