Re: [cocci] Checking data structure member accesses after function return value assignments?

Julia Lawall <[email protected]>
Newsgroups fr.inria.cocci
Message-ID <[email protected]>

On Mon, 19 Jan 2026, Markus Elfring wrote:

> Hello,
>
> Felix Gu pointed also another software correction out.
>
> [PATCH] regulator: fp9931: Add missing memory allocation check
> https://lore.kernel.org/lkml/[email protected]/
> https://lkml.org/lkml/2026/1/18/129
>
>
> Such an update candidate can be found also by the following tiny SmPL script.
> https://elixir.bootlin.com/linux/v6.19-rc5/source/drivers/regulator/fp9931.c#L441-L442
>
> @display@
> expression action, action2, pointer;
> identifier member;
> @@
> *pointer = action(...);
> *pointer->member = action2(...);
>
>
> May I expect that the same data processing result can be achieved together with
> the application of an SmPL nest construct?
>
> @display@
> expression action, pointer;
> identifier member;
> @@
> *pointer = action(...);
> *<+... pointer->member ...+>
>  ;

Since you haven't told me what happens when you run this, I don't know
what the issue is.
But it may work better with () around the <+... ...+>, to avoid a parsing
conflict.

julia


>
>
> Regards,
> Markus
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.