aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitstats.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-08-21 10:19:26 -0400
committerNick Mathewson <nickm@torproject.org>2014-08-21 10:19:26 -0400
commit2a0a5fe6123bd87f996814991641cc404601ea55 (patch)
tree3f9511c9cbb39231850881bf970fbb9d09c27807 /src/or/circuitstats.c
parentb6a725c67e46d274a518b6c5243fffdf1730a23f (diff)
downloadtor-2a0a5fe6123bd87f996814991641cc404601ea55.tar.gz
tor-2a0a5fe6123bd87f996814991641cc404601ea55.zip
Explicitly cast when dividing ints then implicitly casting to double.
Coverity thinks that when we do "double x = int1/int2;", we probably meant "double x = ((double)int1) / int2;". In these cases, we didn't. [Coverity CID 1232089 and 1232090]
Diffstat (limited to 'src/or/circuitstats.c')
-rw-r--r--src/or/circuitstats.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/or/circuitstats.c b/src/or/circuitstats.c
index 5cdd534507..88a1f9b46c 100644
--- a/src/or/circuitstats.c
+++ b/src/or/circuitstats.c
@@ -1371,10 +1371,11 @@ circuit_build_times_network_check_changed(circuit_build_times_t *cbt)
}
cbt->liveness.after_firsthop_idx = 0;
+#define MAX_TIMEOUT ((int32_t) (INT32_MAX/2))
/* Check to see if this has happened before. If so, double the timeout
* to give people on abysmally bad network connections a shot at access */
if (cbt->timeout_ms >= circuit_build_times_get_initial_timeout()) {
- if (cbt->timeout_ms > INT32_MAX/2 || cbt->close_ms > INT32_MAX/2) {
+ if (cbt->timeout_ms > MAX_TIMEOUT || cbt->close_ms > MAX_TIMEOUT) {
log_warn(LD_CIRC, "Insanely large circuit build timeout value. "
"(timeout = %fmsec, close = %fmsec)",
cbt->timeout_ms, cbt->close_ms);
@@ -1386,6 +1387,7 @@ circuit_build_times_network_check_changed(circuit_build_times_t *cbt)
cbt->close_ms = cbt->timeout_ms
= circuit_build_times_get_initial_timeout();
}
+#undef MAX_TIMEOUT
cbt_control_event_buildtimeout_set(cbt, BUILDTIMEOUT_SET_EVENT_RESET);