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 AF49FA0548; Thu, 2 Jun 2022 17:09:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9F4F040E0F; Thu, 2 Jun 2022 17:09:24 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 71FCE4021E for ; Thu, 2 Jun 2022 17:09:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654182563; x=1685718563; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3bYZd7WaygJHt04iU3XkX+D09IsIaqQmoGf+qxGxtmw=; b=Qp9h6JMtOC39q+vYrX6azRd69FskRWDlSxWJjcp/wJgBRWT/o/0Lbc6K g1iThzSniFcVeXpqZkHEwBdQ9fkHCnv8GyQTkmQOw05U2R8XUUpQfyy0I SjpbwTHJgvRnTPOOtN9OjqnVOCpTlTkTQbTA6cXLvGoSFEKK5kj25hEBf iAWyLI6cbb8XiEi4ez8c8us3rGj/YbsyhBon+hi+1TQdQSjQoQlzY2Avx hpuFMqv219T90U2J002/BUU69nNkG8MINNT180fPIX6N8WdA2Zd83T9q2 uYLPD+p7sq6B/6AYrdpCzEZJnugp1uJvjHBo8xhVxkmgmO9hRV+DH+kYD g==; X-IronPort-AV: E=McAfee;i="6400,9594,10365"; a="301343810" X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="301343810" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 08:09:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="905025851" Received: from silpixa00401385.ir.intel.com (HELO silpixa00401385.ger.corp.intel.com.) ([10.237.222.171]) by fmsmga005.fm.intel.com with ESMTP; 02 Jun 2022 08:08:50 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, stephen@networkplumber.org, Bruce Richardson Subject: [PATCH 1/4] cocci: add script for zero-length arrays in structs Date: Thu, 2 Jun 2022 16:08:31 +0100 Message-Id: <20220602150834.643745-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220602150834.643745-1-bruce.richardson@intel.com> References: <20220602150834.643745-1-bruce.richardson@intel.com> MIME-Version: 1.0 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 --- 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