Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove return type of xbt_cfg_set_as_string()
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 29 Apr 2016 14:39:50 +0000 (16:39 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 29 Apr 2016 14:43:04 +0000 (16:43 +0200)
It was not used and was not correctly set for the string type branch.

include/xbt/config.h
src/xbt/config.cpp

index 71aaab5..b995d5e 100644 (file)
@@ -96,7 +96,7 @@ XBT_PUBLIC(void) xbt_cfg_set_int       (const char *name, int val);
 XBT_PUBLIC(void) xbt_cfg_set_double    (const char *name, double val);
 XBT_PUBLIC(void) xbt_cfg_set_string    (const char *name, const char *val);
 XBT_PUBLIC(void) xbt_cfg_set_boolean   (const char *name, const char *val);
-XBT_PUBLIC(void*) xbt_cfg_set_as_string(const char *name, const char *val);
+XBT_PUBLIC(void) xbt_cfg_set_as_string(const char *name, const char *val);
 
 /*
   Set the default value of the cell \a name in \a cfg with the provided value.
index 45c09e8..acc34ba 100644 (file)
@@ -533,11 +533,9 @@ void xbt_cfg_set_parse(const char *options)
  *
  * @param key name of the variable to modify
  * @param value string representation of the value to set
- *
- * @return the first char after the parsed value in val
  */
 
-void *xbt_cfg_set_as_string(const char *key, const char *value)
+void xbt_cfg_set_as_string(const char *key, const char *value)
 {
   simgrid::config::ConfigurationElement* variable = (*simgrid_config)[key];
   if (variable == nullptr)
@@ -553,27 +551,23 @@ void *xbt_cfg_set_as_string(const char *key, const char *value)
     break;
   case xbt_cfgelm_int:
     i = strtol(value, &ret, 0);
-    if (ret == value) {
+    if (ret == value || *ret != '\0')
       xbt_die("Value of option %s not valid. Should be an integer", key);
-    }
     xbt_cfg_set_int(key, i);  /* throws */
     break;
   case xbt_cfgelm_double:
     d = strtod(value, &ret);
-    if (ret == value) {
+    if (ret == value || *ret != '\0')
       xbt_die("Value of option %s not valid. Should be a double", key);
-    }
     xbt_cfg_set_double(key, d);       /* throws */
     break;
   case xbt_cfgelm_boolean:
     xbt_cfg_set_boolean(key, value);  /* throws */
-    ret = (char *)value + strlen(value);
     break;
   default:
     THROWF(unknown_error, 0, "Type of config element %s is not valid.", key);
     break;
   }
-  return ret;
 }
 
 /** @brief Set an integer value to \a name within \a cfg if it wasn't changed yet