From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [RFC 1/2] devtools: add script to check for zero length array
Date: Tue, 15 Feb 2022 15:00:57 -0800 [thread overview]
Message-ID: <20220215230058.64760-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20220215230058.64760-1-stephen@networkplumber.org>
Use the same script as Linux kernel to find and replace
zero length arrays at end of structures.
Flexible arrays were introduced in C99 and help catch
some obvious errors (like incorrect sizeof).
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
devtools/cocci/zerolengtharray.cocci | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 devtools/cocci/zerolengtharray.cocci
diff --git a/devtools/cocci/zerolengtharray.cocci b/devtools/cocci/zerolengtharray.cocci
new file mode 100644
index 000000000000..50d8b00716ae
--- /dev/null
+++ b/devtools/cocci/zerolengtharray.cocci
@@ -0,0 +1,17 @@
+//
+// Replace all older style of one-element or zero length arrays
+// with current flexible member arraya
+//
+
+@@
+identifier S, member, array;
+type T1, T2;
+@@
+
+struct S {
+ ...
+ T1 member;
+ T2 array[
+- 0
+ ];
+};
--
2.34.1
next prev parent reply other threads:[~2022-02-15 23:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-15 23:00 [RFC 0/2] Eliminate zero length arrays in DPDK Stephen Hemminger
2022-02-15 23:00 ` Stephen Hemminger [this message]
2022-02-15 23:00 ` [RFC 2/2] treewide: replace zero-length array with flex array Stephen Hemminger
2022-02-16 9:27 ` [RFC 0/2] Eliminate zero length arrays in DPDK Morten Brørup
2022-02-16 9:33 ` Bruce Richardson
2022-02-16 10:05 ` Morten Brørup
2022-02-16 10:10 ` Bruce Richardson
2022-02-17 7:41 ` Tyler Retzlaff
2022-02-24 21:51 ` Morten Brørup
2022-02-24 23:03 ` Stephen Hemminger
2022-02-16 18:56 ` Stephen Hemminger
2022-02-17 8:09 ` Tyler Retzlaff
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=20220215230058.64760-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).