I have discovered some condition which coccinelle is not able to parse
correctly.
This by itself might be ok, but I do not think it is ok that it is
completely silent
about it (unless you happen to run with "-debug").
The parse problem occurs after macro invocations which does not end with a
terminating semicolon.
Example:
prompt>cat test.cocci
@@
@@
-OLD
+NEW
prompt>cat test.c
#define DEBUG(statement) statement
void test1(void)
{
OLD();
}
void test2(void)
{
int i;
OLD();
DEBUG( printf("hello world\n"); )
i = 42;
}
void test3(void)
{
int* ptr;
OLD();
DEBUG( printf("hello world\n"); )
*ptr = 42;
}
void test4(void)
{
int* ptr;
OLD();
DEBUG( printf("hello world\n") );
*ptr = 42;
}
prompt>/opt/coccinelle/bin/spatch -cocci_file test.cocci test.c
init_defs_builtins: /opt/coccinelle/share/coccinelle/standard.h
HANDLING: test.c
diff =
--- test.c 2010-01-21 09:57:48.000000000 +0100
+++ /tmp/cocci-output-10712-3ccf19-test.c 2010-01-21
09:59:38.852000000 +0100
@@ -2,13 +2,13 @@
void test1(void)
{
- OLD();
+ NEW();
}
void test2(void)
{
int i;
- OLD();
+ NEW();
DEBUG( printf("hello world\n"); )
i = 42;
}
@@ -24,7 +24,7 @@ void test3(void)
void test4(void)
{
int* ptr;
- OLD();
+ NEW();
DEBUG( printf("hello world\n") );
*ptr = 42;
}
prompt>
Notice here that coccinelle changes from OLD to NEW in test1, test2 and
test4 but not in test3 without any indications of problems.
Running with debug reveals why test3 is not processed:
prompt>/opt/coccinelle/bin/spatch -debug -cocci_file test.cocci test.c
...
HANDLING: test.c
-----------------------------------------------------------------------
let's go
-----------------------------------------------------------------------
parse error
= error in test.c; set verbose_parsing for more info
badcount: 8
bad: }
bad:
bad: void test3(void)
bad: {
bad: int* ptr;
bad: OLD();
BAD:!!!!! DEBUG( printf("hello world\n"); )
bad: *ptr = 42;
bad: }
-----------------------------------------------------------------------
...
prompt>
Question 1:
Could you please update coccinelle to be verbose about such parse failures?
Question 2:
How do I tell coccinelle to ignore the DEBUG macro?
BR Håkon Løvdal
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)