From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Jann Horn <jannh@google.com>
Cc: Lucas Stach <dev@lynxeye.de>,
Vignesh Raghavendra <vigneshr@ti.com>,
Richard Weinberger <richard@nod.at>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Stefan Agner <stefan@agner.ch>,
Jonathan Hunter <jonathanh@nvidia.com>,
Thierry Reding <thierry.reding@gmail.com>,
linux-mtd@lists.infradead.org, linux-hardening@vger.kernel.org,
linux-tegra@vger.kernel.org,
kernel list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][next] mtd: rawnand: Replace one-element array with flexible-array member
Date: Thu, 1 Oct 2020 10:12:06 +0200 [thread overview]
Message-ID: <20201001101206.6e4beea7@xps13> (raw)
In-Reply-To: <CAG48ez3XqE0m2UmRh+OtmYJRhyCBYY=sdJKaWBXtJZKCRpLMYQ@mail.gmail.com>
Hi Jann,
Jann Horn <jannh@google.com> wrote on Thu, 1 Oct 2020 00:32:24 +0200:
> On Wed, Sep 30, 2020 at 11:30 PM Gustavo A. R. Silva
> <gustavoars@kernel.org> wrote:
> > On Wed, Sep 30, 2020 at 11:10:43PM +0200, Jann Horn wrote:
> > > On Wed, Sep 30, 2020 at 11:02 PM Gustavo A. R. Silva
> > > <gustavoars@kernel.org> wrote:
> > > > There is a regular need in the kernel to provide a way to declare having
> > > > a dynamically sized set of trailing elements in a structure. Kernel code
> > > > should always use “flexible array members”[1] for these cases. The older
> > > > style of one-element or zero-length arrays should no longer be used[2].
> > >
> > > But this is not such a case, right? Isn't this a true fixed-size
> > > array? It sounds like you're just changing it because it
> > > pattern-matched on "array of length 1 at the end of a struct".
> >
> > Yeah; I should have changed that 'dynamically' part of the text above
> > a bit. However, as I commented in the text below, in the case that more
> > CS IDs are needed (let's wait for the maintainers to comment on this...)
> > in the future, this change makes the code more maintainable, as for
> > the allocation part, the developer would only have to update the CS_N
> > macro to the number of CS IDs that are needed.
>
> But in that case, shouldn't you change it to "int cs[CS_N]" and get
> rid of the struct_size() stuff?
I do agree with Jann, I think it's best to consider this a fixed-size
array for now. If we ever want to extend the number of supported CS,
there is much more rework involved anyway.
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2020-10-01 8:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-30 21:08 [PATCH][next] mtd: rawnand: Replace one-element array with flexible-array member Gustavo A. R. Silva
2020-09-30 21:10 ` Jann Horn
2020-09-30 21:36 ` Gustavo A. R. Silva
2020-09-30 22:32 ` Jann Horn
2020-10-01 8:12 ` Miquel Raynal [this message]
2020-10-01 9:21 ` Stefan Agner
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=20201001101206.6e4beea7@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=dev@lynxeye.de \
--cc=gustavoars@kernel.org \
--cc=jannh@google.com \
--cc=jonathanh@nvidia.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-tegra@vger.kernel.org \
--cc=richard@nod.at \
--cc=stefan@agner.ch \
--cc=thierry.reding@gmail.com \
--cc=vigneshr@ti.com \
/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).