On Sun, 12 May 2024, Markus Elfring wrote: > > Your semantic patch needs to be: > > > > @display@ > > @@ > > my_action(...); > > <+... when any > > *my_action(...); > > ...+> > > > > Without that, a call to my_action is forbidden in the region matched by > > the <+... ...+>. Because any kind of dot thing matches the shortest path > > between what comes before and what comes after (here the end of the function). > > Can the Coccinelle software inform better about the case that the shortest > path constraint was “accidentally overlooked” in a SmPL script? > > > There are further development challenges to consider. > See also a corresponding transformation approach by the means of > another tiny script for the semantic patch language: > > @adjustment@ > @@ > my_action( > - ... > + 0 > ); > <+... when any > -my_action(...); > ...+> > > > Test result: > Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch use_one_test_call.cocci repeated_three_calls.c > … > previous modification: > > <<< 0 > CONTEXT > > According to environment 0: > > > current modification: > MINUS > > According to environment 0: > > > adjustment: already tagged token: > C code context > File "repeated_three_calls.c", line 4, column 12, charpos = 48 > around = ')', > whole content = my_action(2); > > > Can the data processing be improved anyhow? The current semantic pach allows the first my_action to match anywhere, including the second my_action, third, etc. So if you have changes in both, then there will be contradictory changes to the code. Probably you should start with ... when != my_action(...) to be sure to get the first one. julia