cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Thomas Adam <thomas@xteddy.org>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: Coccinelle <cocci@systeme.lip6.fr>
Subject: Re: [Cocci] Using SmPL scripts to mangle function arguments
Date: Tue, 26 May 2020 02:21:47 +0100	[thread overview]
Message-ID: <CAOhcEPY8r2fjJmJP4A6ZzFdhTGJB=RYVcVt8k6KV9EaMzc_oSQ@mail.gmail.com> (raw)
In-Reply-To: <24b3f013-21e4-99e8-5366-cfc944077cc2@web.de>

On Sun, 17 May 2020 at 10:22, Markus Elfring <Markus.Elfring@web.de> 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
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

  parent reply	other threads:[~2020-05-26  1:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17  9:22 [Cocci] Using SmPL scripts to mangle function arguments Markus Elfring
2020-05-17  9:45 ` Julia Lawall
2020-05-26  1:21 ` Thomas Adam [this message]
2020-05-26  6:00   ` Markus Elfring
2020-05-26  6:41   ` Julia Lawall
2020-05-27 14:21   ` Markus Elfring
2020-05-26 11:23 Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOhcEPY8r2fjJmJP4A6ZzFdhTGJB=RYVcVt8k6KV9EaMzc_oSQ@mail.gmail.com' \
    --to=thomas@xteddy.org \
    --cc=Markus.Elfring@web.de \
    --cc=cocci@systeme.lip6.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).