On Thu, 9 Sep 2010, Joe Perches wrote:
> On Thu, 2010-09-09 at 09:46 +0200, Julia Lawall wrote:
> > The following works:
> > @@
> > expression E;
> > @@
> >
> > * struct pci_driver I = { .name = E, };
>
> Doesn't I need to be specified?
Yes, sorry. My rule only matched structures with the name "I" :)
> @@
> identifier I;
> expression E;
> @@
>
> * struct pci_driver I = { .name = E, };
>
> > > How would it find a non-c90 initializer like bar?
> >
> > In principle, you would have to find the type definition, find the offset
> > of the desired field in that type definition, and then find the value at
> > that offset in the initializer. Finding the type definition is only
> > possible if it is directly included by the C file. At the moment, there
> > is unfortunately nothing to support either finding the offset of a field
> > in a structure definition or finding the offset of a value in a
> > declaration of the form { a, b, c }. However, I am currently working on
> > improving the support for initializers of the form { a, b, c }, and I
> > think it would be easy to add that at the same time. With that in place,
> > you could find the offset of the field you are interested in in pci_driver
> > byhand, and specify that offset explicitly in the semantic patch.
>
> Perhaps you could also add when given the structure definition,
> spatch could do that offset->name translation instead of requiring
> the user to do it.
OK, it may be possible.
julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)