From: Bruce Richardson Date: Fri, 3 Jun 2022 11:16:22 +0000 (+0100) Subject: cocci: add script for zero-length arrays in structs X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=beeed9d92aca54f9e7a3881a14af2528bb227926;p=dpdk.git cocci: add script for zero-length arrays in structs Add script to replace [0] with [] when used at the end of a struct. The script also includes an additional struct member to match against so as to avoid issues with arrays with only a single zero-length element. Signed-off-by: Bruce Richardson Acked-by: Morten Brørup Acked-by: Stephen Hemminger Acked-by: Hemant Agrawal --- diff --git a/devtools/cocci/zero_length_array.cocci b/devtools/cocci/zero_length_array.cocci new file mode 100644 index 0000000000..de8783bc7a --- /dev/null +++ b/devtools/cocci/zero_length_array.cocci @@ -0,0 +1,21 @@ +// Replace zero-length array members with [] +@@ +identifier st, member, arr; +type T1, T2; +@@ +struct st { + ... + T1 member; +- T2 arr[0]; ++ T2 arr[]; +}; +@@ +identifier st, member, arr, id; +type T1, T2; +@@ +struct st { + ... + T1 member; +- T2 arr[0]; ++ T2 arr[]; +} id;