]> git.ipfire.org Git - thirdparty/systemd.git/blob - coccinelle/in_set.cocci
Merge pull request #23560 from mrc0mmand/coccinelle
[thirdparty/systemd.git] / coccinelle / in_set.cocci
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /* Limit the number of expressions to 6 for performance reasons */
3
4 @ is_in_assert_cc @
5 identifier id = assert_cc;
6 position p1;
7 expression e;
8 constant n0;
9 @@
10
11 id(e@p1 == n0 || ...);
12
13 @@
14 expression e;
15 position p2 != is_in_assert_cc.p1;
16 /* Exclude JsonVariant * from the transformation, as it can't work with the
17 * current version of the IN_SET macro */
18 typedef JsonVariant;
19 type T != JsonVariant*;
20 constant T n0, n1, n2, n3, n4, n5;
21 @@
22
23 (
24 - e@p2 == n0 || e == n1 || e == n2 || e == n3 || e == n4 || e == n5
25 + IN_SET(e, n0, n1, n2, n3, n4, n5)
26 |
27 - e@p2 == n0 || e == n1 || e == n2 || e == n3 || e == n4
28 + IN_SET(e, n0, n1, n2, n3, n4)
29 |
30 - e@p2 == n0 || e == n1 || e == n2 || e == n3
31 + IN_SET(e, n0, n1, n2, n3)
32 |
33 - e@p2 == n0 || e == n1 || e == n2
34 + IN_SET(e, n0, n1, n2)
35 |
36 - e@p2 == n0 || e == n1
37 + IN_SET(e, n0, n1)
38 )