mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
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.
This commit is contained in:
committed by
Nick Mathewson
parent
de2010e9c2
commit
d6e6c63baf
@@ -0,0 +1,4 @@
|
||||
o Minor bugfixes (build):
|
||||
- Resolve clang complaints on OpenBSD with -Wshorten-64-to-32 due to
|
||||
treatment of long and time_t as comparable types. Fixes part of bug 11633.
|
||||
Patch from Dana Koch.
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -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.",
|
||||
|
||||
+1
-1
@@ -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),
|
||||
|
||||
+1
-1
@@ -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));
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+3
-3
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user