Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

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