> Sure, so if I have code like this: > #define pte_alloc_one(mm, vmaddr) ((pte_t *) page_table_alloc(mm)) > > I want to have a rule that does: > - #define pte_alloc_one(mm, vmaddr) ((pte_t *) page_table_alloc(mm)) > + #define pte_alloc_one(mm) ((pte_t *) page_table_alloc(mm)) > > So far everything I tried only works for functions so I was wondering how one > do this with macros.
Maybe @r@ position p; identifier i,a,b; @@ #define i(a,b)@p <+...b...+> @@ position p != r.p; identifier i,a,b; expresssion e; @@ - #define i(a,b)@p e + #define i(a) e The rule r finds #defines that refer to the second argument, and records their position in p, while the second rule finds all other #defines with two arguments. Of course, you would want to use a regular expression for the macro name, or do something to avoid changing all two argument macros. Macros are often defined in header files, so you may want to use the command line options --no-includes --include-headers. --no-includes means ignore header files when they are included into .c files and --include-headers means treat both .c an .h files. Otherwise, you only get .c files. julia _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
