Skip to contentSkip to conversation

coccinelle: Adjust the position of some coccinelle rules

PATCH In review Jiazi Li 2 participants 2 messages May 6

Subsystems (2)
lore
Share & tools
lore

Jiazi Li

author
#0 lore raw

PATCH v3 1/1 coccinelle: Adjust the position of some coccinelle rules

Adjust the position of some coccinelle rules, so they sorted in the same order as they appear in the header.

---
Changes in v3:
Split position adjustment to a separate patch

v2: https://lore.kernel.org/linux-hardening/CAHp75Vdvdr0TPzuDDPSoJ4Nixk-6qO_x6Or9iY9LNwSO1Q6mHg@mail.gmail.com/T/#t

---
 scripts/coccinelle/api/string_choices.cocci | 234 ++++++++++----------
 1 file changed, 117 insertions(+), 117 deletions(-)
scripts/coccinelle/api/string_choices.cocci +117 -117
index 375045086912..7b2b76a42acc 100644
@@ -7,109 +7,43 @@ virtual patch
 virtual context
 virtual report
 
-@str_plural depends on patch@
-expression E;
-@@
-(
--	((E == 1) ? "" : "s")
-+	str_plural(E)
-|
--	((E > 1) ? "s" : "")
-+	str_plural(E)
-)
-
-@str_plural_r depends on !patch@
-expression E;
-position P;
-@@
-(
-*	(E@P == 1) ? "" : "s"
-|
-*	(E@P > 1) ? "s" : ""
-)
-
-@script:python depends on report@
-p << str_plural_r.P;
-e << str_plural_r.E;
-@@
-
-coccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e)
-
-@str_up_down depends on patch disable neg_if_exp@
-expression E;
-@@
--	((E) ? "up" : "down")
-+	str_up_down(E)
-
-@str_up_down_r depends on !patch disable neg_if_exp@
-expression E;
-position P;
-@@
-*	E@P ? "up" : "down"
-
-@script:python depends on report@
-p << str_up_down_r.P;
-e << str_up_down_r.E;
-@@
-
-coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e)
-
-@str_down_up depends on patch disable neg_if_exp@
-expression E;
-@@
--      ((E) ? "down" : "up")
-+      str_down_up(E)
-
-@str_down_up_r depends on !patch disable neg_if_exp@
-expression E;
-position P;
-@@
-*      E@P ? "down" : "up"
-
-@script:python depends on report@
-p << str_down_up_r.P;
-e << str_down_up_r.E;
-@@
-
-coccilib.report.print_report(p[0], "opportunity for str_down_up(%s)" % e)
-
-@str_true_false depends on patch disable neg_if_exp@
+@str_enable_disable depends on patch@
 expression E;
 @@
--      ((E) ? "true" : "false")
-+      str_true_false(E)
+-      ((E) ? "enable" : "disable")
++      str_enable_disable(E)
 
-@str_true_false_r depends on !patch disable neg_if_exp@
+@str_enable_disable_r depends on !patch@
 expression E;
 position P;
 @@
-*      E@P ? "true" : "false"
+*      E@P ? "enable" : "disable"
 
 @script:python depends on report@
-p << str_true_false_r.P;
-e << str_true_false_r.E;
+p << str_enable_disable_r.P;
+e << str_enable_disable_r.E;
 @@
 
-coccilib.report.print_report(p[0], "opportunity for str_true_false(%s)" % e)
+coccilib.report.print_report(p[0], "opportunity for str_enable_disable(%s)" % e)
 
-@str_false_true depends on patch disable neg_if_exp@
+@str_enabled_disabled depends on patch@
 expression E;
 @@
--      ((E) ? "false" : "true")
-+      str_false_true(E)
+-      ((E) ? "enabled" : "disabled")
++      str_enabled_disabled(E)
 
-@str_false_true_r depends on !patch disable neg_if_exp@
+@str_enabled_disabled_r depends on !patch@
 expression E;
 position P;
 @@
-*      E@P ? "false" : "true"
+*      E@P ? "enabled" : "disabled"
 
 @script:python depends on report@
-p << str_false_true_r.P;
-e << str_false_true_r.E;
+p << str_enabled_disabled_r.P;
+e << str_enabled_disabled_r.E;
 @@
 
-coccilib.report.print_report(p[0], "opportunity for str_false_true(%s)" % e)
+coccilib.report.print_report(p[0], "opportunity for str_enabled_disabled(%s)" % e)
 
 @str_hi_lo depends on patch disable neg_if_exp@
 expression E;
@@ -187,43 +121,24 @@ e << str_low_high_r.E;
 
 coccilib.report.print_report(p[0], "opportunity for str_low_high(%s)" % e)
 
