Skip to content

Commit 68e4b0e

Browse files
committed
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
2 parents e7ebdb5 + 4003ba6 commit 68e4b0e

File tree

1 file changed

+237
-22
lines changed

1 file changed

+237
-22
lines changed

scripts/coccinelle/api/string_choices.cocci

Lines changed: 237 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,18 @@ expression E;
1414
- ((E == 1) ? "" : "s")
1515
+ str_plural(E)
1616
|
17-
- ((E != 1) ? "s" : "")
18-
+ str_plural(E)
19-
|
2017
- ((E > 1) ? "s" : "")
2118
+ str_plural(E)
2219
)
2320

24-
@str_plural_r depends on !patch exists@
21+
@str_plural_r depends on !patch@
2522
expression E;
2623
position P;
2724
@@
2825
(
29-
* ((E@P == 1) ? "" : "s")
30-
|
31-
* ((E@P != 1) ? "s" : "")
26+
* (E@P == 1) ? "" : "s"
3227
|
33-
* ((E@P > 1) ? "s" : "")
28+
* (E@P > 1) ? "s" : ""
3429
)
3530

3631
@script:python depends on report@
@@ -40,21 +35,17 @@ e << str_plural_r.E;
4035
4136
coccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e)
4237
43-
@str_up_down depends on patch@
38+
@str_up_down depends on patch disable neg_if_exp@
4439
expression E;
4540
@@
46-
(
4741
- ((E) ? "up" : "down")
4842
+ str_up_down(E)
49-
)
5043

51-
@str_up_down_r depends on !patch exists@
44+
@str_up_down_r depends on !patch disable neg_if_exp@
5245
expression E;
5346
position P;
5447
@@
55-
(
56-
* ((E@P) ? "up" : "down")
57-
)
48+
* E@P ? "up" : "down"
5849

5950
@script:python depends on report@
6051
p << str_up_down_r.P;
@@ -63,25 +54,249 @@ e << str_up_down_r.E;
6354
6455
coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e)
6556
66-
@str_down_up depends on patch@
57+
@str_down_up depends on patch disable neg_if_exp@
6758
expression E;
6859
@@
69-
(
7060
- ((E) ? "down" : "up")
7161
+ str_down_up(E)
72-
)
7362

74-
@str_down_up_r depends on !patch exists@
63+
@str_down_up_r depends on !patch disable neg_if_exp@
7564
expression E;
7665
position P;
7766
@@
78-
(
79-
* ((E@P) ? "down" : "up")
80-
)
67+
* E@P ? "down" : "up"
8168

8269
@script:python depends on report@
8370
p << str_down_up_r.P;
8471
e << str_down_up_r.E;
8572
@@
8673
8774
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)

0 commit comments

Comments
 (0)