thp: add debug checks for mapcount related invariants
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / scripts / coccinelle / iterators / itnull.cocci
blobbaa4297a4ed18d6ae757b10404dcdcefb88d7892
1 /// Many iterators have the property that the first argument is always bound
2 /// to a real list element, never NULL.  False positives arise for some
3 /// iterators that do not have this property, or in cases when the loop
4 /// cursor is reassigned.  The latter should only happen when the matched
5 /// code is on the way to a loop exit (break, goto, or return).
6 ///
7 // Confidence: Moderate
8 // Copyright: (C) 2010 Nicolas Palix, DIKU.  GPLv2.
9 // Copyright: (C) 2010 Julia Lawall, DIKU.  GPLv2.
10 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
11 // URL: http://coccinelle.lip6.fr/
12 // Comments:
13 // Options: -no_includes -include_headers
15 virtual patch
18 iterator I;
19 expression x,E,E1,E2;
20 statement S,S1,S2;
23 I(x,...) { <...
25 - if (x == NULL && ...) S
27 - if (x != NULL || ...)
28   S
30 - (x == NULL) ||
31   E
33 - (x != NULL) &&
34   E
36 - (x == NULL && ...) ? E1 :
37   E2
39 - (x != NULL || ...) ?
40   E1
41 - : E2
43 - if (x == NULL && ...) S1 else
44   S2
46 - if (x != NULL || ...)
47   S1
48 - else S2
50 + BAD(
51   x == NULL
52 + )
54 + BAD(
55   x != NULL
56 + )
58   ...> }