tools headers UAPI: Synch KVM's svm.h header with the kernel
[linux-2.6-microblaze.git] / scripts / coccinelle / iterators / device_node_continue.cocci
1 // SPDX-License-Identifier: GPL-2.0-only
2 /// Device node iterators put the previous value of the index variable, so an
3 /// explicit put causes a double put.
4 ///
5 // Confidence: High
6 // Copyright: (C) 2015 Julia Lawall, Inria.
7 // URL: http://coccinelle.lip6.fr/
8 // Options: --no-includes --include-headers
9 // Requires: 1.0.4
10 // Keywords: for_each_child_of_node, etc.
11
12 // This uses a conjunction, which requires at least coccinelle >= 1.0.4
13
14 virtual patch
15 virtual context
16 virtual org
17 virtual report
18
19 @r exists@
20 expression e1,e2;
21 local idexpression n;
22 iterator name for_each_node_by_name, for_each_node_by_type,
23 for_each_compatible_node, for_each_matching_node,
24 for_each_matching_node_and_match, for_each_child_of_node,
25 for_each_available_child_of_node, for_each_node_with_property;
26 iterator i;
27 position p1,p2;
28 statement S;
29 @@
30
31 (
32 (
33 for_each_node_by_name(n,e1) S
34 |
35 for_each_node_by_type(n,e1) S
36 |
37 for_each_compatible_node(n,e1,e2) S
38 |
39 for_each_matching_node(n,e1) S
40 |
41 for_each_matching_node_and_match(n,e1,e2) S
42 |
43 for_each_child_of_node(e1,n) S
44 |
45 for_each_available_child_of_node(e1,n) S
46 |
47 for_each_node_with_property(n,e1) S
48 )
49 &
50 i@p1(...) {
51    ... when != of_node_get(n)
52        when any
53    of_node_put@p2(n);
54    ... when any
55 }
56 )
57
58 @s exists@
59 local idexpression r.n;
60 statement S;
61 position r.p1,r.p2;
62 iterator i;
63 @@
64
65  of_node_put@p2(n);
66  ... when any
67  i@p1(..., n, ...)
68  S
69
70 @t depends on s && patch && !context && !org && !report@
71 local idexpression n;
72 position r.p2;
73 @@
74
75 - of_node_put@p2(n);
76
77 // ----------------------------------------------------------------------------
78
79 @t_context depends on s && !patch && (context || org || report)@
80 local idexpression n;
81 position r.p2;
82 position j0;
83 @@
84
85 *  of_node_put@j0@p2(n);
86
87 // ----------------------------------------------------------------------------
88
89 @script:python t_org depends on org@
90 j0 << t_context.j0;
91 @@
92
93 msg = "ERROR: probable double put."
94 coccilib.org.print_todo(j0[0], msg)
95
96 // ----------------------------------------------------------------------------
97
98 @script:python t_report depends on report@
99 j0 << t_context.j0;
100 @@
101
102 msg = "ERROR: probable double put."
103 coccilib.report.print_report(j0[0], msg)
104