Loading...
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: https://coccinelle.gitlabpages.inria.fr/website
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
14virtual patch
15virtual context
16virtual org
17virtual report
18
19@r exists@
20expression e1,e2;
21local idexpression n;
22iterator name for_each_node_by_name, for_each_node_by_type,
23for_each_compatible_node, for_each_matching_node,
24for_each_matching_node_and_match, for_each_child_of_node,
25for_each_available_child_of_node, for_each_node_with_property;
26iterator i;
27position p1,p2;
28statement S;
29@@
30
31(
32(
33for_each_node_by_name(n,e1) S
34|
35for_each_node_by_type(n,e1) S
36|
37for_each_compatible_node(n,e1,e2) S
38|
39for_each_matching_node(n,e1) S
40|
41for_each_matching_node_and_match(n,e1,e2) S
42|
43for_each_child_of_node(e1,n) S
44|
45for_each_available_child_of_node(e1,n) S
46|
47for_each_node_with_property(n,e1) S
48)
49&
50i@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@
59local idexpression r.n;
60statement S;
61position r.p1,r.p2;
62iterator 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@
71local idexpression n;
72position r.p2;
73@@
74
75- of_node_put@p2(n);
76
77// ----------------------------------------------------------------------------
78
79@t_context depends on s && !patch && (context || org || report)@
80local idexpression n;
81position r.p2;
82position j0;
83@@
84
85* of_node_put@j0@p2(n);
86
87// ----------------------------------------------------------------------------
88
89@script:python t_org depends on org@
90j0 << t_context.j0;
91@@
92
93msg = "ERROR: probable double put."
94coccilib.org.print_todo(j0[0], msg)
95
96// ----------------------------------------------------------------------------
97
98@script:python t_report depends on report@
99j0 << t_context.j0;
100@@
101
102msg = "ERROR: probable double put."
103coccilib.report.print_report(j0[0], msg)
104
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
8// Keywords: for_each_child_of_node, etc.
9
10virtual patch
11virtual context
12virtual org
13virtual report
14
15@r exists@
16expression e1,e2;
17local idexpression n;
18iterator name for_each_node_by_name, for_each_node_by_type,
19for_each_compatible_node, for_each_matching_node,
20for_each_matching_node_and_match, for_each_child_of_node,
21for_each_available_child_of_node, for_each_node_with_property;
22iterator i;
23position p1,p2;
24statement S;
25@@
26
27(
28(
29for_each_node_by_name(n,e1) S
30|
31for_each_node_by_type(n,e1) S
32|
33for_each_compatible_node(n,e1,e2) S
34|
35for_each_matching_node(n,e1) S
36|
37for_each_matching_node_and_match(n,e1,e2) S
38|
39for_each_child_of_node(e1,n) S
40|
41for_each_available_child_of_node(e1,n) S
42|
43for_each_node_with_property(n,e1) S
44)
45&
46i@p1(...) {
47 ... when != of_node_get(n)
48 when any
49 of_node_put@p2(n);
50 ... when any
51}
52)
53
54@s exists@
55local idexpression r.n;
56statement S;
57position r.p1,r.p2;
58iterator i;
59@@
60
61 of_node_put@p2(n);
62 ... when any
63 i@p1(..., n, ...)
64 S
65
66@t depends on s && patch && !context && !org && !report@
67local idexpression n;
68position r.p2;
69@@
70
71- of_node_put@p2(n);
72
73// ----------------------------------------------------------------------------
74
75@t_context depends on s && !patch && (context || org || report)@
76local idexpression n;
77position r.p2;
78position j0;
79@@
80
81* of_node_put@j0@p2(n);
82
83// ----------------------------------------------------------------------------
84
85@script:python t_org depends on org@
86j0 << t_context.j0;
87@@
88
89msg = "ERROR: probable double put."
90coccilib.org.print_todo(j0[0], msg)
91
92// ----------------------------------------------------------------------------
93
94@script:python t_report depends on report@
95j0 << t_context.j0;
96@@
97
98msg = "ERROR: probable double put."
99coccilib.report.print_report(j0[0], msg)
100