Re: [cocci] [PATCH net-next 1/2] scripts/coccinelle: Find PTR_ERR() to %pe candidates
From: Gal Pressman
Date: Sun Sep 28 2025 - 07:40:28 EST
Hi Markus!
Thanks for the review, forgive for being a total noob at coccinelle,
hence the many questions.
On 25/09/2025 18:07, Markus Elfring wrote:
> …> The script supports context, report, and org modes.
>
> I suggest to omit this sentence from the description.
>
>
> Will the hint “scripts/” be omitted from the patch prefix?
The patch was merged already, so I'm skipping to comments that can be
fixed in a followup patch.
>
>
> …> +++ b/scripts/coccinelle/misc/ptr_err_to_pe.cocci
> …> +// URL: https://coccinelle.gitlabpages.inria.fr/website
>
> I suggest to omit this comment line.
Sure.
>
>
> …> +virtual context
>> +virtual org
>> +virtual report
>
> The restriction on the support for three operation modes will need further development considerations.
I don't understand what you mean?
>
>
>> +@r@
>> +expression ptr;
>> +constant fmt;
>> +position p;
>> +identifier print_func;
>> +@@
>> +* print_func(..., fmt, ..., PTR_ERR@p(ptr), ...)
>
> How do you think about to use the metavariable type “format list”?
I did find "format list" in the documentation, but spatch fails when I
try to use it.
>
> Would it matter to restrict expressions to pointer expressions?
I tried changing 'expression ptr;' -> 'expression *ptr;', but then it
didn't find anything. Am I doing it wrong?
>
>
>> +@script:python depends on r && org@
>
> I guess that such an SmPL dependency specification can be simplified a bit.
You mean drop the depends on r?
>
>
>> +p << r.p;
>> +@@
>> +coccilib.org.print_todo(p[0], "WARNING: Consider using %pe to print PTR_ERR()")
>
> I suggest to reconsider the implementation detail once more
> if the SmPL asterisk functionality fits really to the operation modes “org” and “report”.
>
> The operation mode “context” can usually work also without an extra position variable,
> can't it?
Can you please explain?