All of lore.kernel.org
 help / color / mirror / Atom feed
From: der.herr@hofr.at (Nicholas Mc Guire)
To: cocci@systeme.lip6.fr
Subject: [Cocci] RFC - simple scanners and matching macros
Date: Tue, 23 Dec 2014 18:33:31 +0100	[thread overview]
Message-ID: <20141223173331.GA17709@opentech.at> (raw)
In-Reply-To: <alpine.DEB.2.10.1412231810140.2480@hadrien>

> > > >
> > > > because that would match cases like
> > > >
> > > >  init_completion(cmp)
> > > >  wait_for_completion(cmp)
> > > >  init_completion(cmp)
> > >
> > > Doesn't this match the "first working case" rule?
> > >
> >
> > yes - just not sure if the first case is exhaustive - only
> > if it is would the second rule in the simplified version
> > be correct I believe.
> 
> I mean, wouldn't the first rule match code like:
> 
> > > >  init_completion(cmp)
> > > >  wait_for_completion(cmp)
> > > >  init_completion(cmp)
> 
> and thus make a transformation that is not desired?
>

yes it does and should. That second init_completion is incorrect it should be
 init_completion(cmp)
 ...
 wait_for_completion(cmp)
 ...
 reinit_completion(cmp)

> > tried that first then removed the r assuming it was a typo
> >
> > hofrat at debian:~/git/linux-next$ make coccicheck COCCI=false_declare_completion.cocci MODE=report
> >
> > Please check for false positives in the output before submitting a patch.
> > When using "patch" mode, carefully review the patch before submitting it.
> >
> > 297 298
> > Fatal error: exception Failure("meta: parse error:
> >  = File "false_declare_completion.cocci", line 14, column 32,  charpos = 297
> >     around = '@', whole content = declarer name DECLARE_COMPLETION@;
> > ")
> 
> There seems to be a @ at the end of the declared declarer name.  You can't
> use @ in a metavariable name.
>
sorry not sure how I managed that - gives me the same error though

hofrat at debian:/tmp/linux-next$ make coccicheck COCCI=false_declare_completion.cocci MODE=patch

Please check for false positives in the output before submitting a patch.
When using "patch" mode, carefully review the patch before submitting it.

Fatal error: exception Failure("meta: parse error: 
 = File "false_declare_completion.cocci", line 27, column 14,  charpos = 511
    around = 'DECLARE_COMPLETION', whole content = declarer name DECLARE_COMPLETION;
")
...

complete script:
/* check for incorrect DECLARE_COMPLETION use within a function                 
 *
 * Options:  --no-includes --include-headers
 */
virtual context
virtual patch
virtual org
virtual report

/* flag incorrect initializer*/
@e depends on patch && !(context || org || report)@
expression cmp;
identifier f;
declarer name DECLARE_COMPLETION;
position p;
@@

f(...) {
  ...
- DECLARE_COMPLETION at p(cmp);
+ DECLARE_COMPLETION_ONSTACK(cmp);
  ...
}

@ep depends on !patch && (context || org || report)@
expression cmp;
identifier f;
declarer name DECLARE_COMPLETION;
position p;
@@

f(...) {
  ...
* DECLARE_COMPLETION at p(cmp);
  ...
}

@script:python depends on org@
p << ep.p;
@@

msg="WARNING: possible incorrect use of DECLARE_COMPLETION"
coccilib.org.print_todo(p[0], msg)

thx!
hofrat

  reply	other threads:[~2014-12-23 17:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-23 15:20 [Cocci] RFC - simple scanners and matching macros Nicholas Mc Guire
2014-12-23 15:59 ` Julia Lawall
2014-12-23 16:29   ` Nicholas Mc Guire
2014-12-23 16:48     ` Julia Lawall
2014-12-23 17:02       ` Nicholas Mc Guire
2014-12-23 17:12         ` Julia Lawall
2014-12-23 17:33           ` Nicholas Mc Guire [this message]
2014-12-23 18:08             ` Julia Lawall
2014-12-23 19:28               ` Nicholas Mc Guire
2014-12-23 20:53                 ` Julia Lawall
2014-12-24  8:57                   ` Nicholas Mc Guire
2014-12-24  9:27                     ` Julia Lawall
2014-12-24  9:39                       ` Nicholas Mc Guire
2014-12-24  9:42                         ` Julia Lawall
2014-12-24  9:50                           ` Nicholas Mc Guire
2014-12-24  9:56                             ` Julia Lawall

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=20141223173331.GA17709@opentech.at \
    --to=der.herr@hofr.at \
    --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.