So, if I don't have any typedef in the code and I just want to replace the name of the field of a struct?

for example to modify this function:

f() {

struct my_struct *m;

struct my_struct x;

...

m->len = 10; // this should become m->length = 10;

...

fill(x.buf); // this should become fill(x.addr);

}

I'm trying to use

@@
identifier a;
@@
struct my_struct a.
- len
+ length

Which gives syntax error. I need somehow to tell spatch that "identifier a" has type "struct my_struct" but "type struct osmo_gsn_address;" seems to be invalid syntax.

18.12.18 17:54, Julia Lawall пишет:

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

--
- 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

Reply via email to