On Fri, 13 May 2011, Jim Cromie wrote:

> Nicolas, Julia,
> 
> thanks for the help.
> With it, Ive gotten most call-sites (40 of them) transformed automatically.
> 
> the ones that remain have MKDEV () calls inline.
> There are only a few of these, so I could do them manually,
> but, well, I want to build my spatch-fu.
> 
> 
> drivers/tty/tty_io.c: unregister_chrdev_region(MKDEV(driver->major,
> driver->minor_start),
> drivers/tty/tty_io.c:     register_chrdev_region(MKDEV(TTYAUX_MAJOR,
> 0), 1, "/dev/tty") < 0)
> drivers/tty/tty_io.c:     register_chrdev_region(MKDEV(TTYAUX_MAJOR,
> 1), 1, "/dev/console") < 0)
> 
> Ive tried this rule to fix it:
> 
> @ mdev_inline @
> dev_t devid;
> expression ct, name;
> expression major, minor;
> position p;
> @@
> 
>  {
>  @p
>  ...
> - register_chrdev_region(MKDEV(major, minor), ct, name)
>  ...
>  }
> 
>  @p
> + dev_t devid = MKDEV(major, minor);
> 
> + register_chrdev_ids(devid, ct, name)

I'm not sure what you mean here.  Are the last three lines a separate 
rule?

Also, a position variable has to be attached to something, which is the 
token that comes just before it.

Finally, register_chrdev_ids(devid, ct, name) is an expression, not a 
statement (missing semicolon).

If you make a second rule

@@
position rule1.p; // assuming the first was called rule1
@@

{@p
+ dev_t devid = MKDEV(major, minor);
+ register_chrdev_ids(devid, ct, name);
...
}

then it should put the declaration at the top of the innermost pair of 
braces.

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

Reply via email to