ctrl-reply-cleanup.cocci 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Script to clean up after ctrl-reply.cocci -- run as a separate step
  2. // because cleanup_write2 (even when disabled) somehow prevents the
  3. // match rule in ctrl-reply.cocci from matching.
  4. // If it doesn't have to be a printf, turn it into a write
  5. @ cleanup_write @
  6. expression E;
  7. constant code, s;
  8. @@
  9. -control_printf_endreply(E, code, s)
  10. +control_write_endreply(E, code, s)
  11. // Use send_control_done() instead of explicitly writing it out
  12. @ cleanup_send_done @
  13. type T;
  14. identifier f != send_control_done;
  15. expression E;
  16. @@
  17. T f(...) {
  18. <...
  19. -control_write_endreply(E, 250, "OK")
  20. +send_control_done(E)
  21. ...>
  22. }
  23. // Clean up more printfs that could be writes
  24. //
  25. // For some reason, including this rule, even disabled, causes the
  26. // match rule in ctrl-reply.cocci to fail to match some code that has
  27. // %s in its format strings
  28. @ cleanup_write2 @
  29. expression E1, E2;
  30. constant code;
  31. @@
  32. (
  33. -control_printf_endreply(E1, code, "%s", E2)
  34. +control_write_endreply(E1, code, E2)
  35. |
  36. -control_printf_midreply(E1, code, "%s", E2)
  37. +control_write_midreply(E1, code, E2)
  38. )