summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-07-28 10:17:14 -0400
committerNick Mathewson <nickm@torproject.org>2017-07-28 10:17:57 -0400
commitdecb9276852b4cb7f9f2472c81cd47fbab60845f (patch)
tree3ef8013320eaa1655ea1d677c0493d13d0a071d5
parent602c52cad486516defc9d5ed375effd74cfe4529 (diff)
downloadtor-decb9276852b4cb7f9f2472c81cd47fbab60845f.tar.gz
tor-decb9276852b4cb7f9f2472c81cd47fbab60845f.zip
Add an assertion to try to please coverity.
Coverity, for some reason, thought that weight_scale might be 0, leading to a divide-by-zero error.
-rw-r--r--src/or/routerparse.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index f4e87a00d8..8823c0b53e 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -2854,7 +2854,6 @@ compare_vote_routerstatus_entries(const void **_a, const void **_b)
int
networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
{
- int64_t weight_scale;
int64_t G=0, M=0, E=0, D=0, T=0;
double Wgg, Wgm, Wgd, Wmg, Wmm, Wme, Wmd, Weg, Wem, Wee, Wed;
double Gtotal=0, Mtotal=0, Etotal=0;
@@ -2862,7 +2861,8 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
int valid = 1;
(void) consensus_method;
- weight_scale = networkstatus_get_weight_scale_param(ns);
+ const int64_t weight_scale = networkstatus_get_weight_scale_param(ns);
+ tor_assert(weight_scale >= 1);
Wgg = networkstatus_get_bw_weight(ns, "Wgg", -1);
Wgm = networkstatus_get_bw_weight(ns, "Wgm", -1);
Wgd = networkstatus_get_bw_weight(ns, "Wgd", -1);