1 // SPDX-License-Identifier: GPL-2.0-only
2 /// Many iterators have the property that the first argument is always bound
3 /// to a real list element, never NULL.
4 //# False positives arise for some iterators that do not have this property,
5 //# or in cases when the loop cursor is reassigned. The latter should only
6 //# happen when the matched code is on the way to a loop exit (break, goto,
9 // Confidence: Moderate
10 // Copyright: (C) 2010-2012 Nicolas Palix.
11 // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.
12 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.
13 // URL: http://coccinelle.lip6.fr/
15 // Options: --no-includes --include-headers
30 - if (x == NULL && ...) S
32 - if (x != NULL || ...)
41 - (x == NULL && ...) ? E1 :
44 - (x != NULL || ...) ?
48 - if (x == NULL && ...) S1 else
51 - if (x != NULL || ...)
65 @r depends on !patch exists@
81 @script:python depends on org@
86 cocci.print_main("iterator-bound variable",p1)
87 cocci.print_secs("useless NULL test",p2)
89 @script:python depends on report@
94 msg = "ERROR: iterator variable bound on line %s cannot be NULL" % (p1[0].line)
95 coccilib.report.print_report(p2[0], msg)