summaryrefslogtreecommitdiffstats
path: root/scripts/coccinelle/api/string_choices.cocci
blob: 96dc7090395d7e7ac21e71e73c12feb08ecabb00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
// SPDX-License-Identifier: GPL-2.0-only
/// Find places to use string_choices.h's various helpers.
//
// Confidence: Medium
// Options: --no-includes --include-headers
virtual patch
virtual context
virtual report

@str_plural depends on patch@
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@
expression E;
position P;
@@
(
*	((E@P == 1) ? "" : "s")
|
*	((E@P != 1) ? "s" : "")
|
*	((E@P > 1) ? "s" : "")
)

@script:python depends on report@
p << str_plural_r.P;
e << str_plural_r.E;
@@

coccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e)

@str_up_down depends on patch@
expression E;
@@
(
-	((E) ? "up" : "down")
+	str_up_down(E)
)

@str_up_down_r depends on !patch exists@
expression E;
position P;
@@
(
*	((E@P) ? "up" : "down")
)

@script:python depends on report@
p << str_up_down_r.P;
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@
expression E;
@@
(
-      ((E) ? "down" : "up")
+      str_down_up(E)
)

@str_down_up_r depends on !patch exists@
expression E;
position P;
@@
(
*      ((E@P) ? "down" : "up")
)

@script:python depends on report@
p << str_down_up_r.P;
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@
expression E;
@@
-      ((E) ? "true" : "false")
+      str_true_false(E)

@str_true_false_r depends on !patch exists@
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@
expression E;
@@
-      ((E) ? "false" : "true")
+      str_false_true(E)

@str_false_true_r depends on !patch exists@
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@
expression E;
@@
(
-      ((E) ? "hi" : "lo")
+      str_hi_lo(E)
)

@str_hi_lo_r depends on !patch exists@
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@
expression E;
@@
-      ((E) ? "high" : "low")
+      str_high_low(E)

@str_high_low_r depends on !patch exists@
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@
expression E;
@@
-      ((E) ? "lo" : "hi")
+      str_lo_hi(E)

@str_lo_hi_r depends on !patch exists@
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@
expression E;
@@
-      ((E) ? "low" : "high")
+      str_low_high(E)

@str_low_high_r depends on !patch exists@
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 exists@
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 exists@
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@
expression E;
@@
-      ((E) ? "read" : "write")
+      str_read_write(E)

@str_read_write_r depends on !patch exists@
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@
expression E;
@@
-      ((E) ? "write" : "read")
+      str_write_read(E)

@str_write_read_r depends on !patch exists@
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 exists@
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 exists@
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)