-@str_enable_disable depends on patch@
-expression E;
-@@
--      ((E) ? "enable" : "disable")
-+      str_enable_disable(E)
-
-@str_enable_disable_r depends on !patch@
-expression E;
-position P;
-@@
-*      E@P ? "enable" : "disable"
-
-@script:python depends on report@
-p << str_enable_disable_r.P;
-e << str_enable_disable_r.E;
-@@
-
-coccilib.report.print_report(p[0], "opportunity for str_enable_disable(%s)" % e)
-
-@str_enabled_disabled depends on patch@
+@str_on_off depends on patch@
 expression E;
 @@
--      ((E) ? "enabled" : "disabled")
-+      str_enabled_disabled(E)
+-      ((E) ? "on" : "off")
++      str_on_off(E)
 
-@str_enabled_disabled_r depends on !patch@
+@str_on_off_r depends on !patch@
 expression E;
 position P;
 @@
-*      E@P ? "enabled" : "disabled"
+*      E@P ? "on" : "off"
 
 @script:python depends on report@
-p << str_enabled_disabled_r.P;
-e << str_enabled_disabled_r.E;
+p << str_on_off_r.P;
+e << str_on_off_r.E;
 @@
 
-coccilib.report.print_report(p[0], "opportunity for str_enabled_disabled(%s)" % e)
+coccilib.report.print_report(p[0], "opportunity for str_on_off(%s)" % e)
 
 @str_read_write depends on patch disable neg_if_exp@
 expression E;
@@ -263,24 +178,81 @@ e << str_write_read_r.E;
 
 coccilib.report.print_report(p[0], "opportunity for str_write_read(%s)" % e)
 
-@str_on_off depends on patch@
+@str_true_false depends on patch disable neg_if_exp@
 expression E;
 @@
--      ((E) ? "on" : "off")
-+      str_on_off(E)
+-      ((E) ? "true" : "false")
++      str_true_false(E)
 
-@str_on_off_r depends on !patch@
+@str_true_false_r depends on !patch disable neg_if_exp@
 expression E;
 position P;
 @@
-*      E@P ? "on" : "off"
+*      E@P ? "true" : "false"
 
 @script:python depends on report@
-p << str_on_off_r.P;
-e << str_on_off_r.E;
+p << str_true_false_r.P;
+e << str_true_false_r.E;
 @@
 
-coccilib.report.print_report(p[0], "opportunity for str_on_off(%s)" % e)
+coccilib.report.print_report(p[0], "opportunity for str_true_false(%s)" % e)
+
+@str_false_true depends on patch disable neg_if_exp@
+expression E;
+@@
+-      ((E) ? "false" : "true")
++      str_false_true(E)
+
+@str_false_true_r depends on !patch disable neg_if_exp@
+expression E;
+position P;
+@@
+*      E@P ? "false" : "true"
+
+@script:python depends on report@
+p << str_false_true_r.P;
+e << str_false_true_r.E;
+@@
+
+coccilib.report.print_report(p[0], "opportunity for str_false_true(%s)" % e)
+
+@str_up_down depends on patch disable neg_if_exp@
+expression E;
+@@
+-	((E) ? "up" : "down")
++	str_up_down(E)
+
+@str_up_down_r depends on !patch disable neg_if_exp@
+expression E;
+position P;
+@@
+*	E@P ? "up" : "down"
+
+@script:python depends on report@
+p << str_up_down_r.P;
+e << str_up_down_r.E;
+@@
+
+coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e)
+
+@str_down_up depends on patch disable neg_if_exp@
+expression E;
+@@
+-      ((E) ? "down" : "up")
++      str_down_up(E)
+
+@str_down_up_r depends on !patch disable neg_if_exp@
+expression E;
+position P;
+@@
+*      E@P ? "down" : "up"
+
+@script:python depends on report@
+p << str_down_up_r.P;
+e << str_down_up_r.E;
+@@
+
+coccilib.report.print_report(p[0], "opportunity for str_down_up(%s)" % e)
 
 @str_yes_no depends on patch@
 expression E;
@@ -300,3 +272,31 @@ e << str_yes_no_r.E;
 @@
 
 coccilib.report.print_report(p[0], "opportunity for str_yes_no(%s)" % e)
+
+@str_plural depends on patch@
+expression E;
+@@
+(
+-	((E == 1) ? "" : "s")
++	str_plural(E)
+|
+-	((E > 1) ? "s" : "")
++	str_plural(E)
+)
+
+@str_plural_r depends on !patch@
+expression E;
+position P;
+@@
+(
+*	(E@P == 1) ? "" : "s"
+|
+*	(E@P > 1) ? "s" : ""
+)
+
+@script:python depends on report@
+p << str_plural_r.P;
+e << str_plural_r.E;
+@@
+
+coccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e)
Signature · 1 line
2.49.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 3 lines · Jiazi Li

Adjust the position of some coccinelle rules, so they sorted in the same order as they appear in the header.

LGTM, thanks

Signature · 2 lines
With Best Regards,
Andy Shevchenko