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 741A4A055B; Fri, 3 Jun 2022 12:13:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 63D6342B74; Fri, 3 Jun 2022 12:13:55 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 9607F40691 for ; Fri, 3 Jun 2022 12:13:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654251233; x=1685787233; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BY2GESWBMEfdGqFQLhB3yEPo8OBPmthfTPDljQhhnI0=; b=l8PZn54HQ+EMj6aGr/z9Fho3iFEyrQ0qmFhrngZ5jebPpzvRKa3mb6ny 5p1p3a6S2tmC7AWGn8LLad47vcnhJ7dGV1YeqbK1KypDQAZzMjN72XZ+M wutk6DPd433dH0L/pJ4vdiWcbmI57ELGWbngYElWSYPxsTwxWrgbp72l2 kX3+CpA/3o8MYdlWsCzUE7aiziegXTRcUW7W3TZGv4AIP6JESov1utaCv NPt4O6xs65WXyu7WFPiIHj7J8Y+8ZXcn2BDfnz00THrDZfHzSJizEPRR9 0lFOXfkAYBNWShTm0kQ9en411M9hTAdd4fnmhYMij6NRBt0Od9eUU9XD1 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10366"; a="273783800" X-IronPort-AV: E=Sophos;i="5.91,274,1647327600"; d="scan'208";a="273783800" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2022 03:13:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,274,1647327600"; d="scan'208";a="530957203" Received: from silpixa00401026.ir.intel.com ([10.243.22.135]) by orsmga003.jf.intel.com with ESMTP; 03 Jun 2022 03:13:50 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , =?UTF-8?q?Morten=20Br=C3=83=C2=B8rup?= , Stephen Hemminger , Hemant Agrawal Subject: [PATCH v3 1/4] cocci: add script for zero-length arrays in structs Date: Fri, 3 Jun 2022 11:13:28 +0100 Message-Id: <20220603101331.1030993-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220603101331.1030993-1-bruce.richardson@intel.com> References: <20220602150834.643745-1-bruce.richardson@intel.com> <20220603101331.1030993-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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