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 <step...@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

Reply via email to