[Cocci] Finding a field in a structure

Michael Stefaniuc mstefani at redhat.com
Wed Mar 31 21:22:34 CEST 2010


Hello Frederic,

On 03/31/2010 08:50 PM, Frederic Weisbecker wrote:
> I'm trying to fetch all declarations of a variable of a given
> type and patch one of its field assignment.
>
> In this particular case, I want to do this:
>
> struct file_operations foo = {
> 	.....
> -	.ioctl = blah,
> +	.unlocked_ioctl = blah,
> 	.....
> };
>
> I tried to do this with this cocci script:
>
> @@
> identifier I;
> expression E;
> @@
>
> struct file_operations I = {
> -       .ioctl = E,
> +       .unlocked_ioctl = E,
> };
>
>
> But it never matches.
>
> I think it's because I have to handle the other fields
> in the definition, like open, close, things I have materialized
> with "...." in the above example. I'm not sure how to do this.
use "..." instead ;)

@@
identifier I;
expression E;
@@

struct file_operations I = {
     ...
-   .ioctl = E,
+   .unlocked_ioctl = E,
     ...
};


bye
	michael



More information about the Cocci mailing list