sz3.cocci 844 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // Take size of pointed value, not pointer
  3. //
  4. // Target: Linux, Generic
  5. // Copyright: 2012 - LIP6/INRIA
  6. // License: Licensed under GPLv2 or any later version.
  7. // Author: Julia Lawall <Julia.Lawall@lip6.fr>
  8. // URL: http://coccinelle.lip6.fr/
  9. // URL: http://coccinellery.org/
  10. // Modified by Eric Leblond <eric@regit.org> for suricata test system
  11. @preuse@
  12. expression *e;
  13. type T;
  14. identifier f;
  15. position p1;
  16. @@
  17. f(...,
  18. sizeof(e@p1)
  19. ,...,(T)e,...)
  20. @ script:python @
  21. p1 << preuse.p1;
  22. @@
  23. print("Size of pointed value not pointer used at %s:%s" % (p1[0].file, p1[0].line))
  24. import sys
  25. sys.exit(1)
  26. @postuse@
  27. expression *e;
  28. type T;
  29. identifier f;
  30. position p1;
  31. @@
  32. f(...,(T)e,...,
  33. sizeof(e@p1)
  34. ,...)
  35. @ script:python @
  36. p1 << postuse.p1;
  37. @@
  38. print("Size of pointed value not pointer used at %s:%s" % (p1[0].file, p1[0].line))
  39. import sys
  40. sys.exit(1)