device_node_continue.cocci 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. // Keywords: for_each_child_of_node, etc.
  9. virtual patch
  10. virtual context
  11. virtual org
  12. virtual report
  13. @r exists@
  14. expression e1,e2;
  15. local idexpression n;
  16. iterator name for_each_node_by_name, for_each_node_by_type,
  17. for_each_compatible_node, for_each_matching_node,
  18. for_each_matching_node_and_match, for_each_child_of_node,
  19. for_each_available_child_of_node, for_each_node_with_property;
  20. iterator i;
  21. position p1,p2;
  22. statement S;
  23. @@
  24. (
  25. (
  26. for_each_node_by_name(n,e1) S
  27. |
  28. for_each_node_by_type(n,e1) S
  29. |
  30. for_each_compatible_node(n,e1,e2) S
  31. |
  32. for_each_matching_node(n,e1) S
  33. |
  34. for_each_matching_node_and_match(n,e1,e2) S
  35. |
  36. for_each_child_of_node(e1,n) S
  37. |
  38. for_each_available_child_of_node(e1,n) S
  39. |
  40. for_each_node_with_property(n,e1) S
  41. )
  42. &
  43. i@p1(...) {
  44. ... when != of_node_get(n)
  45. when any
  46. of_node_put@p2(n);
  47. ... when any
  48. }
  49. )
  50. @s exists@
  51. local idexpression r.n;
  52. statement S;
  53. position r.p1,r.p2;
  54. iterator i;
  55. @@
  56. of_node_put@p2(n);
  57. ... when any
  58. i@p1(..., n, ...)
  59. S
  60. @t depends on s && patch && !context && !org && !report@
  61. local idexpression n;
  62. position r.p2;
  63. @@
  64. - of_node_put@p2(n);
  65. // ----------------------------------------------------------------------------
  66. @t_context depends on s && !patch && (context || org || report)@
  67. local idexpression n;
  68. position r.p2;
  69. position j0;
  70. @@
  71. * of_node_put@j0@p2(n);
  72. // ----------------------------------------------------------------------------
  73. @script:python t_org depends on org@
  74. j0 << t_context.j0;
  75. @@
  76. msg = "ERROR: probable double put."
  77. coccilib.org.print_todo(j0[0], msg)
  78. // ----------------------------------------------------------------------------
  79. @script:python t_report depends on report@
  80. j0 << t_context.j0;
  81. @@
  82. msg = "ERROR: probable double put."
  83. coccilib.report.print_report(j0[0], msg)