On Tue, 18 Dec 2018, Max wrote: > That almost works: both function parameters and variable declarations > are updated in .c files but the function prototypes in .h are ignored. > > I call it as follows: > > spatch --in-place --sp-file struct.spatch -I include --dir src > > The source code from 'src' is updated but header files in 'include' are > not affected. > > Specifying multiple dir doesn't work: "ignoring all but the last > specified directory". > > Adding --include-headers doesn't do what I hoped it would. > > Using top-level directory doesn't help as well: .c in multiple sub-dirs > are processed but .h are not. > > Reading docs so far revealed no way to update function definition in > both .c and .h at the same time. > > Does spatch have to be called in some special way for this to work? Or > .spatch file should have some particular syntax so it would affect both > .c and .h simultaneously? 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 > > 13.12.18 21:01, Julia Lawall пишет: > > > > If this is to be a function prototype, the parameter should be surrounded > > with commas. If there is no comma before or after the parameter > > declaration, Coccinelle will take care of doing the right thing. > > > > But actually your rule should be: > > > > @@ > > @@ > > > > struct > > - old_thing > > + new_thing > > > > Then it will just change the type whereever it occurs. > > > -- > - Max Suraev 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 > Cocci@systeme.lip6.fr > https://systeme.lip6.fr/mailman/listinfo/cocci >