On Sun, 30 Jan 2011, Julia Lawall wrote:

> The simple solution is just:
> 
> @@
> @@
> 
> * bar();
> 
> But maybe you also want to capture cases where the return value is stored 
> in a variable and that variable is never used.  Then you could say:
> 
> @@
> local idexpression x;
> @@
> 
> (
> x = bar()
> ...
> x
> |
> *x = bar()
> )
> 
> I put local idexpression to be sure that x is a local variable.  If it 
> were an expression such as a->b or a global variable, then it might be 
> used somewhere else.

>From the recent email of SF Markus Elfring, I realize that this is not 
quite good enough.  Because 

 x = bar()
 ...
 x

will also match the case where x is used in a reassignment.  So you could 
try:

 @@
 local idexpression x;
 expression E;
 @@
 
 (
 *x = bar()
 ... when != x
 x = E
 | 
 x = bar()
 ...
 x
 |
 *x = bar()
 ) 

julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to