Merge branch 'maint-0.4.7' into maint-0.4.8
[tor.git] / scripts / coccinelle / ctrl-reply-cleanup.cocci
blobf085cd4684518546ce5802f90eb9b28b995739d8
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.
5 // If it doesn't have to be a printf, turn it into a write
7 @ cleanup_write @
8 expression E;
9 constant code, s;
11 -control_printf_endreply(E, code, s)
12 +control_write_endreply(E, code, s)
14 // Use send_control_done() instead of explicitly writing it out
15 @ cleanup_send_done @
16 type T;
17 identifier f != send_control_done;
18 expression E;
20  T f(...) {
21 <...
22 -control_write_endreply(E, 250, "OK")
23 +send_control_done(E)
24  ...>
25  }
27 // Clean up more printfs that could be writes
29 // For some reason, including this rule, even disabled, causes the
30 // match rule in ctrl-reply.cocci to fail to match some code that has
31 // %s in its format strings
33 @ cleanup_write2 @
34 expression E1, E2;
35 constant code;
38 -control_printf_endreply(E1, code, "%s", E2)
39 +control_write_endreply(E1, code, E2)
41 -control_printf_midreply(E1, code, "%s", E2)
42 +control_write_midreply(E1, code, E2)