All of lore.kernel.org
 help / color / mirror / Atom feed
From: lars@metafoo.de (Lars-Peter Clausen)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Help with SMPL
Date: Wed, 26 Sep 2012 18:01:27 +0200	[thread overview]
Message-ID: <506326D7.4040802@metafoo.de> (raw)
In-Reply-To: <CALF0-+WC8EG861-szF3yQQEpawvv8QS4j7qZTqZGKy08-8=Ekg@mail.gmail.com>

On 09/26/2012 05:40 PM, Ezequiel Garcia wrote:
> Hi,
> 
> On Wed, Sep 26, 2012 at 12:27 PM, Lars-Peter Clausen <lars@metafoo.de> wrote:
>> On 09/26/2012 04:36 PM, Peter Senna Tschudin wrote:
>>> Dear List,
>>>
>>> I'm trying to make a semantic patch for the case described on the patch:
>>> http://www.mail-archive.com/linux-media at vger.kernel.org/msg52660.html
>>>
> 
> More cases like these:
> 
> http://patchwork.linuxtv.org/patch/13100/
> 
> This is part of a whole patchset with subject:
> 
> media: XXX: Replace struct memcpy with struct assignment
> 
> The type of src and dst structs should match, but in some buggy code
> that may not be true.

I suppose these should not be auto-converted since there is clearly a bug
somewhere. The following cocci patch can be used to find locations where
memcpy is used and the types of "to" and "from" do not match, but the size
parameter is sizeof one of them.

@r1@
type T;
T to;
T from;
position p;
@@
memcpy at p(&to, &from,
(
 sizeof(T)
|
 sizeof(to)
|
 sizeof(from)
)
 );

@r2@
type T;
T to;
const T from;
position p;
@@
memcpy at p(&to, &from,
(
 sizeof(T)
|
 sizeof(to)
|
 sizeof(from)
)
 );


@@
position p != {r1.p,r2.p};
type T1, T2;
T1 to;
T2 from;
@@
*memcpy at p(&to, &from,
(
 sizeof(T1)
|
 sizeof(T2)
|
 sizeof(to)
|
 sizeof(from)
)
*);

  reply	other threads:[~2012-09-26 16:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-26 14:36 [Cocci] Help with SMPL Peter Senna Tschudin
2012-09-26 15:27 ` Lars-Peter Clausen
2012-09-26 15:40   ` Ezequiel Garcia
2012-09-26 16:01     ` Lars-Peter Clausen [this message]
2012-09-26 16:02       ` Ezequiel Garcia
2012-09-26 16:06       ` Peter Senna Tschudin
2012-09-26 15:57   ` Peter Senna Tschudin
     [not found] <CA+MoWDpBor-e+69ioxPH-kWcdnd8iYE3E9aXjC79dNO+_COxeg@mail.gmail.com>
     [not found] ` <501BEA35.5030008@redhat.com>
     [not found]   ` <501BFA96.6080803@metafoo.de>
     [not found]     ` <alpine.DEB.2.02.1208031832490.2827@hadrien>
     [not found]       ` <501C0878.1010906@metafoo.de>
     [not found]         ` <alpine.DEB.2.02.1208032309470.1928@localhost6.localdomain6>
2012-09-27 15:29           ` [Cocci] Help with SmPL Peter Senna Tschudin
2012-09-27 16:30             ` Håkon Løvdal
2012-09-27 17:54               ` Håkon Løvdal

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=506326D7.4040802@metafoo.de \
    --to=lars@metafoo.de \
    --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.