All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: "Winkler, Tomas" <tomas.winkler@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][next] mei: Avoid the use of one-element arrays
Date: Tue, 14 Jul 2020 15:13:24 -0500	[thread overview]
Message-ID: <20200714201324.GA31673@embeddedor> (raw)
In-Reply-To: <32f85e185c2244a19a1705d0db315c69@intel.com>

On Tue, Jul 14, 2020 at 07:57:51PM +0000, Winkler, Tomas wrote:
> > 
> > On Tue, Jul 14, 2020 at 05:54:32PM +0000, Winkler, Tomas 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 or, as in this particular case, replace the one-element array
> > > > with a simple value type u8 reserved once this is just a placeholder
> > > > for alignment. The older style of one-element or zero-length arrays
> > should no longer be used[2].
> > > >
> > > > Also, while there, use the preferred form for passing a size of a struct.
> > > > The alternative form where struct name is spelled out hurts
> > > > readability and introduces an opportunity for a bug when the
> > > > variable type is changed but the corresponding sizeof that is passed as
> > argument is not.
> > > >
> > > > [1] https://en.wikipedia.org/wiki/Flexible_array_member
> > > > [2] https://github.com/KSPP/linux/issues/79
> > > >
> > > > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> > > I'm okay with the patch but in this case the description is a bit off.
> > > In this case there was no intention for a flexible arrays its just a reserved
> > field.
> > >
> > 
> > The reserved field is actually mentioned in the description:
> > 
> > "... or, as in this particular case, replace the one-element array with a simple
> > value type u8 reserved once this is just a placeholder for alignment."
> 
> Right, but it looks not connected to overall context, it looks like not very clean reuse of a commit message.
> I would say that this reserved[1] rather had confused the detection scripts you are using for the  cleanup you are doing. 
> Again, I'm okay with the patch, but if you can  reword the commit message it would be even more okay.
> 

Yep; I've come up with a more concise text for these sorts of cases:

"One-element arrays are being deprecated[1]. Replace the one-element
array with a simple value type u8 reserved, once this is just a
placeholder for alignment.

[1] https://github.com/KSPP/linux/issues/79"

I'll send v2 with the text above, shortly.

Thanks for the feedback.
--
Gustavo

      reply	other threads:[~2020-07-14 20:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 17:46 [PATCH][next] mei: Avoid the use of one-element arrays Gustavo A. R. Silva
2020-07-14 17:54 ` Winkler, Tomas
2020-07-14 18:08   ` Gustavo A. R. Silva
2020-07-14 19:57     ` Winkler, Tomas
2020-07-14 20:13       ` Gustavo A. R. Silva [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=20200714201324.GA31673@embeddedor \
    --to=gustavoars@kernel.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tomas.winkler@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.