mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
Reduce Coccinelle choices in string_choices.cocci
The isomorphism neg_if_exp negates the test of a ?: conditional, making it unnecessary to have an explicit case for a negated test with the branches inverted. At the same time, we can disable neg_if_exp in cases where a different API function may be more suitable for a negated test. Finally, in the non-patch cases, E matches an expression with parentheses around it, so there is no need to mention () explicitly in the pattern. The () are still needed in the patch cases, because we want to drop them, if they are present. Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
This commit is contained in:
parent
f584e3752c
commit
4003ba664b
@ -14,23 +14,18 @@ expression E;
|
|||||||
- ((E == 1) ? "" : "s")
|
- ((E == 1) ? "" : "s")
|
||||||
+ str_plural(E)
|
+ str_plural(E)
|
||||||
|
|
|
|
||||||
- ((E != 1) ? "s" : "")
|
|
||||||
+ str_plural(E)
|
|
||||||
|
|
|
||||||
- ((E > 1) ? "s" : "")
|
- ((E > 1) ? "s" : "")
|
||||||
+ str_plural(E)
|
+ str_plural(E)
|
||||||
)
|
)
|
||||||
|
|
||||||
@str_plural_r depends on !patch exists@
|
@str_plural_r depends on !patch@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
(
|
(
|
||||||
* ((E@P == 1) ? "" : "s")
|
* (E@P == 1) ? "" : "s"
|
||||||
|
|
|
|
||||||
* ((E@P != 1) ? "s" : "")
|
* (E@P > 1) ? "s" : ""
|
||||||
|
|
|
||||||
* ((E@P > 1) ? "s" : "")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
@ -40,17 +35,17 @@ e << str_plural_r.E;
|
|||||||
|
|
||||||
coccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e)
|
coccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e)
|
||||||
|
|
||||||
@str_up_down depends on patch@
|
@str_up_down depends on patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
@@
|
@@
|
||||||
- ((E) ? "up" : "down")
|
- ((E) ? "up" : "down")
|
||||||
+ str_up_down(E)
|
+ str_up_down(E)
|
||||||
|
|
||||||
@str_up_down_r depends on !patch exists@
|
@str_up_down_r depends on !patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
* ((E@P) ? "up" : "down")
|
* E@P ? "up" : "down"
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_up_down_r.P;
|
p << str_up_down_r.P;
|
||||||
@ -59,17 +54,17 @@ e << str_up_down_r.E;
|
|||||||
|
|
||||||
coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e)
|
coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e)
|
||||||
|
|
||||||
@str_down_up depends on patch@
|
@str_down_up depends on patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
@@
|
@@
|
||||||
- ((E) ? "down" : "up")
|
- ((E) ? "down" : "up")
|
||||||
+ str_down_up(E)
|
+ str_down_up(E)
|
||||||
|
|
||||||
@str_down_up_r depends on !patch exists@
|
@str_down_up_r depends on !patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
* ((E@P) ? "down" : "up")
|
* E@P ? "down" : "up"
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_down_up_r.P;
|
p << str_down_up_r.P;
|
||||||
@ -78,17 +73,17 @@ e << str_down_up_r.E;
|
|||||||
|
|
||||||
coccilib.report.print_report(p[0], "opportunity for str_down_up(%s)" % e)
|
coccilib.report.print_report(p[0], "opportunity for str_down_up(%s)" % e)
|
||||||
|
|
||||||
@str_true_false depends on patch@
|
@str_true_false depends on patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
@@
|
@@
|
||||||
- ((E) ? "true" : "false")
|
- ((E) ? "true" : "false")
|
||||||
+ str_true_false(E)
|
+ str_true_false(E)
|
||||||
|
|
||||||
@str_true_false_r depends on !patch exists@
|
@str_true_false_r depends on !patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
* ((E@P) ? "true" : "false")
|
* E@P ? "true" : "false"
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_true_false_r.P;
|
p << str_true_false_r.P;
|
||||||
@ -97,17 +92,17 @@ e << str_true_false_r.E;
|
|||||||
|
|
||||||
coccilib.report.print_report(p[0], "opportunity for str_true_false(%s)" % e)
|
coccilib.report.print_report(p[0], "opportunity for str_true_false(%s)" % e)
|
||||||
|
|
||||||
@str_false_true depends on patch@
|
@str_false_true depends on patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
@@
|
@@
|
||||||
- ((E) ? "false" : "true")
|
- ((E) ? "false" : "true")
|
||||||
+ str_false_true(E)
|
+ str_false_true(E)
|
||||||
|
|
||||||
@str_false_true_r depends on !patch exists@
|
@str_false_true_r depends on !patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
* ((E@P) ? "false" : "true")
|
* E@P ? "false" : "true"
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_false_true_r.P;
|
p << str_false_true_r.P;
|
||||||
@ -116,21 +111,17 @@ e << str_false_true_r.E;
|
|||||||
|
|
||||||
coccilib.report.print_report(p[0], "opportunity for str_false_true(%s)" % e)
|
coccilib.report.print_report(p[0], "opportunity for str_false_true(%s)" % e)
|
||||||
|
|
||||||
@str_hi_lo depends on patch@
|
@str_hi_lo depends on patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
@@
|
@@
|
||||||
(
|
|
||||||
- ((E) ? "hi" : "lo")
|
- ((E) ? "hi" : "lo")
|
||||||
+ str_hi_lo(E)
|
+ str_hi_lo(E)
|
||||||
)
|
|
||||||
|
|
||||||
@str_hi_lo_r depends on !patch exists@
|
@str_hi_lo_r depends on !patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
(
|
* E@P ? "hi" : "lo"
|
||||||
* ((E@P) ? "hi" : "lo")
|
|
||||||
)
|
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_hi_lo_r.P;
|
p << str_hi_lo_r.P;
|
||||||
@ -139,17 +130,17 @@ e << str_hi_lo_r.E;
|
|||||||
|
|
||||||
coccilib.report.print_report(p[0], "opportunity for str_hi_lo(%s)" % e)
|
coccilib.report.print_report(p[0], "opportunity for str_hi_lo(%s)" % e)
|
||||||
|
|
||||||
@str_high_low depends on patch@
|
@str_high_low depends on patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
@@
|
@@
|
||||||
- ((E) ? "high" : "low")
|
- ((E) ? "high" : "low")
|
||||||
+ str_high_low(E)
|
+ str_high_low(E)
|
||||||
|
|
||||||
@str_high_low_r depends on !patch exists@
|
@str_high_low_r depends on !patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
* ((E@P) ? "high" : "low")
|
* E@P ? "high" : "low"
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_high_low_r.P;
|
p << str_high_low_r.P;
|
||||||
@ -158,17 +149,17 @@ e << str_high_low_r.E;
|
|||||||
|
|
||||||
coccilib.report.print_report(p[0], "opportunity for str_high_low(%s)" % e)
|
coccilib.report.print_report(p[0], "opportunity for str_high_low(%s)" % e)
|
||||||
|
|
||||||
@str_lo_hi depends on patch@
|
@str_lo_hi depends on patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
@@
|
@@
|
||||||
- ((E) ? "lo" : "hi")
|
- ((E) ? "lo" : "hi")
|
||||||
+ str_lo_hi(E)
|
+ str_lo_hi(E)
|
||||||
|
|
||||||
@str_lo_hi_r depends on !patch exists@
|
@str_lo_hi_r depends on !patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
* ((E@P) ? "lo" : "hi")
|
* E@P ? "lo" : "hi"
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_lo_hi_r.P;
|
p << str_lo_hi_r.P;
|
||||||
@ -177,17 +168,17 @@ e << str_lo_hi_r.E;
|
|||||||
|
|
||||||
coccilib.report.print_report(p[0], "opportunity for str_lo_hi(%s)" % e)
|
coccilib.report.print_report(p[0], "opportunity for str_lo_hi(%s)" % e)
|
||||||
|
|
||||||
@str_low_high depends on patch@
|
@str_low_high depends on patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
@@
|
@@
|
||||||
- ((E) ? "low" : "high")
|
- ((E) ? "low" : "high")
|
||||||
+ str_low_high(E)
|
+ str_low_high(E)
|
||||||
|
|
||||||
@str_low_high_r depends on !patch exists@
|
@str_low_high_r depends on !patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
* ((E@P) ? "low" : "high")
|
* E@P ? "low" : "high"
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_low_high_r.P;
|
p << str_low_high_r.P;
|
||||||
@ -202,11 +193,11 @@ expression E;
|
|||||||
- ((E) ? "enable" : "disable")
|
- ((E) ? "enable" : "disable")
|
||||||
+ str_enable_disable(E)
|
+ str_enable_disable(E)
|
||||||
|
|
||||||
@str_enable_disable_r depends on !patch exists@
|
@str_enable_disable_r depends on !patch@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
* ((E@P) ? "enable" : "disable")
|
* E@P ? "enable" : "disable"
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_enable_disable_r.P;
|
p << str_enable_disable_r.P;
|
||||||
@ -221,11 +212,11 @@ expression E;
|
|||||||
- ((E) ? "enabled" : "disabled")
|
- ((E) ? "enabled" : "disabled")
|
||||||
+ str_enabled_disabled(E)
|
+ str_enabled_disabled(E)
|
||||||
|
|
||||||
@str_enabled_disabled_r depends on !patch exists@
|
@str_enabled_disabled_r depends on !patch@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
* ((E@P) ? "enabled" : "disabled")
|
* E@P ? "enabled" : "disabled"
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_enabled_disabled_r.P;
|
p << str_enabled_disabled_r.P;
|
||||||
@ -234,17 +225,17 @@ e << str_enabled_disabled_r.E;
|
|||||||
|
|
||||||
coccilib.report.print_report(p[0], "opportunity for str_enabled_disabled(%s)" % e)
|
coccilib.report.print_report(p[0], "opportunity for str_enabled_disabled(%s)" % e)
|
||||||
|
|
||||||
@str_read_write depends on patch@
|
@str_read_write depends on patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
@@
|
@@
|
||||||
- ((E) ? "read" : "write")
|
- ((E) ? "read" : "write")
|
||||||
+ str_read_write(E)
|
+ str_read_write(E)
|
||||||
|
|
||||||
@str_read_write_r depends on !patch exists@
|
@str_read_write_r depends on !patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
* ((E@P) ? "read" : "write")
|
* E@P ? "read" : "write"
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_read_write_r.P;
|
p << str_read_write_r.P;
|
||||||
@ -253,17 +244,17 @@ e << str_read_write_r.E;
|
|||||||
|
|
||||||
coccilib.report.print_report(p[0], "opportunity for str_read_write(%s)" % e)
|
coccilib.report.print_report(p[0], "opportunity for str_read_write(%s)" % e)
|
||||||
|
|
||||||
@str_write_read depends on patch@
|
@str_write_read depends on patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
@@
|
@@
|
||||||
- ((E) ? "write" : "read")
|
- ((E) ? "write" : "read")
|
||||||
+ str_write_read(E)
|
+ str_write_read(E)
|
||||||
|
|
||||||
@str_write_read_r depends on !patch exists@
|
@str_write_read_r depends on !patch disable neg_if_exp@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
* ((E@P) ? "write" : "read")
|
* E@P ? "write" : "read"
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_write_read_r.P;
|
p << str_write_read_r.P;
|
||||||
@ -278,11 +269,11 @@ expression E;
|
|||||||
- ((E) ? "on" : "off")
|
- ((E) ? "on" : "off")
|
||||||
+ str_on_off(E)
|
+ str_on_off(E)
|
||||||
|
|
||||||
@str_on_off_r depends on !patch exists@
|
@str_on_off_r depends on !patch@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
* ((E@P) ? "on" : "off")
|
* E@P ? "on" : "off"
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_on_off_r.P;
|
p << str_on_off_r.P;
|
||||||
@ -297,11 +288,11 @@ expression E;
|
|||||||
- ((E) ? "yes" : "no")
|
- ((E) ? "yes" : "no")
|
||||||
+ str_yes_no(E)
|
+ str_yes_no(E)
|
||||||
|
|
||||||
@str_yes_no_r depends on !patch exists@
|
@str_yes_no_r depends on !patch@
|
||||||
expression E;
|
expression E;
|
||||||
position P;
|
position P;
|
||||||
@@
|
@@
|
||||||
* ((E@P) ? "yes" : "no")
|
* E@P ? "yes" : "no"
|
||||||
|
|
||||||
@script:python depends on report@
|
@script:python depends on report@
|
||||||
p << str_yes_no_r.P;
|
p << str_yes_no_r.P;
|
||||||
|
Loading…
Reference in New Issue
Block a user