[Cocci] strange behaviour, failing to insert expression in valid C source file
leif.lindholm at linaro.org
Wed Nov 26 16:07:28 CET 2014
I was asked to change an API in the Linux kernel by adding an optional
parameter in form of a pointer. So I reached for coccinelle to add
", NULL" to all existing callers. To do so, I used the following sp-file:
+ of_find_node_by_path(E1, NULL)
This worked splendidly on all call sites in the kernel, except for two
in the of_resolve_phandles() function in drivers/of/resolver.c.
It looks like spatch becomes upset on encountering a variable with the
same name as an autodetected typedef. This can be confirmed with
I've reduced my test case to the following:
struct device_node *node;
node = of_find_node_by_path("/__symbols__");
Running the command:
spatch --in-place --sp-file ../of.cocci foo.c
fails silently to update the file, and returns 0.
Tested on 1.0.0-rc22 and -rc12.
More information about the Cocci