[or-cvs] r10925: Better fix for GCC 4.2 warning on routerlist.c (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Wed Jul 25 22:56:37 UTC 2007


Author: nickm
Date: 2007-07-25 18:56:34 -0400 (Wed, 25 Jul 2007)
New Revision: 10925

Modified:
   tor/trunk/
   tor/trunk/src/or/routerlist.c
Log:
 r13900 at catbus:  nickm | 2007-07-25 16:16:30 -0400
 Better fix for GCC 4.2 warning on routerlist.c



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13900] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-07-25 22:19:16 UTC (rev 10924)
+++ tor/trunk/src/or/routerlist.c	2007-07-25 22:56:34 UTC (rev 10925)
@@ -1165,7 +1165,7 @@
 static void *
 smartlist_choose_by_bandwidth(smartlist_t *sl, int for_exit, int statuses)
 {
-  int i;
+  unsigned int i;
   routerinfo_t *router;
   routerstatus_t *status;
   int32_t *bandwidths;
@@ -1182,7 +1182,7 @@
   bandwidths = tor_malloc(sizeof(int32_t)*smartlist_len(sl));
 
   /* 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 */
     int is_known = 1;
     int32_t flags = 0;
@@ -1232,7 +1232,7 @@
       avg_fast = 40000;
       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];
       if (bw>=0)
         continue;
@@ -1283,7 +1283,7 @@
 
   /* Last, count through sl until we get to the element we picked */
   tmp = 0;
-  for (i=0; i < smartlist_len(sl); i++) {
+  for (i=0; i < (unsigned)smartlist_len(sl); i++) {
     if (statuses) {
       status = smartlist_get(sl, i);
       is_exit = status->is_exit;
@@ -1298,7 +1298,7 @@
     if (tmp >= rand_bw)
       break;
   }
-  if (i == smartlist_len(sl)) {
+  if (i == (unsigned)smartlist_len(sl)) {
     /* This is possible due to round-off error. */
     --i;
     log_warn(LD_BUG, "Round-off error in computing bandwidth had an effect on "



More information about the tor-commits mailing list