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 10 11virtual context 12virtual org 13virtual report 14 15@r exists@ 16expression lock1,lock2,flags; 17position p1,p2; 18@@ 19 20( 21spin_lock_irqsave@p1(lock1,flags) 22| 23read_lock_irqsave@p1(lock1,flags) 24| 25write_lock_irqsave@p1(lock1,flags) 26) 27... when != flags 28( 29spin_lock_irqsave(lock1,flags) 30| 31read_lock_irqsave(lock1,flags) 32| 33write_lock_irqsave(lock1,flags) 34| 35spin_lock_irqsave@p2(lock2,flags) 36| 37read_lock_irqsave@p2(lock2,flags) 38| 39write_lock_irqsave@p2(lock2,flags) 40) 41 42@d exists@ 43expression f <= r.flags; 44expression lock1,lock2,flags; 45position 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@ 67p1 << r.p1; 68p2 << r.p2; 69@@ 70 71cocci.print_main("original lock",p1) 72cocci.print_secs("nested lock+irqsave that reuses flags",p2) 73 74@script:python depends on d && report@ 75p1 << r.p1; 76p2 << r.p2; 77@@ 78 79msg="ERROR: nested lock+irqsave that reuses flags from line %s." % (p1[0].line) 80coccilib.report.print_report(p2[0], msg) 81