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.
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/
14 // Options: --no-includes --include-headers
59 for(...;...;...) { <+... return@r ...; ...+> }
64 position up != prelocked.p1;
66 identifier lock,unlock;
80 @script:python depends on org@
87 cocci.print_main(lock,p)
88 cocci.print_secs(unlock,p2)
90 @script:python depends on report@
97 msg = "preceding lock on line %s" % (p[0].line)
98 coccilib.report.print_report(p2[0],msg)