On Thu, Dec 03, 2015 at 11:12:56PM +0100, Julia Lawall wrote:
> > Usually you'd do something like first find all that have the initializer and
> > then match all that where not matched before using a position metavariable.
> > E.g.
> >
> > @r1@
> > identifier fops;
> > identifier fn;
> > position p;
> > @@
> > struct tty_operations fops@p = {
> > ...,
> > .cleanup = fn,
> > ...
> > };
>
> You don't need the ... Coccinelle is very relaxed about matching
> structure initializers. What you provide should be a subset, in any
> order, of what is present. The ... would only be needed if you want to
> add a new field initialization, and to force it to the beginning or end
> of the structure.
>
> Luis, why did you use a regular expression for cleanup?
You're right no need:
virtual context
@ is_tty @
identifier fops;
@@
struct tty_operations fops = {
};
@ tty_has_cleanup depends on is_tty @
identifier is_tty.fops;
identifier fn;
@@
struct tty_operations fops = {
.cleanup = fn,
};
@ depends on is_tty && !tty_has_cleanup && context @
identifier is_tty.fops;
@@
* struct tty_operations fops = {
};
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
