Hi Josh,

This error usually means the SP is wrongly written. But I am not sure
it is the case here.

Julia, do you have an explanation? What's wrong? The SP or Coccinelle ?

Josh, the following SP seems to work on your code snippet.
Note that the rule order is important.

@@
identifier dpy;
@@
-if (dpy) { XCloseDisplay(dpy); }
+xcb_disconnect(conn);

@@
identifier dpy;
@@
-XCloseDisplay(dpy);
+xcb_disconnect(conn);

On Sunday 13 June 2010 21:11:11 Josh Triplett wrote:
> Hello,
> 
> I've just started trying to use Coccinelle to rewrite code written for
> Xlib to use our replacement library XCB instead.
> 
> In trying some simple test patches and learning Coccinelle, I
> encountered this error:
> 
> """
> HANDLING: /tmp/bug.c
> 
> previous modification:
> MINUS
>   >>> xcb_disconnect(conn);
> 
> According to environment 0:
> 
> 
> current modification:
> MINUS
> According to environment 0:
> 
> 
> Fatal error: exception Failure("rule starting on line 1: already tagged token:
> C code context
> File "/tmp/bug.c", line 5, column 1,  charpos = 45
>     around = 'XCloseDisplay', whole content =   XCloseDisplay (dpy);")
> """
> 
> I reduced the semantic patch and the source file to minimal test cases.
> The semantic patch:
> 
> @@
> identifier dpy;
> @@
> (
> -if (dpy) { XCloseDisplay(dpy); }
> +xcb_disconnect(conn);
> |
> -XCloseDisplay(dpy);
> +xcb_disconnect(conn);
> )
> 
> The source file:
> 
> static void
> Exit(int code)
> {
>     if (dpy) {
>         XCloseDisplay (dpy);
>     }
>     exit (code);
> }
> 
> 
> What does this error mean?  Does it indicate an error in Coccinelle or
> in my patch?
> 
> Thanks for Coccinelle; I can already see that it will work very well for
> several tasks I want to accomplish.
> 
> - Josh Triplett
> _______________________________________________
> Cocci mailing list
> [email protected]
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)
> 

-- 
Nicolas Palix
Tel: (+33) 1 44 27 87 25
Tel: (+33) 6 81 07 91 72
Web: http://www.diku.dk/~npalix/
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to