diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-06-06 13:02:22 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-06-06 13:02:22 +0000 |
commit | 6673d445f57aac34035393cdbfefaf67249e1a34 (patch) | |
tree | 696a9eb5596078cbb4692288dadc2951d71ea78d /src/or/rephist.c | |
parent | 1a29d6808140df77dc8a9381906f178588440e1c (diff) | |
download | tor-6673d445f57aac34035393cdbfefaf67249e1a34.tar.gz tor-6673d445f57aac34035393cdbfefaf67249e1a34.zip |
r13283@catbus: nickm | 2007-06-06 01:43:44 -0400
Fix up a couple of loops flagged by -Wunsafe-loop-optimizations so that they are more readable (and more amenable to compilation)
svn:r10513
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r-- | src/or/rephist.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c index ae9442dd55..c712f1525e 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -599,7 +599,9 @@ rep_hist_fill_bandwidth_history(char *buf, size_t len, bw_array_t *b) for (n=0; n<b->num_maxes_set; ++n,++i) { uint64_t total; - while (i >= NUM_TOTALS) i -= NUM_TOTALS; + if (i >= NUM_TOTALS) + i -= NUM_TOTALS; + tor_assert(i < NUM_TOTALS); /* Round the bandwidth used down to the nearest 1k. */ total = b->totals[i] & ~0x3ff; if (n==(b->num_maxes_set-1)) @@ -1473,7 +1475,9 @@ hs_usage_format_history(char *buf, size_t len, uint32_t *data) i = current_period->next_idx; } for (n = 0; n < current_period->num_set; ++n,++i) { - while (i >= NUM_TOTALS_HS_USAGE) i -= NUM_TOTALS_HS_USAGE; + if (i >= NUM_TOTALS_HS_USAGE) + i -= NUM_TOTALS_HS_USAGE; + tor_assert(i < NUM_TOTALS_HS_USAGE); if (n == (current_period->num_set-1)) tor_snprintf(cp, len-(cp-buf), "%d", data[i]); else |