On Tue, 1 Nov 2011, Russell King wrote:

> My third attempt with coccinelle isn't proving successful either.
> 
> setup_mm_for_reboot() takes an argument, which is never used.  So I
> want to remove the argument at the function definition and all call
> sites.
> 
> So I tried this:
> 
> @@
> identifier i;
> @@
> -setup_mm_for_reboot(i)
> +setup_mm_for_reboot()
> 
> @@
> identifier i;
> @@
> -setup_mm_for_reboot(char i)
> +setup_mm_for_reboot(void)
> 
> which produces:
> 
> init_defs_builtins: /usr/share/coccinelle/standard.h
> Fatal error: exception Failure("minus: parse error:
>  = File "arch_reset-1.5.cocci", line 10, column 26,  charpos = 114
>     around = 'i', whole content = -setup_mm_for_reboot(char i)
> ")
> 
> I don't understand why the addition of 'char' in there causes coccinelle
> a parse error.
> 
> So I tried a different way:
> 
> @@
> identifier i;
> @@
> setup_mm_for_reboot(
> -char i
> +void
> )
> 
> which produces:
> 
> init_defs_builtins: /usr/share/coccinelle/standard.h
> Fatal error: exception Failure("normal parenthesis in line 4 matched to 
> disjunction parenthesis on line 7 column 0
> ")
> 
> So I tried a space before the ')':
> 
> init_defs_builtins: /usr/share/coccinelle/standard.h
> Fatal error: exception Failure("minus: parse error:
>  = File "arch_reset-1.5.cocci", line 5, column 6,  charpos = 47
>     around = 'i', whole content = -char i
> ")
> 
> so we're back to coccinelle not liking 'char'.

Coccinelle expects complete terms.

setup_mm_for_reboot(char i)

looks like a function call, but a function call shouldn't have a type in 
the argument list.  What you need to do is make the rule into a function:

@@
identifier i;
@@
setup_mm_for_reboot(
-char i
+void
 ) { ... }

This should implicitly fix up any function prototypes as well.

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

Reply via email to