public inbox for cocci@systeme.lip6.fr
 help / color / mirror / Atom feed
From: julia.lawall@lip6.fr (Julia Lawall)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Prepending '*' to an expression (Was: [PATCH V2] scripts/coccinelle/misc/memcpy-assign.cocci: Replace memcpy with struct assignment)
Date: Mon, 28 Jan 2013 23:04:38 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.02.1301282303220.2060@hadrien> (raw)
In-Reply-To: <51059238.1090009@redhat.com>

On Sun, 27 Jan 2013, Michael Stefaniuc wrote:

> Hello Peter,
>
> On 01/26/2013 02:28 AM, Peter Senna Tschudin wrote:
> > Thank you for testing.
> >
> > I made changes on the semantic patch. I believe it fixed the problem.
> > Can you test it?
> while it does fix the issue it makes the cocci script less readable and
> works only in that particular case. Not sure it is worth the effort as
> the bad generated patch can be trivially detected and easily fixed
> manually. My email was more of a bug report / feature request for
> coccinelle than an improvement request to the script.
>
> Though I've noticed an other issue with the script: Any reason you use
> "Options: --no-includes"? While it does speed up things it misses quite
> a few cases as a lot of types are defined in the headers.

I think it should be --all-includes or even --recursive-includes

julia.

>
> bye
> 	michael
>
> > On Thu, Jan 24, 2013 at 3:47 PM, Michael Stefaniuc <mstefani@redhat.com> wrote:
> >> Hello,
> >>
> >> On 01/23/2013 11:06 PM, Peter Senna Tschudin wrote:
> >>> There are error-prone memcpy() that can be replaced by struct
> >>> assignment that are type-safe and much easier to read. This semantic
> >>> patch looks for memcpy() that can be replaced by struct assignment.
> >> thanks for the script by Peter this script as it proved useful for Wine
> >> too. Though in one case it generated the wrong patch.
> >>
> >> @@
> >> struct struct_name to;
> >> struct struct_name from;
> >> @@
> >>
> >> 'to' and 'from' above are expressions and not identifiers; that's a
> >> feature. The bug happened in the replacement
> >> - memcpy(foos + count, &foo, sizeof(struct foo_t));
> >> + *foos + count = foo;
> >>
> >> Shouldn't cocinelle automatically add the parenthesis when prepending a
> >> '*' or '&' to an expression which isn't an identifier?
> >>
> >>
> >> The script itself is "safe" as the compiler will error out on that
> >> patch. And the people that just take generated patches and submit them
> >> without even compiling them deserve the public tar and feathering ;)
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

  reply	other threads:[~2013-01-28 22:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-23 22:06 [Cocci] [PATCH V2] scripts/coccinelle/misc/memcpy-assign.cocci: Replace memcpy with struct assignment Peter Senna Tschudin
2013-01-24 17:47 ` [Cocci] Prepending '*' to an expression (Was: [PATCH V2] scripts/coccinelle/misc/memcpy-assign.cocci: Replace memcpy with struct assignment) Michael Stefaniuc
2013-01-24 18:05   ` Julia Lawall
2013-01-26  1:28   ` Peter Senna Tschudin
2013-01-27 20:46     ` Michael Stefaniuc
2013-01-28 22:04       ` Julia Lawall [this message]
2013-01-29 21:38         ` Michael Stefaniuc
2013-01-29 21:42           ` Julia Lawall
2013-02-06 14:37           ` Michael Stefaniuc
2013-02-22 10:25 ` [Cocci] [PATCH V2] scripts/coccinelle/misc/memcpy-assign.cocci: Replace memcpy with struct assignment Michal Marek

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.1301282303220.2060@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox