xref: /OK3568_Linux_fs/kernel/scripts/coccinelle/api/resource_size.cocci (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun// SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun///
3*4882a593Smuzhiyun/// Use resource_size function on resource object
4*4882a593Smuzhiyun/// instead of explicit computation.
5*4882a593Smuzhiyun///
6*4882a593Smuzhiyun//  Confidence: High
7*4882a593Smuzhiyun//  Copyright: (C) 2009, 2010 Nicolas Palix, DIKU.
8*4882a593Smuzhiyun//  Copyright: (C) 2009, 2010 Julia Lawall, DIKU.
9*4882a593Smuzhiyun//  Copyright: (C) 2009, 2010 Gilles Muller, INRIA/LiP6.
10*4882a593Smuzhiyun//  URL: http://coccinelle.lip6.fr/
11*4882a593Smuzhiyun//  Options:
12*4882a593Smuzhiyun//
13*4882a593Smuzhiyun//  Keywords: resource_size
14*4882a593Smuzhiyun//  Version min: 2.6.27 resource_size
15*4882a593Smuzhiyun//
16*4882a593Smuzhiyun
17*4882a593Smuzhiyunvirtual context
18*4882a593Smuzhiyunvirtual patch
19*4882a593Smuzhiyunvirtual org
20*4882a593Smuzhiyunvirtual report
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun//----------------------------------------------------------
23*4882a593Smuzhiyun//  For context mode
24*4882a593Smuzhiyun//----------------------------------------------------------
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun@r_context depends on context && !patch && !org@
27*4882a593Smuzhiyunstruct resource *res;
28*4882a593Smuzhiyun@@
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun* (res->end - res->start) + 1
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun//----------------------------------------------------------
33*4882a593Smuzhiyun//  For patch mode
34*4882a593Smuzhiyun//----------------------------------------------------------
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun@r_patch depends on !context && patch && !org@
37*4882a593Smuzhiyunstruct resource *res;
38*4882a593Smuzhiyun@@
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun- (res->end - res->start) + 1
41*4882a593Smuzhiyun+ resource_size(res)
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun//----------------------------------------------------------
44*4882a593Smuzhiyun//  For org mode
45*4882a593Smuzhiyun//----------------------------------------------------------
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun@r_org depends on !context && !patch && (org || report)@
49*4882a593Smuzhiyunstruct resource *res;
50*4882a593Smuzhiyunposition p;
51*4882a593Smuzhiyun@@
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun (res->end@p - res->start) + 1
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun@rbad_org depends on !context && !patch && (org || report)@
56*4882a593Smuzhiyunstruct resource *res;
57*4882a593Smuzhiyunposition p != r_org.p;
58*4882a593Smuzhiyun@@
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun res->end@p - res->start
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun@script:python depends on org@
63*4882a593Smuzhiyunp << r_org.p;
64*4882a593Smuzhiyunx << r_org.res;
65*4882a593Smuzhiyun@@
66*4882a593Smuzhiyun
67*4882a593Smuzhiyunmsg="ERROR with %s" % (x)
68*4882a593Smuzhiyunmsg_safe=msg.replace("[","@(").replace("]",")")
69*4882a593Smuzhiyuncoccilib.org.print_todo(p[0], msg_safe)
70*4882a593Smuzhiyun
71*4882a593Smuzhiyun@script:python depends on report@
72*4882a593Smuzhiyunp << r_org.p;
73*4882a593Smuzhiyunx << r_org.res;
74*4882a593Smuzhiyun@@
75*4882a593Smuzhiyun
76*4882a593Smuzhiyunmsg="ERROR: Missing resource_size with %s" % (x)
77*4882a593Smuzhiyuncoccilib.report.print_report(p[0], msg)
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun@script:python depends on org@
80*4882a593Smuzhiyunp << rbad_org.p;
81*4882a593Smuzhiyunx << rbad_org.res;
82*4882a593Smuzhiyun@@
83*4882a593Smuzhiyun
84*4882a593Smuzhiyunmsg="WARNING with %s" % (x)
85*4882a593Smuzhiyunmsg_safe=msg.replace("[","@(").replace("]",")")
86*4882a593Smuzhiyuncoccilib.org.print_todo(p[0], msg_safe)
87*4882a593Smuzhiyun
88*4882a593Smuzhiyun@script:python depends on report@
89*4882a593Smuzhiyunp << rbad_org.p;
90*4882a593Smuzhiyunx << rbad_org.res;
91*4882a593Smuzhiyun@@
92*4882a593Smuzhiyun
93*4882a593Smuzhiyunmsg="WARNING: Suspicious code. resource_size is maybe missing with %s" % (x)
94*4882a593Smuzhiyuncoccilib.report.print_report(p[0], msg)
95