Discussion:
[Cocci] Removing trailing whitespace at the end of changes lines?
Timur Tabi
2018-07-30 19:53:09 UTC
Permalink
I've noticed that some lines changed with my cocci script have a
trailing whitespace at the end of the first line. For example:

- DBG_PRINTF((DBG_MODULE_GLOBAL, DBG_LEVEL_ERRORS,
- "NVRM: %s: failed to save GPU crash data\n",
- __FUNCTION__));
+ NV_PRINTF(LEVEL_ERROR,
+ "%s: failed to save GPU crash data\n", __FUNCTION__);

There is a blank space after "LEVEL_ERROR,". I've attached my cocci
script, but considering that coccinelle seems to reformat lines after
they've been modified,
I suspect that the problem is not in my script per se.
Julia Lawall
2018-07-30 20:21:03 UTC
Permalink
Post by Timur Tabi
I've noticed that some lines changed with my cocci script have a
- DBG_PRINTF((DBG_MODULE_GLOBAL, DBG_LEVEL_ERRORS,
- "NVRM: %s: failed to save GPU crash data\n",
- __FUNCTION__));
+ NV_PRINTF(LEVEL_ERROR,
+ "%s: failed to save GPU crash data\n", __FUNCTION__);
There is a blank space after "LEVEL_ERROR,". I've attached my cocci
script, but considering that coccinelle seems to reformat lines after
they've been modified,
I suspect that the problem is not in my script per se.
Coccinelle makes some special efforts to add newlines to respect the 80
character boundary. It seems that the associated space is not always
getting removed. I will try to take a look.

julia
Timur Tabi
2018-07-30 20:27:35 UTC
Permalink
Post by Julia Lawall
Coccinelle makes some special efforts to add newlines to respect the 80
character boundary. It seems that the associated space is not always
getting removed. I will try to take a look.
It appears to happen only when the second parameter is on the second
line. That is, the LEVEL_xxx parameter is the only parameter on the
first line.
Julia Lawall
2018-07-31 19:18:43 UTC
Permalink
Post by Timur Tabi
I've noticed that some lines changed with my cocci script have a
- DBG_PRINTF((DBG_MODULE_GLOBAL, DBG_LEVEL_ERRORS,
- "NVRM: %s: failed to save GPU crash data\n",
- __FUNCTION__));
+ NV_PRINTF(LEVEL_ERROR,
+ "%s: failed to save GPU crash data\n", __FUNCTION__);
There is a blank space after "LEVEL_ERROR,". I've attached my cocci
script, but considering that coccinelle seems to reformat lines after
they've been modified,
I suspect that the problem is not in my script per se.
Could you send a .c file that produces the problem? I tried with the
attached file but I don't get any trailing spaces.

julia

Loading...