aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2012-03-25 14:12:59 -0400
committerMichal Marek <mmarek@suse.cz>2012-03-26 16:51:24 -0400
commit468db96122152fad1a23fc9024523f35140e5675 (patch)
tree7d4d9ce0f8845cc2f8dae4fda30276221b82312b
parent66979224c0d288331edcadb1e6ebd978d920d476 (diff)
scripts/coccinelle/api/ptr_ret.cocci: semantic patch for ptr_err
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.cocci70
1 files changed, 70 insertions, 0 deletions
diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci
new file mode 100644
index 000000000000..cbfd08c7d8c7
--- /dev/null
+++ b/scripts/coccinelle/api/ptr_ret.cocci
@@ -0,0 +1,70 @@
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
14virtual context
15virtual patch
16virtual org
17virtual report
18
19@depends on patch@
20expression 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@
27expression ptr;
28@@
29
30- if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
31+ return PTR_RET(ptr);
32
33@r1 depends on !patch@
34expression ptr;
35position p1;
36@@
37
38* if@p1 (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0;
39
40@r2 depends on !patch@
41expression ptr;
42position p2;
43@@
44
45* if@p2 (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
46
47@script:python depends on org@
48p << r1.p1;
49@@
50
51coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used")
52
53
54@script:python depends on org@
55p << r2.p2;
56@@
57
58coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used")
59
60@script:python depends on report@
61p << r1.p1;
62@@
63
64coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used")
65
66@script:python depends on report@
67p << r2.p2;
68@@
69
70coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used")