1 /// Many iterators have the property that the first argument is always bound
2 /// to a real list element, never NULL.
3 //# False positives arise for some iterators that do not have this property,
4 //# or in cases when the loop cursor is reassigned. The latter should only
5 //# happen when the matched code is on the way to a loop exit (break, goto,
8 // Confidence: Moderate
9 // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2.
10 // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2.
11 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
12 // URL: http://coccinelle.lip6.fr/
14 // Options: -no_includes -include_headers
29 - if (x == NULL && ...) S
31 - if (x != NULL || ...)
40 - (x == NULL && ...) ? E1 :
43 - (x != NULL || ...) ?
47 - if (x == NULL && ...) S1 else
50 - if (x != NULL || ...)
64 @r depends on !patch exists@
80 @script:python depends on org@
85 cocci.print_main("iterator-bound variable",p1)
86 cocci.print_secs("useless NULL test",p2)
88 @script:python depends on report@
93 msg = "ERROR: iterator variable bound on line %s cannot be NULL" % (p1[0].line)
94 coccilib.report.print_report(p2[0], msg)