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

From: Marc Kleine-Budde
Date: Wed Mar 02 2022 - 08:04:45 EST


On 02.03.2022 21:49:27, Vincent MAILHOL wrote:
> > I think it's possible to assign rx_event_msg before the
> > es58x_check_msg_len().
>
> Yes, I will do so. Even if this is a false positive, this pattern
> can be misleading. e.g. during a code review, this does indeed
> look incorrect at first glance.
>
> Also, doing such change would be consistent with was is done in
> other functions:
> https://elixir.bootlin.com/linux/latest/source/drivers/net/can/usb/etas_es58x/es58x_fd.c#L210
>
> This not being a bug fix, is it fine to send it to net-next?

ACK

> Or do you see a need to backport this?

Don't think so.

> > I think (hope?) the compiler will not optimize
> > anything away. :)
>
> With a function call and a return statement, the compiler would
> need to be severely defective to try to optimize this away :)

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.

Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |

Attachment: signature.asc
Description: PGP signature