aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordana koch <dsk@google.com>2014-05-12 09:16:06 +1000
committerNick Mathewson <nickm@torproject.org>2014-05-11 23:36:00 -0400
commitd6e6c63baf4409766ffd82fc859187b6285b093f (patch)
tree0a38dfcecc034cc33348a238cc0a210d840f2e67 /src
parentde2010e9c229cb130c30659aa62122529c125637 (diff)
downloadtor-d6e6c63baf4409766ffd82fc859187b6285b093f.tar
tor-d6e6c63baf4409766ffd82fc859187b6285b093f.tar.gz
Quench clang's complaints with -Wshorten-64-to-32 when time_t is not long.
On OpenBSD 5.4, time_t is a 32-bit integer. These instances contain implicit treatment of long and time_t as comparable types, so explicitly cast to time_t.
Diffstat (limited to 'src')
-rw-r--r--src/common/util.c2
-rw-r--r--src/or/circuituse.c10
-rw-r--r--src/or/directory.c2
-rw-r--r--src/or/dirserv.c2
-rw-r--r--src/or/main.c2
-rw-r--r--src/or/networkstatus.c6
-rw-r--r--src/or/rephist.c6
-rw-r--r--src/test/test_util.c4
8 files changed, 17 insertions, 17 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 6524be3ed..d40e83dbb 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1516,7 +1516,7 @@ void
format_iso_time_nospace_usec(char *buf, const struct timeval *tv)
{
tor_assert(tv);
- format_iso_time_nospace(buf, tv->tv_sec);
+ format_iso_time_nospace(buf, (time_t)tv->tv_sec);
tor_snprintf(buf+ISO_TIME_LEN, 8, ".%06d", (int)tv->tv_usec);
}
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 9d2decf57..467bef652 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -296,7 +296,7 @@ circuit_get_best(const entry_connection_t *conn,
}
if (!circuit_is_acceptable(origin_circ,conn,must_be_open,purpose,
- need_uptime,need_internal,now.tv_sec))
+ need_uptime,need_internal, (time_t)now.tv_sec))
continue;
/* now this is an acceptable circ to hand back. but that doesn't
@@ -683,9 +683,9 @@ circuit_expire_building(void)
victim->purpose,
circuit_purpose_to_string(victim->purpose));
} else if (circuit_build_times_count_close(
- get_circuit_build_times_mutable(),
- first_hop_succeeded,
- victim->timestamp_created.tv_sec)) {
+ get_circuit_build_times_mutable(),
+ first_hop_succeeded,
+ (time_t)victim->timestamp_created.tv_sec)) {
circuit_build_times_set_timeout(get_circuit_build_times_mutable());
}
}
@@ -825,7 +825,7 @@ circuit_log_ancient_one_hop_circuits(int age)
char created[ISO_TIME_LEN+1];
circ = TO_CIRCUIT(ocirc);
format_local_iso_time(created,
- circ->timestamp_created.tv_sec);
+ (time_t)circ->timestamp_created.tv_sec);
log_notice(LD_HEARTBEAT, " #%d created at %s. %s, %s. %s for close. "
"%s for new conns.",
diff --git a/src/or/directory.c b/src/or/directory.c
index 428fd01be..b94aac45b 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -2299,7 +2299,7 @@ write_http_response_header_impl(dir_connection_t *conn, ssize_t length,
}
if (cache_lifetime > 0) {
char expbuf[RFC1123_TIME_LEN+1];
- format_rfc1123_time(expbuf, now + cache_lifetime);
+ format_rfc1123_time(expbuf, (time_t)(now + cache_lifetime));
/* We could say 'Cache-control: max-age=%d' here if we start doing
* http/1.1 */
tor_snprintf(cp, sizeof(tmp)-(cp-tmp),
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 2d623a655..aedd09252 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2507,7 +2507,7 @@ dirserv_read_measured_bandwidths(const char *from_file,
}
line[strlen(line)-1] = '\0';
- file_time = tor_parse_ulong(line, 10, 0, ULONG_MAX, &ok, NULL);
+ file_time = (time_t)tor_parse_ulong(line, 10, 0, ULONG_MAX, &ok, NULL);
if (!ok) {
log_warn(LD_DIRSERV, "Non-integer time in bandwidth file: %s",
escaped(line));
diff --git a/src/or/main.c b/src/or/main.c
index 1e591577f..5532026e3 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1755,7 +1755,7 @@ refill_callback(periodic_timer_t *timer, void *arg)
accounting_add_bytes(bytes_read, bytes_written, seconds_rolled_over);
if (milliseconds_elapsed > 0)
- connection_bucket_refill(milliseconds_elapsed, now.tv_sec);
+ connection_bucket_refill(milliseconds_elapsed, (time_t)now.tv_sec);
stats_prev_global_read_bucket = global_read_bucket;
stats_prev_global_write_bucket = global_write_bucket;
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 90918d4fe..890da0ad1 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -830,7 +830,7 @@ update_consensus_networkstatus_fetch_time_impl(time_t now, int flav)
if (directory_fetches_dir_info_early(options)) {
/* We want to cache the next one at some point after this one
* is no longer fresh... */
- start = c->fresh_until + min_sec_before_caching;
+ start = (time_t)(c->fresh_until + min_sec_before_caching);
/* Some clients may need the consensus sooner than others. */
if (options->FetchDirInfoExtraEarly || authdir_mode_v3(options)) {
dl_interval = 60;
@@ -843,7 +843,7 @@ update_consensus_networkstatus_fetch_time_impl(time_t now, int flav)
} else {
/* We're an ordinary client or a bridge. Give all the caches enough
* time to download the consensus. */
- start = c->fresh_until + (interval*3)/4;
+ start = (time_t)(c->fresh_until + (interval*3)/4);
/* But download the next one well before this one is expired. */
dl_interval = ((c->valid_until - start) * 7 )/ 8;
@@ -851,7 +851,7 @@ update_consensus_networkstatus_fetch_time_impl(time_t now, int flav)
* to choose the rest of the interval *after* them. */
if (directory_fetches_dir_info_later(options)) {
/* Give all the *clients* enough time to download the consensus. */
- start = start + dl_interval + min_sec_before_caching;
+ start = (time_t)(start + dl_interval + min_sec_before_caching);
/* But try to get it before ours actually expires. */
dl_interval = (c->valid_until - start) - min_sec_before_caching;
}
diff --git a/src/or/rephist.c b/src/or/rephist.c
index a0f24e18f..5446c25e3 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -931,7 +931,7 @@ correct_time(time_t t, time_t now, time_t stored_at, time_t started_measuring)
return 0;
else {
long run_length = stored_at - t;
- t = now - run_length;
+ t = (time_t)(now - run_length);
if (t < started_measuring)
t = started_measuring;
return t;
@@ -1092,7 +1092,7 @@ rep_hist_load_mtbf_data(time_t now)
hist->start_of_run = correct_time(start_of_run, now, stored_at,
tracked_since);
if (hist->start_of_run < latest_possible_start + wrl)
- latest_possible_start = hist->start_of_run - wrl;
+ latest_possible_start = (time_t)(hist->start_of_run - wrl);
hist->weighted_run_length = wrl;
hist->total_run_weights = trw;
@@ -2311,7 +2311,7 @@ rep_hist_buffer_stats_add_circ(circuit_t *circ, time_t end_of_interval)
return;
start_of_interval = (circ->timestamp_created.tv_sec >
start_of_buffer_stats_interval) ?
- circ->timestamp_created.tv_sec :
+ (time_t)circ->timestamp_created.tv_sec :
start_of_buffer_stats_interval;
interval_length = (int) (end_of_interval - start_of_interval);
if (interval_length <= 0)
diff --git a/src/test/test_util.c b/src/test/test_util.c
index d66be32a7..65cc58a66 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -344,7 +344,7 @@ test_util_time(void)
tv.tv_sec = (time_t)1326296338;
tv.tv_usec = 3060;
- format_iso_time(timestr, tv.tv_sec);
+ format_iso_time(timestr, (time_t)tv.tv_sec);
test_streq("2012-01-11 15:38:58", timestr);
/* The output of format_local_iso_time will vary by timezone, and setting
our timezone for testing purposes would be a nontrivial flaky pain.
@@ -352,7 +352,7 @@ test_util_time(void)
format_local_iso_time(timestr, tv.tv_sec);
test_streq("2012-01-11 10:38:58", timestr);
*/
- format_iso_time_nospace(timestr, tv.tv_sec);
+ format_iso_time_nospace(timestr, (time_t)tv.tv_sec);
test_streq("2012-01-11T15:38:58", timestr);
test_eq(strlen(timestr), ISO_TIME_LEN);
format_iso_time_nospace_usec(timestr, &tv);