Re: drivers/net/can/usb/etas_es58x/es58x_fd.c:174:8: warning: Uninitialized variable: rx_event_msg [uninitvar]

From: Vincent MAILHOL
Date: Wed Mar 02 2022 - 09:43:19 EST


On Wed. 2 Mar 2022 at 22:04, Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote:
> I was thinking of this:
>
> | void *foo = bar->baz;
> |
> | if (!bar)
> | return;
> |
> | printf("%p", foo);
>
> There were/are compilers that optimize the bar NULL pointer check away,
> because bar has already been de-referenced.

Sorry, I do not get your example. If bar is NULL,
| void *foo = bar->baz;
would segfault and thus the check is not reached.

If bar is not NULL, the check succeeds.

In both cases, the return statement of the if branch is never
executed making this some dead code. So I do not see why this is
an issue if the compiler removes it.


Yours sincerely,
Vincent Mailhol