[RFC,1/2] devtools: add script to check for zero length array
Checks
Commit Message
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
new file mode 100644
@@ -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
+ ];
+};