diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-05-07 16:35:52 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-05-09 12:02:19 -0400 |
commit | 79b38081e985d65cfd08236d2eb42a87cc59a786 (patch) | |
tree | 37293e0a02c1f8afcfc11cc636bc97874c66ecfe /src/or/control.c | |
parent | 61d5ce83a1ecc459798b530730316bfebe3bb192 (diff) | |
download | tor-79b38081e985d65cfd08236d2eb42a87cc59a786.tar.gz tor-79b38081e985d65cfd08236d2eb42a87cc59a786.zip |
Add a macro to simplify control_update_global_event_mask().
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/or/control.c b/src/or/control.c index 93b204f9a3..695f0779cf 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -288,10 +288,13 @@ control_update_global_event_mask(void) * we want to hear...*/ control_adjust_event_log_severity(); + /* Macro: true if ev was false before and is true now. */ +#define NEWLY_ENABLED(ev) \ + (! (old_mask & (ev)) && (new_mask & (ev))) + /* ...then, if we've started logging stream or circ bw, clear the * appropriate fields. */ - if (! (old_mask & EVENT_STREAM_BANDWIDTH_USED) && - (new_mask & EVENT_STREAM_BANDWIDTH_USED)) { + if (NEWLY_ENABLED(EVENT_STREAM_BANDWIDTH_USED)) { SMARTLIST_FOREACH(conns, connection_t *, conn, { if (conn->type == CONN_TYPE_AP) { @@ -300,10 +303,10 @@ control_update_global_event_mask(void) } }); } - if (! (old_mask & EVENT_CIRC_BANDWIDTH_USED) && - (new_mask & EVENT_CIRC_BANDWIDTH_USED)) { + if (NEWLY_ENABLED(EVENT_CIRC_BANDWIDTH_USED)) { clear_circ_bw_fields(); } +#undef NEWLY_ENABLED } /** Adjust the log severities that result in control_event_logmsg being called |