cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: johannes@sipsolutions.net (Johannes Berg)
To: cocci@systeme.lip6.fr
Subject: [Cocci] moving const instead of not matching?
Date: Tue, 18 Sep 2018 12:43:57 +0200	[thread overview]
Message-ID: <1537267437.2957.22.camel@sipsolutions.net> (raw)
In-Reply-To: <alpine.DEB.2.20.1809181239470.3737@hadrien>

On Tue, 2018-09-18 at 12:41 +0200, Julia Lawall wrote:
> > but then I ran across a place that had a const, and the result was
> > rather unexpected:
> > 
> > $ spatch --sp-file /tmp/test3.spatch /tmp/test.c
> > init_defs_builtins: /usr/lib64/coccinelle/standard.h
> > HANDLING: /tmp/test.c
> > diff =
> > --- /tmp/test.c
> > +++ /tmp/cocci-output-8879-8411db-test.c
> > @@ -1,4 +1,4 @@
> >  int main()
> >  {
> > -	memcpy(dst, (const u8 *)src, sz);
> > +	memcpy(dst, src const, sz);
> >  }
> > 
> > 
> > Why is the const being moved there, rather than not matching?
> 
> To get it to not match this case, put disable optional_qualifier in the
> rule header.

Ok, I can try that.

>   There is an isomorphism that allows it to not care about
> whether things like const or volatile are present or not, but apparently
> it is not deleting it as it should be.

Still seems like a bug?

> If you want to match the const case, you can make some other rules with
> const explicitly.

Right. I tried to put that before this one, but somehow it still
resulted in the same. Perhaps if I disable optional_qualifier for both
it'll work.

> > spatch version 1.0.6.
> 
> You may want to upgrade, although it's unrelated to this issue.

Yeah, I'm (obviously) aware, but with all the version number issues with
1.0.7 I haven't gotten around to it :)

johannes

  reply	other threads:[~2018-09-18 10:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-18  9:20 [Cocci] moving const instead of not matching? Johannes Berg
2018-09-18 10:41 ` Julia Lawall
2018-09-18 10:43   ` Johannes Berg [this message]
2018-09-18 11:47     ` 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=1537267437.2957.22.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --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).