device_node_continue.cocci 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /// Device node iterators put the previous value of the index variable, so an
  2. /// explicit put causes a double put.
  3. ///
  4. // Confidence: High
  5. // Copyright: (C) 2015 Julia Lawall, Inria. GPLv2.
  6. // URL: http://coccinelle.lip6.fr/
  7. // Options: --no-includes --include-headers
  8. // Requires: 1.0.4
  9. // Keywords: for_each_child_of_node, etc.
  10. // This uses a conjunction, which requires at least coccinelle >= 1.0.4
  11. virtual patch
  12. virtual context
  13. virtual org
  14. virtual report
  15. @r exists@
  16. expression e1,e2;
  17. local idexpression n;
  18. iterator name for_each_node_by_name, for_each_node_by_type,
  19. for_each_compatible_node, for_each_matching_node,
  20. for_each_matching_node_and_match, for_each_child_of_node,
  21. for_each_available_child_of_node, for_each_node_with_property;
  22. iterator i;
  23. position p1,p2;
  24. statement S;
  25. @@
  26. (
  27. (
  28. for_each_node_by_name(n,e1) S
  29. |
  30. for_each_node_by_type(n,e1) S
  31. |
  32. for_each_compatible_node(n,e1,e2) S
  33. |
  34. for_each_matching_node(n,e1) S
  35. |
  36. for_each_matching_node_and_match(n,e1,e2) S
  37. |
  38. for_each_child_of_node(e1,n) S
  39. |
  40. for_each_available_child_of_node(e1,n) S
  41. |
  42. for_each_node_with_property(n,e1) S
  43. )
  44. &
  45. i@p1(...) {
  46. ... when != of_node_get(n)
  47. when any
  48. of_node_put@p2(n);
  49. ... when any
  50. }
  51. )
  52. @s exists@
  53. local idexpression r.n;
  54. statement S;
  55. position r.p1,r.p2;
  56. iterator i;
  57. @@
  58. of_node_put@p2(n);
  59. ... when any
  60. i@p1(..., n, ...)
  61. S
  62. @t depends on s && patch && !context && !org && !report@
  63. local idexpression n;
  64. position r.p2;
  65. @@
  66. - of_node_put@p2(n);
  67. // ----------------------------------------------------------------------------
  68. @t_context depends on s && !patch && (context || org || report)@
  69. local idexpression n;
  70. position r.p2;
  71. position j0;
  72. @@
  73. * of_node_put@j0@p2(n);
  74. // ----------------------------------------------------------------------------
  75. @script:python t_org depends on org@
  76. j0 << t_context.j0;
  77. @@
  78. msg = "ERROR: probable double put."
  79. coccilib.org.print_todo(j0[0], msg)
  80. // ----------------------------------------------------------------------------
  81. @script:python t_report depends on report@
  82. j0 << t_context.j0;
  83. @@
  84. msg = "ERROR: probable double put."
  85. coccilib.report.print_report(j0[0], msg)