]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add a macro to simplify control_update_global_event_mask().
authorNick Mathewson <nickm@torproject.org>
Mon, 7 May 2018 20:35:52 +0000 (16:35 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 9 May 2018 16:02:19 +0000 (12:02 -0400)
src/or/control.c

index 93b204f9a3b71d68f9eee50b09c9fb6e7988df0c..695f0779cf82a4e74d0a0e992d110d5d3040c789 100644 (file)
@@ -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