Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / scripts / coccinelle / locks / flags.cocci
blob1c4ffe6fd846746d64a1a34168fb3864f18b9af8
1 /// Find nested lock+irqsave functions that use the same flags variables
2 ///
3 // Confidence: High
4 // Copyright: (C) 2010-2012 Nicolas Palix.  GPLv2.
5 // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.  GPLv2.
6 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
7 // URL: http://coccinelle.lip6.fr/
8 // Comments:
9 // Options: -no_includes -include_headers
11 virtual context
12 virtual org
13 virtual report
15 @r exists@
16 expression lock1,lock2,flags;
17 position p1,p2;
21 spin_lock_irqsave@p1(lock1,flags)
23 read_lock_irqsave@p1(lock1,flags)
25 write_lock_irqsave@p1(lock1,flags)
27 ... when != flags
29 spin_lock_irqsave(lock1,flags)
31 read_lock_irqsave(lock1,flags)
33 write_lock_irqsave(lock1,flags)
35 spin_lock_irqsave@p2(lock2,flags)
37 read_lock_irqsave@p2(lock2,flags)
39 write_lock_irqsave@p2(lock2,flags)
42 @d exists@
43 expression f <= r.flags;
44 expression lock1,lock2,flags;
45 position r.p1, r.p2;
49 *spin_lock_irqsave@p1(lock1,flags)
51 *read_lock_irqsave@p1(lock1,flags)
53 *write_lock_irqsave@p1(lock1,flags)
55 ... when != f
57 *spin_lock_irqsave@p2(lock2,flags)
59 *read_lock_irqsave@p2(lock2,flags)
61 *write_lock_irqsave@p2(lock2,flags)
64 // ----------------------------------------------------------------------
66 @script:python depends on d && org@
67 p1 << r.p1;
68 p2 << r.p2;
71 cocci.print_main("original lock",p1)
72 cocci.print_secs("nested lock+irqsave that reuses flags",p2)
74 @script:python depends on d && report@
75 p1 << r.p1;
76 p2 << r.p2;
79 msg="ERROR: nested lock+irqsave that reuses flags from line %s." % (p1[0].line)
80 coccilib.report.print_report(p2[0], msg)