Julia Lawall | 468db96 | 2012-03-25 20:12:59 +0200 | [diff] [blame] | 1 | /// |
Rusty Russell | 8c6ffba | 2013-07-15 11:20:32 +0930 | [diff] [blame] | 2 | /// Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR |
Julia Lawall | 468db96 | 2012-03-25 20:12:59 +0200 | [diff] [blame] | 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/ |
Nicolas Palix | 93f1446 | 2013-06-20 13:10:56 +0200 | [diff] [blame] | 8 | // Options: --no-includes --include-headers |
Julia Lawall | 468db96 | 2012-03-25 20:12:59 +0200 | [diff] [blame] | 9 | // |
Rusty Russell | 8c6ffba | 2013-07-15 11:20:32 +0930 | [diff] [blame] | 10 | // Keywords: ERR_PTR, PTR_ERR, PTR_RET, PTR_ERR_OR_ZERO |
Julia Lawall | 468db96 | 2012-03-25 20:12:59 +0200 | [diff] [blame] | 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; |
Rusty Russell | 8c6ffba | 2013-07-15 11:20:32 +0930 | [diff] [blame] | 24 | + return PTR_ERR_OR_ZERO(ptr); |
Julia Lawall | 468db96 | 2012-03-25 20:12:59 +0200 | [diff] [blame] | 25 | |
| 26 | @depends on patch@ |
| 27 | expression ptr; |
| 28 | @@ |
| 29 | |
| 30 | - if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; |
Rusty Russell | 8c6ffba | 2013-07-15 11:20:32 +0930 | [diff] [blame] | 31 | + return PTR_ERR_OR_ZERO(ptr); |
Julia Lawall | 468db96 | 2012-03-25 20:12:59 +0200 | [diff] [blame] | 32 | |
Lars-Peter Clausen | 3085897 | 2012-08-21 10:49:58 +0200 | [diff] [blame] | 33 | @depends on patch@ |
| 34 | expression ptr; |
| 35 | @@ |
| 36 | |
| 37 | - (IS_ERR(ptr) ? PTR_ERR(ptr) : 0) |
Rusty Russell | 8c6ffba | 2013-07-15 11:20:32 +0930 | [diff] [blame] | 38 | + PTR_ERR_OR_ZERO(ptr) |
Lars-Peter Clausen | 3085897 | 2012-08-21 10:49:58 +0200 | [diff] [blame] | 39 | |
Julia Lawall | 468db96 | 2012-03-25 20:12:59 +0200 | [diff] [blame] | 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 | |
Lars-Peter Clausen | 3085897 | 2012-08-21 10:49:58 +0200 | [diff] [blame] | 54 | @r3 depends on !patch@ |
| 55 | expression ptr; |
| 56 | position p3; |
| 57 | @@ |
| 58 | |
| 59 | * IS_ERR@p3(ptr) ? PTR_ERR(ptr) : 0 |
| 60 | |
Julia Lawall | 468db96 | 2012-03-25 20:12:59 +0200 | [diff] [blame] | 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 | |
Lars-Peter Clausen | 3085897 | 2012-08-21 10:49:58 +0200 | [diff] [blame] | 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 | |
Julia Lawall | 468db96 | 2012-03-25 20:12:59 +0200 | [diff] [blame] | 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") |
Lars-Peter Clausen | 3085897 | 2012-08-21 10:49:58 +0200 | [diff] [blame] | 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") |