On Sat, 27 Nov 2010, Eric Leblond wrote:

> Hi,
> 
> Le jeudi 25 novembre 2010 à 18:55 +0100, Julia Lawall a écrit :
> > On Wed, 24 Nov 2010, Julia Lawall wrote:
> > 
> > > Thanks for your interest in Coccinelle.  I had thought that in the 
> > > special 
> > > case where the change is only on the variable that it would be able to 
> > > make the transformation.  Ie, if the second rule were rather written with:
> > > 
> > >   Packet
> > > - p
> > > + *p = SCMalloc(SIZE_OF_PACKET)
> > >   ;
> > > 
> > > But I see that this is not working either.  I will look into it and hope 
> > > to find a solution today or tomorrow.
> > 
> > It turned out to be a little more subtle than expected.  I will hope to 
> > have a working solution soon.
> 
> Working on the same code modification, I did not found a way to treat
> the case where I've got multiple Packet variable.
> 
> If I use : 
>         @rule1@
>         identifier p;
>         identifier func;
>         identifier fdl;
>         @@
>         func(...) {
>         ...
>         Packet p;
>         <...
>         (
>         - p.fdl
>         + p->fdl
>         |
>         - &(p)
>         + p
>         )
>         ...>
>         }
> 
> on a file where there is :
>         Packet p1;
>         Packet p2;
> 
> then the modification is only done on p1.
> 
> Is there a way to treat all variables at once ?

Yes, it should work better if you move the <... up above the declaration 
of Packet.  You may also want to change it to <+... ...+> if you want to 
be sure there is at least one match.

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

Reply via email to