On Fri, Jul 30, 2021 at 7:00 AM Andrew Yourtchenko
wrote:
>
> However, when I run it, the "done: " label, etc. gets inserted twice:
Every return statement is the end of a function. ;)
I don't know of a way to match only the "last" return statement in a
function, maybe with scripting...
> On 23 Jul 2021, at 21:35, Julia Lawall wrote:
>
>
>>
>> I missed the fact that the "return ERR" were actually not replaced on
>> this example at all,
>
> This is because there are no occurrences of return ERR; in your code.
> Probably you expected ERR to be a metavariable, but it's not.
Here is another attempt:
@initialize:ocaml@
@@
let check p =
let p = List.hd p in
p.line_end = p.current_element_line_end
@ detect_func @
identifier CLI_FN, AVM, AIN, ACMD;
fresh identifier LAIN = "line_" ## AIN;
expression ERR, exp;
statement S1;
typedef clib_error_t, vlib_main_t,
> yourtch@ayourtch-lnx:~/cocci$ diff -c patch-old.cocci patch-new.cocci
> *** patch-old.cocci 2021-07-22 22:41:19.516957878 +0200
> --- patch-new.cocci 2021-07-22 22:41:52.625184341 +0200
> ***
> *** 3,8
> --- 3,9
> fresh identifier LAIN = "line_" ## AIN;
>
>
> I missed the fact that the "return ERR" were actually not replaced on
> this example at all,
This is because there are no occurrences of return ERR; in your code.
Probably you expected ERR to be a metavariable, but it's not. Actually,
fully capitalizing your metavariables is not a good idea.
Hi Julia,
thanks a lot for such a quick reply! :)
I tried this:
yourtch@ayourtch-lnx:~/cocci$ diff -c patch-old.cocci patch-new.cocci
*** patch-old.cocci 2021-07-22 22:41:19.516957878 +0200
--- patch-new.cocci 2021-07-22 22:41:52.625184341 +0200
***
*** 3,8
--- 3,9
On Thu, 22 Jul 2021, Andrew Yourtchenko wrote:
> Hi all,
>
> I work on the VPP project (http://fd.io/ - open source software
> dataplane), and tried to use coccinelle to make a relatively
> non-trivial change
> as in the mail https://lists.fd.io/g/vpp-dev/message/17532 - it seemed
> to be a