Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
With optimizations, gcc 4.6 warns about clobbered variables
[simgrid.git] / src / xbt / config.c
index a5207db..13df108 100644 (file)
@@ -18,7 +18,6 @@
 #include "xbt/peer.h"
 
 #include "xbt/config.h"         /* prototypes of this module */
-#include "surf/surf.h"                 /* COORD_HOST_LEVEL and COORD_ASR_LEVEL */
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_cfg, xbt, "configuration support");
 
@@ -292,7 +291,7 @@ void xbt_cfg_unregister(xbt_cfg_t cfg, const char *name)
  * Each of them must use the following syntax: \<name\>:\<min nb\>_to_\<max nb\>_\<type\>
  * with type being one of  'string','int', 'peer' or 'double'.
  *
- * @fixme: this does not allow to set the description
+ * FIXME: this does not allow to set the description
  */
 
 void xbt_cfg_register_str(xbt_cfg_t * cfg, const char *entry)
@@ -516,7 +515,8 @@ void xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name, va_list pa)
 
   TRY {
     type = xbt_cfg_get_type(cfg, name);
-  } CATCH(e) {
+  }
+  CATCH(e) {
     if (e.category == not_found_error) {
       xbt_ex_free(e);
       THROWF(not_found_error, 0,
@@ -589,7 +589,7 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options)
   double d;
   char *str;
 
-  xbt_cfgelm_t variable = NULL;
+  volatile xbt_cfgelm_t variable = NULL;
   char *optionlist_cpy;
   char *option, *name, *val;
 
@@ -651,33 +651,21 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options)
     }
     *(val++) = '\0';
 
-    if (!strcmp(name,"coordinates")){
-       if(!strcmp(val,"yes") && !COORD_HOST_LEVEL){
-               XBT_INFO("Configuration change: Set '%s' to '%s'", name, val);
-                       COORD_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_dynar_free_voidp);
-                       COORD_ASR_LEVEL  = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp);
-                       free(optionlist_cpy);
-                       return;
-       }
-       if(strcmp(val,"yes"))
-               xbt_die("Setting CMD prop coordinates must be \"yes\"");
-    }
-
-    if (strcmp(name,"contexts/factory"))
+    if (strncmp(name, "contexts/", strlen("contexts/")))
       XBT_INFO("Configuration change: Set '%s' to '%s'", name, val);
 
     TRY {
       variable = xbt_dict_get((xbt_dict_t) cfg, name);
     }
     CATCH(e) {
-      /* put it back on what won't get freed, ie within "options" and out of "optionlist_cpy" */
-      name = (char *) (optionlist_cpy - name + options);
-      free(optionlist_cpy);
       if (e.category == not_found_error) {
         xbt_ex_free(e);
+        name = xbt_strdup(name);
+        free(optionlist_cpy);
         THROWF(not_found_error, 0,
                "No registered variable corresponding to '%s'.", name);
       }
+      free(optionlist_cpy);
       RETHROW;
     }
 
@@ -732,7 +720,7 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options)
                name);
       }
     }
-    CATCH(e) {
+    CATCH_ANONYMOUS {
       free(optionlist_cpy);
       RETHROW;
     }
@@ -1145,7 +1133,8 @@ void xbt_cfg_empty(xbt_cfg_t cfg, const char *name)
 
   TRY {
     variable = xbt_dict_get((xbt_dict_t) cfg, name);
-  } CATCH(e) {
+  }
+  CATCH(e) {
     if (e.category != not_found_error)
       RETHROW;
 
@@ -1306,7 +1295,8 @@ xbt_dynar_t xbt_cfg_get_dynar(xbt_cfg_t cfg, const char *name)
 
   TRY {
     variable = xbt_dict_get((xbt_dict_t) cfg, name);
-  } CATCH(e) {
+  }
+  CATCH(e) {
     if (e.category == not_found_error) {
       xbt_ex_free(e);
       THROWF(not_found_error, 0,
@@ -1485,7 +1475,8 @@ XBT_TEST_UNIT("use", test_config_use, "Data retrieving tests")
 
     TRY {
       xbt_cfg_set_parse(myset, "color:blue");
-    } CATCH(e) {
+    }
+    CATCH(e) {
       if (e.category != not_found_error)
         xbt_test_exception(e);
       xbt_ex_free(e);