[PATCH] powerpc/476: Drop explicit initialization of struct i2c_device_id::driver_data to 0
Uwe Kleine-König
u.kleine-koenig at baylibre.com
Thu Aug 8 16:39:08 AEST 2024
Hello,
On Wed, Aug 07, 2024 at 07:50:26AM +0200, Christophe Leroy wrote:
> Le 04/08/2024 à 13:20, Uwe Kleine-König a écrit :
> > This driver doesn't use the driver_data member of struct i2c_device_id,
> > so don't explicitly initialize this member.
>
> Well, even if the member was used, a 0 init is useless because as soon as
> you initialise one field of the struct, the compiler initialise everything
> else with 0.
Yeah, there are different shades of "useless". I'd say that if the
driver_data member is used, e.g. like:
static const struct i2c_device_id avr_id[] = {
{
.name = "akebono-avr",
.driver_data = 0,
}, {
.name = "akebono-arduino",
.driver_data = 1,
}, {
}
};
the assignment to driver_data in the first entry is useless as it
doesn't make a difference for the compiler, but still has a benefit for
the human reader of the code. So I would keep that one.
> Reviewed-by: Christophe Leroy <christophe leroy at csgroup.eu>
Thanks
Uwe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20240808/62c41cc3/attachment.sig>
More information about the Linuxppc-dev
mailing list