From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id DCFA543E83;
	Tue, 16 Apr 2024 17:21:36 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 49ADB402BD;
	Tue, 16 Apr 2024 17:21:31 +0200 (CEST)
Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com
 [209.85.214.174])
 by mails.dpdk.org (Postfix) with ESMTP id 8A5EF40262
 for <dev@dpdk.org>; Tue, 16 Apr 2024 17:21:28 +0200 (CEST)
Received: by mail-pl1-f174.google.com with SMTP id
 d9443c01a7336-1e4f341330fso37590795ad.0
 for <dev@dpdk.org>; Tue, 16 Apr 2024 08:21:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1713280887;
 x=1713885687; darn=dpdk.org; 
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=QW+HKNGxUagYmmYl1XJKUzn5fTnWCQoUK/WJxFrsHPQ=;
 b=1udf59DM88ZS61n7pjfZjutgXwB04riOqpwozQRjKImZStcDRovLwZdEHRC1Vd2k6r
 j+dfTlx1PgVhWoHCRaVNEJsejVWbdgPLSqcY0jvmQizbTJZa/mxYh64nazxpR1TTwy0Y
 d6J0gZLd48k0TMQHfpe0u1QBmM4egNWBuvC2YZlc4BswVjWO1e65HEA6GHliVBu3ynxr
 xyw5YWbUKEoV0AbMUJJGghD7CGyf6Nr4vfezIcM6Phcpz2pQPpcuFvdcyJ5y2+7OXh84
 E8k2lxM5I9Xujfn+SmXtl5G6ue92Iy0mR7XYWQOdBcENrwQAwA2rXKhljQ+JikNQehUA
 /fUA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1713280887; x=1713885687;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=QW+HKNGxUagYmmYl1XJKUzn5fTnWCQoUK/WJxFrsHPQ=;
 b=ZXN9uDQUdgLEsX3a1R15qSe3NBlyVJ8VoaoauAdj1M2V1GTNXm6llJ0UcRHa00R0Xp
 r8OPYMTroI/EcbB3fq8ye3nKa9vVsPqVsI21HIYrtyhRB1uTUon9pEbAfE1zRLpUeqvj
 vwh0anpm9Mbbnw7FvTXXxRpwr5i3bUZU6OvrP/q1NqL7LajeXxI1D8MRwgx3SGg3/gRg
 p1EnEonZGERwsCXPlUSbADaaGLy60TMKtPlGbfCTKrN4ZEWFv5vYIfK8zrsECm/pBSZ+
 V4S3ahLjuyYYmrj29PaDTIyIGtPng/uFfh/+sGDxjHISSqrSB8+vw2xECPX896oBWawl
 Hrrw==
X-Gm-Message-State: AOJu0YwEytdNz+Eegro5NFte0vRYimUKUU8T+LDo3kItjxde0u3qSdQb
 DbOH6TqPyvpwqESuwTy51gQYa+HaeOI03muPJmOWExK4j8+Yw+Vm7Mu/ZILJlYcU4cp/9glUKAk
 i
X-Google-Smtp-Source: AGHT+IEYO2TlGDuFAVEp7WCSJj4rdeqGgFd8p1qKBKBCd10HEPMBjvuxpn2TMn5wZ83v5/UEeHTPrQ==
X-Received: by 2002:a17:902:e809:b0:1e3:d470:823d with SMTP id
 u9-20020a170902e80900b001e3d470823dmr13153592plg.21.1713280887628; 
 Tue, 16 Apr 2024 08:21:27 -0700 (PDT)
Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226])
 by smtp.gmail.com with ESMTPSA id
 l17-20020a170903245100b001e80154a400sm213348pls.126.2024.04.16.08.21.27
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 16 Apr 2024 08:21:27 -0700 (PDT)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH 1/5] cocci: add script to use RTE_DIM
Date: Tue, 16 Apr 2024 08:19:27 -0700
Message-ID: <20240416152124.69590-2-stephen@networkplumber.org>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20240416152124.69590-1-stephen@networkplumber.org>
References: <20240416152124.69590-1-stephen@networkplumber.org>
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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

New script to find RTE_DIM should be used.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 devtools/cocci/rte-dim.cocci | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 devtools/cocci/rte-dim.cocci

diff --git a/devtools/cocci/rte-dim.cocci b/devtools/cocci/rte-dim.cocci
new file mode 100644
index 0000000000..e7fcadec98
--- /dev/null
+++ b/devtools/cocci/rte-dim.cocci
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: BSD-3-Clause
+// Use RTE_DIM macro instead of dividing sizeof array with sizeof an elmemnt
+//
+// Based of Linux kernela array_size.cocci
+//
+@@
+type T;
+T[] E;
+@@
+(
+|
+- (sizeof(E)/sizeof(E[...]))
++ RTE_DIM(E)
+|
+- (sizeof(E)/sizeof(*E))
++ RTE_DIM(E)
+|
+- (sizeof(E)/sizeof(T))
++ RTE_DIM(E)
+|
+- RTE_DIM((E))
++ RTE_DIM(E)
+)
-- 
2.43.0