diff options
author | Sebastian Hahn <sebastian@torproject.org> | 2009-09-01 05:23:47 +0200 |
---|---|---|
committer | Sebastian Hahn <sebastian@torproject.org> | 2009-09-01 22:16:46 +0200 |
commit | 0a71d1c6a7289cbadcef5f4a28dd94307decc5be (patch) | |
tree | 3a49133baf8c81fd7f962d9c0a8f01f63cb26a64 /src/or | |
parent | a95947b0d74ec8313313919624ec99a62b91ff5c (diff) | |
download | tor-0a71d1c6a7289cbadcef5f4a28dd94307decc5be.tar.gz tor-0a71d1c6a7289cbadcef5f4a28dd94307decc5be.zip |
Fix compile warnings on Snow Leopard
Big thanks to nickm and arma for helping me with this!
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/dirserv.c | 2 | ||||
-rw-r--r-- | src/or/geoip.c | 4 | ||||
-rw-r--r-- | src/or/relay.c | 13 | ||||
-rw-r--r-- | src/or/router.c | 8 | ||||
-rw-r--r-- | src/or/routerparse.c | 11 |
5 files changed, 22 insertions, 16 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index a240fd4bbb..c4a339738e 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -2324,7 +2324,7 @@ measured_bw_line_apply(measured_bw_line_t *parsed_line, if (rs) { rs->has_measured_bw = 1; - rs->measured_bw = parsed_line->bw; + rs->measured_bw = (uint32_t)parsed_line->bw; } else { log_info(LD_DIRSERV, "Node ID %s not found in routerstatus list", parsed_line->node_hex); diff --git a/src/or/geoip.c b/src/or/geoip.c index befc3d9e06..00e608214c 100644 --- a/src/or/geoip.c +++ b/src/or/geoip.c @@ -340,7 +340,7 @@ geoip_determine_shares(time_t now) ((double) (now - last_time_determined_shares)); v3_share_times_seconds += v3_share * ((double) (now - last_time_determined_shares)); - share_seconds += now - last_time_determined_shares; + share_seconds += (int)(now - last_time_determined_shares); } last_time_determined_shares = now; } @@ -768,7 +768,7 @@ geoip_get_dirreq_history(geoip_client_action_t action, time_diff = 1; /* Avoid DIV/0; "instant" answers are impossible * by law of nature or something, but a milisecond * is a bit greater than "instantly" */ - bytes_per_second = 1000 * ent->response_size / time_diff; + bytes_per_second = (uint32_t)(1000 * ent->response_size / time_diff); dltimes[ent_sl_idx] = bytes_per_second; } SMARTLIST_FOREACH_END(ent); median_uint32(dltimes, complete); /* sorts as a side effect. */ diff --git a/src/or/relay.c b/src/or/relay.c index c81b8311a0..653aa594cc 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -1635,7 +1635,8 @@ cell_queue_append_packed_copy(cell_queue_t *queue, const cell_t *cell) it_pool = mp_pool_new(sizeof(insertion_time_elem_t), 1024); tor_gettimeofday(&now); #define SECONDS_IN_A_DAY 86400L - added = (now.tv_sec % SECONDS_IN_A_DAY) * 100L + now.tv_usec / 10000L; + added = (uint32_t)(((now.tv_sec % SECONDS_IN_A_DAY) * 100L) + + ((uint32_t)now.tv_usec / (uint32_t)10000L)); if (!it_queue) { it_queue = tor_malloc_zero(sizeof(insertion_time_queue_t)); queue->insertion_times = it_queue; @@ -1879,15 +1880,17 @@ connection_or_flush_from_first_active_circuit(or_connection_t *conn, int max, uint32_t cell_waiting_time; insertion_time_queue_t *it_queue = queue->insertion_times; tor_gettimeofday(&now); - flushed = (now.tv_sec % SECONDS_IN_A_DAY) * 100L + - now.tv_usec / 10000L; + flushed = (uint32_t)((now.tv_sec % SECONDS_IN_A_DAY) * 100L + + (uint32_t)now.tv_usec / (uint32_t)10000L); if (!it_queue || !it_queue->first) { log_warn(LD_BUG, "Cannot determine insertion time of cell."); } else { or_circuit_t *orcirc = TO_OR_CIRCUIT(circ); insertion_time_elem_t *elem = it_queue->first; - cell_waiting_time = (flushed * 10L + SECONDS_IN_A_DAY * 1000L - - elem->insertion_time * 10L) % (SECONDS_IN_A_DAY * 1000L); + cell_waiting_time = + (uint32_t)((flushed * 10L + SECONDS_IN_A_DAY * 1000L - + elem->insertion_time * 10L) % + (SECONDS_IN_A_DAY * 1000L)); #undef SECONDS_IN_A_DAY elem->counter--; if (elem->counter < 1) { diff --git a/src/or/router.c b/src/or/router.c index 3b50c5caa9..085a597ea2 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1908,7 +1908,7 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo, if (options->DirReqStatistics && load_stats_file("stats"PATH_SEPARATOR"dirreq-stats", "dirreq-stats-end", since, &contents) > 0) { - int pos = strlen(s); + size_t pos = strlen(s); if (strlcpy(s + pos, contents, maxlen - strlen(s)) != strlen(contents)) { log_warn(LD_DIR, "Could not write dirreq-stats to extra-info " @@ -1920,7 +1920,7 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo, if (options->EntryStatistics && load_stats_file("stats"PATH_SEPARATOR"entry-stats", "entry-stats-end", since, &contents) > 0) { - int pos = strlen(s); + size_t pos = strlen(s); if (strlcpy(s + pos, contents, maxlen - strlen(s)) != strlen(contents)) { log_warn(LD_DIR, "Could not write entry-stats to extra-info " @@ -1932,7 +1932,7 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo, if (options->CellStatistics && load_stats_file("stats"PATH_SEPARATOR"buffer-stats", "cell-stats-end", since, &contents) > 0) { - int pos = strlen(s); + size_t pos = strlen(s); if (strlcpy(s + pos, contents, maxlen - strlen(s)) != strlen(contents)) { log_warn(LD_DIR, "Could not write buffer-stats to extra-info " @@ -1944,7 +1944,7 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo, if (options->ExitPortStatistics && load_stats_file("stats"PATH_SEPARATOR"exit-stats", "exit-stats-end", since, &contents) > 0) { - int pos = strlen(s); + size_t pos = strlen(s); if (strlcpy(s + pos, contents, maxlen - strlen(s)) != strlen(contents)) { log_warn(LD_DIR, "Could not write exit-stats to extra-info " diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 0fb08d8cec..4137dd2812 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -2012,8 +2012,9 @@ routerstatus_parse_entry_from_string(memarea_t *area, rs->has_bandwidth = 1; } else if (!strcmpstart(tok->args[i], "Measured=")) { int ok; - rs->measured_bw = tor_parse_ulong(strchr(tok->args[i], '=')+1, 10, - 0, UINT32_MAX, &ok, NULL); + rs->measured_bw = + (uint32_t)tor_parse_ulong(strchr(tok->args[i], '=')+1, + 10, 0, UINT32_MAX, &ok, NULL); if (!ok) { log_warn(LD_DIR, "Invalid Measured Bandwidth %s", escaped(tok->args[i])); @@ -3517,9 +3518,11 @@ tor_version_parse(const char *s, tor_version_t *out) if (! close_paren) return -1; cp += 5; - hexlen = (close_paren-cp); + if (close_paren-cp > HEX_DIGEST_LEN) + return -1; + hexlen = (int)(close_paren-cp); memset(digest, 0, sizeof(digest)); - if (hexlen > HEX_DIGEST_LEN || hexlen == 0 || (hexlen % 2) == 1) + if ( hexlen == 0 || (hexlen % 2) == 1) return -1; if (base16_decode(digest, hexlen/2, cp, hexlen)) return -1; |