of_table.cocci 831 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /// Make sure of_device_id tables are NULL terminated
  2. //
  3. // Keywords: of_table
  4. // Confidence: Medium
  5. // Options: --include-headers
  6. virtual patch
  7. virtual context
  8. virtual org
  9. virtual report
  10. @depends on context@
  11. identifier var, arr;
  12. expression E;
  13. @@
  14. struct of_device_id arr[] = {
  15. ...,
  16. {
  17. .var = E,
  18. * }
  19. };
  20. @depends on patch@
  21. identifier var, arr;
  22. expression E;
  23. @@
  24. struct of_device_id arr[] = {
  25. ...,
  26. {
  27. .var = E,
  28. - }
  29. + },
  30. + { }
  31. };
  32. @r depends on org || report@
  33. position p1;
  34. identifier var, arr;
  35. expression E;
  36. @@
  37. struct of_device_id arr[] = {
  38. ...,
  39. {
  40. .var = E,
  41. }
  42. @p1
  43. };
  44. @script:python depends on org@
  45. p1 << r.p1;
  46. arr << r.arr;
  47. @@
  48. cocci.print_main(arr,p1)
  49. @script:python depends on report@
  50. p1 << r.p1;
  51. arr << r.arr;
  52. @@
  53. msg = "%s is not NULL terminated at line %s" % (arr, p1[0].line)
  54. coccilib.report.print_report(p1[0],msg)