From: Peter Oberparleiter <oberpar@linux.ibm.com>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] gcov: use struct_size() in kzalloc()
Date: Fri, 11 Jan 2019 16:59:08 +0100 [thread overview]
Message-ID: <b49b58f5-8047-4d14-cfb8-ab182235e389@linux.ibm.com> (raw)
In-Reply-To: <20190109172445.GA15908@embeddedor>
On 09.01.2019 18:24, Gustavo A. R. Silva wrote:
> One of the more common cases of allocation size calculations is finding the
> size of a structure that has a zero-sized array at the end, along with memory
> for some number of elements for that array. For example:
>
> struct foo {
> int stuff;
> void *entry[];
> };
>
> instance = kzalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
>
> Instead of leaving these open-coded and prone to type mistakes, we can now
> use the new struct_size() helper:
>
> instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
>
> This code was detected with the help of Coccinelle.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Looks sane.
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Andrew, could you pick this patch up?
--
Peter Oberparleiter
Linux on Z Development - IBM Germany
prev parent reply other threads:[~2019-01-11 15:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-09 17:24 Gustavo A. R. Silva
2019-01-11 15:59 ` Peter Oberparleiter [this message]
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=b49b58f5-8047-4d14-cfb8-ab182235e389@linux.ibm.com \
--to=oberpar@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=gustavo@embeddedor.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®