]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Compile-time check that control_event_t.event_mask is big enough
authorteor <teor2345@gmail.com>
Sun, 22 Mar 2015 03:25:42 +0000 (14:25 +1100)
committerteor <teor2345@gmail.com>
Sun, 22 Mar 2015 03:25:42 +0000 (14:25 +1100)
Add a compile-time check that the number of events doesn't exceed
the capacity of control_event_t.event_mask.

changes/ticket15431
src/or/control.h

index e35bab6e8555ed9261dffe34d654f6d40725799f..ea6821afdfce125cb95e8523055c01b0a25d9bca 100644 (file)
@@ -1,4 +1,6 @@
   o Minor features (testing):
     - Add unit tests for control_event_is_interesting().
-      Part of ticket 15431, checks for bugs similar to 13085.
+      Add a compile-time check that the number of events doesn't exceed
+      the capacity of control_event_t.event_mask.
+      Closes ticket 15431, checks for bugs similar to 13085.
       Patch by "teor".
index 9b0362a9a50efb7e4564a52bc4c38a2fa3343189..dbb80b1f2009de2020a382baa9cb48a035df6025 100644 (file)
@@ -166,6 +166,10 @@ void control_free_all(void);
 /* If EVENT_MAX_ ever hits 0x0040, we need to make the mask into a
  * different structure, as it can only handle a maximum left shift of 1<<63. */
 
+#if EVENT_MAX_ >= EVENT_CAPACITY_
+#error control_connection_t.event_mask has an event greater than its capacity
+#endif
+
 #define EVENT_MASK_(e)               (((uint64_t)1)<<(e))
 
 #define EVENT_MASK_NONE_             ((uint64_t)0x0)