On Sat, 18 Dec 2010, L. Alberto Giménez wrote:

> Hi,
> 
> I've starting to use coccinelle to submit some trivial cleanup patches for the
> Linux kernel, and now I'm trying to write a "delete unneede braces" for
> single-statement if/else branches.
> 
> I've tried this approach (the most naive possible, I fear :):
> 
> -------8<----------
> @@
> expression E;
> statement S1,S2;
> @@
> 
> - if (E) {
> if (E)
>         S1
> - } else {
> + else
>         S2
> -}
> -------8<----------
> 
> But it doesn't work, I get a lot of errors when parsing the .cocci file 
> itself: 
> 
> warning: iso neg_if does not match the code below on line 6
> if (E) {
>   if (E) S1
> }else {
>   >>> else
> 
>   S2
> }
> he following code matched is not uniformly minus or context,
> or contains a disjunction:
> Stm:
> if (E) {
>   if (E) S1
> }else {
>   >>> else
> 
>   S2
> }
> ....
> 
> and so on...
> 
> I just can't figure out what the problem is here or what I'm doing wrong. 
> Could
> you please give me a hand? I'm using the standard spatch shipped with the
> lattest Debian Squeeze (testing): 0.2.3.

These are warnings not errors.  They refer to the inability to apply 
certain isomorphisms.  For example, neg_if switches the branches of an if 
and replaces the test by its negation.  But adjusting the braces and the 
else makes it unwilling to do this.  You could try leaving the else 
unmodified, since you want to both remove and add it.  You can find the 
various isomorphisms it would like to apply in the file standard.iso (I'm 
not sure where this file ends up when you get coccinelle from Debian).

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

Reply via email to