>> 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?


I hadnt intended it, but accept that it might be necessary.
@p was supposed to mark the beginning of the inner {scope}
where its legal to insert a local variable decl with the first +line

The "rule" (sarcastic air-quotes)
had the ... between the beginning of scope and the -line,
but didnt capture it for reuse.

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

does '{'  ie 'open new scope' count ?

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

That was intended.  Some of the uses are embedded inside
if (-here-) so wouldnt be a complete statement.

>
> 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.

ok, that seems to confirm my question:  {@p is meaningful.
(and better written on same line - clearer intent)

> julia
>

thanks again.  I'll go try this now,
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to