cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Problem with improper multi-line string literals
@ 2018-10-12 21:28 Timur Tabi
  2018-10-12 21:37 ` Julia Lawall
  2018-10-13 21:19 ` Julia Lawall
  0 siblings, 2 replies; 20+ messages in thread
From: Timur Tabi @ 2018-10-12 21:28 UTC (permalink / raw)
  To: cocci

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".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 267 bytes
Desc: not available
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20181012/b8997b9c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nv_printf.cocci
Type: application/octet-stream
Size: 4024 bytes
Desc: not available
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20181012/b8997b9c/attachment.obj>

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2018-10-16 17:14 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-12 21:28 [Cocci] Problem with improper multi-line string literals Timur Tabi
2018-10-12 21:37 ` Julia Lawall
2018-10-12 21:42   ` Timur Tabi
2018-10-12 22:24     ` Timur Tabi
2018-10-12 23:08       ` Timur Tabi
2018-10-12 23:22         ` Timur Tabi
2018-10-13  3:08           ` Julia Lawall
     [not found]     ` <e4e5dc37-c364-c53d-26f6-52205cfee304@users.sourceforge.net>
2018-10-13 15:56       ` Timur Tabi
2018-10-13 21:19 ` Julia Lawall
2018-10-15 16:37   ` Timur Tabi
2018-10-15 16:39     ` Julia Lawall
2018-10-15 16:50       ` Timur Tabi
2018-10-15 16:55         ` Julia Lawall
2018-10-15 18:35           ` Timur Tabi
2018-10-16 15:10     ` Himanshu Jha
2018-10-16 15:12       ` Julia Lawall
2018-10-16 16:28       ` Timur Tabi
2018-10-16 16:39         ` Julia Lawall
2018-10-16 17:14           ` Timur Tabi
2018-10-16 17:10         ` Himanshu Jha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).