I've attached a test.c and nv_printf.cocci file that demonstrates the problem.
It appears that Coccinelle sometimes cannot handle multi-line string
literals that are syntactically correct but still improper. For
example:
DBG_PRINTF((DBG_MODULE_OS, DBG_LEVEL_ERRORS,
"NVRM: %s: this is a test \
of multiline " NvP64_fmt " strings %p\n",
__FUNCTION__,
p1,
p2));
This is valid C, but technically the string literal should have
quotation marks at the beginning of each line. When Coccinelle
attempts to process my script with this, it gets confused and mangles
the parameters after the string literal:
void func(void)
{
- DBG_PRINTF((DBG_MODULE_OS, DBG_LEVEL_ERRORS,
- "NVRM: %s: this is a test \
- of multiline " NvP64_fmt " strings %p\n",
- __FUNCTION__,
- p1,
- p2));
-}
+ NV_PRINTF(DBG_LEVEL_ERRORS, "NVRM: %s: this is a test \
+ of multiline " NvP64_fmt " strings %p\n", __FUNCTION__,
+ of multiline "p1, p2);
+}"
I added code into my Python script to combine the string into one
line, but that doesn't really matter because Coccinelle doesn't even
call my Python code. In fact, it ignores many of my rules because the
DBG_LEVEL_ERRORS should have been changed to "LEVEL_ERROR".
void func(void)
{
DBG_PRINTF((DBG_MODULE_OS, DBG_LEVEL_ERRORS,
"NVRM: %s: this is a test \
of multiline " NvP64_fmt " strings %p\n",
__FUNCTION__,
p1,
p2));
}
nv_printf.cocci
Description: Binary data
_______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
