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;
78 @script:python depends on org@
85 cocci.print_main(lock,p)
86 cocci.print_secs(unlock,p2)
88 @script:python depends on report@
95 msg = "preceding lock on line %s" % (p[0].line)
96 coccilib.report.print_report(p2[0],msg)