summaryrefslogtreecommitdiffstats
path: root/scripts/coccinelle
diff options
context:
space:
mode:
authorDenis Efremov <efremov@linux.com>2021-03-08 22:12:15 +0300
committerJulia Lawall <Julia.Lawall@inria.fr>2021-05-01 21:23:56 +0200
commit3afb532b19df3238dede98b184bc8852517f206a (patch)
tree9fcbef271e3f103383f0a13e4d2419369fae46dd /scripts/coccinelle
parent5f66f73b9ff4dcabd4e2405ba9c32e80e02f9408 (diff)
downloadlinux-3afb532b19df3238dede98b184bc8852517f206a.tar.gz
linux-3afb532b19df3238dede98b184bc8852517f206a.tar.bz2
linux-3afb532b19df3238dede98b184bc8852517f206a.zip
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 637464c59e0b ("ACPI: NFIT: Fix flexible_array.cocci warnings"). Signed-off-by: Denis Efremov <efremov@linux.com> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
Diffstat (limited to 'scripts/coccinelle')
-rw-r--r--scripts/coccinelle/misc/flexible_array.cocci23
1 files changed, 21 insertions, 2 deletions
diff --git a/scripts/coccinelle/misc/flexible_array.cocci b/scripts/coccinelle/misc/flexible_array.cocci
index 947fbaff82a9..f427fd68ed2d 100644
--- a/scripts/coccinelle/misc/flexible_array.cocci
+++ b/scripts/coccinelle/misc/flexible_array.cocci
@@ -51,21 +51,40 @@ position p : script:python() { relevant(p) };
};
)
+@only_field depends on patch@
+identifier name, array;
+type T;
+position q;
+@@
+
+(
+ struct name {@q
+ T array[0];
+ };
+|
+ struct {@q
+ T array[0];
+ };
+)
+
@depends on patch@
identifier name, array;
type T;
position p : script:python() { relevant(p) };
+// position @q with rule "only_field" simplifies
+// handling of bitfields, arrays, etc.
+position q != only_field.q;
@@
(
- struct name {
+ struct name {@q
...
T array@p[
- 0
];
};
|
- struct {
+ struct {@q
...
T array@p[
- 0