Commit Graph

2 Commits

Author SHA1 Message Date
Denis Efremov 3afb532b19 coccinelle: misc: restrict patch mode in flexible_array.cocci
Skip patches generation for structs with a single field.
Changing a zero-length array to a flexible array member in a struct
with no named members breaks the compilation. However, reporting
such cases is still valuable, e.g. commit 637464c59e
("ACPI: NFIT: Fix flexible_array.cocci warnings").

Signed-off-by: Denis Efremov <efremov@linux.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
2021-05-01 21:23:56 +02:00
Denis Efremov 7b36c1398f coccinelle: misc: add flexible_array.cocci script
One-element and zero-length arrays are deprecated [1]. Kernel
code should always use "flexible array members" instead, except
for existing uapi definitions.

The script warns about one-element and zero-length arrays in structs.

[1] commit 68e4cd17e2 ("docs: deprecated.rst: Add zero-length and
    one-element arrays")

Cc: Kees Cook <keescook@chromium.org>
Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Denis Efremov <efremov@linux.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
2020-10-03 22:08:40 +02:00