From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BEE6C433EF for ; Thu, 2 Jun 2022 16:13:45 +0000 (UTC) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A3C1040DF7; Thu, 2 Jun 2022 18:13:43 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id ADF0B40DDE for ; Thu, 2 Jun 2022 18:13:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654186422; x=1685722422; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8vM6zCWXWvM6jCv4ceAwu+gaWLu7yZur8gZYmDzRxYw=; b=DqH0Et7ZStWSjsETjfFt5/Wk/i58BMrpZhWkE9XI88KHox6c8asLmRY3 Z2XOHNBv7x+IcYSUUG24cUKyDcm4JRnyeZH+BI4qAn9a0nUIXboSrqs1K GGpSmv1R9Fbj/KH0Ah4xBb+8slZRmhVPfKvdk4SoAyUUMUKq2A2fHmyTl J4zwv0ZjkClEnAXBkEtkE9Q+rlNVBnnsQCNpSqDY2JQwt0i72WpS4YLE7 s9WnH+DvV2jtQaU3yfl2ChyqMZlBImTNvs8tR46ai3zqknGri7dUUyHaY UPZZfQ3S0xejHkIeVbv9s495w+e3G+VOPEJdO85PSl+XNuaybdC+fqCmb g==; X-IronPort-AV: E=McAfee;i="6400,9594,10366"; a="276005628" X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="276005628" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 09:13:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="577575009" Received: from silpixa00401385.ir.intel.com (HELO silpixa00401385.ger.corp.intel.com.) ([10.237.222.171]) by orsmga007.jf.intel.com with ESMTP; 02 Jun 2022 09:13:39 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Stephen Hemminger Subject: [PATCH v2 1/4] cocci: add script for zero-length arrays in structs Date: Thu, 2 Jun 2022 17:13:21 +0100 Message-Id: <20220602161324.1123926-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220602161324.1123926-1-bruce.richardson@intel.com> References: <20220602150834.643745-1-bruce.richardson@intel.com> <20220602161324.1123926-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 --- 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