Skip to contentSkip to conversation

Moving setting of error codes into if branches with SmPL?

Cocci SF Markus Elfring 1 participant 1 message Jan 17, 2017

lore
Share & tools
lore
#0 lore raw

Hello,

I have tried the following small script out for the semantic patch language.

@show_assignments@
expression target;
identifier code =~ "^E[A-Z]+$";
statement is, es;
@@
*target = -(code);
if (...)
is
else
es

elfring at Sonne:~/Projekte/Linux/next-patched> spatch.opt -timeout 23 -j 4 --chunksize 1 -sp-file ~/Projekte/Coccinelle/janitor/show_misplaced_error_code_assignments1.cocci -dir security/selinux 2> ~/Projekte/Bau/Linux/scripts/Coccinelle/show_misplaced_error_code_assignments1-errors.txt

Some update candidates were displayed.

Is such a simple source code search pattern worth to be integrated into the Coccinelle script collection?

I see further development challenges for the specification of a corresponding source code transformation.
How hard can it become to move the found variable assignments before condition checks to the place before the last goto statement within an if branch automatically?

Regards,
Markus