[Cocci] Transformation challenges with SmPL around “LIST_FOR_EACH_ENTRY”

SF Markus Elfring elfring at users.sourceforge.net
Sat Dec 2 10:20:06 CET 2017


>> I think I've found a bug in spatch,

You showed another opportunity for further development considerations.


>> or maybe I'm just using it wrong.

Not really.

But the specification in the shown small SmPL script could be adjusted.


>> - LIST_FOR_EACH_ENTRY(c,f,g,member) S
>> + hlist_for_each_entry(c,f,member) S

> Actually, the problem is that you have removed S and dded it back.
> Then you are relying on Coccinelle to do the pretty printing,
> and all comments will be dropped.  Just rewrite your rule as follows,
> and everything will be fine:

> - LIST_FOR_EACH_ENTRY(c,f,g,member)
> + hlist_for_each_entry(c,f,member)
>   S

How do you think about further possibilities?

Can it be also sufficient to express only the source code adjustment for
two details?

* Replacement of a macro name

* Deletion (or omission) of a parameter


@adjustment@
expression ex;
statement S;
@@
-LIST_FOR_EACH_ENTRY
+hlist_for_each_entry
 (..., ...,
-ex,
 ...)
 S

Regards,
Markus


More information about the Cocci mailing list