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

Julia Lawall <[email protected]> Tue, 20 Jan 2026 14:30:09 +0100 (CET)
Newsgroups fr.inria.cocci
Message-ID <[email protected]>

----- Mail original -----
> De: "Markus Elfring" <[email protected]>
> À: "Julia Lawall" <[email protected]>
> Cc: "cocci" <[email protected]>
> Envoyé: Mardi 20 Janvier 2026 08:23:48
> Objet: Re: [cocci] Checking data structure member accesses after function return value assignments?

>> And yet I made another suggestion that you completely ignored:
>> 
>> * pointer = action(...);
>>   (<+...
>> * pointer->member
>>   ...+>);
> 
> Can such an SmPL code variant prevent the interpretation as an “empty
> statement”?

Yes, because as already explained the () forces the <+... ...+> to be considered to be an expression.


> 
>> This should you give what you seemed to want, with pointer->member in the
>> immediately following statement only.
> 
> Another SmPL script variant can be tried out:
> @refined_display@
> expression action;
> expression * pointer;
> identifier member;
> @@
> *pointer = action(...);
> (
> <+...
> *pointer->member
> ...+>
> );
> 
> 
> Corresponding test result:
> Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch
> --no-loops
> …/Projekte/Coccinelle/janitor/show_questionable_statement_combination7.cocci
> drivers/regulator/fp9931.c
> …
> @@ -438,8 +438,6 @@ static int fp9931_probe(struct i2c_clien
> …
> -       data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
> -       data->regmap = devm_regmap_init_i2c(client, &regmap_config);
>        if (IS_ERR(data->regmap))
> …
> 
> real    0m0,175s
> user    0m0,150s
> sys     0m0,022s
> 
> 
> Regards,
> Markus