mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-03 19:55:31 +00:00
coccinelle: Extend string_choices.cocci to use more available helpers
10 patches from Hongbo Li <lihongbo22@huawei.com> extending string_choices.cocci with the complete set of functions offered by include/linux/string_choices.h. 1 patch from myself reducing the number of redundant cases that are checked by Coccinelle, giving a small performance improvement. Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEnGZC8gbRfLXdcpA0F+92B3f5RZ0FAmb4XlAACgkQF+92B3f5 RZ1FKg//RKigv3cY08f3lfcs6Kaa8tlUSOPHNtBmuBZn+v+YjJTqwvkGzZuc7suW OF1qfXy+/ym30psbOZ1B+dKojnmi4nCqgoZ+iu4ZbuRmKsRNF8ezF7D372suWy+F PiW/lRqJZVhoV8FsGhCoK6TUUNAIdn+zgUnW80yPkk9Q8gLwv9Mbkh14upnqIS94 ksfDYIQ0jz7UZCpS2a6AqTQdtYvIca+SVgE+t5Dd0lSp6FIC2b11mqM6jKdi/Jg1 JWV7CzlRcfvuVtc1st33k4zfC0zdefKQzGt+yHuUsHtrxN62ZoxSIpnAlN/0hoaz 6TNsKHd3JcWC9V6/aAJWSpSGqNmuTDX8dNkeGLdl1TGY1Daxfxd+/Gj0ehZn5jHA FQK0K0k+g9PQeV1iFcpbqGk3YjRE/qsz6V4OjKkoUavAMbQfjKlyrmP84eKm+uKs Mfc/L47wokIvXAbyhURS1hoEXSCyPhfXXsP6vLtlPeql4HCicRzbpvvDgdLiXuBs UADg44lQp/IA3YOYJahiBlWhLezL4ODTCQIRt5WRj1/AoWjMic0TucAUWS9Db8t1 CHN2ATBSdZ5w3xMyIoY4EsN4NfA/b6/5B3m8mlvLbjlVyqzotLRCWEzfzwegoccj /PdbD9CBdBebdVyEXc+EO+xMfNPwXpdtq9dUjzUr/cHFQCkjYa0= =B80l -----END PGP SIGNATURE----- Merge tag 'cocci-for-6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux Pull coccinelle updates from Julia Lawall: "Extend string_choices.cocci to use more available helpers Ten patches from Hongbo Li extending string_choices.cocci with the complete set of functions offered by include/linux/string_choices.h. One patch from myself reducing the number of redundant cases that are checked by Coccinelle, giving a small performance improvement" * tag 'cocci-for-6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux: Reduce Coccinelle choices in string_choices.cocci coccinelle: Remove unnecessary parentheses for only one possible change. coccinelle: Add rules to find str_yes_no() replacements coccinelle: Add rules to find str_on_off() replacements coccinelle: Add rules to find str_write_read() replacements coccinelle: Add rules to find str_read_write() replacements coccinelle: Add rules to find str_enable{d}_disable{d}() replacements coccinelle: Add rules to find str_lo{w}_hi{gh}() replacements coccinelle: Add rules to find str_hi{gh}_lo{w}() replacements coccinelle: Add rules to find str_false_true() replacements coccinelle: Add rules to find str_true_false() replacements
This commit is contained in:
commit
68e4b0e024
@ -14,23 +14,18 @@ expression E;
|
||||
- ((E == 1) ? "" : "s")
|
||||
+ str_plural(E)
|
||||
|
|
||||
- ((E != 1) ? "s" : "")
|
||||
+ str_plural(E)
|
||||
|
|
||||
- ((E > 1) ? "s" : "")
|
||||
+ str_plural(E)
|
||||
)
|
||||
|
||||
@str_plural_r depends on !patch exists@
|
||||
@str_plural_r depends on !patch@
|
||||
expression E;
|
||||
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@
|
||||
@ -40,21 +35,17 @@ e << str_plural_r.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;
|
||||
@@
|
||||
(
|
||||
- ((E) ? "up" : "down")
|
||||
+ 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;
|
||||
position P;
|
||||
@@
|
||||
(
|
||||
* ((E@P) ? "up" : "down")
|
||||
)
|
||||
* E@P ? "up" : "down"
|
||||
|
||||
@script:python depends on report@
|
||||
p << str_up_down_r.P;
|
||||
@ -63,21 +54,17 @@ 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@
|
||||
@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 exists@
|
||||
@str_down_up_r depends on !patch disable neg_if_exp@
|
||||
expression E;
|
||||
position P;
|
||||
@@
|
||||
(
|
||||
* ((E@P) ? "down" : "up")
|
||||
)
|
||||
* E@P ? "down" : "up"
|
||||
|
||||
@script:python depends on report@
|
||||
p << str_down_up_r.P;
|
||||
@ -85,3 +72,231 @@ 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@
|
||||
expression E;
|
||||
@@
|
||||
- ((E) ? "true" : "false")
|
||||
+ str_true_false(E)
|
||||
|
||||
@str_true_false_r depends on !patch disable neg_if_exp@
|
||||
expression E;
|
||||
position P;
|
||||
@@
|
||||
* E@P ? "true" : "false"
|
||||
|
||||
@script:python depends on report@
|
||||
p << str_true_false_r.P;
|
||||
e << str_true_false_r.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_hi_lo depends on patch disable neg_if_exp@
|
||||
expression E;
|
||||
@@
|
||||
- ((E) ? "hi" : "lo")
|
||||
+ str_hi_lo(E)
|
||||
|
||||
@str_hi_lo_r depends on !patch disable neg_if_exp@
|
||||
expression E;
|
||||
position P;
|
||||
@@
|
||||
* E@P ? "hi" : "lo"
|
||||
|
||||
@script:python depends on report@
|
||||
p << str_hi_lo_r.P;
|
||||
e << str_hi_lo_r.E;
|
||||
@@
|
||||
|
||||
coccilib.report.print_report(p[0], "opportunity for str_hi_lo(%s)" % e)
|
||||
|
||||
@str_high_low depends on patch disable neg_if_exp@
|
||||
expression E;
|
||||
@@
|
||||
- ((E) ? "high" : "low")
|
||||
+ str_high_low(E)
|
||||
|
||||
@str_high_low_r depends on !patch disable neg_if_exp@
|
||||
expression E;
|
||||
position P;
|
||||
@@
|
||||
* E@P ? "high" : "low"
|
||||
|
||||
@script:python depends on report@
|
||||
p << str_high_low_r.P;
|
||||
e << str_high_low_r.E;
|
||||
@@
|
||||
|
||||
coccilib.report.print_report(p[0], "opportunity for str_high_low(%s)" % e)
|
||||
|
||||
@str_lo_hi depends on patch disable neg_if_exp@
|
||||
expression E;
|
||||
@@
|
||||
- ((E) ? "lo" : "hi")
|
||||
+ str_lo_hi(E)
|
||||
|
||||
@str_lo_hi_r depends on !patch disable neg_if_exp@
|
||||
expression E;
|
||||
position P;
|
||||
@@
|
||||
* E@P ? "lo" : "hi"
|
||||
|
||||
@script:python depends on report@
|
||||
p << str_lo_hi_r.P;
|
||||
e << str_lo_hi_r.E;
|
||||
@@
|
||||
|
||||
coccilib.report.print_report(p[0], "opportunity for str_lo_hi(%s)" % e)
|
||||
|
||||
@str_low_high depends on patch disable neg_if_exp@
|
||||
expression E;
|
||||
@@
|
||||
- ((E) ? "low" : "high")
|
||||
+ str_low_high(E)
|
||||
|
||||
@str_low_high_r depends on !patch disable neg_if_exp@
|
||||
expression E;
|
||||
position P;
|
||||
@@
|
||||
* E@P ? "low" : "high"
|
||||
|
||||
@script:python depends on report@
|
||||
p << str_low_high_r.P;
|
||||
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@
|
||||
expression E;
|
||||
@@
|
||||
- ((E) ? "enabled" : "disabled")
|
||||
+ str_enabled_disabled(E)
|
||||
|
||||
@str_enabled_disabled_r depends on !patch@
|
||||
expression E;
|
||||
position P;
|
||||
@@
|
||||
* E@P ? "enabled" : "disabled"
|
||||
|
||||
@script:python depends on report@
|
||||
p << str_enabled_disabled_r.P;
|
||||
e << str_enabled_disabled_r.E;
|
||||
@@
|
||||
|
||||
coccilib.report.print_report(p[0], "opportunity for str_enabled_disabled(%s)" % e)
|
||||
|
||||
@str_read_write depends on patch disable neg_if_exp@
|
||||
expression E;
|
||||
@@
|
||||
- ((E) ? "read" : "write")
|
||||
+ str_read_write(E)
|
||||
|
||||
@str_read_write_r depends on !patch disable neg_if_exp@
|
||||
expression E;
|
||||
position P;
|
||||
@@
|
||||
* E@P ? "read" : "write"
|
||||
|
||||
@script:python depends on report@
|
||||
p << str_read_write_r.P;
|
||||
e << str_read_write_r.E;
|
||||
@@
|
||||
|
||||
coccilib.report.print_report(p[0], "opportunity for str_read_write(%s)" % e)
|
||||
|
||||
@str_write_read depends on patch disable neg_if_exp@
|
||||
expression E;
|
||||
@@
|
||||
- ((E) ? "write" : "read")
|
||||
+ str_write_read(E)
|
||||
|
||||
@str_write_read_r depends on !patch disable neg_if_exp@
|
||||
expression E;
|
||||
position P;
|
||||
@@
|
||||
* E@P ? "write" : "read"
|
||||
|
||||
@script:python depends on report@
|
||||
p << str_write_read_r.P;
|
||||
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@
|
||||
expression E;
|
||||
@@
|
||||
- ((E) ? "on" : "off")
|
||||
+ str_on_off(E)
|
||||
|
||||
@str_on_off_r depends on !patch@
|
||||
expression E;
|
||||
position P;
|
||||
@@
|
||||
* E@P ? "on" : "off"
|
||||
|
||||
@script:python depends on report@
|
||||
p << str_on_off_r.P;
|
||||
e << str_on_off_r.E;
|
||||
@@
|
||||
|
||||
coccilib.report.print_report(p[0], "opportunity for str_on_off(%s)" % e)
|
||||
|
||||
@str_yes_no depends on patch@
|
||||
expression E;
|
||||
@@
|
||||
- ((E) ? "yes" : "no")
|
||||
+ str_yes_no(E)
|
||||
|
||||
@str_yes_no_r depends on !patch@
|
||||
expression E;
|
||||
position P;
|
||||
@@
|
||||
* E@P ? "yes" : "no"
|
||||
|
||||
@script:python depends on report@
|
||||
p << str_yes_no_r.P;
|
||||
e << str_yes_no_r.E;
|
||||
@@
|
||||
|
||||
coccilib.report.print_report(p[0], "opportunity for str_yes_no(%s)" % e)
|
||||
|
Loading…
Reference in New Issue
Block a user