Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : stateful mode disabled by default
[simgrid.git] / src / xbt / config.c
index aa55aa6..87418cd 100644 (file)
@@ -33,7 +33,7 @@ typedef struct {
   /* Allowed type of the variable */
   e_xbt_cfgelm_type_t type;
   int min, max;
-  int isdefault:1;
+  unsigned isdefault:1;
 
   /* Callbacks */
   xbt_cfg_cb_t cb_set;
@@ -64,7 +64,7 @@ static xbt_cfgelm_t xbt_cfgelm_get(xbt_cfg_t cfg, const char *name,
 
 xbt_cfg_t xbt_cfg_new(void)
 {
-  return (xbt_cfg_t) xbt_dict_new();
+  return (xbt_cfg_t) xbt_dict_new_homogeneous(&xbt_cfgelm_free);
 }
 
 /** \brief Copy an existing configuration set
@@ -213,7 +213,7 @@ xbt_cfg_register(xbt_cfg_t * cfg,
     *cfg = xbt_cfg_new();
   xbt_assert(type >= xbt_cfgelm_int && type <= xbt_cfgelm_peer,
               "type of %s not valid (%d should be between %d and %d)",
-              name, type, xbt_cfgelm_int, xbt_cfgelm_peer);
+             name, (int)type, xbt_cfgelm_int, xbt_cfgelm_peer);
   res = xbt_dict_get_or_null((xbt_dict_t) * cfg, name);
 
   if (res) {
@@ -223,7 +223,7 @@ xbt_cfg_register(xbt_cfg_t * cfg,
 
   res = xbt_new(s_xbt_cfgelm_t, 1);
   XBT_DEBUG("Register cfg elm %s (%s) (%d to %d %s (=%d) @%p in set %p)",
-         name, desc, min, max, xbt_cfgelm_type_name[type], type, res,
+            name, desc, min, max, xbt_cfgelm_type_name[type], (int)type, res,
          *cfg);
 
   res->desc = xbt_strdup(desc);
@@ -260,10 +260,10 @@ xbt_cfg_register(xbt_cfg_t * cfg,
     break;
 
   default:
-    XBT_ERROR("%d is an invalide type code", type);
+    XBT_ERROR("%d is an invalide type code", (int)type);
   }
 
-  xbt_dict_set((xbt_dict_t) * cfg, name, res, &xbt_cfgelm_free);
+  xbt_dict_set((xbt_dict_t) * cfg, name, res, NULL);
 }
 
 /** @brief Unregister an element from a config set.
@@ -326,7 +326,7 @@ void xbt_cfg_register_str(xbt_cfg_t * cfg, const char *entry)
               "; Should be <name>:<min nb>_to_<max nb>_<type>");
   tok++;
 
-  for (type = 0;
+  for (type = (e_xbt_cfgelm_type_t)0;
        type < xbt_cfgelm_type_count
        && strcmp(tok, xbt_cfgelm_type_name[type]); type++);
   xbt_assert(type < xbt_cfgelm_type_count,
@@ -490,7 +490,7 @@ e_xbt_cfgelm_type_t xbt_cfg_get_type(xbt_cfg_t cfg, const char *name)
            "Can't get the type of '%s' since this variable does not exist",
            name);
 
-  XBT_INFO("type in variable = %d", variable->type);
+  XBT_INFO("type in variable = %d", (int)variable->type);
 
   return variable->type;
 }
@@ -509,7 +509,7 @@ void xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name, va_list pa)
   char *str;
   int i;
   double d;
-  e_xbt_cfgelm_type_t type = 0; /* Set a dummy value to make gcc happy. It cannot get uninitialized */
+  e_xbt_cfgelm_type_t type = xbt_cfgelm_any; /* Set a dummy value to make gcc happy. It cannot get uninitialized */
 
   xbt_ex_t e;
 
@@ -549,7 +549,7 @@ void xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name, va_list pa)
     break;
 
   default:
-    xbt_die("Config element variable %s not valid (type=%d)", name, type);
+    xbt_die("Config element variable %s not valid (type=%d)", name, (int)type);
   }
 }
 
@@ -595,7 +595,7 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options)
 
   int len;
 
-  XBT_IN("");
+  XBT_IN();
   if (!options || !strlen(options)) {   /* nothing to do */
     return;
   }
@@ -828,7 +828,7 @@ void xbt_cfg_set_int(xbt_cfg_t cfg, const char *name, int val)
   variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_int);
 
   if (variable->max == 1) {
-    if (variable->cb_rm && xbt_dynar_length(variable->content))
+    if (variable->cb_rm && !xbt_dynar_is_empty(variable->content))
       variable->cb_rm(name, 0);
 
     xbt_dynar_set(variable->content, 0, &val);
@@ -863,7 +863,7 @@ void xbt_cfg_set_double(xbt_cfg_t cfg, const char *name, double val)
   variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_double);
 
   if (variable->max == 1) {
-    if (variable->cb_rm && xbt_dynar_length(variable->content))
+    if (variable->cb_rm && !xbt_dynar_is_empty(variable->content))
       variable->cb_rm(name, 0);
 
     xbt_dynar_set(variable->content, 0, &val);
@@ -899,10 +899,10 @@ void xbt_cfg_set_string(xbt_cfg_t cfg, const char *name, const char *val)
   variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_string);
   XBT_DEBUG("Variable: %d to %d %s (=%d) @%p",
          variable->min, variable->max,
-         xbt_cfgelm_type_name[variable->type], variable->type, variable);
+            xbt_cfgelm_type_name[variable->type], (int)variable->type, variable);
 
   if (variable->max == 1) {
-    if (xbt_dynar_length(variable->content)) {
+    if (!xbt_dynar_is_empty(variable->content)) {
       if (variable->cb_rm)
         variable->cb_rm(name, 0);
       else if (variable->type == xbt_cfgelm_string) {
@@ -949,7 +949,7 @@ xbt_cfg_set_peer(xbt_cfg_t cfg, const char *name, const char *peer,
   variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_peer);
 
   if (variable->max == 1) {
-    if (variable->cb_rm && xbt_dynar_length(variable->content))
+    if (variable->cb_rm && !xbt_dynar_is_empty(variable->content))
       variable->cb_rm(name, 0);
 
     xbt_dynar_set(variable->content, 0, &val);
@@ -1245,7 +1245,7 @@ char *xbt_cfg_get_string(xbt_cfg_t cfg, const char *name)
     XBT_WARN
         ("You asked for the first value of the config element '%s', but there is %lu values\n",
          name, xbt_dynar_length(variable->content));
-  } else if (xbt_dynar_length(variable->content) == 0) {
+  } else if (xbt_dynar_is_empty(variable->content)) {
     return NULL;
   }
 
@@ -1359,8 +1359,7 @@ xbt_cfg_get_peer_at(xbt_cfg_t cfg, const char *name, int pos,
 #include "xbt.h"
 #include "xbt/ex.h"
 
-XBT_LOG_EXTERNAL_CATEGORY(xbt_cfg);
-XBT_LOG_DEFAULT_CATEGORY(xbt_cfg);
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_cfg);
 
 XBT_TEST_SUITE("config", "Configuration support");