Commit | Line | Data |
---|---|---|
468db961 JL |
1 | /// |
2 | /// Use PTR_RET rather than if(IS_ERR(...)) + PTR_ERR | |
3 | /// | |
4 | // Confidence: High | |
5 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | |
6 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | |
7 | // URL: http://coccinelle.lip6.fr/ | |
8 | // Options: -no_includes -include_headers | |
9 | // | |
10 | // Keywords: ERR_PTR, PTR_ERR, PTR_RET | |
11 | // Version min: 2.6.39 | |
12 | // | |
13 | ||
14 | virtual context | |
15 | virtual patch | |
16 | virtual org | |
17 | virtual report | |
18 | ||
19 | @depends on patch@ | |
20 | expression ptr; | |
21 | @@ | |
22 | ||
23 | - if (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0; | |
24 | + return PTR_RET(ptr); | |
25 | ||
26 | @depends on patch@ | |
27 | expression ptr; | |
28 | @@ | |
29 | ||
30 | - if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; | |
31 | + return PTR_RET(ptr); | |
32 | ||
30858973 LPC |
33 | @depends on patch@ |
34 | expression ptr; | |
35 | @@ | |
36 | ||
37 | - (IS_ERR(ptr) ? PTR_ERR(ptr) : 0) | |
38 | + PTR_RET(ptr) | |
39 | ||
468db961 JL |
40 | @r1 depends on !patch@ |
41 | expression ptr; | |
42 | position p1; | |
43 | @@ | |
44 | ||
45 | * if@p1 (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0; | |
46 | ||
47 | @r2 depends on !patch@ | |
48 | expression ptr; | |
49 | position p2; | |
50 | @@ | |
51 | ||
52 | * if@p2 (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; | |
53 | ||
30858973 LPC |
54 | @r3 depends on !patch@ |
55 | expression ptr; | |
56 | position p3; | |
57 | @@ | |
58 | ||
59 | * IS_ERR@p3(ptr) ? PTR_ERR(ptr) : 0 | |
60 | ||
468db961 JL |
61 | @script:python depends on org@ |
62 | p << r1.p1; | |
63 | @@ | |
64 | ||
65 | coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") | |
66 | ||
67 | ||
68 | @script:python depends on org@ | |
69 | p << r2.p2; | |
70 | @@ | |
71 | ||
72 | coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") | |
73 | ||
30858973 LPC |
74 | @script:python depends on org@ |
75 | p << r3.p3; | |
76 | @@ | |
77 | ||
78 | coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") | |
79 | ||
468db961 JL |
80 | @script:python depends on report@ |
81 | p << r1.p1; | |
82 | @@ | |
83 | ||
84 | coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") | |
85 | ||
86 | @script:python depends on report@ | |
87 | p << r2.p2; | |
88 | @@ | |
89 | ||
90 | coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") | |
30858973 LPC |
91 | |
92 | @script:python depends on report@ | |
93 | p << r3.p3; | |
94 | @@ | |
95 | ||
96 | coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") |