From: Arnaud Giersch Date: Thu, 6 Feb 2020 08:34:30 +0000 (+0100) Subject: Avoid needless loop. X-Git-Tag: v3.26~1029 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3d19df6eff777590cd26782f97dea0a454f677b3 Avoid needless loop. --- diff --git a/teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c b/teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c index d0dcfa99f7..ff86f3af60 100644 --- a/teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c +++ b/teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c @@ -28,10 +28,12 @@ int main(int argc, char **argv) /* Random number initialization */ srand( (int) (xbt_os_time()*1000) ); - do { - i = rand()%host_count; - j = rand()%host_count; - } while(i==j); + /* Take random i and j, with i != j */ + xbt_assert(host_count > 1); + i = rand() % host_count; + j = rand() % (host_count - 1); + if (j >= i) + j++; const_sg_host_t h1 = hosts[i]; const_sg_host_t h2 = hosts[j];