debugmm.cocci 567 B

1234567891011121314151617181920212223242526272829
  1. // Look for use of expressions with side-effects inside of debug logs.
  2. //
  3. // This script detects expressions like ++E, --E, E++, and E-- inside of
  4. // calls to log_debug().
  5. //
  6. // The log_debug() macro exits early if debug logging is not enabled,
  7. // potentially causing problems if its arguments have side-effects.
  8. @@
  9. expression E;
  10. @@
  11. *log_debug(... , <+... --E ...+>, ... );
  12. @@
  13. expression E;
  14. @@
  15. *log_debug(... , <+... ++E ...+>, ... );
  16. @@
  17. expression E;
  18. @@
  19. *log_debug(... , <+... E-- ...+>, ... );
  20. @@
  21. expression E;
  22. @@
  23. *log_debug(... , <+... E++ ...+>, ... );