Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Avoid needless loop.
[simgrid.git] / teshsuite / simdag / evaluate-get-route-time / evaluate-get-route-time.c
index 0c674e8..ff86f3a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2018. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -28,13 +28,15 @@ 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++;
 
-  sg_host_t h1 = hosts[i];
-  sg_host_t h2 = hosts[j];
+  const_sg_host_t h1 = hosts[i];
+  const_sg_host_t h2 = hosts[j];
   printf("%d\tand\t%d\t\t",i,j);
   xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);