On Wed, 16 Feb 2011, Oliver McFadden wrote: > Hi, > > I'm quite new to Coccinelle but it seems to be an excellent tool, > however, I have a question about how to use it to do what I need. > > I have a bunch of code that looks like this (inside a function): > > xFoobarReply foobar; > /* many lines of code */ > WriteToClient(client, sizeof(xFoobarReply), &foobar); > > I would like to transform these into (note change of foobar to rep): > > REPLY(xFoobarReply); > /* many lines of code */ > WriteToClient(client, sizeof(xFoobarReply), &rep); > > Then the REPLY macro is defined to expand to: > xFoobarReply rep; memset(&rep, 0, sizeof(xFoobarReply); > > But note that I must only match on calls to WriteToClient. I know how I > could change the WriteToClient line easily, but not how to change the > declaration of one of it's arguments?
Thank you for your interest in Coccinelle. When you say "change the declaration of one of it's arguments", do you actually mean change the parameter declaration of the definition of the WriteToClient function? If so, then perhaps the following page in the wiki can help you: http://cocci.ekstranet.diku.dk/wiki/doku.php?id=parameter_list_matching This is going the other way, from when you have information about a parameter argument position and want to adjust the corresponding call sites, but it should be adaptable to what I think you want to do. If I have completely missed understanding, please write back and I or someone else will get back to you later. julia _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
