coccinelle: Add str_off_on() and str_no_yes() rules
Subsystems (2)
PATCH 1/1 coccinelle: Add str_off_on() and str_no_yes() rules
In addition to str_on_off() and str_yes_no(), add rules to search for str_off_on() and str_no_yes() replacements.
--- scripts/coccinelle/api/string_choices.cocci | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+)
scripts/coccinelle/api/string_choices.cocci +38 -0
@@ -282,6 +282,25 @@ e << str_on_off_r.E; coccilib.report.print_report(p[0], "opportunity for str_on_off(%s)" % e) +@str_off_on depends on patch@ +expression E; +@@ +- ((E) ? "off" : "on") ++ str_off_on(E) + +@str_off_on_r depends on !patch@ +expression E; +position P; +@@ +* E@P ? "off" : "on" + +@script:python depends on report@ +p << str_off_on_r.P; +e << str_off_on_r.E; +@@ + +coccilib.report.print_report(p[0], "opportunity for str_off_on(%s)" % e) + @str_yes_no depends on patch@ expression E; @@
@@ -300,3 +319,22 @@ e << str_yes_no_r.E; @@ coccilib.report.print_report(p[0], "opportunity for str_yes_no(%s)" % e) + +@str_no_yes depends on patch@ +expression E; +@@ +- ((E) ? "no" : "yes") ++ str_no_yes(E) + +@str_no_yes_r depends on !patch@ +expression E; +position P; +@@ +* E@P ? "no" : "yes" + +@script:python depends on report@ +p << str_no_yes_r.P; +e << str_no_yes_r.E; +@@ + +coccilib.report.print_report(p[0], "opportunity for str_no_yes(%s)" % e)
Signature · 1 line
2.47.0
Quoted 3 lines · Thorsten Blum
In addition to
str_on_off()andstr_yes_no(), add rules to search forstr_off_on()andstr_no_yes()replacements.
I don't know cocci well enough, but this does simply not scale. We also have cases where "Yes"/"No", "YES"/"NO" and all possible variations of that.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Julia Lawall
maintainerQuoted 8 lines · Andy Shevchenko
Quoted 3 lines · Thorsten Blum
In addition to
str_on_off()andstr_yes_no(), add rules to search forstr_off_on()andstr_no_yes()replacements.I don't know cocci well enough, but this does simply not scale. We also have cases where "Yes"/"No", "YES"/"NO" and all possible variations of that.
Andy, are you concerned about the number of such functions in the kernel or the number of rules in the semantic patch. There are indeed more concise ways to write the semantic patch.
julia
Quoted 6 lines
--
With Best Regards,
Andy Shevchenko
Quoted 6 lines · Julia Lawall
Quoted 5 lines · Andy Shevchenko
Quoted 3 lines · Thorsten Blum
In addition to
str_on_off()andstr_yes_no(), add rules to search forstr_off_on()andstr_no_yes()replacements.
Quoted 6 lines
Quoted 3 lines
I don't know cocci well enough, but this does simply not scale. We also have cases where "Yes"/"No", "YES"/"NO" and all possible variations of that.
Andy, are you concerned about the number of such functions in the kernel or the number of rules in the semantic patch.
Rules for the semantic patches I am worried about.
Quoted 2 lines
There are indeed more
concise ways to write the semantic patch.
Would be nice to see ways to cover more cases in less lines in the spatch.
Signature · 2 lines
With Best Regards, Andy Shevchenko