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

+237 -22
+237 -22
scripts/coccinelle/api/string_choices.cocci
··· 14 - ((E == 1) ? "" : "s") 15 + str_plural(E) 16 | 17 - - ((E != 1) ? "s" : "") 18 - + str_plural(E) 19 - | 20 - ((E > 1) ? "s" : "") 21 + str_plural(E) 22 ) 23 24 - @str_plural_r depends on !patch exists@ 25 expression E; 26 position P; 27 @@ 28 ( 29 - * ((E@P == 1) ? "" : "s") 30 | 31 - * ((E@P != 1) ? "s" : "") 32 - | 33 - * ((E@P > 1) ? "s" : "") 34 ) 35 36 @script:python depends on report@ ··· 35 36 coccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e) 37 38 - @str_up_down depends on patch@ 39 expression E; 40 @@ 41 - ( 42 - ((E) ? "up" : "down") 43 + str_up_down(E) 44 - ) 45 46 - @str_up_down_r depends on !patch exists@ 47 expression E; 48 position P; 49 @@ 50 - ( 51 - * ((E@P) ? "up" : "down") 52 - ) 53 54 @script:python depends on report@ 55 p << str_up_down_r.P; ··· 54 55 coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e) 56 57 - @str_down_up depends on patch@ 58 expression E; 59 @@ 60 - ( 61 - ((E) ? "down" : "up") 62 + str_down_up(E) 63 - ) 64 65 - @str_down_up_r depends on !patch exists@ 66 expression E; 67 position P; 68 @@ 69 - ( 70 - * ((E@P) ? "down" : "up") 71 - ) 72 73 @script:python depends on report@ 74 p << str_down_up_r.P; ··· 72 @@ 73 74 coccilib.report.print_report(p[0], "opportunity for str_down_up(%s)" % e)
··· 14 - ((E == 1) ? "" : "s") 15 + str_plural(E) 16 | 17 - ((E > 1) ? "s" : "") 18 + str_plural(E) 19 ) 20 21 + @str_plural_r depends on !patch@ 22 expression E; 23 position P; 24 @@ 25 ( 26 + * (E@P == 1) ? "" : "s" 27 | 28 + * (E@P > 1) ? "s" : "" 29 ) 30 31 @script:python depends on report@ ··· 40 41 coccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e) 42 43 + @str_up_down depends on patch disable neg_if_exp@ 44 expression E; 45 @@ 46 - ((E) ? "up" : "down") 47 + str_up_down(E) 48 49 + @str_up_down_r depends on !patch disable neg_if_exp@ 50 expression E; 51 position P; 52 @@ 53 + * E@P ? "up" : "down" 54 55 @script:python depends on report@ 56 p << str_up_down_r.P; ··· 63 64 coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e) 65 66 + @str_down_up depends on patch disable neg_if_exp@ 67 expression E; 68 @@ 69 - ((E) ? "down" : "up") 70 + str_down_up(E) 71 72 + @str_down_up_r depends on !patch disable neg_if_exp@ 73 expression E; 74 position P; 75 @@ 76 + * E@P ? "down" : "up" 77 78 @script:python depends on report@ 79 p << str_down_up_r.P; ··· 85 @@ 86 87 coccilib.report.print_report(p[0], "opportunity for str_down_up(%s)" % e) 88 + 89 + @str_true_false depends on patch disable neg_if_exp@ 90 + expression E; 91 + @@ 92 + - ((E) ? "true" : "false") 93 + + str_true_false(E) 94 + 95 + @str_true_false_r depends on !patch disable neg_if_exp@ 96 + expression E; 97 + position P; 98 + @@ 99 + * E@P ? "true" : "false" 100 + 101 + @script:python depends on report@ 102 + p << str_true_false_r.P; 103 + e << str_true_false_r.E; 104 + @@ 105 + 106 + coccilib.report.print_report(p[0], "opportunity for str_true_false(%s)" % e) 107 + 108 + @str_false_true depends on patch disable neg_if_exp@ 109 + expression E; 110 + @@ 111 + - ((E) ? "false" : "true") 112 + + str_false_true(E) 113 + 114 + @str_false_true_r depends on !patch disable neg_if_exp@ 115 + expression E; 116 + position P; 117 + @@ 118 + * E@P ? "false" : "true" 119 + 120 + @script:python depends on report@ 121 + p << str_false_true_r.P; 122 + e << str_false_true_r.E; 123 + @@ 124 + 125 + coccilib.report.print_report(p[0], "opportunity for str_false_true(%s)" % e) 126 + 127 + @str_hi_lo depends on patch disable neg_if_exp@ 128 + expression E; 129 + @@ 130 + - ((E) ? "hi" : "lo") 131 + + str_hi_lo(E) 132 + 133 + @str_hi_lo_r depends on !patch disable neg_if_exp@ 134 + expression E; 135 + position P; 136 + @@ 137 + * E@P ? "hi" : "lo" 138 + 139 + @script:python depends on report@ 140 + p << str_hi_lo_r.P; 141 + e << str_hi_lo_r.E; 142 + @@ 143 + 144 + coccilib.report.print_report(p[0], "opportunity for str_hi_lo(%s)" % e) 145 + 146 + @str_high_low depends on patch disable neg_if_exp@ 147 + expression E; 148 + @@ 149 + - ((E) ? "high" : "low") 150 + + str_high_low(E) 151 + 152 + @str_high_low_r depends on !patch disable neg_if_exp@ 153 + expression E; 154 + position P; 155 + @@ 156 + * E@P ? "high" : "low" 157 + 158 + @script:python depends on report@ 159 + p << str_high_low_r.P; 160 + e << str_high_low_r.E; 161 + @@ 162 + 163 + coccilib.report.print_report(p[0], "opportunity for str_high_low(%s)" % e) 164 + 165 + @str_lo_hi depends on patch disable neg_if_exp@ 166 + expression E; 167 + @@ 168 + - ((E) ? "lo" : "hi") 169 + + str_lo_hi(E) 170 + 171 + @str_lo_hi_r depends on !patch disable neg_if_exp@ 172 + expression E; 173 + position P; 174 + @@ 175 + * E@P ? "lo" : "hi" 176 + 177 + @script:python depends on report@ 178 + p << str_lo_hi_r.P; 179 + e << str_lo_hi_r.E; 180 + @@ 181 + 182 + coccilib.report.print_report(p[0], "opportunity for str_lo_hi(%s)" % e) 183 + 184 + @str_low_high depends on patch disable neg_if_exp@ 185 + expression E; 186 + @@ 187 + - ((E) ? "low" : "high") 188 + + str_low_high(E) 189 + 190 + @str_low_high_r depends on !patch disable neg_if_exp@ 191 + expression E; 192 + position P; 193 + @@ 194 + * E@P ? "low" : "high" 195 + 196 + @script:python depends on report@ 197 + p << str_low_high_r.P; 198 + e << str_low_high_r.E; 199 + @@ 200 + 201 + coccilib.report.print_report(p[0], "opportunity for str_low_high(%s)" % e) 202 + 203 + @str_enable_disable depends on patch@ 204 + expression E; 205 + @@ 206 + - ((E) ? "enable" : "disable") 207 + + str_enable_disable(E) 208 + 209 + @str_enable_disable_r depends on !patch@ 210 + expression E; 211 + position P; 212 + @@ 213 + * E@P ? "enable" : "disable" 214 + 215 + @script:python depends on report@ 216 + p << str_enable_disable_r.P; 217 + e << str_enable_disable_r.E; 218 + @@ 219 + 220 + coccilib.report.print_report(p[0], "opportunity for str_enable_disable(%s)" % e) 221 + 222 + @str_enabled_disabled depends on patch@ 223 + expression E; 224 + @@ 225 + - ((E) ? "enabled" : "disabled") 226 + + str_enabled_disabled(E) 227 + 228 + @str_enabled_disabled_r depends on !patch@ 229 + expression E; 230 + position P; 231 + @@ 232 + * E@P ? "enabled" : "disabled" 233 + 234 + @script:python depends on report@ 235 + p << str_enabled_disabled_r.P; 236 + e << str_enabled_disabled_r.E; 237 + @@ 238 + 239 + coccilib.report.print_report(p[0], "opportunity for str_enabled_disabled(%s)" % e) 240 + 241 + @str_read_write depends on patch disable neg_if_exp@ 242 + expression E; 243 + @@ 244 + - ((E) ? "read" : "write") 245 + + str_read_write(E) 246 + 247 + @str_read_write_r depends on !patch disable neg_if_exp@ 248 + expression E; 249 + position P; 250 + @@ 251 + * E@P ? "read" : "write" 252 + 253 + @script:python depends on report@ 254 + p << str_read_write_r.P; 255 + e << str_read_write_r.E; 256 + @@ 257 + 258 + coccilib.report.print_report(p[0], "opportunity for str_read_write(%s)" % e) 259 + 260 + @str_write_read depends on patch disable neg_if_exp@ 261 + expression E; 262 + @@ 263 + - ((E) ? "write" : "read") 264 + + str_write_read(E) 265 + 266 + @str_write_read_r depends on !patch disable neg_if_exp@ 267 + expression E; 268 + position P; 269 + @@ 270 + * E@P ? "write" : "read" 271 + 272 + @script:python depends on report@ 273 + p << str_write_read_r.P; 274 + e << str_write_read_r.E; 275 + @@ 276 + 277 + coccilib.report.print_report(p[0], "opportunity for str_write_read(%s)" % e) 278 + 279 + @str_on_off depends on patch@ 280 + expression E; 281 + @@ 282 + - ((E) ? "on" : "off") 283 + + str_on_off(E) 284 + 285 + @str_on_off_r depends on !patch@ 286 + expression E; 287 + position P; 288 + @@ 289 + * E@P ? "on" : "off" 290 + 291 + @script:python depends on report@ 292 + p << str_on_off_r.P; 293 + e << str_on_off_r.E; 294 + @@ 295 + 296 + coccilib.report.print_report(p[0], "opportunity for str_on_off(%s)" % e) 297 + 298 + @str_yes_no depends on patch@ 299 + expression E; 300 + @@ 301 + - ((E) ? "yes" : "no") 302 + + str_yes_no(E) 303 + 304 + @str_yes_no_r depends on !patch@ 305 + expression E; 306 + position P; 307 + @@ 308 + * E@P ? "yes" : "no" 309 + 310 + @script:python depends on report@ 311 + p << str_yes_no_r.P; 312 + e << str_yes_no_r.E; 313 + @@ 314 + 315 + coccilib.report.print_report(p[0], "opportunity for str_yes_no(%s)" % e)