clk_put.cocci 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /// Find missing clk_puts.
  2. ///
  3. //# This only signals a missing clk_put when there is a clk_put later
  4. //# in the same function.
  5. //# False positives can be due to loops.
  6. //
  7. // Confidence: Moderate
  8. // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
  9. // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
  10. // URL: http://coccinelle.lip6.fr/
  11. // Comments:
  12. // Options:
  13. virtual context
  14. virtual org
  15. virtual report
  16. @clk@
  17. expression e;
  18. statement S,S1;
  19. int ret;
  20. position p1,p2,p3;
  21. @@
  22. e = clk_get@p1(...)
  23. ... when != clk_put(e)
  24. if (<+...e...+>) S
  25. ... when any
  26. when != clk_put(e)
  27. when != if (...) { ... clk_put(e); ... }
  28. (
  29. if (ret == 0) S1
  30. |
  31. if (...)
  32. { ...
  33. return 0; }
  34. |
  35. if (...)
  36. { ...
  37. return <+...e...+>; }
  38. |
  39. *if@p2 (...)
  40. { ... when != clk_put(e)
  41. when forall
  42. return@p3 ...; }
  43. )
  44. ... when any
  45. clk_put(e);
  46. @script:python depends on org@
  47. p1 << clk.p1;
  48. p2 << clk.p2;
  49. p3 << clk.p3;
  50. @@
  51. cocci.print_main("clk_get",p1)
  52. cocci.print_secs("if",p2)
  53. cocci.print_secs("needed clk_put",p3)
  54. @script:python depends on report@
  55. p1 << clk.p1;
  56. p2 << clk.p2;
  57. p3 << clk.p3;
  58. @@
  59. msg = "ERROR: missing clk_put; clk_get on line %s and execution via conditional on line %s" % (p1[0].line,p2[0].line)
  60. coccilib.report.print_report(p3[0],msg)