[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Compile-time check that control_event_t.event_mask is big enough



commit b41a5039f1ee16ddbcb5cbef63d5ba9abf802834
Author: teor <teor2345@xxxxxxxxx>
Date:   Sun Mar 22 14:25:42 2015 +1100

    Compile-time check that control_event_t.event_mask is big enough
    
    Add a compile-time check that the number of events doesn't exceed
    the capacity of control_event_t.event_mask.
---
 changes/ticket15431 |    4 +++-
 src/or/control.h    |    4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/changes/ticket15431 b/changes/ticket15431
index e35bab6..ea6821a 100644
--- a/changes/ticket15431
+++ b/changes/ticket15431
@@ -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".
diff --git a/src/or/control.h b/src/or/control.h
index 9b0362a..dbb80b1 100644
--- a/src/or/control.h
+++ b/src/or/control.h
@@ -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)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits