On Tue, 18 Dec 2018, Max wrote:
> I see. Yes, --all-includes did the trick for me, thank you.
>
> Although I'm still have to update struct fields in addition to struct
> name and it seems like I'm using typedef in a wrong way.
>
> For example:
>
> _______________________
>
> @@
> @@
> struct
> - old_addr
> + new_address
>
> @@
> identifier a;
> typedef new_address;
> @@
> new_address a;
> - a.len;
> + a.length;
I don't understand what you are trying to do here. typedef new_address;
is find for indicating that new_address is a typedef. Ie you have
somewhere said:
typedef ... new_address;
new_address a; will then match a declaration where the type of the
declared variable is new_address. But I don't understand - a.len;.
First, this is only going to match a statement that comes right after the
variable declaration. Second, a.len; is a very strange statement, because
it doesn't do anything.
Maybe you want:
@@
typedef new_address;
new_address a;
@@
- a.len
+ a.length
That is, a should be a metavariable representing an expression of the
given type, and then you want to replace a len field by length.
You could also write the change as:
a.
-len
+length
julia
>
> _______________________
>
> This does not cause field updates although first part (names) works.
>
> Using 'typedef struct new_address' instead gives "meta: parse error".
>
> Using 'old_addr' instead of 'new_address' in 2nd part doesn't make any
> difference.
>
> The len/length are pretty generic names used in multiple structs. How do
> I instruct Coccinelle to make replacement only for identifiers which
> belong to a particular struct type (or pointer to it)?
>
> Is there some specific metaver syntax related to structs which I haven't
> found yet?
>
> 18.12.18 17:19, Julia Lawall пишет:
> >
> > By default, Coccinelle only includes the headers that have the same name
> > as the .c file. Ie for foo.c, it considers that foo.h is prbably
> > important, and thus worth the often large extra runtime cost to take into
> > account.
> >
> > If you want more aggressive inclusion of headers, you need --all-includes
> > (the headers explicitly mentioned in the .c file) or --recursive-includes
> > (headers included by other headers).
> >
> > julia
>
> --
> - Max Suraev <[email protected]> http://www.sysmocom.de/
> =======================================================================
> * sysmocom - systems for mobile communications GmbH
> * Alt-Moabit 93
> * 10559 Berlin, Germany
> * Sitz / Registered office: Berlin, HRB 134158 B
> * Geschaeftsfuehrer / Managing Directors: Harald Welte
>
> _______________________________________________
> Cocci mailing list
> [email protected]
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci