* [PATCH] HID: fix semantic patch and improve its performance
@ 2026-08-27 11:29 Julia Lawall
2026-08-27 11:51 ` [cocci] " Markus Elfring
0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2026-08-27 11:29 UTC (permalink / raw)
To: Ricardo Ribalda, dmitry.torokhov, bentiss, cocci, corbet, hadess,
jikos, lains, linux-doc, linux-input, linux-kernel, nicolas.palix,
skhan
Replace "expression" with "identifier" in the declaration of hdev.
This is necessary because hdev is used as the name of a function
parameter.
Move the two uses of @p2 to the relevant function names.
Convert <... ...>, meaning that the contained pattern is optional,
to use ..., when any, and exists. This requires that the function
contain calls to hid_hw_start, etc, which reduces the set of files
that are considered for matching against this pattern.
Reported-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
---
scripts/coccinelle/hid/ff_race.cocci | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/scripts/coccinelle/hid/ff_race.cocci b/scripts/coccinelle/hid/ff_race.cocci
index 479f5d1e3..e861de00c 100644
--- a/scripts/coccinelle/hid/ff_race.cocci
+++ b/scripts/coccinelle/hid/ff_race.cocci
@@ -7,18 +7,19 @@
virtual report
-@r@
+@r exists@
identifier probe_fn;
-expression hdev, flags;
+identifier hdev;
+expression flags;
position p1, p2;
@@
probe_fn(struct hid_device *hdev, ...) {
- <...
+ ... when any
hid_hw_start@p1(hdev, flags)
...
- \(input_ff_create\|input_ff_create_memless\)@p2(...)
- ...>
+ \(input_ff_create@p2\|input_ff_create_memless@p2\)(...)
+ ... when any
}
@script:python depends on report@
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [cocci] [PATCH] HID: fix semantic patch and improve its performance
2026-08-27 11:29 [PATCH] HID: fix semantic patch and improve its performance Julia Lawall
@ 2026-08-27 11:51 ` Markus Elfring
2026-08-27 12:00 ` Julia Lawall
0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2026-08-27 11:51 UTC (permalink / raw)
To: Julia Lawall, Ricardo Ribalda, cocci, linux-input
Cc: LKML, linux-doc, Bastien Nocera, Benjamin Tissoires,
Dmitry Torokhov, Filipe Laíns, Jiri Kosina, Jonathan Corbet,
Nicolas Palix, Shuah Khan
> Replace "expression" with "identifier" in the declaration of hdev.
> This is necessary because hdev is used as the name of a function
> parameter.
…
> +++ b/scripts/coccinelle/hid/ff_race.cocci
…
> -@r@
> +@r exists@
> identifier probe_fn;
> -expression hdev, flags;
> +identifier hdev;
May the following SmPL code variant be applied?
identifier hdev, probe_fn;
> +expression flags;
> position p1, p2;
> @@
>
> probe_fn(struct hid_device *hdev, ...) {
> - <...
> + ... when any
> hid_hw_start@p1(hdev, flags)
> ...
> - \(input_ff_create\|input_ff_create_memless\)@p2(...)
> - ...>
> + \(input_ff_create@p2\|input_ff_create_memless@p2\)(...)
How do you think about to use the following SmPL code variation?
(input_ff_create@p2
|input_ff_create_memless@p2
)(...)
> + ... when any
> }
>
> @script:python depends on report@
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [cocci] [PATCH] HID: fix semantic patch and improve its performance
2026-08-27 11:51 ` [cocci] " Markus Elfring
@ 2026-08-27 12:00 ` Julia Lawall
2026-08-27 12:08 ` Markus Elfring
0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2026-08-27 12:00 UTC (permalink / raw)
To: Markus Elfring
Cc: Ricardo Ribalda, cocci, linux-input, LKML, linux-doc,
Bastien Nocera, Benjamin Tissoires, Dmitry Torokhov,
Filipe Laíns, Jiri Kosina, Jonathan Corbet, Nicolas Palix,
Shuah Khan
[-- Attachment #1: Type: text/plain, Size: 1070 bytes --]
On Thu, 27 Aug 2026, Markus Elfring wrote:
> > Replace "expression" with "identifier" in the declaration of hdev.
> > This is necessary because hdev is used as the name of a function
> > parameter.
> …
> > +++ b/scripts/coccinelle/hid/ff_race.cocci
> …
> > -@r@
> > +@r exists@
> > identifier probe_fn;
> > -expression hdev, flags;
> > +identifier hdev;
>
> May the following SmPL code variant be applied?
>
> identifier hdev, probe_fn;
Yes, but it doesn't matter.
>
>
> > +expression flags;
> > position p1, p2;
> > @@
> >
> > probe_fn(struct hid_device *hdev, ...) {
> > - <...
> > + ... when any
> > hid_hw_start@p1(hdev, flags)
> > ...
> > - \(input_ff_create\|input_ff_create_memless\)@p2(...)
> > - ...>
> > + \(input_ff_create@p2\|input_ff_create_memless@p2\)(...)
>
> How do you think about to use the following SmPL code variation?
>
> (input_ff_create@p2
> |input_ff_create_memless@p2
> )(...)
I find this completely unreadable.
julia
>
>
> > + ... when any
> > }
> >
> > @script:python depends on report@
>
> Regards,
> Markus
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [cocci] [PATCH] HID: fix semantic patch and improve its performance
2026-08-27 12:00 ` Julia Lawall
@ 2026-08-27 12:08 ` Markus Elfring
0 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2026-08-27 12:08 UTC (permalink / raw)
To: Julia Lawall, Ricardo Ribalda, cocci, linux-input
Cc: LKML, linux-doc, Bastien Nocera, Benjamin Tissoires,
Dmitry Torokhov, Filipe Laíns, Jiri Kosina, Jonathan Corbet,
Nicolas Palix, Shuah Khan
>> …
>>> +++ b/scripts/coccinelle/hid/ff_race.cocci
>> …
>>> -@r@
>>> +@r exists@
>>> identifier probe_fn;
>>> -expression hdev, flags;
>>> +identifier hdev;
>>
>> May the following SmPL code variant be applied?
>>
>> identifier hdev, probe_fn;
>
> Yes, but it doesn't matter.
Can it occasionally matter to avoid the duplication of such an SmPL key word?
Can SmPL variable declarations become a bit shorter?
>>> +expression flags;
>>> position p1, p2;
>>> @@
>>>
>>> probe_fn(struct hid_device *hdev, ...) {
>>> - <...
>>> + ... when any
>>> hid_hw_start@p1(hdev, flags)
>>> ...
>>> - \(input_ff_create\|input_ff_create_memless\)@p2(...)
>>> - ...>
>>> + \(input_ff_create@p2\|input_ff_create_memless@p2\)(...)
>>
>> How do you think about to use the following SmPL code variation?
>>
>> (input_ff_create@p2
>> |input_ff_create_memless@p2
>> )(...)
>
> I find this completely unreadable.
I find this view surprising.
There are special views involved for the layout of such SmPL disjunctions.
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-27 12:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-27 11:29 [PATCH] HID: fix semantic patch and improve its performance Julia Lawall
2026-08-27 11:51 ` [cocci] " Markus Elfring
2026-08-27 12:00 ` Julia Lawall
2026-08-27 12:08 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox