Re: char/tpm: Improve a size determination in nine functions
From: SF Markus Elfring
Date: Tue Oct 17 2017 - 14:41:39 EST
>> p = kmalloc(sizeof(*p), ...);
>>
>> The alternative form where struct name is spelled out hurts readability and
>> introduces an opportunity for a bug when the pointer variable type is changed
>> but the corresponding sizeof that is passed to a memory allocator is not.
>
> True, thanks for the reminder.
Will it trigger further software development considerations (besides my contributions)?
> Is this common in new code?
Do you start an official survey here?
> Is there a script/ or some other automated way of catching this usage
Yes. - I am using an approach for the semantic patch language. ;-)
> before patches are upstreamed?
I imagine that a corresponding source code analysis variant could be applied
in more cases if sufficient acceptance could be achieved.
> Just as you're doing here, the patch description should reference this
> in the patch description.
Do you find my wording âThis issue was detected by using the Coccinelle software.â insufficient?
Regards,
Markus