[Letux-kernel] New LetuxOS Kernels - strcmp(NULL)

Andreas Kemnade andreas at kemnade.info
Sun Jun 24 22:12:03 CEST 2018

On Sun, 24 Jun 2018 20:17:38 +0200
"H. Nikolaus Schaller" <hns at goldelico.com> wrote:

> http://git.goldelico.com/?p=gta04-kernel.git;a=blob;f=drivers/power/supply/generic-adc-battery.c;h=359cc8dac245c071f1ff21b12791ad6c5a9332c4;hb=dca26f608a765008b869991bf29fa241769599fb#l429
>    memcpy(properties + sizeof(*(psy_desc->properties)) * index,
> the + of 'properties' and some integer already multiplies the index by sizeof(*properties).
Well, the enum might or might not be 8bit size, so that multiply might
be a nop, or it will not be a not at some time.

Lets cite the standard: Enumeration specifiers
The expression that defines the value of an enumeration constant shall be an integer constant expression that has a value representable as an int.
Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration.

> Hence it should IMHO be
>    memcpy(properties + index,
> or to better describe that memcpy takes an address
>    memcpy(&properties[index],
> What do you think?
Why not simply

                        properties[index] = gab_dyn_props[chan];

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.goldelico.com/pipermail/letux-kernel/attachments/20180624/29c57d28/attachment.asc>

More information about the Letux-kernel mailing list