xref: /linux/scripts/coccinelle/api/string_choices.cocci (revision 1d02f252339e2eaf3ba35b9dc77e7a1a9aa7414c)
1*1d02f252SKees Cook// SPDX-License-Identifier: GPL-2.0-only
2*1d02f252SKees Cook/// Find places to use string_choices.h's various helpers.
3*1d02f252SKees Cook//
4*1d02f252SKees Cook// Confidence: Medium
5*1d02f252SKees Cook// Options: --no-includes --include-headers
6*1d02f252SKees Cookvirtual patch
7*1d02f252SKees Cookvirtual context
8*1d02f252SKees Cookvirtual report
9*1d02f252SKees Cook
10*1d02f252SKees Cook@str_plural depends on patch@
11*1d02f252SKees Cookexpression E;
12*1d02f252SKees Cook@@
13*1d02f252SKees Cook(
14*1d02f252SKees Cook-	((E == 1) ? "" : "s")
15*1d02f252SKees Cook+	str_plural(E)
16*1d02f252SKees Cook|
17*1d02f252SKees Cook-	((E != 1) ? "s" : "")
18*1d02f252SKees Cook+	str_plural(E)
19*1d02f252SKees Cook|
20*1d02f252SKees Cook-	((E > 1) ? "s" : "")
21*1d02f252SKees Cook+	str_plural(E)
22*1d02f252SKees Cook)
23*1d02f252SKees Cook
24*1d02f252SKees Cook@str_plural_r depends on !patch exists@
25*1d02f252SKees Cookexpression E;
26*1d02f252SKees Cookposition P;
27*1d02f252SKees Cook@@
28*1d02f252SKees Cook(
29*1d02f252SKees Cook*	((E@P == 1) ? "" : "s")
30*1d02f252SKees Cook|
31*1d02f252SKees Cook*	((E@P != 1) ? "s" : "")
32*1d02f252SKees Cook|
33*1d02f252SKees Cook*	((E@P > 1) ? "s" : "")
34*1d02f252SKees Cook)
35*1d02f252SKees Cook
36*1d02f252SKees Cook@script:python depends on report@
37*1d02f252SKees Cookp << str_plural_r.P;
38*1d02f252SKees Cooke << str_plural_r.E;
39*1d02f252SKees Cook@@
40*1d02f252SKees Cook
41*1d02f252SKees Cookcoccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e)
42