not_unlocked_mutex.cocci 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * StarPU --- Runtime system for heterogeneous multicore architectures.
  3. *
  4. * Copyright (C) 2012 inria
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. virtual context
  18. virtual org
  19. virtual patch
  20. virtual report
  21. @initialize:python depends on report || org@
  22. msg="The mutex \"%s\" is not unlocked when leaving \"%s\""
  23. @r@
  24. expression E;
  25. identifier func;
  26. position p;
  27. @@
  28. func(...)
  29. {
  30. <...
  31. _STARPU_PTHREAD_MUTEX_LOCK(E);
  32. <... when != _STARPU_PTHREAD_MUTEX_UNLOCK(E)
  33. if (...)
  34. {
  35. ... when != _STARPU_PTHREAD_MUTEX_UNLOCK(E)
  36. return@p ...;
  37. }
  38. ...>
  39. _STARPU_PTHREAD_MUTEX_UNLOCK(E);
  40. ...>
  41. }
  42. @depends on r && context@
  43. position r.p;
  44. @@
  45. * return@p ...;
  46. @script:python depends on r && org@
  47. ps << r.p;
  48. f << r.func;
  49. E << r.E;
  50. @@
  51. for p in ps:
  52. coccilib.org.print_todo(p, msg % (E, f))
  53. @depends on r && patch@
  54. expression r.E;
  55. position r.p;
  56. @@
  57. + _STARPU_PTHREAD_MUTEX_UNLOCK(E);
  58. return@p ...;
  59. @script:python depends on r && report@
  60. ps << r.p;
  61. f << r.func;
  62. E << r.E;
  63. @@
  64. for p in ps:
  65. coccilib.org.print_todo(p, msg % (E, f))