On Tue, Apr 13, 2021 at 11:56:20AM +0200, Julia Lawall wrote: > > > On Tue, 13 Apr 2021, Fabio Aiuto wrote: > > > Hi, > > > > I would like to improve the following coccinelle script: > > > > @@ > > expression a, fmt; > > expression list var_args; > > @@ > > > > - DBG_871X_LEVEL(a, fmt, var_args); > > + printk(fmt, var_args); > > > > I would replace the DBG_871X_LEVEL macro with printk, but > > I can't find a way to add KERN_* constant prefix to the fmt > > argument in the + code line. If i try this > > > > @@ > > expression a, fmt; > > expression list var_args; > > @@ > > > > - DBG_871X_LEVEL(a, fmt, var_args); > > + printk(KERN_DEBUG fmt, var_args); > > > > plus: parse error: > > File "../test.cocci", line 94, column 20, charpos = 1171 > > around = 'fmt', > > whole content = + printk(KERN_DEBUG fmt, var_args); > > > > how could I do this? > > Although I certainly agree with Greg, I'll answer the question from a > technical point of view. > > I'm not sure that that kind of compound string is supported for a > metavariable. It is possible to get around this problem using a python > script. If you ever need to do this for a better reason, you can take a > look at demos/pythontococci.cocci in the Coccinelle source code > distribution. > > julia thank you, this helps a lot! fabio