lkml.org 
[lkml]   [2005]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: p = kmalloc(sizeof(*p), )
    Btw, I would prefer this one to be applied instead. The other parts should 
    be okay, right?

    [PATCH] CodingStyle remove sizeof preferred form

    It isn't clear that the use of p = kmalloc(sizeof(*p), ...) is
    preferred over p = kmalloc(sizeof(struct foo), ...) - in fact,
    there are some good reasons to use the latter form.

    Therefore, the choice of which to use should be left up to the
    developer concerned, and not written in to the coding style.

    For discussion, please see the thread:
    http://lkml.org/lkml/2005/9/18/29

    Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
    Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>

    Index: 2.6/Documentation/CodingStyle
    ===================================================================
    --- 2.6.orig/Documentation/CodingStyle
    +++ 2.6/Documentation/CodingStyle
    @@ -416,14 +416,6 @@ The kernel provides the following genera
    kmalloc(), kzalloc(), kcalloc(), and vmalloc(). Please refer to the API
    documentation for further information about them.

    -The preferred form for passing a size of a struct is the following:
    -
    - p = kmalloc(sizeof(*p), ...);
    -
    -The alternative form where struct name is spelled out hurts readability and
    -introduces an opportunity for a bug when the pointer variable type is changed
    -but the corresponding sizeof that is passed to a memory allocator is not.
    -
    Casting the return value which is a void pointer is redundant. The conversion
    from void pointer to any other pointer type is guaranteed by the C programming
    language.
    -
    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: 2005-09-20 14:56    [W:4.332 / U:0.268 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site