Re: x86-ksysfs: Use kmalloc_array() in create_setup_data_nodes()

From: SF Markus Elfring
Date: Wed Sep 07 2016 - 07:48:09 EST


>> Would the following script (for the semantic patch language)
>> be useful enough for further development considerations?
>>
>> usage_of_kmalloc_array1-excerpt2.cocci:
>> @replacement2@
>> expression count, pointer, target;
>> @@
>> target =
>> - kmalloc(sizeof(*pointer) * (count)
>> + kmalloc_array(count, sizeof(*pointer)
>> , ...);
>
> Why don't you include the _exact_ script that you run?

I showed only the "excerpt" above because of the current situation
that this single SmPL rule triggered the software change
which I suggested for the referenced source file.

How do you think about to try a command out like the following
also in your development (or test) environment?

elfring@Sonne:~/Projekte/Linux/next-patched> spatch.opt ~/Projekte/Coccinelle/janitor/usage_of_kmalloc_array1-excerpt2.cocci arch/x86/kernel/ksysfs.c


Regards,
Markus