1 /// If list_for_each_entry, etc complete a traversal of the list, the iterator
2 /// variable ends up pointing to an address at an offset from the list head,
3 /// and not a meaningful structure. Thus this value should not be used after
4 /// the end of the iterator.
5 //#False positives arise when there is a goto in the iterator and the
6 //#reported reference is at the label of this goto. Some flag tests
7 //#may also cause a report to be a false positive.
9 // Confidence: Moderate
10 // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
11 // Copyright: (C) 2012 Gilles Muller, INRIA/LIP6. GPLv2.
12 // URL: http://coccinelle.lip6.fr/
14 // Options: --no-includes --include-headers
23 iterator name list_for_each_entry;
24 iterator name list_for_each_entry_reverse;
25 iterator name list_for_each_entry_continue;
26 iterator name list_for_each_entry_continue_reverse;
27 iterator name list_for_each_entry_from;
28 iterator name list_for_each_entry_safe;
29 iterator name list_for_each_entry_safe_continue;
30 iterator name list_for_each_entry_safe_from;
31 iterator name list_for_each_entry_safe_reverse;
32 iterator name hlist_for_each_entry;
33 iterator name hlist_for_each_entry_continue;
34 iterator name hlist_for_each_entry_from;
35 iterator name hlist_for_each_entry_safe;
42 list_for_each_entry@p1(c,...,member) { ... when != break;
47 list_for_each_entry_reverse@p1(c,...,member) { ... when != break;
52 list_for_each_entry_continue@p1(c,...,member) { ... when != break;
57 list_for_each_entry_continue_reverse@p1(c,...,member) { ... when != break;
62 list_for_each_entry_from@p1(c,...,member) { ... when != break;
67 list_for_each_entry_safe@p1(c,...,member) { ... when != break;
72 list_for_each_entry_safe_continue@p1(c,...,member) { ... when != break;
77 list_for_each_entry_safe_from@p1(c,...,member) { ... when != break;
82 list_for_each_entry_safe_reverse@p1(c,...,member) { ... when != break;
89 list_for_each_entry(c,...) S
91 list_for_each_entry_reverse(c,...) S
93 list_for_each_entry_continue(c,...) S
95 list_for_each_entry_continue_reverse(c,...) S
97 list_for_each_entry_from(c,...) S
99 list_for_each_entry_safe(c,...) S
101 list_for_each_entry_safe(x,c,...) S
103 list_for_each_entry_safe_continue(c,...) S
105 list_for_each_entry_safe_continue(x,c,...) S
107 list_for_each_entry_safe_from(c,...) S
109 list_for_each_entry_safe_from(x,c,...) S
111 list_for_each_entry_safe_reverse(c,...) S
113 list_for_each_entry_safe_reverse(x,c,...) S
115 hlist_for_each_entry(c,...) S
117 hlist_for_each_entry_continue(c,...) S
119 hlist_for_each_entry_from(c,...) S
121 hlist_for_each_entry_safe(c,...) S
123 list_remove_head(x,c,...)
136 @script:python depends on org@
141 cocci.print_main("invalid iterator index reference",p2)
142 cocci.print_secs("iterator",p1)
144 @script:python depends on report@
149 msg = "ERROR: invalid reference to the index variable of the iterator on line %s" % (p1[0].line)
150 coccilib.report.print_report(p2[0], msg)