On Sun, 9 Mar 2014, SF Markus Elfring wrote:

> > Have a special rule for such functions and use position variables to
> > prevent the rule that matches interesting parameter lists from matching
> > functions that have satisfied this case:
>
> I have adjusted your suggestion a little bit here.
>
> @no_input@
> identifier fun;
> position pos;
> @@
>  fun@pos(void) { ... }
>
> @input depends on no_input@
> identifier fun;
> parameter list [count] pl;
> position pos != no_input.pos;
> @@
>  fun@pos(pl) { ... }
>
> @script:python collection depends on input@

No need for depends on input.  For a python rule, all metavariables have
to be bound before anything happens.

> fun << input.fun;
> count << input.count;
> places << input.pos;
> @@
> store_positions(fun, count, places)
>
>
> This pattern variant works as expected for a source code example that was
> already mentioned before.
>
> elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file
> list_function_parameters2.cocci ../Probe/f-ptr-test1.c
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: ../Probe/f-ptr-test1.c
> function|"parameter count"|"source file"|line|column
> my_log|1|"../Probe/f-ptr-test1.c"|1|6
> my_safe_log|1|"../Probe/f-ptr-test1.c"|6|5
> my_addition|2|"../Probe/f-ptr-test1.c"|25|5
>
>
> But I wonder about the processing for the following small source file.
>
> void my_log(char const * format, ...)
> {
>   /* Write something ... */
> }
>
> elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file
> list_function_parameters2.cocci ../Probe/ellipsis-test1.c
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: ../Probe/ellipsis-test1.c
> No result for this analysis!
>
>
> I would appreciate your advices.

I have no idea.  I would have sort of expected that it would return a
length of 2, but I guess it is reasonable, and even desirable, that it
does not.  What answer would you like?

julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to