noderef.cocci 992 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. type T;
  18. @@
  19. (
  20. x = <+... sizeof(
  21. - x
  22. + *x
  23. ) ...+>
  24. |
  25. f(...,(T)(x),...,sizeof(
  26. - x
  27. + *x
  28. ),...)
  29. |
  30. f(...,sizeof(x),...,(T)(
  31. - x
  32. + *x
  33. ),...)
  34. )
  35. @r depends on !patch@
  36. expression *x;
  37. expression f;
  38. position p;
  39. type T;
  40. @@
  41. (
  42. *x = <+... sizeof@p(x) ...+>
  43. |
  44. *f(...,(T)(x),...,sizeof@p(x),...)
  45. |
  46. *f(...,sizeof@p(x),...,(T)(x),...)
  47. )
  48. @script:python depends on org@
  49. p << r.p;
  50. @@
  51. cocci.print_main("application of sizeof to pointer",p)
  52. @script:python depends on report@
  53. p << r.p;
  54. @@
  55. msg = "ERROR: application of sizeof to pointer"
  56. coccilib.report.print_report(p[0],msg)