From: julia.lawall@lip6.fr (Julia Lawall)
To: cocci@systeme.lip6.fr
Subject: [Cocci] isomorphism with unlikely
Date: Wed, 22 May 2013 19:36:37 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.02.1305221936070.2020@hadrien> (raw)
In-Reply-To: <519A75DE.1040604@metafoo.de>
On Mon, 20 May 2013, Lars-Peter Clausen wrote:
> On 05/20/2013 08:51 PM, Julia Lawall wrote:
> > On Mon, 20 May 2013, Lars-Peter Clausen wrote:
> >
> >> On 05/20/2013 08:24 PM, Wolfram Sang wrote:
> >>>
> >>>> There is already an isomorphism for unlikely. But it is in one direction
> >>>> only, so 'unlikely(E)' in your cocci script will also match 'E', but 'E'
> >>>> wont match 'unlikely(E)'.
> >>>
> >>> Okay, but I would then still need 'unlikely(!r)' and 'unlikely(r ==
> >>> NULL)' because the !r isomorphisms won't apply. I'd like to have both :)
> >>
> >> No, just unlikley(r == NULL) also matches !r (and unlikely(!r)). This should
> >> also work for unlikely(!r) matching unlikely(r == NULL) but for some reason
> >> it doesn't. I just did a quick test and it looks as if even 'if(!r) ..."
> >> doesn't match 'if(r == NULL) ...' either.
> >
> > It should work if r has pointer type. Otherwise, if r is not a pointer,
> > then !r should become r == 0.
>
> But for some reason it does not. With --verbose-match I can see that it
> generates the correct isomorphisms (both for the case that r is a pointer or
> that r is an integer), but for some reason they don't seem to match.
>
> The testcase is simple:
>
> cocci file:
>
> @@
> expression *r;
> statement S;
> @@
> *if(!r) S
>
> c file:
>
> int foo(struct resource *r)
> {
> if (r == NULL)
> return 0;
> return 1;
> }
Thanks for the report. I have found the problem, and will try to fix it
shortly.
julia
next prev parent reply other threads:[~2013-05-22 17:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-20 17:34 [Cocci] isomorphism with unlikely Wolfram Sang
2013-05-20 17:47 ` Lars-Peter Clausen
2013-05-20 18:24 ` Wolfram Sang
2013-05-20 18:26 ` Lars-Peter Clausen
2013-05-20 18:51 ` Julia Lawall
2013-05-20 19:13 ` Lars-Peter Clausen
2013-05-22 17:36 ` Julia Lawall [this message]
2013-05-26 20:01 ` 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=alpine.DEB.2.02.1305221936070.2020@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.