Re: [cocci] Checking data structure member accesses after function return value assignments?
Markus Elfring <[email protected]> Tue, 20 Jan 2026 14:23:48 +0100
| Newsgroups | fr.inria.cocci |
|---|---|
| Message-ID | <[email protected]> |
> 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”?
> 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, ®map_config);
if (IS_ERR(data->regmap))
…
real 0m0,175s
user 0m0,150s
sys 0m0,022s
Regards,
Markus