There is nothing that really tries to do this. The semantic match
specifies a pointer, and a top-level structure is a structure, not a
pointer to a structure. There is an isomorphism that converts a field
reference to a pointer reference:
Expression
@ fld_to_ptr @
type T;
pure T E;
pure T *E1;
identifier fld;
@@
E.fld => E1->fld
There is also an isomorphism that converts a field initialization to a C90
initialization:
TopLevel
@ mkinit @
type T;
pure context T E;
identifier I;
identifier fld;
expression E1;
@@
E.fld = E1; => T I = { .fld = E1, };
It could be possible to add the following isomorphism:
TopLevel
@ mkinit @
type T;
pure context T E;
identifier I;
identifier fld;
@@
E.fld => T I = { .fld = ..., };
But you could also just add a second rule to your semantic match:
@@
identifier I;
@@
* struct pci_driver I { .name = ..., };
julia
On Wed, 8 Sep 2010, Joe Perches wrote:
> $ cat find_pci_name.cocci
> @@
> struct pci_driver * I;
> @@
>
> * I->name
> $
>
> The cocci script above does not find pci_driver->name references
> that are set by c90 initializers like:
>
> $ grep "struct pci_driver atl1_driver" drivers/net/atlx/atl1.c -A 8
> drivers/net/atlx/atl1.c:static struct pci_driver atl1_driver = {
> drivers/net/atlx/atl1.c- .name = ATLX_DRIVER_NAME,
> drivers/net/atlx/atl1.c- .id_table = atl1_pci_tbl,
> drivers/net/atlx/atl1.c- .probe = atl1_probe,
> drivers/net/atlx/atl1.c- .remove = __devexit_p(atl1_remove),
> drivers/net/atlx/atl1.c- .suspend = atl1_suspend,
> drivers/net/atlx/atl1.c- .resume = atl1_resume,
> drivers/net/atlx/atl1.c- .shutdown = atl1_shutdown
> drivers/net/atlx/atl1.c-};
>
> $ cocci -sp_file find_pci_name.cocci drivers/net/atlx/atl1.c
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: drivers/net/atlx/atl1.c
> $
>
> _______________________________________________
> Cocci mailing list
> [email protected]
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)
>
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)