On Wed, 12 Dec 2018, Max wrote:
> Hi.
>
> I have been trying to use spatch to update c struct but haven't found a way to
> do so yet.
>
> For example, we have
>
> struct old_thing {
>
> uint8_t a;
>
> uint16_t b[5];
>
> };
>
> which I'd like to replace with
>
> struct new_thing {
>
> uint8_t x1;
>
> uint32_t x2;
>
> uint8_t x3[11];
>
> };
>
> So pretty much replace every function parameter:
>
> f1(... struct old_thing *t...) => f1(... struct new_thing *t...)
>
> Replace the field access and variable definitions:
>
> ...
>
> struct old_thing t1; => struct new_thing t1;
>
> struct old_thing *t2; => struct new_thing *t2;
>
> ...
>
> t1.a => t1.x1
>
> t2->b => t2->x3
>
> ...
>
> The thing which escapes me is how to make coccinelle treat it like a type?
>
> Do I need to use @@typedef struct old_thing@@? Do I use it as @@identifier
> old_stuff@@ or @@identifier struct old_stuff@@?
>
> Doesn't seem to work for me.
>
> Any links to .spatch examples playing around with structs would be greatly
> appreciated.
Again, please send your attempt. What you want to do actually looks
straightforward, so it's hard for me to guess where the problem could be.
thanks,
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