pktnotset-packet.cocci 373 B

123456789101112131415161718192021222324252627282930
  1. @zeroed@
  2. typedef Packet;
  3. typedef uint8_t;
  4. Packet *p;
  5. position p1;
  6. @@
  7. memset(p@p1, 0, ...);
  8. @isset@
  9. Packet *p;
  10. position zeroed.p1;
  11. @@
  12. memset(p@p1, 0, ...);
  13. ... when != p
  14. (
  15. p->pkt
  16. |
  17. PacketInit(p)
  18. )
  19. @script:python depends on !isset@
  20. p1 << zeroed.p1;
  21. @@
  22. print("Packet zeroed at %s:%s but pkt field is not set afterward." % (p1[0].file, p1[0].line))
  23. import sys
  24. sys.exit(1)