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

H. Nikolaus Schaller hns at goldelico.com
Sun Jun 24 22:20:06 CEST 2018

> Am 24.06.2018 um 22:12 schrieb Andreas Kemnade <andreas at kemnade.info>:
> 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
> [...]
> Constraints
> 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];

Because that is far too simple :)

What I assume is that someone developed that before the variable was an enum.
Maybe a struct with multiple fields. But even then struct assignments are possible...

But see my overlapping mail - it was originally introduced that way long ago in 3.7-rc1.

Now I am curious what your statistical test shows. It is of course a much
better validation than mine (with 0/5 failures vs. 1/3 failures).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.goldelico.com/pipermail/letux-kernel/attachments/20180624/4a1a3e94/attachment.asc>

More information about the Letux-kernel mailing list