Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use new macros THROWF and RETHROWF.
[simgrid.git] / src / surf / surf_routing.c
index 2bc91e5..0493a95 100644 (file)
@@ -326,7 +326,7 @@ static void parse_S_router_lua(const char* router_id)
 static void parse_S_route_new_and_endpoints(const char *src_id, const char *dst_id)
 {
   if (src != NULL && dst != NULL && link_list != NULL)
-    THROW2(arg_error, 0, "Route between %s to %s can not be defined",
+    THROWF(arg_error, 0, "Route between %s to %s can not be defined",
            src_id, dst_id);
   src = src_id;
   dst = dst_id;
@@ -359,7 +359,7 @@ static void parse_S_route_new_and_endpoints_lua(const char *id_src, const char *
 static void parse_S_ASroute_new_and_endpoints(void)
 {
   if (src != NULL && dst != NULL && link_list != NULL)
-    THROW2(arg_error, 0, "Route between %s to %s can not be defined",
+    THROWF(arg_error, 0, "Route between %s to %s can not be defined",
            A_surfxml_ASroute_src, A_surfxml_ASroute_dst);
   src = A_surfxml_ASroute_src;
   dst = A_surfxml_ASroute_dst;
@@ -378,7 +378,7 @@ static void parse_S_ASroute_new_and_endpoints(void)
 static void parse_S_bypassRoute_new_and_endpoints(void)
 {
   if (src != NULL && dst != NULL && link_list != NULL)
-    THROW2(arg_error, 0,
+    THROWF(arg_error, 0,
            "Bypass Route between %s to %s can not be defined",
            A_surfxml_bypassRoute_src, A_surfxml_bypassRoute_dst);
   src = A_surfxml_bypassRoute_src;
@@ -550,7 +550,7 @@ static void parse_S_AS(char *AS_id, char *AS_routing)
     (*(current_routing->routing->unload)) ();
 
   } else {
-    THROW0(arg_error, 0, "All defined components must be belong to a AS");
+    THROWF(arg_error, 0, "All defined components must be belong to a AS");
   }
   /* set the new parse rules */
   (*(new_routing->routing->load)) ();
@@ -593,7 +593,7 @@ static void parse_E_AS(const char *AS_id)
 {
 
   if (current_routing == NULL) {
-    THROW1(arg_error, 0, "Close AS(%s), that never open", AS_id);
+    THROWF(arg_error, 0, "Close AS(%s), that never open", AS_id);
   } else {
     network_element_info_t info = NULL;
     xbt_assert1(!xbt_lib_get_or_null(as_router_lib,current_routing->name, ROUTING_ASR_LEVEL),
@@ -2672,7 +2672,7 @@ static route_extended_t rulebased_get_route(routing_component_t rc,
           if (link)
             xbt_dynar_push(links_list, &link);
           else
-            THROW1(mismatch_error, 0, "Link %s not found", new_link_name);
+            THROWF(mismatch_error, 0, "Link %s not found", new_link_name);
           xbt_free(new_link_name);
         }
       }
@@ -3147,7 +3147,7 @@ generic_new_route(e_surf_routing_hierarchy_t hierarchy,
       else
         xbt_dynar_unshift(links_id, &link);
     } else
-      THROW1(mismatch_error, 0, "Link %s not found", link_name);
+      THROWF(mismatch_error, 0, "Link %s not found", link_name);
   }
 
   return new_route;
@@ -3203,7 +3203,7 @@ generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy,
       else
         xbt_dynar_unshift(links_id, &link);
     } else
-      THROW1(mismatch_error, 0, "Link %s not found", link_name);
+      THROWF(mismatch_error, 0, "Link %s not found", link_name);
   }
 
   return new_e_route;
@@ -3353,8 +3353,8 @@ static void routing_parse_Scluster(void)
   char *cluster_state_file = A_surfxml_cluster_state_file;
   char *host_id, *groups, *link_id = NULL;
   char *router_id, *link_router, *link_backbone;
-  char *availability_file = bprintf("%s",cluster_availability_file);
-  char *state_file = bprintf("%s",cluster_state_file);
+  char *availability_file = xbt_strdup(cluster_availability_file);
+  char *state_file = xbt_strdup(cluster_state_file);
 
   if(xbt_dict_size(patterns)==0)
          patterns = xbt_dict_new();
@@ -3412,7 +3412,7 @@ static void routing_parse_Scluster(void)
       link_id = bprintf("%s_link_%d", cluster_id, start);
 
       xbt_dict_set(patterns, "radical", bprintf("%d", start), xbt_free);
-      temp_cluster_power = bprintf("%s",cluster_power);
+      temp_cluster_power = xbt_strdup(cluster_power);
       temp_cluster_power = replace_random_parameter(temp_cluster_power);
       XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%s\">", host_id, temp_cluster_power);
       A_surfxml_host_state = A_surfxml_host_state_ON;
@@ -3422,9 +3422,9 @@ static void routing_parse_Scluster(void)
       SURFXML_BUFFER_SET(host_availability, "1.0");
       SURFXML_BUFFER_SET(host_coordinates, "");
       xbt_free(availability_file);
-      availability_file = bprintf("%s",cluster_availability_file);
+      availability_file = xbt_strdup(cluster_availability_file);
       xbt_free(state_file);
-      state_file = bprintf("%s",cluster_state_file);
+      state_file = xbt_strdup(cluster_state_file);
       XBT_DEBUG("\tavailability_file=\"%s\"",xbt_str_varsubst(availability_file,patterns));
       XBT_DEBUG("\tstate_file=\"%s\"",xbt_str_varsubst(state_file,patterns));
       SURFXML_BUFFER_SET(host_availability_file, xbt_str_varsubst(availability_file,patterns));
@@ -3434,9 +3434,9 @@ static void routing_parse_Scluster(void)
       SURFXML_END_TAG(host);
 
 
-      temp_cluster_bw = bprintf("%s",cluster_bw);
+      temp_cluster_bw = xbt_strdup(cluster_bw);
       temp_cluster_bw = replace_random_parameter(temp_cluster_bw);
-      temp_cluster_lat = bprintf("%s",cluster_lat);
+      temp_cluster_lat = xbt_strdup(cluster_lat);
       temp_cluster_lat = replace_random_parameter(temp_cluster_lat);
       XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>", link_id,temp_cluster_bw, cluster_lat);
       A_surfxml_link_state = A_surfxml_link_state_ON;
@@ -3474,7 +3474,7 @@ static void routing_parse_Scluster(void)
         link_id = bprintf("%s_link_%d", cluster_id, i);
 
         xbt_dict_set(patterns, "radical", bprintf("%d", i), xbt_free);
-        temp_cluster_power = bprintf("%s",cluster_power);
+        temp_cluster_power = xbt_strdup(cluster_power);
         temp_cluster_power = replace_random_parameter(temp_cluster_power);
         XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%s\">", host_id, temp_cluster_power);
         A_surfxml_host_state = A_surfxml_host_state_ON;
@@ -3484,9 +3484,9 @@ static void routing_parse_Scluster(void)
         SURFXML_BUFFER_SET(host_availability, "1.0");
         SURFXML_BUFFER_SET(host_coordinates, "");
         xbt_free(availability_file);
-        availability_file = bprintf("%s",cluster_availability_file);
+        availability_file = xbt_strdup(cluster_availability_file);
         xbt_free(state_file);
-        state_file = bprintf("%s",cluster_state_file);
+        state_file = xbt_strdup(cluster_state_file);
         XBT_DEBUG("\tavailability_file=\"%s\"",xbt_str_varsubst(availability_file,patterns));
         XBT_DEBUG("\tstate_file=\"%s\"",xbt_str_varsubst(state_file,patterns));
         SURFXML_BUFFER_SET(host_availability_file, xbt_str_varsubst(availability_file,patterns));
@@ -3497,9 +3497,9 @@ static void routing_parse_Scluster(void)
 
         xbt_free(temp_cluster_power);
 
-        temp_cluster_bw = bprintf("%s",cluster_bw);
+        temp_cluster_bw = xbt_strdup(cluster_bw);
         temp_cluster_bw = replace_random_parameter(temp_cluster_bw);
-        temp_cluster_lat = bprintf("%s",cluster_lat);
+        temp_cluster_lat = xbt_strdup(cluster_lat);
         temp_cluster_lat = replace_random_parameter(temp_cluster_lat);
         XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>", link_id,temp_cluster_bw, cluster_lat);
         A_surfxml_link_state = A_surfxml_link_state_ON;
@@ -3546,10 +3546,10 @@ static void routing_parse_Scluster(void)
   SURFXML_END_TAG(router);
 
   //TODO
-  xbt_dict_set(patterns, "radical", bprintf("_router"), xbt_free);
-  temp_cluster_bw = bprintf("%s",cluster_bw);
+  xbt_dict_set(patterns, "radical", xbt_strdup("_router"), xbt_free);
+  temp_cluster_bw = xbt_strdup(cluster_bw);
   temp_cluster_bw = replace_random_parameter(temp_cluster_bw);
-  temp_cluster_lat = bprintf("%s",cluster_lat);
+  temp_cluster_lat = xbt_strdup(cluster_lat);
   temp_cluster_lat = replace_random_parameter(temp_cluster_lat);
   XBT_DEBUG("<link\tid=\"%s\" bw=\"%s\" lat=\"%s\"/>", link_router,temp_cluster_bw, temp_cluster_lat);
   A_surfxml_link_state = A_surfxml_link_state_ON;
@@ -3904,7 +3904,12 @@ static void routing_parse_Speer(void)
   XBT_DEBUG(" ");
 
   //xbt_dynar_free(&tab_elements_num);
-
+       free(host_id);
+       free(router_id);
+       free(link_router);
+       free(link_backbone);
+       free(link_id_up);
+       free(link_id_down);
   surfxml_bufferstack_pop(1);
 }
 
@@ -3939,12 +3944,12 @@ static void routing_parse_Srandom(void)
 
          /* Check user stupidities */
          if (max < min)
-           THROW2(arg_error, 0, "random->max < random->min (%f < %f)", max, min);
+           THROWF(arg_error, 0, "random->max < random->min (%f < %f)", max, min);
          if (mean < min)
-           THROW2(arg_error, 0, "random->mean < random->min (%f < %f)", mean,
+           THROWF(arg_error, 0, "random->mean < random->min (%f < %f)", mean,
                   min);
          if (mean > max)
-           THROW2(arg_error, 0, "random->mean > random->max (%f > %f)", mean,
+           THROWF(arg_error, 0, "random->mean > random->max (%f > %f)", mean,
                   max);
 
          /* normalize the mean and standard deviation before storing */
@@ -3952,7 +3957,7 @@ static void routing_parse_Srandom(void)
          random->std = std / (max - min);
 
          if (random->mean * (1 - random->mean) < random->std * random->std)
-           THROW2(arg_error, 0, "Invalid mean and standard deviation (%f and %f)",
+           THROWF(arg_error, 0, "Invalid mean and standard deviation (%f and %f)",
                   random->mean, random->std);
 
          XBT_DEBUG("id = '%s' min = '%f' max = '%f' mean = '%f' std_deviatinon = '%f' generator = '%d' seed = '%ld' radical = '%s'",