blob: cfe0a35cf2dd219090d6186996fd3a5ca6b94fda [file] [log] [blame]
Julia Lawalle8fa6002012-08-25 22:42:45 +02001/// PTR_ERR should access the value just tested by IS_ERR
2//# There can be false positives in the patch case, where it is the call
3//# IS_ERR that is wrong.
4///
5// Confidence: High
6// Copyright: (C) 2012 Julia Lawall, INRIA. GPLv2.
7// Copyright: (C) 2012 Gilles Muller, INRIA. GPLv2.
8// URL: http://coccinelle.lip6.fr/
9// Comments:
Nicolas Palix93f14462013-06-20 13:10:56 +020010// Options: --no-includes --include-headers
Julia Lawalle8fa6002012-08-25 22:42:45 +020011
12virtual patch
13virtual context
14virtual org
15virtual report
16
17@depends on patch@
18expression e,e1;
19@@
20
21(
22if (IS_ERR(e)) { ... PTR_ERR(e) ... }
23|
24if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... }
25|
26if (IS_ERR(e))
27 { ...
28 PTR_ERR(
29- e1
30+ e
31 )
32 ... }
33)
34
35@r depends on !patch@
36expression e,e1;
37position p1,p2;
38@@
39
40(
41if (IS_ERR(e)) { ... PTR_ERR(e) ... }
42|
43if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... }
44|
45*if (IS_ERR@p1(e))
46 { ...
47* PTR_ERR@p2(e1)
48 ... }
49)
50
51@script:python depends on org@
52p1 << r.p1;
53p2 << r.p2;
54@@
55
56cocci.print_main("inconsistent IS_ERR and PTR_ERR",p1)
57cocci.print_secs("PTR_ERR",p2)
58
59@script:python depends on report@
60p1 << r.p1;
61p2 << r.p2;
62@@
63
64msg = "inconsistent IS_ERR and PTR_ERR, PTR_ERR on line %s" % (p2[0].line)
65coccilib.report.print_report(p1[0],msg)