From mboxrd@z Thu Jan 1 00:00:00 1970 From: elfring@users.sourceforge.net (SF Markus Elfring) Date: Sun, 09 Mar 2014 13:51:04 +0100 Subject: [Cocci] Determination of the number for named function parameters In-Reply-To: References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <531B0D52.5070008@users.sourceforge.net> <531B32F4.9080004@users.sourceforge.net> <531B771D.3020900@users.sourceforge.net> <531C1FAD.6030009@users.sourceforge.net> Message-ID: <531C63B8.6090403@users.sourceforge.net> To: cocci@systeme.lip6.fr List-Id: cocci@systeme.lip6.fr > 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 at pos(void) { ... } @input depends on no_input@ identifier fun; parameter list [count] pl; position pos != no_input.pos; @@ fun at pos(pl) { ... } @script:python collection depends on input@ 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 at 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. Regards, Markus