From: Gal Pressman <gal@nvidia.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: Markus Elfring <Markus.Elfring@web.de>,
Tariq Toukan <tariqt@nvidia.com>,
cocci@inria.fr, Alexei Lazar <alazar@nvidia.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
Leon Romanovsky <leon@kernel.org>, Mark Bloch <mbloch@nvidia.com>,
Nicolas Palix <nicolas.palix@imag.fr>,
Richard Cochran <richardcochran@gmail.com>,
Saeed Mahameed <saeedm@nvidia.com>
Subject: Re: [cocci] [PATCH net-next 1/2] scripts/coccinelle: Find PTR_ERR() to %pe candidates
Date: Sun, 28 Sep 2025 16:17:53 +0300 [thread overview]
Message-ID: <6b2eb2c2-15e7-49b4-aaca-6fd58af9ec6c@nvidia.com> (raw)
In-Reply-To: <7522bdc8-1379-d516-d1fd-f7835453f23@inria.fr>
Thanks for the review Julia!
On 28/09/2025 15:23, Julia Lawall wrote:
>>>> +@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.
>
> I would suggest constant char[] fmt.
That works, thanks!
>
> format is for the case where you want to specify something about the %d
> %s, etc in the string.
>
>>> 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?
>
> expression *ptr should be a valid metavariable declaration. But
> Coccinelle needs to have enough information to know that something is a
> pointer. If you have code like a->b and you don't have the definition of
> the structure type of a, then it won't know the type of a->b. More
> information about types is available if you use options like
> --recursive-includes, but then treatment of every C file will entail
> parsing lots of header files, which could make things very slow. So you
> have to consider whether the information that the thing is a pointer is
> really necessary to what you are trying to do.
Makes sense, indeed the pointer is embedded in another struct.
I'll keep it as is, if the code calls PTR_ERR() on something that is not
a pointer it has bigger problems than using %pe.
>
>>>> +@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;
>
> Since you have r.p, the rule will only be applied if r has succeeded and
> furthermore if p has a value. So depends on r is not necessary.
Got it.
next prev parent reply other threads:[~2025-09-28 13:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 10:43 [PATCH net-next 0/2] scripts/coccinelle: Symbolic error names script Tariq Toukan
2025-09-18 10:43 ` [PATCH net-next 1/2] scripts/coccinelle: Find PTR_ERR() to %pe candidates Tariq Toukan
2025-09-19 16:54 ` Simon Horman
2025-09-22 23:36 ` Jakub Kicinski
2025-09-25 15:07 ` [cocci] " Markus Elfring
2025-09-28 11:40 ` Gal Pressman
2025-09-28 12:00 ` Markus Elfring
2025-09-28 13:24 ` Gal Pressman
2025-09-28 14:16 ` Markus Elfring
2025-09-28 16:40 ` Gal Pressman
2025-09-28 17:51 ` [cocci] [1/2] " Markus Elfring
2025-09-28 12:23 ` [cocci] [PATCH net-next 1/2] " Julia Lawall
2025-09-28 13:17 ` Gal Pressman [this message]
2025-09-18 10:43 ` [PATCH net-next 2/2] net/mlx5: Use %pe format specifier for error pointers Tariq Toukan
2025-09-19 16:55 ` Simon Horman
2025-09-26 19:50 ` [PATCH net-next 0/2] scripts/coccinelle: Symbolic error names script patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6b2eb2c2-15e7-49b4-aaca-6fd58af9ec6c@nvidia.com \
--to=gal@nvidia.com \
--cc=Markus.Elfring@web.de \
--cc=alazar@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=cocci@inria.fr \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=julia.lawall@inria.fr \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.palix@imag.fr \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox