Hi,

Thanks for bring up a good tool - coccinelle.

I did a simple test just now and found a problem, seems it cannot parse/handle 
the code in some "#ifdef ... #endif" sections.

The details is below:
I have a project with many source files, I want to replace "my_mutex_lock" 
function call to "mutext_lock".
I wrote a simple rule(test.spatch) for it:
@@ expression X; @@
- my_mutex_lock(X)
+ mutex_lock(X)

And I apply the semantic patch by "spatch -dir ~/my_dir --sp-file test.spatch 
-in_place -include_headers".

After it is done, I checked that most "my_mutex_lock" function calls are 
replaced by  "mutext_lock" successfully, but some are not.
The failure cases seem to be in some "#ifdef ... #endif" sections, such as
#ifdef MY_MACRO_A
my_mutex_lock(x);
#endif
The "my_mutex_lock" in the above case cannot be detected by coccinelle, it kept 
unchanged.

Is there any method to workaround it?

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

Reply via email to