There is more information about fresh identifiers here:

http://cocci.ekstranet.diku.dk/wiki/doku.php?id=metavariables#fresh_identifier

julia


On Mon, 16 May 2011, Nicolas Palix wrote:

> Hi,
> 
> On Mon, May 16, 2011 at 9:24 AM, Jim Cromie <[email protected]> wrote:
> > On Sun, May 15, 2011 at 2:04 AM, Julia Lawall <[email protected]> wrote:
> >
> > One thing Id like to add is  a  _0 and _1 suffix
> > to the 2 new varnames, using the bound values of minor
> > would be useful in this case.
> >
> >  int __init tty_init(void)
> >  {
> > +       dev_t devt;
> > +       devt = MKDEV(TTYAUX_MAJOR, 0);
> > +       dev_t devt;
> > +       devt = MKDEV(TTYAUX_MAJOR, 1);
> > +       dev_t devt;
> > +       devt = devt;
> > +       dev_t devt;
> > +       devt = devt;
> 
> It is done with "fresh identifier". See an example below :
> 
> @ rcr_md @
> identifier f;
> fresh identifier devt = "devt";
> expression major, minor;
> expression ct, name;
> @@
> 
>        f(...) {
> ++      dev_t devt;
> ++      devt = MKDEV(major,minor);
> 
> <+...
> -       register_chrdev_region
> +       register_chrdev_ids
>        (
> -       MKDEV(major,minor),
> +       &devt,
>        ct, name)
> ...+>
> 
> }
> 
> @ all_md depends on rcr_md @    // where above changes made, also do
> identifier f;
> identifier rcr_md.devt;
> expression major, minor;
> @@
> 
>        f(...) {
>        dev_t devt;
>        devt = MKDEV(major,minor);
> 
> <+...
> -       MKDEV(major,minor)
> +       devt
> ...+>
> }
> 
> -- 
> Nicolas Palix
> http://sardes.inrialpes.fr/~npalix/
> 
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to