On Sun, 17 May 2020 at 10:22, Markus Elfring <[email protected]> wrote:
> Generally, yes.
>
> A more complete source code transformation approach can become challenging.

So I've decided to try and take a different approach, and have
rethrough the function interface.

Rather than try and modify the arguments in the way I was, I think it
makes sense to largely keep the existing function signatures.

So for example, currently there is:

func_old(int level, const char *func, const char *fmt, ...);

What I'm after here is to modify func_old, such that I drop the "int
level" parameter, and change the *func occurrences to "__func__", and
drag the variadic arguments with the transformation, hence, I'd like
func_old to now look like:

func_old(const char *func, const char *fmt, ...);

So what was once:

func_old(ERR, "MyFunction", "%s: hello: %d, %d", myvar, x, y);

Should now be:

func_old(__func__,  "%s: hello: %d, %d", myvar, x, y);

I'm having trouble expressing my smPL to understand the ellipses
correctly.  Here's what I have so far:

@@
expression L, F;
@@

- func_old(L, F, ...);
+ func_old(__func_, ...);

... but here, things fall apart:

init_defs_builtins: /usr/bin/../lib/coccinelle/standard.h
File "contrib/coccinelle/remove_debug.cocci", line 6, column 21, charpos = 68
  around = '...',
  whole content = + func_old(__func__, ...);

Any ideas on what I'm doing wrong?  If there's appropriate
documentation on this, please feel free to point me toward it.  I feel
as though I'm missing something obvious here, so thanks for your time
and for any help you can give.

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

Reply via email to