Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
boolean can only take true or false as a value, don't fear
[simgrid.git] / src / surf / surf_routing_floyd.cpp
index 48a6941..b1b6909 100644 (file)
@@ -134,17 +134,14 @@ static int floyd_pointer_resource_cmp(const void *a, const void *b) {
 
 void AsFloyd::parseRoute(sg_platf_route_cbarg_t route)
 {
-  char *src = (char*)(route->src);
-  char *dst = (char*)(route->dst);
-
-  int as_route = 0;
+  const char *src = route->src;
+  const char *dst = route->dst;
 
   /* set the size of table routing */
   int table_size = (int)xbt_dynar_length(vertices_);
-  NetCard *src_net_elm, *dst_net_elm;
 
-  src_net_elm = sg_netcard_by_name_or_null(src);
-  dst_net_elm = sg_netcard_by_name_or_null(dst);
+  NetCard *src_net_elm = sg_netcard_by_name_or_null(src);
+  NetCard *dst_net_elm = sg_netcard_by_name_or_null(dst);
 
   xbt_assert(src_net_elm, "Network elements %s not found", src);
   xbt_assert(dst_net_elm, "Network elements %s not found", dst);
@@ -168,7 +165,6 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route)
   if(!route->gw_dst && !route->gw_src)
     XBT_DEBUG("Load Route from \"%s\" to \"%s\"", src, dst);
   else{
-    as_route = 1;
     XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", src,
         route->gw_src->name(), dst, route->gw_dst->name());
     if(route->gw_dst->getRcType() == SURF_NETWORK_ELEMENT_NULL)
@@ -204,22 +200,17 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route)
         ((TO_FLOYD_LINK(src_net_elm->id(), dst_net_elm->id()))->link_list)->used;   /* count of links, old model assume 1 */
   }
 
-  if ( (route->symmetrical == TRUE && as_route == 0)
-      || (route->symmetrical == TRUE && as_route == 1)
-  )
-  {
+  if (route->symmetrical == TRUE) {
     if(TO_FLOYD_LINK(dst_net_elm->id(), src_net_elm->id()))
     {
       if(!route->gw_dst && !route->gw_src)
         XBT_DEBUG("See Route from \"%s\" to \"%s\"", dst, src);
       else
-        XBT_DEBUG("See ASroute from \"%s(%s)\" to \"%s(%s)\"", dst,
-            route->gw_src->name(), src, route->gw_dst->name());
+        XBT_DEBUG("See ASroute from \"%s(%s)\" to \"%s(%s)\"", dst, route->gw_src->name(), src, route->gw_dst->name());
+
       char * link_name;
-      unsigned int i;
       xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
-      for(i=xbt_dynar_length(route->link_list) ;i>0 ;i--)
-      {
+      for(int i=xbt_dynar_length(route->link_list) ;i>0 ;i--) {
         link_name = xbt_dynar_get_as(route->link_list,i-1,char *);
         void *link = Link::byName(link_name);
         xbt_assert(link,"Link : '%s' doesn't exists.",link_name);
@@ -231,14 +222,12 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route)
           (int_f_cpvoid_cpvoid_t) floyd_pointer_resource_cmp),
           "The route between \"%s\" and \"%s\" already exists", src,dst);
     }
-    else
-    {
-      if(route->gw_dst && route->gw_src)
-      {
-        sg_netcard_t gw_src = route->gw_src;
-        sg_netcard_t gw_dst = route->gw_dst;
-        route->gw_src = gw_dst;
-        route->gw_dst = gw_src;
+    else {
+
+      if(route->gw_dst && route->gw_src) {
+        NetCard* gw_tmp = route->gw_src;
+        route->gw_src = route->gw_dst;
+        route->gw_dst = gw_tmp;
       }
 
       if(!route->gw_src && !route->gw_dst)