* [PATCH] coccinelle: misc: restrict patch mode in flexible_array.cocci
@ 2021-03-08 19:12 Denis Efremov
2021-03-24 7:43 ` Denis Efremov
2021-03-24 20:16 ` Julia Lawall
0 siblings, 2 replies; 3+ messages in thread
From: Denis Efremov @ 2021-03-08 19:12 UTC (permalink / raw)
To: Julia Lawall; +Cc: Denis Efremov, cocci, linux-kernel
Skip patches generation for structs/unions 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>
---
scripts/coccinelle/misc/flexible_array.cocci | 23 ++++++++++++++++++--
1 file 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
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] coccinelle: misc: restrict patch mode in flexible_array.cocci
2021-03-08 19:12 [PATCH] coccinelle: misc: restrict patch mode in flexible_array.cocci Denis Efremov
@ 2021-03-24 7:43 ` Denis Efremov
2021-03-24 20:16 ` Julia Lawall
1 sibling, 0 replies; 3+ messages in thread
From: Denis Efremov @ 2021-03-24 7:43 UTC (permalink / raw)
To: Julia Lawall; +Cc: cocci, linux-kernel
Ping?
On 3/8/21 10:12 PM, Denis Efremov wrote:
> Skip patches generation for structs/unions 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>
> ---
> scripts/coccinelle/misc/flexible_array.cocci | 23 ++++++++++++++++++--
> 1 file 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] coccinelle: misc: restrict patch mode in flexible_array.cocci
2021-03-08 19:12 [PATCH] coccinelle: misc: restrict patch mode in flexible_array.cocci Denis Efremov
2021-03-24 7:43 ` Denis Efremov
@ 2021-03-24 20:16 ` Julia Lawall
1 sibling, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2021-03-24 20:16 UTC (permalink / raw)
To: Denis Efremov; +Cc: cocci, linux-kernel
On Mon, 8 Mar 2021, Denis Efremov wrote:
> Skip patches generation for structs/unions 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>
Applied. I changed the log message to remove "/unions", since the change
doesn't mention unions.
julia
> ---
> scripts/coccinelle/misc/flexible_array.cocci | 23 ++++++++++++++++++--
> 1 file 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
> --
> 2.26.2
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-24 20:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08 19:12 [PATCH] coccinelle: misc: restrict patch mode in flexible_array.cocci Denis Efremov
2021-03-24 7:43 ` Denis Efremov
2021-03-24 20:16 ` Julia Lawall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).