platform_no_drv_owner.cocci 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /// Remove .owner field if calls are used which set it automatically
  2. ///
  3. // Confidence: High
  4. // Copyright: (C) 2014 Wolfram Sang. GPL v2.
  5. virtual patch
  6. virtual context
  7. virtual org
  8. virtual report
  9. @match1@
  10. declarer name module_platform_driver;
  11. declarer name module_platform_driver_probe;
  12. identifier __driver;
  13. @@
  14. (
  15. module_platform_driver(__driver);
  16. |
  17. module_platform_driver_probe(__driver, ...);
  18. )
  19. @fix1 depends on match1 && patch && !context && !org && !report@
  20. identifier match1.__driver;
  21. @@
  22. static struct platform_driver __driver = {
  23. .driver = {
  24. - .owner = THIS_MODULE,
  25. }
  26. };
  27. @match2@
  28. identifier __driver;
  29. @@
  30. (
  31. platform_driver_register(&__driver)
  32. |
  33. platform_driver_probe(&__driver, ...)
  34. |
  35. platform_create_bundle(&__driver, ...)
  36. )
  37. @fix2 depends on match2 && patch && !context && !org && !report@
  38. identifier match2.__driver;
  39. @@
  40. static struct platform_driver __driver = {
  41. .driver = {
  42. - .owner = THIS_MODULE,
  43. }
  44. };
  45. // ----------------------------------------------------------------------------
  46. @fix1_context depends on match1 && !patch && (context || org || report)@
  47. identifier match1.__driver;
  48. position j0;
  49. @@
  50. static struct platform_driver __driver = {
  51. .driver = {
  52. * .owner@j0 = THIS_MODULE,
  53. }
  54. };
  55. @fix2_context depends on match2 && !patch && (context || org || report)@
  56. identifier match2.__driver;
  57. position j0;
  58. @@
  59. static struct platform_driver __driver = {
  60. .driver = {
  61. * .owner@j0 = THIS_MODULE,
  62. }
  63. };
  64. // ----------------------------------------------------------------------------
  65. @script:python fix1_org depends on org@
  66. j0 << fix1_context.j0;
  67. @@
  68. msg = "No need to set .owner here. The core will do it."
  69. coccilib.org.print_todo(j0[0], msg)
  70. @script:python fix2_org depends on org@
  71. j0 << fix2_context.j0;
  72. @@
  73. msg = "No need to set .owner here. The core will do it."
  74. coccilib.org.print_todo(j0[0], msg)
  75. // ----------------------------------------------------------------------------
  76. @script:python fix1_report depends on report@
  77. j0 << fix1_context.j0;
  78. @@
  79. msg = "No need to set .owner here. The core will do it."
  80. coccilib.report.print_report(j0[0], msg)
  81. @script:python fix2_report depends on report@
  82. j0 << fix2_context.j0;
  83. @@
  84. msg = "No need to set .owner here. The core will do it."
  85. coccilib.report.print_report(j0[0], msg)