net: skb_segment() provides list head and tail
[linux/fpc-iii.git] / scripts / coccinelle / api / pm_runtime.cocci
blobf01789e967ec4bc10b5cb5aae8f83fc3e6ab2408
1 /// Make sure pm_runtime_* calls does not use unnecessary IS_ERR_VALUE
2 //
3 // Keywords: pm_runtime
4 // Confidence: Medium
5 // Copyright (C) 2013 Texas Instruments Incorporated - GPLv2.
6 // URL: http://coccinelle.lip6.fr/
7 // Options: --include-headers
9 virtual patch
10 virtual context
11 virtual org
12 virtual report
14 //----------------------------------------------------------
15 //  Detection
16 //----------------------------------------------------------
18 @runtime_bad_err_handle exists@
19 expression ret;
22 ret = \(pm_runtime_idle\|
23         pm_runtime_suspend\|
24         pm_runtime_autosuspend\|
25         pm_runtime_resume\|
26         pm_request_idle\|
27         pm_request_resume\|
28         pm_request_autosuspend\|
29         pm_runtime_get\|
30         pm_runtime_get_sync\|
31         pm_runtime_put\|
32         pm_runtime_put_autosuspend\|
33         pm_runtime_put_sync\|
34         pm_runtime_put_sync_suspend\|
35         pm_runtime_put_sync_autosuspend\|
36         pm_runtime_set_active\|
37         pm_schedule_suspend\|
38         pm_runtime_barrier\|
39         pm_generic_runtime_suspend\|
40         pm_generic_runtime_resume\)(...);
41 ...
42 IS_ERR_VALUE(ret)
43 ...
46 //----------------------------------------------------------
47 //  For context mode
48 //----------------------------------------------------------
50 @depends on runtime_bad_err_handle && context@
51 identifier pm_runtime_api;
52 expression ret;
55 ret = pm_runtime_api(...);
56 ...
57 * IS_ERR_VALUE(ret)
58 ...
61 //----------------------------------------------------------
62 //  For patch mode
63 //----------------------------------------------------------
65 @depends on runtime_bad_err_handle && patch@
66 identifier pm_runtime_api;
67 expression ret;
70 ret = pm_runtime_api(...);
71 ...
72 - IS_ERR_VALUE(ret)
73 + ret < 0
74 ...
77 //----------------------------------------------------------
78 //  For org and report mode
79 //----------------------------------------------------------
81 @r depends on runtime_bad_err_handle exists@
82 position p1, p2;
83 identifier pm_runtime_api;
84 expression ret;
87 ret = pm_runtime_api@p1(...);
88 ...
89 IS_ERR_VALUE@p2(ret)
90 ...
93 @script:python depends on org@
94 p1 << r.p1;
95 p2 << r.p2;
96 pm_runtime_api << r.pm_runtime_api;
99 cocci.print_main(pm_runtime_api,p1)
100 cocci.print_secs("IS_ERR_VALUE",p2)
102 @script:python depends on report@
103 p1 << r.p1;
104 p2 << r.p2;
105 pm_runtime_api << r.pm_runtime_api;
108 msg = "%s returns < 0 as error. Unecessary IS_ERR_VALUE at line %s" % (pm_runtime_api, p2[0].line)
109 coccilib.report.print_report(p1[0],msg)