All of lore.kernel.org
 help / color / mirror / Atom feed
From: julia.lawall@lip6.fr (Julia Lawall)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Replacing one (specific!) type with another
Date: Mon, 10 Oct 2016 21:45:54 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.10.1610102144590.3438@hadrien> (raw)
In-Reply-To: <87shs4oxeh.fsf@vostro.rath.org>



On Mon, 10 Oct 2016, Nikolaus Rath wrote:

> On Oct 10 2016, Nikolaus Rath <Nikolaus@rath.org> wrote:
> > On Oct 10 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >> On Sun, 9 Oct 2016, Nikolaus Rath wrote:
> >>
> >>> On Oct 08 2016, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >>> >> > Write separate rules for that.  You would need one case for a local
> >>> >> > variable and one case fora parameter.  You can actually probably just drop
> >>> >> > the rule you have currently.  I would imagine something like the
> >>> >> > following:
> >>> >> >
> >>> >> > @@
> >>> >> > symbol f, se; // avoid unneeded warnings from Coccinelle
> >>> >> > @@
> >>> >> >
> >>> >> > struct fuse_session *
> >>> >> > -f
> >>> >> > +se
> >>> >> >  ;
> >>> >> > <...
> >>> >> > -f
> >>> >> > +se
> >>> >> > ...>
> >>> >> > @@
> >>> >> > identifier fn;
> >>> >> > @@
> >>> >> >
> >>> >> > fn(...,struct fuse_session *f,...) { <...
> >>
> >> Oops, the first line should be:
> >>
> >> fn(...,struct fuse_session *
> >> -f
> >> +se
> >>   ,...) { <...
> >>
> >> The rule works fine even when f is the first argument.
> >
> > Ouch, I guess I could have caught that too. Works like a charm now!
>
> I claimed success too early. There are still the following cases left:
>
>
> static void do_destroy(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
> {
> 	struct fuse_session *f = req->se;
> [....]
>
> I tried to adapt the rules myself as follows:
>
> @@
> symbol f, se;
> @@
> struct fuse_session *
> -f
> +se
> ;
> <...
> -f
> +se
> ...>
>
> @@
> symbol f, se;
> expression expr;
> @@
> struct fuse_session *
> -f
> +se
> = expr;
> <...
> -f
> +se
> ...>
>
>
> @@
> identifier fn;
> @@
> fn(...,struct fuse_session *
> -f
> +se
> ,...) { <...
> -f
> +se
> ...> }
>
>
> But this gives an error:
>
>
> Fatal error: exception Failure("meta: parse error:
>  = File "se-rename.cocci", line 14, column 7,  charpos = 79
>     around = 'f', whole content = symbol f, se;
> ")
>
>
> What am I doing wrong?

What version of Coccinelle are you using?  Before 1.0.6, it was not
possible to declare something to be a symbol more than once.  In any case,
once it is declared as a symbol, it is always a symbol.

julia

  reply	other threads:[~2016-10-10 19:45 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05  3:27 [Cocci] Replacing one (specific!) type with another Nikolaus Rath
2016-10-05  5:45 ` Julia Lawall
2016-10-05 16:09   ` Nikolaus Rath
2016-10-05 16:39     ` Michael Stefaniuc
2016-10-05 17:21     ` [Cocci] Replacing one variable name " SF Markus Elfring
2016-10-05 22:34       ` Nikolaus Rath
2016-10-06  5:42         ` SF Markus Elfring
2016-10-06  5:56         ` Julia Lawall
2016-10-05 20:02     ` [Cocci] Replacing one (specific!) type " Julia Lawall
2016-10-05 22:38       ` Nikolaus Rath
2016-10-06  5:55         ` Julia Lawall
2016-10-08  3:16           ` Nikolaus Rath
2016-10-08  5:50             ` Julia Lawall
2016-10-08 20:45               ` Nikolaus Rath
2016-10-08 21:23                 ` Julia Lawall
2016-10-09  6:32                 ` SF Markus Elfring
2016-10-08  6:48             ` [Cocci] Usage of "expressions" and "identifiers" with SmPL SF Markus Elfring
2016-10-08  6:57               ` Julia Lawall
     [not found]               ` <alpine.DEB.2.10.1610080850470.7750@hadrien>
2016-10-08  7:49                 ` SF Markus Elfring
2016-10-08  7:56                   ` Julia Lawall
2016-10-08  8:26                     ` SF Markus Elfring
2016-10-08  8:38                       ` Julia Lawall
2016-10-08  9:25                         ` SF Markus Elfring
2016-10-08 20:28                           ` Nikolaus Rath
2016-10-09  7:49                             ` SF Markus Elfring
2016-10-09 20:38                               ` Nikolaus Rath
2016-10-10  6:48                                 ` SF Markus Elfring
2016-10-10  6:50                                   ` Julia Lawall
2016-10-06  6:30         ` [Cocci] Replacing one (specific!) type with another SF Markus Elfring
2016-10-08  4:22       ` Nikolaus Rath
2016-10-08  5:31         ` Julia Lawall
2016-10-08 20:52           ` Nikolaus Rath
2016-10-08 21:21             ` Julia Lawall
2016-10-09 20:45               ` Nikolaus Rath
2016-10-10  4:49                 ` Julia Lawall
2016-10-10  4:54                 ` Julia Lawall
2016-10-10 15:56                   ` Nikolaus Rath
2016-10-10 18:45                     ` Nikolaus Rath
2016-10-10 19:45                       ` Julia Lawall [this message]
2016-10-10 21:27                         ` Nikolaus Rath
2016-10-10 21:33                           ` Julia Lawall
2016-10-10 23:00                             ` Nikolaus Rath
2016-10-11  6:51                               ` Julia Lawall
2016-10-12 15:08                                 ` Nikolaus Rath
2016-10-12 20:37                                   ` Julia Lawall
2016-10-05  5:51 ` SF 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=alpine.DEB.2.10.1610102144590.3438@hadrien \
    --to=julia.lawall@lip6.fr \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.