diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2012-08-21 04:49:58 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2012-08-31 10:55:15 -0400 |
commit | 3085897359d80e73da2b4ea32ade7a9095594422 (patch) | |
tree | c4341eae2f9af55c41e31a0debd22f7cbe5c8ef9 | |
parent | 8700d3cd7b92267ebc00b011433389489243fde0 (diff) |
scripts/coccinelle: ptr_ret: Add ternary operator version
Add a ternary operator version of the open-coded PTR_RET().
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.cz>
-rw-r--r-- | scripts/coccinelle/api/ptr_ret.cocci | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci index cbfd08c7d8c7..15f076fdecbe 100644 --- a/scripts/coccinelle/api/ptr_ret.cocci +++ b/scripts/coccinelle/api/ptr_ret.cocci | |||
@@ -30,6 +30,13 @@ expression ptr; | |||
30 | - if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; | 30 | - if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; |
31 | + return PTR_RET(ptr); | 31 | + return PTR_RET(ptr); |
32 | 32 | ||
33 | @depends on patch@ | ||
34 | expression ptr; | ||
35 | @@ | ||
36 | |||
37 | - (IS_ERR(ptr) ? PTR_ERR(ptr) : 0) | ||
38 | + PTR_RET(ptr) | ||
39 | |||
33 | @r1 depends on !patch@ | 40 | @r1 depends on !patch@ |
34 | expression ptr; | 41 | expression ptr; |
35 | position p1; | 42 | position p1; |
@@ -44,6 +51,13 @@ position p2; | |||
44 | 51 | ||
45 | * if@p2 (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; | 52 | * if@p2 (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; |
46 | 53 | ||
54 | @r3 depends on !patch@ | ||
55 | expression ptr; | ||
56 | position p3; | ||
57 | @@ | ||
58 | |||
59 | * IS_ERR@p3(ptr) ? PTR_ERR(ptr) : 0 | ||
60 | |||
47 | @script:python depends on org@ | 61 | @script:python depends on org@ |
48 | p << r1.p1; | 62 | p << r1.p1; |
49 | @@ | 63 | @@ |
@@ -57,6 +71,12 @@ p << r2.p2; | |||
57 | 71 | ||
58 | coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") | 72 | coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") |
59 | 73 | ||
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 | |||
60 | @script:python depends on report@ | 80 | @script:python depends on report@ |
61 | p << r1.p1; | 81 | p << r1.p1; |
62 | @@ | 82 | @@ |
@@ -68,3 +88,9 @@ p << r2.p2; | |||
68 | @@ | 88 | @@ |
69 | 89 | ||
70 | coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") | 90 | coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") |
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") | ||