[Cocci] how to consider castings in semantic patchs

Andrés More more.andres at gmail.com
Tue Mar 12 14:51:49 CET 2013

Hi, I've been playing with Coccinele, I find it really useful.

I'm trying to create a semantic patch to rename a structure (and its
I could get almost everything in place in several patches: the structure
gets renamed, also variables of that type, also their attributes. However,
the code (not mine) uses some explicit castings and I couldn't find a way
to cover those cases also.

I've tried to follow the documented grammar but I think I got lost without
finding how to declare such castings.

I'm appending the last version of the semantic patch I've been working on
just to give the rough idea how what I am trying to describe. The code is a
Linux kernel staging driver (VIA VT6656), using their own Ethernet packet

Thanks, I will really appreciate any hints on how to consider explicit

-- Andres

Sample Line not covered
pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize);

Semantic patch I could get done
$ cat test.cocci
identifier h;
-PSEthernetHeader h;
+struct ethhdr * h;

identifier h;
-PS802_11Header h;
+struct ieee80211_hdr *h;

identifier h;
-SEthernetHeader h;
+struct ethhdr h;

identifier h;
-S802_11Header h;
+struct ieee80211_hdr h;

struct ethhdr *h;

struct ieee80211_hdr *h;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20130312/497e76ed/attachment.html>

More information about the Cocci mailing list