On Fri, 8 Jun 2012, Michael Stefaniuc wrote:

Hello,

On 06/08/2012 10:33 AM, leeyafo wrote:
Hello guys:
   I'm new to Coccinelle, And now I wanna to develop a tool to translate
Linux ethernet driver to freebsd.
  the first problem is to convert an instance of "struct pci_driver" to
"device_method_t".
  Can anybody give me some sample cocci code?
 I have try the following code, but it does not work as expect.


@@
@@

- static struct pci_driver alx_driver = {
+ static device_method_t alx_methods[] = {
coccinelle is not line base like diff but knows C so you need to replace
full C entities.

@@
typedef device_method_t;
@@
- struct pci_driver alx_driver
+ device_method_t alx_methods[]
 = ...;

If you would have changed just the type it would have been even simpler:
@@
typedef device_method_t;
@@
- struct pci_driver
+ device_method_t

I guess that if the introduction of an array is wanted, the more complex rule will be needed.

Thanks,
julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to