From: Gabriel Corona Date: Fri, 29 Apr 2016 14:39:50 +0000 (+0200) Subject: Remove return type of xbt_cfg_set_as_string() X-Git-Tag: v3_14~1294 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/1df58b45c8eecb117a590914af3534e5889a1c1f Remove return type of xbt_cfg_set_as_string() It was not used and was not correctly set for the string type branch. --- diff --git a/include/xbt/config.h b/include/xbt/config.h index 71aaab541f..b995d5efc1 100644 --- a/include/xbt/config.h +++ b/include/xbt/config.h @@ -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. diff --git a/src/xbt/config.cpp b/src/xbt/config.cpp index 45c09e8b05..acc34ba67f 100644 --- a/src/xbt/config.cpp +++ b/src/xbt/config.cpp @@ -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