cppclean_check.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import sys
  2. #cppclean src/*.h | grep "does not need to be #included"
  3. retcode = 0
  4. for l in sys.stdin:
  5. includer = l.split(':')[0]
  6. included = l.split("'")[1]
  7. if included == "rust.h" or included == "suricata-common.h":
  8. continue
  9. if includer == "src/suricata-common.h" or includer == "src/rust-context.h" or includer == "src/rust.h" or includer == "src/threads.h":
  10. continue
  11. if included == "util-file.h" and includer == "src/detect.h":
  12. # SigTableElmt structure field FileMatch being a function pointer using a parameter File defined in util-file.h
  13. continue
  14. if included == "conf.h" and includer == "src/suricata-plugin.h":
  15. # SCEveFileType structure field Init being a function pointer using a parameter ConfNode defined in conf.h
  16. continue
  17. if included == "util-prefilter.h" and includer == "src/util-mpm.h":
  18. # MpmTableElmt_ structure field Search being a function pointer using a parameter PrefilterRuleStore
  19. continue
  20. if included == "flow.h" and includer == "src/output-tx.h":
  21. # TxLogger type being a function pointer using a parameter Flow
  22. continue
  23. if included == "util-debug-filters.h" and includer == "src/util-debug.h":
  24. # Macro SCEnter using SCLogCheckFDFilterEntry defined in util-debug-filters.h
  25. continue
  26. if included == "util-spm-bs.h" and includer == "src/util-spm.h":
  27. # Macro SpmSearch using BasicSearch defined in util-spm-bs.h
  28. continue
  29. if included == "util-cpu.h" and includer == "src/threads-profile.h":
  30. # Macro SCSpinLock_profile using UtilCpuGetTicks
  31. continue
  32. if included == "util-profiling-locks.h" and includer == "src/util-profiling.h":
  33. # Macro SCSpinLock_profile using SCProfilingAddPacketLocks
  34. continue
  35. if included == "threads.h" and includer == "src/util-debug-filters.h":
  36. # pthread_t needed on Windows
  37. continue
  38. print("Unnecessary include from %s for %s" % (includer, included))
  39. retcode = 1
  40. sys.exit(retcode)