coccinelle: misc: add flexible_array.cocci script
authorDenis Efremov <efremov@linux.com>
Mon, 21 Sep 2020 17:49:20 +0000 (20:49 +0300)
committerJulia Lawall <Julia.Lawall@lip6.fr>
Sat, 3 Oct 2020 20:08:40 +0000 (22:08 +0200)
commit7b36c1398fb63f9c38cc83dc75f143d2e5995062
treec9d887a0ffdab1ff767dbea9b714ecab88693ffd
parent44d8870f21529cfa8f50b503b5d949c6d46e6fc1
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 68e4cd17e218 ("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>
scripts/coccinelle/misc/flexible_array.cocci [new file with mode: 0644]