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 Nicolas Palix, DIKU. GPLv2.
10 // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
11 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
12 // URL: http://coccinelle.lip6.fr/
14 // Options: -no_includes -include_headers
58 for(...;...;...) { <+... return@r ...; ...+> }
63 position up != prelocked.p1;
65 identifier lock,unlock;
77 @script:python depends on org@
84 cocci.print_main(lock,p)
85 cocci.print_secs(unlock,p2)
87 @script:python depends on report@
94 msg = "preceding lock on line %s" % (p[0].line)
95 coccilib.report.print_report(p2[0],msg)