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