Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
don't trust globals to be memset'ed to 0 (and rework a message)
[simgrid.git] / src / surf / surf_routing.c
index 6bac929..ed2c35d 100644 (file)
@@ -19,7 +19,7 @@ int SURF_WKS_LEVEL;             //Surf workstation level
 int SIMIX_HOST_LEVEL;           //Simix level
 int MSG_HOST_LEVEL;             //Msg level
 int SD_HOST_LEVEL;              //Simdag level
-int COORD_HOST_LEVEL;           //Coordinates level
+int COORD_HOST_LEVEL=0;         //Coordinates level
 int NS3_HOST_LEVEL;             //host node for ns3
 
 xbt_lib_t link_lib;
@@ -107,7 +107,7 @@ static void parse_S_host(sg_platf_host_cbarg_t host)
   if (host->coord && strcmp(host->coord, "")) {
     if (!COORD_HOST_LEVEL)
       xbt_die
-          ("To use coordinates, you must set configuration 'coordinates' to 'yes'");
+          ("To use host coordinates, please add --cfg=coordinates:yes to your command line");
     xbt_dynar_t ctn = xbt_str_split_str(host->coord, " ");
     xbt_dynar_shrink(ctn, 0);
     xbt_lib_set(host_lib, host->id, COORD_HOST_LEVEL, (void *) ctn);
@@ -225,8 +225,8 @@ static void routing_parse_link_ctn(void)
  */
 static void routing_parse_E_route(void)
 {
-  route_extended_t route = xbt_new0(s_route_extended_t, 1);
-  route->generic_route.link_list = link_list;
+  route_t route = xbt_new0(s_route_t, 1);
+  route->link_list = link_list;
   xbt_assert(current_routing->parse_route,
              "no defined method \"set_route\" in \"%s\"",
              current_routing->name);
@@ -241,8 +241,8 @@ static void routing_parse_E_route(void)
  */
 static void routing_parse_E_ASroute(void)
 {
-  route_extended_t e_route = xbt_new0(s_route_extended_t, 1);
-  e_route->generic_route.link_list = link_list;
+  route_t e_route = xbt_new0(s_route_t, 1);
+  e_route->link_list = link_list;
   e_route->src_gateway = xbt_strdup(gw_src);
   e_route->dst_gateway = xbt_strdup(gw_dst);
   xbt_assert(current_routing->parse_ASroute,
@@ -261,8 +261,8 @@ static void routing_parse_E_ASroute(void)
  */
 static void routing_parse_E_bypassRoute(void)
 {
-  route_extended_t e_route = xbt_new0(s_route_extended_t, 1);
-  e_route->generic_route.link_list = link_list;
+  route_t e_route = xbt_new0(s_route_t, 1);
+  e_route->link_list = link_list;
   e_route->src_gateway = xbt_strdup(gw_src);
   e_route->dst_gateway = xbt_strdup(gw_dst);
   xbt_assert(current_routing->parse_bypassroute,
@@ -464,8 +464,8 @@ static void elements_father(const char *src, const char *dst,
  * This function is called by "get_route" and "get_latency". It allows to walk
  * recursively through the routing components tree.
  */
-static void _get_route_latency(const char *src, const char *dst,
-                               xbt_dynar_t * route, double *latency)
+static void _get_route_and_latency(const char *src, const char *dst,
+                                   xbt_dynar_t * route, double *latency)
 {
   XBT_DEBUG("Solve route/latency  \"%s\" to \"%s\"", src, dst);
   xbt_assert(src && dst, "bad parameters for \"_get_route_latency\" method");
@@ -477,11 +477,11 @@ static void _get_route_latency(const char *src, const char *dst,
 
   if (src_father == dst_father) {       /* SURF_ROUTING_BASE */
 
-    route_extended_t e_route = NULL;
+    route_t e_route = NULL;
     if (route) {
       e_route = common_father->get_route(common_father, src, dst);
       xbt_assert(e_route, "no route between \"%s\" and \"%s\"", src, dst);
-      *route = e_route->generic_route.link_list;
+      *route = e_route->link_list;
     }
     if (latency) {
       *latency = common_father->get_latency(common_father, src, dst, e_route);
@@ -496,14 +496,14 @@ static void _get_route_latency(const char *src, const char *dst,
 
   } else {                      /* SURF_ROUTING_RECURSIVE */
 
-    route_extended_t e_route_bypass = NULL;
+    route_t e_route_bypass = NULL;
     if (common_father->get_bypass_route)
       e_route_bypass = common_father->get_bypass_route(common_father, src, dst);
 
     xbt_assert(!latency || !e_route_bypass,
                "Bypass cannot work yet with get_latency");
 
-    route_extended_t e_route_cnt = e_route_bypass
+    route_t e_route_cnt = e_route_bypass
         ? e_route_bypass : common_father->get_route(common_father,
                                                     src_father->name,
                                                     dst_father->name);
@@ -534,7 +534,7 @@ static void _get_route_latency(const char *src, const char *dst,
       double latency_src;
       xbt_dynar_t route_src;
 
-      _get_route_latency(src, e_route_cnt->src_gateway,
+      _get_route_and_latency(src, e_route_cnt->src_gateway,
                          (route ? &route_src : NULL),
                          (latency ? &latency_src : NULL));
       if (route) {
@@ -554,7 +554,7 @@ static void _get_route_latency(const char *src, const char *dst,
     }
 
     if (route) {
-      xbt_dynar_foreach(e_route_cnt->generic_route.link_list, cpt, link) {
+      xbt_dynar_foreach(e_route_cnt->link_list, cpt, link) {
         xbt_dynar_push(*route, &link);
       }
     }
@@ -563,7 +563,7 @@ static void _get_route_latency(const char *src, const char *dst,
       double latency_dst;
       xbt_dynar_t route_dst;
 
-      _get_route_latency(e_route_cnt->dst_gateway, dst,
+      _get_route_and_latency(e_route_cnt->dst_gateway, dst,
                          (route ? &route_dst : NULL),
                          (latency ? &latency_dst : NULL));
       if (route) {
@@ -582,7 +582,7 @@ static void _get_route_latency(const char *src, const char *dst,
       }
     }
 
-    generic_free_extended_route(e_route_cnt);
+    generic_free_route(e_route_cnt);
   }
 }
 
@@ -594,7 +594,7 @@ void routing_get_route_and_latency(const char *src, const char *dst,
 {
   static xbt_dynar_t last_route = NULL;
 
-  _get_route_latency(src, dst, route, latency);
+  _get_route_and_latency(src, dst, route, latency);
   xbt_assert(!route || *route, "no route between \"%s\" and \"%s\"", src, dst);
   xbt_assert(!latency || *latency >= 0.0,
              "latency error on route between \"%s\" and \"%s\"", src, dst);
@@ -1075,7 +1075,7 @@ static void routing_parse_Srandom(void)
        random_id, random->min, random->max, random->mean, random->std,
        random->generator, random->seed, random_radical);
 
-  if (xbt_dict_size(random_value) == 0)
+  if (!random_value)
     random_value = xbt_dict_new();
 
   if (!strcmp(random_radical, "")) {