[PATCH] drivers: Conversions from kmalloc+memset to k(z|c)alloc.
Jeff Garzik
jgarzik at pobox.com
Fri Jul 21 17:16:22 EDT 2006
Jesper Juhl wrote:
> On 21/07/06, Stefan Richter <stefanr at s5r6.in-berlin.de> wrote:
>> Jeff Garzik wrote:
>> > Pekka Enberg wrote:
>> >> On 7/21/06, Rolf Eike Beer <eike-kernel at sf-tec.de> wrote:
>> >>> > - if (!(handle = kmalloc(sizeof(struct input_handle),
>> GFP_KERNEL)))
>> >>> > + handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
>> >>> > + if (!handle)
>> >>> > return NULL;
>> >>>
>> >>> sizeof(*handle)?
>> >>
>> >> In general, yes. However, some maintainers don't like that, so I would
>> >> recommend to keep them as-is unless you get a clear ack from the
>> >> maintainer to change it.
>>
>> I suggest:
>> - check if "sizeof(type)"->"sizeof(*ptr)" is correct
>> - if yes, change it
> [snip]
>> - better style of the size argument where correct,
>
> Who says it's "better style" ?
> You can argue that sizeof(type) is more readable.
> When reading the code you don't have to go lookup the type of ptr in
> sizeof(*ptr) before you know what type the code is working with.
All the more reason that such changes -- unrelated to kzalloc/kcalloc
conversion -- should be in a separate patch.
Jeff
More information about the linux-pcmcia
mailing list