noderef.cocci 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /// sizeof when applied to a pointer typed expression gives the size of
  2. /// the pointer
  3. ///
  4. // Confidence: High
  5. // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
  6. // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
  7. // URL: http://coccinelle.lip6.fr/
  8. // Comments:
  9. // Options: --no-includes --include-headers
  10. virtual org
  11. virtual report
  12. virtual context
  13. virtual patch
  14. @depends on patch@
  15. expression *x;
  16. expression f;
  17. expression i;
  18. type T;
  19. @@
  20. (
  21. x = <+... sizeof(
  22. - x
  23. + *x
  24. ) ...+>
  25. |
  26. f(...,(T)(x),...,sizeof(
  27. - x
  28. + *x
  29. ),...)
  30. |
  31. f(...,sizeof(
  32. - x
  33. + *x
  34. ),...,(T)(x),...)
  35. |
  36. f(...,(T)(x),...,i*sizeof(
  37. - x
  38. + *x
  39. ),...)
  40. |
  41. f(...,i*sizeof(
  42. - x
  43. + *x
  44. ),...,(T)(x),...)
  45. )
  46. @r depends on !patch@
  47. expression *x;
  48. expression f;
  49. expression i;
  50. position p;
  51. type T;
  52. @@
  53. (
  54. *x = <+... sizeof@p(x) ...+>
  55. |
  56. *f(...,(T)(x),...,sizeof@p(x),...)
  57. |
  58. *f(...,sizeof@p(x),...,(T)(x),...)
  59. |
  60. *f(...,(T)(x),...,i*sizeof@p(x),...)
  61. |
  62. *f(...,i*sizeof@p(x),...,(T)(x),...)
  63. )
  64. @script:python depends on org@
  65. p << r.p;
  66. @@
  67. cocci.print_main("application of sizeof to pointer",p)
  68. @script:python depends on report@
  69. p << r.p;
  70. @@
  71. msg = "ERROR: application of sizeof to pointer"
  72. coccilib.report.print_report(p[0],msg)