From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AE44CA055B; Fri, 3 Jun 2022 12:38:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5699240694; Fri, 3 Jun 2022 12:38:36 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 68B0040691 for ; Fri, 3 Jun 2022 12:38:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654252715; x=1685788715; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=rZ00NPjH3Np6/mky1kPT50qoMnx/8tQisFTxKa/v3bY=; b=KYC8Uhcp7HcI+WuJ1Ug7qYwogZ2O6fyRMJMu+xsp0dNWwCSYtoRTkXCY W4PFwKkRpToDbQcPP4piKOoKVlN5pwtiMTdtKDO13VBDjkwVkWoH2lR5E tkbD7N5RWqtXo47UjflYQKcTS82znxbEvhc/cDsvUHjsCdeOwU0NE7uL+ KbIS9vYT+FvRC+S3aBftX48VkaOB9KsIzp49EQ+OKfme2iaRBM9bC934X TmEzAFpM95zpIXwqrjrYKXyB9J+ktPm7TDqIq4e7yneu0phTlWGrQucXC qjHYI8XYeesbR1DjZckC3UwlzAkIT4cCY/agvoE7bWjTlH5Va/6SQLqw0 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10366"; a="273787799" X-IronPort-AV: E=Sophos;i="5.91,274,1647327600"; d="scan'208";a="273787799" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2022 03:38:34 -0700 X-IronPort-AV: E=Sophos;i="5.91,274,1647327600"; d="scan'208";a="681090577" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.6.223]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 03 Jun 2022 03:38:33 -0700 Date: Fri, 3 Jun 2022 11:38:30 +0100 From: Bruce Richardson To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: dev@dpdk.org, david.marchand@redhat.com, Stephen Hemminger , Hemant Agrawal Subject: Re: [PATCH v3 1/4] cocci: add script for zero-length arrays in structs Message-ID: References: <20220602150834.643745-1-bruce.richardson@intel.com> <20220603101331.1030993-1-bruce.richardson@intel.com> <20220603101331.1030993-2-bruce.richardson@intel.com> <98CBD80474FA8B44BF855DF32C47DC35D870E7@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D870E7@smartserver.smartshare.dk> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 > > Acked-by: Morten Brørup > > Acked-by: Stephen Hemminger > > Acked-by: Hemant Agrawal > > --- > > 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.