Re: [PATCH 1/5] nubus: Simplify check in remove callback

From: Geert Uytterhoeven
Date: Tue Jul 27 2021 - 06:07:46 EST


Hi Finn,

On Tue, Jul 27, 2021 at 11:50 AM Finn Thain <fthain@xxxxxxxxxxxxxx> wrote:
> On Tue, 27 Jul 2021, Uwe Kleine-König wrote:
> > Apart from that, the compiler might already assume dev->driver being
> > non-NULL after to_nubus_driver(dev->driver) was called.
>
> I don't understand how a compiler can make that assumption. But then, I
> don't know why compilers do a lot of the things they do...

It is one of those recent optimizations people have been complaining
about. Once you have dereferenced a pointer, compilers may remove
all further NULL-checks, assuming they can't happen, as the code
would have crashed anyway before due to the dereference.
Good luck running on bare metal with RAM at zero ;-)

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