]>
Commit | Line | Data |
---|---|---|
40451592 NP |
1 | /// These iterators only exit normally when the loop cursor is NULL, so there |
2 | /// is no point to call of_node_put on the final value. | |
3 | /// | |
4 | // Confidence: High | |
29a36d4d JL |
5 | // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. |
6 | // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. | |
7 | // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. | |
40451592 NP |
8 | // URL: http://coccinelle.lip6.fr/ |
9 | // Comments: | |
93f14468 | 10 | // Options: --no-includes --include-headers |
40451592 NP |
11 | |
12 | virtual patch | |
29a36d4d JL |
13 | virtual context |
14 | virtual org | |
15 | virtual report | |
40451592 | 16 | |
29a36d4d | 17 | @depends on patch@ |
40451592 NP |
18 | iterator name for_each_node_by_name; |
19 | expression np,E; | |
20 | identifier l; | |
21 | @@ | |
22 | ||
23 | for_each_node_by_name(np,...) { | |
24 | ... when != break; | |
25 | when != goto l; | |
26 | } | |
27 | ... when != np = E | |
28 | - of_node_put(np); | |
29 | ||
29a36d4d | 30 | @depends on patch@ |
40451592 NP |
31 | iterator name for_each_node_by_type; |
32 | expression np,E; | |
33 | identifier l; | |
34 | @@ | |
35 | ||
36 | for_each_node_by_type(np,...) { | |
37 | ... when != break; | |
38 | when != goto l; | |
39 | } | |
40 | ... when != np = E | |
41 | - of_node_put(np); | |
42 | ||
29a36d4d | 43 | @depends on patch@ |
40451592 NP |
44 | iterator name for_each_compatible_node; |
45 | expression np,E; | |
46 | identifier l; | |
47 | @@ | |
48 | ||
49 | for_each_compatible_node(np,...) { | |
50 | ... when != break; | |
51 | when != goto l; | |
52 | } | |
53 | ... when != np = E | |
54 | - of_node_put(np); | |
55 | ||
29a36d4d | 56 | @depends on patch@ |
40451592 NP |
57 | iterator name for_each_matching_node; |
58 | expression np,E; | |
59 | identifier l; | |
60 | @@ | |
61 | ||
62 | for_each_matching_node(np,...) { | |
63 | ... when != break; | |
64 | when != goto l; | |
65 | } | |
66 | ... when != np = E | |
67 | - of_node_put(np); | |
29a36d4d JL |
68 | |
69 | // ---------------------------------------------------------------------- | |
70 | ||
71 | @r depends on !patch forall@ | |
72 | //iterator name for_each_node_by_name; | |
73 | //iterator name for_each_node_by_type; | |
74 | //iterator name for_each_compatible_node; | |
75 | //iterator name for_each_matching_node; | |
76 | expression np,E; | |
77 | identifier l; | |
78 | position p1,p2; | |
79 | @@ | |
80 | ||
81 | ( | |
82 | *for_each_node_by_name@p1(np,...) | |
83 | { | |
84 | ... when != break; | |
85 | when != goto l; | |
86 | } | |
87 | | | |
88 | *for_each_node_by_type@p1(np,...) | |
89 | { | |
90 | ... when != break; | |
91 | when != goto l; | |
92 | } | |
93 | | | |
94 | *for_each_compatible_node@p1(np,...) | |
95 | { | |
96 | ... when != break; | |
97 | when != goto l; | |
98 | } | |
99 | | | |
100 | *for_each_matching_node@p1(np,...) | |
101 | { | |
102 | ... when != break; | |
103 | when != goto l; | |
104 | } | |
105 | ) | |
106 | ... when != np = E | |
107 | * of_node_put@p2(np); | |
108 | ||
109 | @script:python depends on org@ | |
110 | p1 << r.p1; | |
111 | p2 << r.p2; | |
112 | @@ | |
113 | ||
114 | cocci.print_main("unneeded of_node_put",p2) | |
115 | cocci.print_secs("iterator",p1) | |
116 | ||
117 | @script:python depends on report@ | |
118 | p1 << r.p1; | |
119 | p2 << r.p2; | |
120 | @@ | |
121 | ||
122 | msg = "ERROR: of_node_put not needed after iterator on line %s" % (p1[0].line) | |
123 | coccilib.report.print_report(p2[0], msg) |