linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Schrober <franzschrober@yahoo.de>
To: thomas <thomas@net.t-labs.tu-berlin.de>
Cc: Julian Calaby <julian.calaby@gmail.com>,
	linux-wireless@vger.kernel.org, johannes@sipsolutions.net,
	nbd@openwrt.org
Subject: Re: [PATCH] mac80211: correct size the argument to kzalloc in minstrel_ht
Date: Fri, 29 Jun 2012 09:50:57 +0200	[thread overview]
Message-ID: <1487602.AtWAA39W7Q@bentobox> (raw)
In-Reply-To: <4FED3679.4080107@net.t-labs.tu-berlin.de>

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.
-- 
Franz Schrober

  reply	other threads:[~2012-06-29  7:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-28 23:28 [PATCH] mac80211: correct size the argument to kzalloc in minstrel_ht Thomas Huehn
2012-06-29  1:04 ` Julian Calaby
2012-06-29  5:00   ` thomas
2012-06-29  7:50     ` Schrober [this message]
2012-06-29 13:15       ` thomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1487602.AtWAA39W7Q@bentobox \
    --to=franzschrober@yahoo.de \
    --cc=johannes@sipsolutions.net \
    --cc=julian.calaby@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@openwrt.org \
    --cc=thomas@net.t-labs.tu-berlin.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).