commit 4d6c79d1de5e242c000f28a71c706734d1a2da0b
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Mon May 8 15:34:37 2017 -0400
Fix some clang-i386 warnings in master.
---
src/or/channel.c | 6 ++---
src/or/channel.h | 2 +-
src/or/channelpadding.c | 5 +++-
src/test/test_channelpadding.c | 54 +++++++++++++++++++++---------------------
4 files changed, 35 insertions(+), 32 deletions(-)
diff --git a/src/or/channel.c b/src/or/channel.c
index 5b184f1..0b99dc9 100644
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@ -88,7 +88,7 @@ static smartlist_t *finished_listeners = NULL;
/** Map from channel->global_identifier to channel. Contains the same
* elements as all_channels. */
-HT_HEAD(channel_gid_map, channel_s) channel_gid_map = HT_INITIALIZER();
+static HT_HEAD(channel_gid_map, channel_s) channel_gid_map = HT_INITIALIZER();
static unsigned
channel_id_hash(const channel_t *chan)
@@ -101,10 +101,10 @@ channel_id_eq(const channel_t *a, const channel_t *b)
return a->global_identifier == b->global_identifier;
}
HT_PROTOTYPE(channel_gid_map, channel_s, gidmap_node,
- channel_id_hash, channel_id_eq);
+ channel_id_hash, channel_id_eq)
HT_GENERATE2(channel_gid_map, channel_s, gidmap_node,
channel_id_hash, channel_id_eq,
- 0.6, tor_reallocarray_, tor_free_);
+ 0.6, tor_reallocarray_, tor_free_)
HANDLE_IMPL(channel, channel_s,);
diff --git a/src/or/channel.h b/src/or/channel.h
index bfcdafb..ea280f2 100644
--- a/src/or/channel.h
+++ b/src/or/channel.h
@@ -716,7 +716,7 @@ int packed_cell_is_destroy(channel_t *chan,
circid_t *circid_out);
/* Declare the handle helpers */
-HANDLE_DECL(channel, channel_s,);
+HANDLE_DECL(channel, channel_s,)
#endif
diff --git a/src/or/channelpadding.c b/src/or/channelpadding.c
index e57408a..481d937 100644
--- a/src/or/channelpadding.c
+++ b/src/or/channelpadding.c
@@ -727,13 +727,16 @@ channelpadding_decide_to_pad_channel(channel_t *chan)
chan->currently_padding = 1;
return CHANNELPADDING_PADLATER;
} else {
+ if (BUG(pad_time_ms > INT_MAX)) {
+ pad_time_ms = INT_MAX;
+ }
/* We have to schedule a callback because we're called exactly once per
* second, but we don't want padding packets to go out exactly on an
* integer multiple of seconds. This callback will only be scheduled
* if we're within 1.1 seconds of the padding time.
*/
chan->currently_padding = 1;
- return channelpadding_schedule_padding(chan, pad_time_ms);
+ return channelpadding_schedule_padding(chan, (int)pad_time_ms);
}
} else {
chan->currently_padding = 0;
diff --git a/src/test/test_channelpadding.c b/src/test/test_channelpadding.c
index 8ea0f17..68d5c58 100644
--- a/src/test/test_channelpadding.c
+++ b/src/test/test_channelpadding.c
@@ -409,9 +409,9 @@ test_channelpadding_consensus(void *arg)
tt_int_op(decision, OP_EQ, CHANNELPADDING_WONTPAD);
tt_assert(!chan->pending_padding_callback);
val = channelpadding_get_netflow_inactive_timeout_ms(chan);
- tt_int_op(val, OP_EQ, 0);
+ tt_i64_op(val, OP_EQ, 0);
val = channelpadding_compute_time_until_pad_for_netflow(chan);
- tt_int_op(val, OP_EQ, -2);
+ tt_i64_op(val, OP_EQ, -2);
/* Test 2: Negotiation can't re-enable consensus-disabled padding */
channelpadding_send_enable_command(chan, 100, 200);
@@ -420,9 +420,9 @@ test_channelpadding_consensus(void *arg)
tt_int_op(decision, OP_EQ, CHANNELPADDING_WONTPAD);
tt_assert(!chan->pending_padding_callback);
val = channelpadding_get_netflow_inactive_timeout_ms(chan);
- tt_int_op(val, OP_EQ, 0);
+ tt_i64_op(val, OP_EQ, 0);
val = channelpadding_compute_time_until_pad_for_netflow(chan);
- tt_int_op(val, OP_EQ, -2);
+ tt_i64_op(val, OP_EQ, -2);
tt_assert(!chan->next_padding_time_ms);
smartlist_clear(current_md_consensus->net_params);
@@ -441,10 +441,10 @@ test_channelpadding_consensus(void *arg)
tt_assert(chan->pending_padding_callback);
tt_int_op(tried_to_write_cell, OP_EQ, 0);
val = channelpadding_get_netflow_inactive_timeout_ms(chan);
- tt_int_op(val, OP_GE, 100);
- tt_int_op(val, OP_LE, 200);
+ tt_i64_op(val, OP_GE, 100);
+ tt_i64_op(val, OP_LE, 200);
val = channelpadding_compute_time_until_pad_for_netflow(chan);
- tt_int_op(val, OP_LE, 200);
+ tt_i64_op(val, OP_LE, 200);
// Wait for the timer
event_base_loop(tor_libevent_get_base(), 0);
@@ -464,10 +464,10 @@ test_channelpadding_consensus(void *arg)
tt_int_op(decision, OP_EQ, CHANNELPADDING_PADLATER);
tt_assert(!chan->pending_padding_callback);
val = channelpadding_get_netflow_inactive_timeout_ms(chan);
- tt_int_op(val, OP_GE, 1500);
- tt_int_op(val, OP_LE, 4500);
+ tt_i64_op(val, OP_GE, 1500);
+ tt_i64_op(val, OP_LE, 4500);
val = channelpadding_compute_time_until_pad_for_netflow(chan);
- tt_int_op(val, OP_LE, 4500);
+ tt_i64_op(val, OP_LE, 4500);
/* Test 4: Relay-to-relay padding can be enabled/disabled in consensus */
/* Make this channel a relay's channel */
@@ -488,10 +488,10 @@ test_channelpadding_consensus(void *arg)
tt_int_op(decision, OP_EQ, CHANNELPADDING_PADLATER);
tt_assert(!chan->pending_padding_callback);
val = channelpadding_get_netflow_inactive_timeout_ms(chan);
- tt_int_op(val, OP_GE, 1500);
- tt_int_op(val, OP_LE, 4500);
+ tt_i64_op(val, OP_GE, 1500);
+ tt_i64_op(val, OP_LE, 4500);
val = channelpadding_compute_time_until_pad_for_netflow(chan);
- tt_int_op(val, OP_LE, 4500);
+ tt_i64_op(val, OP_LE, 4500);
/* Test 5: If we disable padding before channel usage, does that work? */
smartlist_add(current_md_consensus->net_params,
@@ -504,15 +504,15 @@ test_channelpadding_consensus(void *arg)
/* Test 6: Can we control circ and TLS conn lifetime from the consensus? */
val = channelpadding_get_channel_idle_timeout(NULL, 0);
- tt_int_op(val, OP_GE, 180);
- tt_int_op(val, OP_LE, 180+90);
+ tt_i64_op(val, OP_GE, 180);
+ tt_i64_op(val, OP_LE, 180+90);
val = channelpadding_get_channel_idle_timeout(chan, 0);
- tt_int_op(val, OP_GE, 180);
- tt_int_op(val, OP_LE, 180+90);
+ tt_i64_op(val, OP_GE, 180);
+ tt_i64_op(val, OP_LE, 180+90);
options->ReducedConnectionPadding = 1;
val = channelpadding_get_channel_idle_timeout(chan, 0);
- tt_int_op(val, OP_GE, 180/2);
- tt_int_op(val, OP_LE, (180+90)/2);
+ tt_i64_op(val, OP_GE, 180/2);
+ tt_i64_op(val, OP_LE, (180+90)/2);
options->ReducedConnectionPadding = 0;
options->ORPort_set = 1;
@@ -520,26 +520,26 @@ test_channelpadding_consensus(void *arg)
(void*)"nf_conntimeout_relays=600");
channelpadding_new_consensus_params(current_md_consensus);
val = channelpadding_get_channel_idle_timeout(chan, 1);
- tt_int_op(val, OP_GE, 450);
- tt_int_op(val, OP_LE, 750);
+ tt_i64_op(val, OP_GE, 450);
+ tt_i64_op(val, OP_LE, 750);
val = channelpadding_get_circuits_available_timeout();
- tt_int_op(val, OP_GE, 30*60);
- tt_int_op(val, OP_LE, 30*60*2);
+ tt_i64_op(val, OP_GE, 30*60);
+ tt_i64_op(val, OP_LE, 30*60*2);
options->ReducedConnectionPadding = 1;
smartlist_add(current_md_consensus->net_params,
(void*)"nf_conntimeout_clients=600");
channelpadding_new_consensus_params(current_md_consensus);
val = channelpadding_get_circuits_available_timeout();
- tt_int_op(val, OP_GE, 600/2);
- tt_int_op(val, OP_LE, 600*2/2);
+ tt_i64_op(val, OP_GE, 600/2);
+ tt_i64_op(val, OP_LE, 600*2/2);
options->ReducedConnectionPadding = 0;
options->CircuitsAvailableTimeout = 24*60*60;
val = channelpadding_get_circuits_available_timeout();
- tt_int_op(val, OP_GE, 24*60*60);
- tt_int_op(val, OP_LE, 24*60*60*2);
+ tt_i64_op(val, OP_GE, 24*60*60);
+ tt_i64_op(val, OP_LE, 24*60*60*2);
done:
free_fake_channeltls((channel_tls_t*)chan);