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 [thread overview]
Message-ID: <20240416152124.69590-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20240416152124.69590-1-stephen@networkplumber.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
next prev parent reply other threads:[~2024-04-16 15:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 15:19 [PATCH 0/5] use RTE_DIM where possible Stephen Hemminger
2024-04-16 15:19 ` Stephen Hemminger [this message]
2024-04-16 15:19 ` [PATCH 2/5] app: use RTE_DIM Stephen Hemminger
2024-04-16 15:30 ` Tyler Retzlaff
2024-04-17 6:13 ` [EXTERNAL] " Akhil Goyal
2024-04-16 15:19 ` [PATCH 3/5] lib: " Stephen Hemminger
2024-04-16 15:32 ` Tyler Retzlaff
2024-04-16 15:19 ` [PATCH 4/5] examples _use RTE_DIM Stephen Hemminger
2024-04-16 15:32 ` Tyler Retzlaff
2024-04-16 15:19 ` [PATCH 5/5] drivers/net: use RTE_DIM Stephen Hemminger
2024-04-16 16:29 ` Ferruh Yigit
2024-04-16 17:32 ` Stephen Hemminger
2024-04-17 8:00 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240416152124.69590-2-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).