mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Kees Cook <keescook@chromium.org>
Cc: linux-kernel@vger.kernel.org,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Subject: Re: [PATCH] overflow.h: Add flex_array_size() helper
Date: Mon, 08 Jun 2020 15:34:52 -0700	[thread overview]
Message-ID: <05ab102b936ce922c4fae67bf5dd3e323aff0b93.camel@perches.com> (raw)
In-Reply-To: <20200608221723.GA23644@embeddedor>

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))

Consistency would be nice.



  reply	other threads:[~2020-06-08 22:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-08 22:17 Gustavo A. R. Silva
2020-06-08 22:34 ` Joe Perches [this message]
2020-06-09  0:47   ` Gustavo A. R. Silva
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=05ab102b936ce922c4fae67bf5dd3e323aff0b93.camel@perches.com \
    --to=joe@perches.com \
    --cc=gustavo@embeddedor.com \
    --cc=gustavoars@kernel.org \
    --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

Powered by JetHome