mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-13 06:33:44 +01:00
r13900@catbus: nickm | 2007-07-25 16:16:30 -0400
Better fix for GCC 4.2 warning on routerlist.c svn:r10925
This commit is contained in:
parent
b764e8ee9e
commit
83fa843663
@ -1165,7 +1165,7 @@ router_get_advertised_bandwidth(routerinfo_t *router)
|
|||||||
static void *
|
static void *
|
||||||
smartlist_choose_by_bandwidth(smartlist_t *sl, int for_exit, int statuses)
|
smartlist_choose_by_bandwidth(smartlist_t *sl, int for_exit, int statuses)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
routerinfo_t *router;
|
routerinfo_t *router;
|
||||||
routerstatus_t *status;
|
routerstatus_t *status;
|
||||||
int32_t *bandwidths;
|
int32_t *bandwidths;
|
||||||
@ -1182,7 +1182,7 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, int for_exit, int statuses)
|
|||||||
bandwidths = tor_malloc(sizeof(int32_t)*smartlist_len(sl));
|
bandwidths = tor_malloc(sizeof(int32_t)*smartlist_len(sl));
|
||||||
|
|
||||||
/* Iterate over all the routerinfo_t or routerstatus_t, and */
|
/* Iterate over all the routerinfo_t or routerstatus_t, and */
|
||||||
for (i = 0; i < smartlist_len(sl); ++i) {
|
for (i = 0; i < (unsigned)smartlist_len(sl); ++i) {
|
||||||
/* first, learn what bandwidth we think i has */
|
/* first, learn what bandwidth we think i has */
|
||||||
int is_known = 1;
|
int is_known = 1;
|
||||||
int32_t flags = 0;
|
int32_t flags = 0;
|
||||||
@ -1232,7 +1232,7 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, int for_exit, int statuses)
|
|||||||
avg_fast = 40000;
|
avg_fast = 40000;
|
||||||
avg_slow = 20000;
|
avg_slow = 20000;
|
||||||
}
|
}
|
||||||
for (i=0; i<smartlist_len(sl); ++i) {
|
for (i=0; i<(unsigned)smartlist_len(sl); ++i) {
|
||||||
int32_t bw = bandwidths[i];
|
int32_t bw = bandwidths[i];
|
||||||
if (bw>=0)
|
if (bw>=0)
|
||||||
continue;
|
continue;
|
||||||
@ -1283,7 +1283,7 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, int for_exit, int statuses)
|
|||||||
|
|
||||||
/* Last, count through sl until we get to the element we picked */
|
/* Last, count through sl until we get to the element we picked */
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
for (i=0; i < smartlist_len(sl); i++) {
|
for (i=0; i < (unsigned)smartlist_len(sl); i++) {
|
||||||
if (statuses) {
|
if (statuses) {
|
||||||
status = smartlist_get(sl, i);
|
status = smartlist_get(sl, i);
|
||||||
is_exit = status->is_exit;
|
is_exit = status->is_exit;
|
||||||
@ -1298,7 +1298,7 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, int for_exit, int statuses)
|
|||||||
if (tmp >= rand_bw)
|
if (tmp >= rand_bw)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == smartlist_len(sl)) {
|
if (i == (unsigned)smartlist_len(sl)) {
|
||||||
/* This is possible due to round-off error. */
|
/* This is possible due to round-off error. */
|
||||||
--i;
|
--i;
|
||||||
log_warn(LD_BUG, "Round-off error in computing bandwidth had an effect on "
|
log_warn(LD_BUG, "Round-off error in computing bandwidth had an effect on "
|
||||||
|
Loading…
Reference in New Issue
Block a user