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: Wed, 24 Dec 2014 09:57:52 +0100	[thread overview]
Message-ID: <20141224085752.GA16334@opentech.at> (raw)
In-Reply-To: <alpine.DEB.2.02.1412232152190.2035@localhost6.localdomain6>

On Tue, 23 Dec 2014, Julia Lawall wrote:

> 
> 
> On Tue, 23 Dec 2014, Nicholas Mc Guire wrote:
> 
> > On Tue, 23 Dec 2014, Julia Lawall wrote:
> > 
> > > > 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;
> > > > ")
> > > > ...
> > > 
> > > OK, it's not super intuitive, but the problem is that it wants declarer
> > > names, like typedefs, to be declared once and only once.  And in deciding
> > > about this, it doesn't take into account the dependencies on virtual
> > > rules.  So if you use -D patch, then it complains about a declaration in a
> > > case that says depends on !patch.  And if you remove the declarer name
> > > declaration in the latter rule, when you use eg -D report, it takes into
> > > account the declaration in the previous, but disabled, -D patch rule.
> > > 
> > > So if you drop the second declarer name declaration, everything will be
> > > fine.
> > > 
> > > The fact that declaring a typedef, declarer name, or iterator name once
> > > was good enough was supposed to make things easier, but it seems to just
> > > make things confusing.  Maybe I should get rid of this feature, or at
> > > least not complain about redeclarations that are consistent with the
> > > previous one.
> > >
> > it did not complain - but something seems to be going wrong now it
> > consumes 100% CPU on all avaialble cores for about 8 minutes and
> > finds no match
> > 
> > hofrat at debian:/tmp/linux-next$ time 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.
> > 
> > 
> > real    8m9.438s
> > user    33m6.005s
> > sys     0m10.277s
> > 
> > about the same in MODE=patch, the other cocci file over the same tree ran
> > 
> > real    0m48.492s
> > user    2m26.627s
> > sys     0m1.933s
> > 
> > an example file where I had expected it to trigger is
> > drivers/scsi/aha152x.c - but it did not.
> > 
> > cut down testcse would be:
> > 
> > test.c:
> > static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
> > {
> >         struct Scsi_Host *shpnt = SCpnt->device->host;
> >         DECLARE_COMPLETION(done);
> >         int ret, issued, disconnected;
> >         unsigned char old_cmd_len = SCpnt->cmd_len;
> >         unsigned long flags;
> >         unsigned long timeleft;
> >         /* snippet from drivers/scsi/aha152x.c */
> > }
> > 
> > test.cocci:
> > @e@
> > expression cmp;
> > identifier f;
> > declarer name DECLARE_COMPLETION;
> > position p;
> > @@
> > 
> > f(...) {
> >   <...
> > - DECLARE_COMPLETION at p(cmp);
> > + DECLARE_COMPLETION_ONSTACK(cmp);
> >   ...>
> > }
> > 
> > which should trigger if I did not do something foolish again
> > but it did not:
> > 
> > hofrat at debian:/tmp/linux-next$ spatch --sp-file test.cocci test.c
> > init_defs_builtins: /usr/local/share/coccinelle/standard.h
> > HANDLING: test.c
> 
> It works fine for me.  What version of Coccinelle do you have?
>

hofrat at debian:/tmp/linux-next$ spatch --version
spatch version 1.0.0-rc21 with Python support and with Str regexp support 

will update to rc23 and retest - can this be a config/python version issue ?
python version is 2.7.3 (Debian 7.6)
 
> For the performance problem, could you send the current semantic patch 
> again, so I could be sure to be testing the right thing?
>
files where this situation exists in linux-next (3.18.0) and which should
trigger are:

 drivers/macintosh/ams/ams-pmu.c        line 52
 drivers/misc/sgi-gru/grukservices.c    line 1044
 drivers/scsi/aha152x.c                 line 1055
 drivers/usb/gadget/udc/fsl_qe_udc.c    line 2630
 drivers/usb/gadget/udc/fsl_udc_core.c  line 2529


the non-working semantic patch below:

/* 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@p(cmp);
+ DECLARE_COMPLETION_ONSTACK(cmp);
  ...>
} 

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

f(...) {
  <...
* DECLARE_COMPLETION@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)

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

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

thx!
hofrat

  reply	other threads:[~2014-12-24  8:57 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
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 [this message]
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=20141224085752.GA16334@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.