xref: /linux/scripts/coccinelle/api/string_choices.cocci (revision 9b97452bcce77f8ef29b20c9662d95988b5990e4)
11d02f252SKees Cook// SPDX-License-Identifier: GPL-2.0-only
21d02f252SKees Cook/// Find places to use string_choices.h's various helpers.
31d02f252SKees Cook//
41d02f252SKees Cook// Confidence: Medium
51d02f252SKees Cook// Options: --no-includes --include-headers
61d02f252SKees Cookvirtual patch
71d02f252SKees Cookvirtual context
81d02f252SKees Cookvirtual report
91d02f252SKees Cook
101d02f252SKees Cook@str_plural depends on patch@
111d02f252SKees Cookexpression E;
121d02f252SKees Cook@@
131d02f252SKees Cook(
141d02f252SKees Cook-	((E == 1) ? "" : "s")
151d02f252SKees Cook+	str_plural(E)
161d02f252SKees Cook|
171d02f252SKees Cook-	((E != 1) ? "s" : "")
181d02f252SKees Cook+	str_plural(E)
191d02f252SKees Cook|
201d02f252SKees Cook-	((E > 1) ? "s" : "")
211d02f252SKees Cook+	str_plural(E)
221d02f252SKees Cook)
231d02f252SKees Cook
241d02f252SKees Cook@str_plural_r depends on !patch exists@
251d02f252SKees Cookexpression E;
261d02f252SKees Cookposition P;
271d02f252SKees Cook@@
281d02f252SKees Cook(
291d02f252SKees Cook*	((E@P == 1) ? "" : "s")
301d02f252SKees Cook|
311d02f252SKees Cook*	((E@P != 1) ? "s" : "")
321d02f252SKees Cook|
331d02f252SKees Cook*	((E@P > 1) ? "s" : "")
341d02f252SKees Cook)
351d02f252SKees Cook
361d02f252SKees Cook@script:python depends on report@
371d02f252SKees Cookp << str_plural_r.P;
381d02f252SKees Cooke << str_plural_r.E;
391d02f252SKees Cook@@
401d02f252SKees Cook
411d02f252SKees Cookcoccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e)
42*9b97452bSMichal Wajdeczko
43*9b97452bSMichal Wajdeczko@str_up_down depends on patch@
44*9b97452bSMichal Wajdeczkoexpression E;
45*9b97452bSMichal Wajdeczko@@
46*9b97452bSMichal Wajdeczko(
47*9b97452bSMichal Wajdeczko-	((E) ? "up" : "down")
48*9b97452bSMichal Wajdeczko+	str_up_down(E)
49*9b97452bSMichal Wajdeczko)
50*9b97452bSMichal Wajdeczko
51*9b97452bSMichal Wajdeczko@str_up_down_r depends on !patch exists@
52*9b97452bSMichal Wajdeczkoexpression E;
53*9b97452bSMichal Wajdeczkoposition P;
54*9b97452bSMichal Wajdeczko@@
55*9b97452bSMichal Wajdeczko(
56*9b97452bSMichal Wajdeczko*	((E@P) ? "up" : "down")
57*9b97452bSMichal Wajdeczko)
58*9b97452bSMichal Wajdeczko
59*9b97452bSMichal Wajdeczko@script:python depends on report@
60*9b97452bSMichal Wajdeczkop << str_up_down_r.P;
61*9b97452bSMichal Wajdeczkoe << str_up_down_r.E;
62*9b97452bSMichal Wajdeczko@@
63*9b97452bSMichal Wajdeczko
64*9b97452bSMichal Wajdeczkococcilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e)
65