Re: [PATCH] some kmalloc/memset ->kzalloc (tree wide)

From: Tilman Schmidt
Date: Sat Jul 07 2007 - 19:02:48 EST


Am 07.07.2007 15:36 schrieb yoann padioleau:
> On 7 juil. 07, at 15:07, Tilman Schmidt wrote:
>
>> This misses the semantic distinction between the first and second
>> arguments of kcalloc(). The first argument is supposed to be the
>> number of elements to allocate and the second their size. As a
>> consequence, the following hunks in your pathc are wrong:
>
> Yes you are right. Andrew Morton fixed the problem in a
> subsequent patch.

That's ok then. Andrew is doing an awesome job.

> I should have written a more precise semantic patch such as
>
> @@
> expression E;
> constant c;
> type T;
> @@
>
> - kzalloc(sizeof(T) * c, E)
> + kcalloc(c, sizeof(T), E)
>
> Note that sometimes the code is written as kzalloc(c * sizeof(T), E)
> as in kzalloc(2 * sizeof(struct resource), GFP_KERNEL) but
> our transformation engine can handle the commutativity of '*' and still
> performs the right transformation.

Cool. That transformation engine sure sounds like an interesting
piece of code.

Regards,
Tilman

--
Tilman Schmidt E-Mail: tilman@xxxxxxx
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)

Attachment: signature.asc
Description: OpenPGP digital signature