lkml.org 
[lkml]   [2006]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] drivers: Conversions from kmalloc+memset to k(z|c)alloc.
On 21/07/06, Stefan Richter <stefanr@s5r6.in-berlin.de> wrote:
> Jeff Garzik wrote:
> > Pekka Enberg wrote:
> >> On 7/21/06, Rolf Eike Beer <eike-kernel@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.

--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-07-21 12:23    [W:0.122 / U:0.632 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site