[Cocci] Code wrapped in macros ignored by script

Julia Lawall julia.lawall at lip6.fr
Thu Aug 2 22:33:25 CEST 2018

On Thu, 2 Aug 2018, Timur Tabi wrote:

> My cocci script (attached) ignores lines that are embedded inside other
> macros.  Example:
> #define DB(x)   x
> void func()
> {
>     DB(if (DEBUG_IO_TRACE())
>                 DBG_PRINTF((DBG_MODULE_GLOBAL, DBG_LEVEL_INFO, "inb %#04x \n",
> addr));)
> }
> Is there a way to get coccinelle to ignore the DB( and )?

No.  Either Coccinelle can parse the macro use as is, which is not
possible here, because an if can't be an argument to a function call, or
it expands the macro, in which case no transformation is possible.


More information about the Cocci mailing list