From mboxrd@z Thu Jan 1 00:00:00 1970 From: lars@metafoo.de (Lars-Peter Clausen) Date: Wed, 26 Sep 2012 17:27:30 +0200 Subject: [Cocci] Help with SMPL In-Reply-To: References: Message-ID: <50631EE2.4030208@metafoo.de> To: cocci@systeme.lip6.fr List-Id: cocci@systeme.lip6.fr 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 > > Some relevant code snippets: > > http://lxr.free-electrons.com/source/drivers/media/video/em28xx/em28xx.h#L482 > -- // -- > struct em28xx { > ... > int model; /* index in the device_data struct */ > ... > struct em28xx_board board; > ... > } > -- // -- > > http://lxr.free-electrons.com/source/drivers/media/video/em28xx/em28xx.h#L690 > -- // -- > ... > extern struct em28xx_board em28xx_boards[]; > ... > -- // -- > > I'm trying the semantic patch: > @@ > type T; > expression to,from,flag; > @@ > - memcpy((T)&to,(T)&from,flag); > + to = from; > > But it is not working. How can I specify "to" and "from" for match > cases like this? Do you want the types of "to" and "from" to match? Then you could do something like: @@ type T; T to; T from; expression size; @@ -memcpy(&to, &from, size); +to = from; - Lars