diff options
author | Julia Lawall <julia@diku.dk> | 2010-10-24 17:37:31 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2010-10-27 18:32:22 -0400 |
commit | 10247179a7af4f000468e12ae73f3cf657b66235 (patch) | |
tree | 2055e9de62cd8f3621cf7f5745aabb657a763dc7 /scripts/coccinelle/locks | |
parent | 24a54f7974a616385b96cd939e004592e2cea484 (diff) |
Coccinelle: Find nested lock+irqsave functions that use the same flags variables.
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Nicolas Palix <npalix.work@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/coccinelle/locks')
-rw-r--r-- | scripts/coccinelle/locks/flags.cocci | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/scripts/coccinelle/locks/flags.cocci b/scripts/coccinelle/locks/flags.cocci new file mode 100644 index 000000000000..b4344d838097 --- /dev/null +++ b/scripts/coccinelle/locks/flags.cocci | |||
@@ -0,0 +1,80 @@ | |||
1 | /// Find nested lock+irqsave functions that use the same flags variables | ||
2 | /// | ||
3 | // Confidence: High | ||
4 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. | ||
5 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. | ||
6 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. | ||
7 | // URL: http://coccinelle.lip6.fr/ | ||
8 | // Comments: | ||
9 | // Options: -no_includes -include_headers | ||
10 | |||
11 | virtual context | ||
12 | virtual org | ||
13 | virtual report | ||
14 | |||
15 | @r@ | ||
16 | expression lock1,lock2,flags; | ||
17 | position p1,p2; | ||
18 | @@ | ||
19 | |||
20 | ( | ||
21 | spin_lock_irqsave@p1(lock1,flags) | ||
22 | | | ||
23 | read_lock_irqsave@p1(lock1,flags) | ||
24 | | | ||
25 | write_lock_irqsave@p1(lock1,flags) | ||
26 | ) | ||
27 | ... when != flags | ||
28 | ( | ||
29 | spin_lock_irqsave(lock1,flags) | ||
30 | | | ||
31 | read_lock_irqsave(lock1,flags) | ||
32 | | | ||
33 | write_lock_irqsave(lock1,flags) | ||
34 | | | ||
35 | spin_lock_irqsave@p2(lock2,flags) | ||
36 | | | ||
37 | read_lock_irqsave@p2(lock2,flags) | ||
38 | | | ||
39 | write_lock_irqsave@p2(lock2,flags) | ||
40 | ) | ||
41 | |||
42 | @d@ | ||
43 | expression f <= r.flags; | ||
44 | expression lock1,lock2,flags; | ||
45 | position r.p1, r.p2; | ||
46 | @@ | ||
47 | |||
48 | ( | ||
49 | *spin_lock_irqsave@p1(lock1,flags) | ||
50 | | | ||
51 | *read_lock_irqsave@p1(lock1,flags) | ||
52 | | | ||
53 | *write_lock_irqsave@p1(lock1,flags) | ||
54 | ) | ||
55 | ... when != f | ||
56 | ( | ||
57 | *spin_lock_irqsave@p2(lock2,flags) | ||
58 | | | ||
59 | *read_lock_irqsave@p2(lock2,flags) | ||
60 | | | ||
61 | *write_lock_irqsave@p2(lock2,flags) | ||
62 | ) | ||
63 | |||
64 | // ---------------------------------------------------------------------- | ||
65 | |||
66 | @script:python depends on d && org@ | ||
67 | p1 << r.p1; | ||
68 | p2 << r.p2; | ||
69 | @@ | ||
70 | |||
71 | cocci.print_main("original lock",p1) | ||
72 | cocci.print_secs("nested lock+irqsave that reuses flags",p2) | ||
73 | |||
74 | @script:python depends on d && report@ | ||
75 | p1 << r.p1; | ||
76 | p2 << r.p2; | ||
77 | @@ | ||
78 | |||
79 | msg="ERROR: nested lock+irqsave that reuses flags from %s." % (p1[0].line) | ||
80 | coccilib.report.print_report(p2[0], msg) | ||