]> Git Repo - J-linux.git/blob - scripts/coccinelle/api/string_choices.cocci
Merge tag 'kbuild-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy...
[J-linux.git] / scripts / coccinelle / api / string_choices.cocci
1 // SPDX-License-Identifier: GPL-2.0-only
2 /// Find places to use string_choices.h's various helpers.
3 //
4 // Confidence: Medium
5 // Options: --no-includes --include-headers
6 virtual patch
7 virtual context
8 virtual report
9
10 @str_plural depends on patch@
11 expression E;
12 @@
13 (
14 -       ((E == 1) ? "" : "s")
15 +       str_plural(E)
16 |
17 -       ((E != 1) ? "s" : "")
18 +       str_plural(E)
19 |
20 -       ((E > 1) ? "s" : "")
21 +       str_plural(E)
22 )
23
24 @str_plural_r depends on !patch exists@
25 expression E;
26 position P;
27 @@
28 (
29 *       ((E@P == 1) ? "" : "s")
30 |
31 *       ((E@P != 1) ? "s" : "")
32 |
33 *       ((E@P > 1) ? "s" : "")
34 )
35
36 @script:python depends on report@
37 p << str_plural_r.P;
38 e << str_plural_r.E;
39 @@
40
41 coccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e)
This page took 0.028247 seconds and 4 git commands to generate.