Re: [PATCH] CodingStyle: delete "kmalloc(sizeof(*var))" as preferred allocation form

From: Joe Perches
Date: Thu May 25 2017 - 06:35:50 EST


On Wed, 2017-05-24 at 13:18 +0300, Alexey Dobriyan wrote:
> Proper fix is to introduce typed allocation macros with the following
> signatures:
>
> T* lmalloc(T, gfp);
[]
> struct foo *x;
> x = lmalloc(struct foo, GFP_KERNEL);

Then code would be written

x = lmalloc(typeof(*x), GFP_KERNEL);