Loading...
1// SPDX-License-Identifier: GPL-2.0
2/// Make sure calls to d_find_alias() have a corresponding call to dput().
3//
4// Keywords: d_find_alias, dput
5//
6// Confidence: Moderate
7// URL: https://coccinelle.gitlabpages.inria.fr/website
8// Options: --include-headers
9
10virtual context
11virtual org
12virtual patch
13virtual report
14
15@r exists@
16local idexpression struct dentry *dent;
17expression E, E1;
18statement S1, S2;
19position p1, p2;
20@@
21(
22 if (!(dent@p1 = d_find_alias(...))) S1
23|
24 dent@p1 = d_find_alias(...)
25)
26
27<...when != dput(dent)
28 when != if (...) { <+... dput(dent) ...+> }
29 when != true !dent || ...
30 when != dent = E
31 when != E = dent
32if (!dent || ...) S2
33...>
34(
35 return <+...dent...+>;
36|
37 return @p2 ...;
38|
39 dent@p2 = E1;
40|
41 E1 = dent;
42)
43
44@depends on context@
45local idexpression struct dentry *r.dent;
46position r.p1,r.p2;
47@@
48* dent@p1 = ...
49 ...
50(
51* return@p2 ...;
52|
53* dent@p2
54)
55
56
57@script:python depends on org@
58p1 << r.p1;
59p2 << r.p2;
60@@
61cocci.print_main("Missing call to dput()",p1)
62cocci.print_secs("",p2)
63
64@depends on patch@
65local idexpression struct dentry *r.dent;
66position r.p2;
67@@
68(
69+ dput(dent);
70 return @p2 ...;
71|
72+ dput(dent);
73 dent@p2 = ...;
74)
75
76@script:python depends on report@
77p1 << r.p1;
78p2 << r.p2;
79@@
80msg = "Missing call to dput() at line %s."
81coccilib.report.print_report(p1[0], msg % (p2[0].line))
1/// Make sure calls to d_find_alias() have a corresponding call to dput().
2//
3// Keywords: d_find_alias, dput
4//
5// Confidence: Moderate
6// URL: http://coccinelle.lip6.fr/
7// Options: --include-headers
8
9virtual context
10virtual org
11virtual patch
12virtual report
13
14@r exists@
15local idexpression struct dentry *dent;
16expression E, E1;
17statement S1, S2;
18position p1, p2;
19@@
20(
21 if (!(dent@p1 = d_find_alias(...))) S1
22|
23 dent@p1 = d_find_alias(...)
24)
25
26<...when != dput(dent)
27 when != if (...) { <+... dput(dent) ...+> }
28 when != true !dent || ...
29 when != dent = E
30 when != E = dent
31if (!dent || ...) S2
32...>
33(
34 return <+...dent...+>;
35|
36 return @p2 ...;
37|
38 dent@p2 = E1;
39|
40 E1 = dent;
41)
42
43@depends on context@
44local idexpression struct dentry *r.dent;
45position r.p1,r.p2;
46@@
47* dent@p1 = ...
48 ...
49(
50* return@p2 ...;
51|
52* dent@p2
53)
54
55
56@script:python depends on org@
57p1 << r.p1;
58p2 << r.p2;
59@@
60cocci.print_main("Missing call to dput()",p1)
61cocci.print_secs("",p2)
62
63@depends on patch@
64local idexpression struct dentry *r.dent;
65position r.p2;
66@@
67(
68+ dput(dent);
69 return @p2 ...;
70|
71+ dput(dent);
72 dent@p2 = ...;
73)
74
75@script:python depends on report@
76p1 << r.p1;
77p2 << r.p2;
78@@
79msg = "Missing call to dput() at line %s."
80coccilib.report.print_report(p1[0], msg % (p2[0].line))