Search Linux Wireless

Re: [PATCH] mac80211: correct size the argument to kzalloc in minstrel_ht

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Schrober schrieb:

> On Thursday 28 June 2012 22:00:41 thomas wrote:
>> Hi Julian,
>>
>> Compiler wise both of our suggestions will lead to the same machine code.
>> So beside the matter of taste, I just followed the other overall usage
>> pattern of kzalloc in minstrel_ht.
>> And it seems to be explicitly using the struct type.
> 
> http://lxr.linux.no/linux/Documentation/CodingStyle
> 
>                 Chapter 14: Allocating memory
> 
> The kernel provides the following general purpose memory allocators:
> kmalloc(), kzalloc(), kcalloc(), vmalloc(), and vzalloc().  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.


Good to have this clarified. I will send a version 2.

Thx Thomas

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux