On Fri, 12 Oct 2018, Timur Tabi wrote:
> 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:
It does look strange. Maybe you can avoid removing and reconstructing the
string. For example, if you rewrite rule1 as:
@rule1@
expression x;
expression list y;
@@
-DBG_PRINTF
+NV_PRINTF
(
- x,
y);
then the code generated by rule1 is OK. I haven't checked whether this
can be done in the whole semantic patch, though.
julia
>
> 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".
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci