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