DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: dev@dpdk.org, david.marchand@redhat.com,
	Stephen Hemminger <stephen@networkplumber.org>,
	Hemant Agrawal <hemant.agrawal@nxp.com>
Subject: Re: [PATCH v3 1/4] cocci: add script for zero-length arrays in structs
Date: Fri, 3 Jun 2022 11:38:30 +0100	[thread overview]
Message-ID: <YpnkpoGzjBLDwvp7@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D870E7@smartserver.smartshare.dk>

On Fri, Jun 03, 2022 at 12:30:25PM +0200, Morten Brørup wrote:
> > From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> > Sent: Friday, 3 June 2022 12.13
> > 
> > Add script to replace [0] with [] when used at the end of a struct.
> > The script also includes an additional struct member to match against
> > so
> > as to avoid issues with arrays with only a single zero-length element.
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > Acked-by: Morten Brørup <mb@smartsharesystems.com>
> > Acked-by: Stephen Hemminger <stephen@networkplumber.org>
> > Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
> > ---
> >  devtools/cocci/zero_length_array.cocci | 21 +++++++++++++++++++++
> >  1 file changed, 21 insertions(+)
> >  create mode 100644 devtools/cocci/zero_length_array.cocci
> > 
> > diff --git a/devtools/cocci/zero_length_array.cocci
> > b/devtools/cocci/zero_length_array.cocci
> > new file mode 100644
> > index 0000000000..de8783bc7a
> > --- /dev/null
> > +++ b/devtools/cocci/zero_length_array.cocci
> > @@ -0,0 +1,21 @@
> > +// Replace zero-length array members with []
> > +@@
> > +identifier st, member, arr;
> > +type T1, T2;
> > +@@
> > +struct st {
> > +	...
> > +	T1 member;
> > +-	T2 arr[0];
> > ++	T2 arr[];
> > +};
> > +@@
> > +identifier st, member, arr, id;
> > +type T1, T2;
> > +@@
> > +struct st {
> > +	...
> > +	T1 member;
> > +-	T2 arr[0];
> > ++	T2 arr[];
> > +} id;
> > --
> > 2.34.1
> > 
> 
> Formally, arr[0] could be the only field in the structure, i.e. with no preceding fields. It would be silly, but consider checking for that too.
> 

I actually had that originally, but the compiler will complain on
structures where there is only an unsized element. Therefore, I made the
script only do replacements on structs which had at least one other
element.


  reply	other threads:[~2022-06-03 10:38 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-02 15:08 [PATCH 0/4] clean up zero-length arrays Bruce Richardson
2022-06-02 15:08 ` [PATCH 1/4] cocci: add script for zero-length arrays in structs Bruce Richardson
2022-06-02 15:08 ` [PATCH 2/4] drivers: replace zero-length arrays with undimensioned ones Bruce Richardson
2022-06-02 15:08 ` [PATCH 3/4] lib: " Bruce Richardson
2022-06-02 15:08 ` [PATCH 4/4] app: examples: " Bruce Richardson
2022-06-02 15:20 ` [PATCH 0/4] clean up zero-length arrays Morten Brørup
2022-06-02 15:35 ` Stephen Hemminger
2022-06-02 16:13 ` [PATCH v2 " Bruce Richardson
2022-06-02 16:13   ` [PATCH v2 1/4] cocci: add script for zero-length arrays in structs Bruce Richardson
2022-06-02 16:13   ` [PATCH v2 2/4] drivers: replace zero-length arrays with undimensioned ones Bruce Richardson
2022-06-03  7:19     ` David Marchand
2022-06-03  7:36       ` Bruce Richardson
2022-06-03  9:18       ` Bruce Richardson
2022-06-02 16:13   ` [PATCH v2 3/4] lib: " Bruce Richardson
2022-06-02 16:13   ` [PATCH v2 4/4] app: examples: " Bruce Richardson
2022-06-03  6:56   ` [PATCH v2 0/4] clean up zero-length arrays Hemant Agrawal
2022-06-03 10:13 ` [PATCH v3 " Bruce Richardson
2022-06-03 10:13   ` [PATCH v3 1/4] cocci: add script for zero-length arrays in structs Bruce Richardson
2022-06-03 10:30     ` Morten Brørup
2022-06-03 10:38       ` Bruce Richardson [this message]
2022-06-03 10:13   ` [PATCH v3 2/4] drivers: replace zero-length arrays with undimensioned ones Bruce Richardson
2022-06-03 10:13   ` [PATCH v3 3/4] lib: " Bruce Richardson
2022-06-03 10:13   ` [PATCH v3 4/4] app: examples: " Bruce Richardson
2022-06-03 11:13   ` [PATCH v3 0/4] clean up zero-length arrays Bruce Richardson
2022-06-03 11:16 ` [PATCH v4 " Bruce Richardson
2022-06-03 11:16   ` [PATCH v4 1/4] cocci: add script for zero-length arrays in structs Bruce Richardson
2022-06-03 11:16   ` [PATCH v4 2/4] drivers: replace zero-length arrays with undimensioned ones Bruce Richardson
2022-06-03 11:16   ` [PATCH v4 3/4] lib: " Bruce Richardson
2022-06-03 11:16   ` [PATCH v4 4/4] app: examples: " Bruce Richardson
2022-06-07 14:16   ` [PATCH v4 0/4] clean up zero-length arrays David Marchand
2022-06-09 15:19   ` Tyler Retzlaff
2022-06-08 15:23 ` [PATCH " Stephen Hemminger
2022-06-14  9:40   ` Bruce Richardson
2022-06-14  9:45     ` Bruce Richardson

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=YpnkpoGzjBLDwvp7@bricha3-MOBL.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=mb@smartsharesystems.com \
    --cc=stephen@networkplumber.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;
as well as URLs for NNTP newsgroup(s).