ARM: imx6q-arm2: Remove hardcoded mac address
[linux-2.6/btrfs-unstable.git] / scripts / coccinelle / locks / mini_lock.cocci
blob3267d7410bd5072aaab32efd8d5e4c4f06205618
1 /// Find missing unlocks.  This semantic match considers the specific case
2 /// where the unlock is missing from an if branch, and there is a lock
3 /// before the if and an unlock after the if.  False positives are due to
4 /// cases where the if branch represents a case where the function is
5 /// supposed to exit with the lock held, or where there is some preceding
6 /// function call that releases the lock.
7 ///
8 // Confidence: Moderate
9 // Copyright: (C) 2010-2012 Nicolas Palix.  GPLv2.
10 // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.  GPLv2.
11 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
12 // URL: http://coccinelle.lip6.fr/
13 // Comments:
14 // Options: -no_includes -include_headers
16 virtual context
17 virtual org
18 virtual report
20 @prelocked@
21 position p1,p;
22 expression E1;
26 mutex_lock@p1
28 mutex_trylock@p1
30 spin_lock@p1
32 spin_trylock@p1
34 read_lock@p1
36 read_trylock@p1
38 write_lock@p1
40 write_trylock@p1
42 read_lock_irq@p1
44 write_lock_irq@p1
46 read_lock_irqsave@p1
48 write_lock_irqsave@p1
50 spin_lock_irq@p1
52 spin_lock_irqsave@p1
53 ) (E1@p,...);
55 @looped@
56 position r;
59 for(...;...;...) { <+... return@r ...; ...+> }
61 @err exists@
62 expression E1;
63 position prelocked.p;
64 position up != prelocked.p1;
65 position r!=looped.r;
66 identifier lock,unlock;
69 *lock(E1@p,...);
70 <+... when != E1
71 if (...) {
72   ... when != E1
73 *  return@r ...;
75 ...+>
76 *unlock@up(E1,...);
78 @script:python depends on org@
79 p << prelocked.p1;
80 lock << err.lock;
81 unlock << err.unlock;
82 p2 << err.r;
85 cocci.print_main(lock,p)
86 cocci.print_secs(unlock,p2)
88 @script:python depends on report@
89 p << prelocked.p1;
90 lock << err.lock;
91 unlock << err.unlock;
92 p2 << err.r;
95 msg = "preceding lock on line %s" % (p[0].line)
96 coccilib.report.print_report(p2[0],msg)