From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Joe Perches <joe@perches.com>
Cc: Kees Cook <keescook@chromium.org>,
linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Subject: Re: [PATCH] overflow.h: Add flex_array_size() helper
Date: Mon, 8 Jun 2020 19:47:56 -0500 [thread overview]
Message-ID: <20200609004756.GH10051@embeddedor> (raw)
In-Reply-To: <05ab102b936ce922c4fae67bf5dd3e323aff0b93.camel@perches.com>
On Mon, Jun 08, 2020 at 03:34:52PM -0700, Joe Perches wrote:
> On Mon, 2020-06-08 at 17:17 -0500, Gustavo A. R. Silva wrote:
> > Add flex_array_size() helper for the calculation of the size, in bytes,
> > of a flexible array member contained within an enclosing structure.
> >
> > Example of usage:
> > foo
> > struct something {
> > size_t count;
> > struct foo items[];
> > };
> >
> > struct something *instance;
> []
> > diff --git a/include/linux/overflow.h b/include/linux/overflow.h
> []
> > +/**
> > + * flex_array_size() - Calculate size of a flexible array member within
> > + * an enclosing structure.
>
> These comment descriptions do not match
>
> > + * Calculates size of memory needed for flexible array @member of @count
> > + * elements within structure @p.
>
> The first comment shows the size of an array member.
> The second shows the size of an array member * count
>
> Also the struct_size and flex_array_size definitions
> are using two different forms:
>
> sizeof(*(p)->member) + __must_be_array((p)->member),\
> and
> sizeof((p)->member[0]) + __must_be_array((p)->member))
>
Good catch.
Thanks
--
Gustavo
next prev parent reply other threads:[~2020-06-09 0:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-08 22:17 [PATCH] overflow.h: Add flex_array_size() helper Gustavo A. R. Silva
2020-06-08 22:34 ` Joe Perches
2020-06-09 0:47 ` Gustavo A. R. Silva [this message]
2020-06-09 15:26 ` Kees Cook
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=20200609004756.GH10051@embeddedor \
--to=gustavoars@kernel.org \
--cc=gustavo@embeddedor.com \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--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