On Thu, 29 Dec 2011, Arie Middelkoop wrote:


2. I do not need an empty ";" ... Should I create a second rule
  which removes extra ";" ? Or there is a better way?

In your rule, you wrote:
- retlen = 0
(without the semicolon)
So, that's why you end up with an empty statement.

Ah. Indeed, if one wants to remove it, one needs to remove the semicolon too. The original problem was that retlen could also be initialized in a variable declaration and - retlen = 0; won't match that. You have to explicitly match the declaration, ie:

(
-T retlen = 0;
|
-retlen = 0;
)

The former unfortunately doesn't work for cases where multiple variables are declared at once. You may want to make two rules, one to do the transformation as above, and another just to find such problematic cases, with retlen = 0 and no semicolon.

julia

I guess that if you turn it into a statement by adding the semicolon, then 
maybe also your question 1 disappears?

3. Why "mtdchar_read3()" does not match?

That probably has to do with the fact that there is an execution path in that function that does not include mtd_read() call (your 'case 2'). You probably have to use one of the special '...', like '... when any' or '.. when exists', but I'd have to lookup which one was which again.

Arie


Thanks for help!

--
Best Regards,
Artem Bityutskiy

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

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

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

Reply via email to