From 7e509b1b8b5a3679094f794cd9334598aef4441e Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Fri, 23 May 2014 17:01:38 +0100 Subject: [PATCH] common/config.cc: allow integer values to be parsed as SI units We are allowing this for all and any integer values; that is, OPT_INT, OPT_LONGLONG, OPT_U32 and OPT_U64. It's on the user to use appropriate units. For instance, the user should not use 'E(xabyte)' when setting a signed int, and use his best judgment when setting options that, for instance, ought to receive seconds. Fixes: 8265 Signed-off-by: Joao Eduardo Luis (cherry picked from commit 5500437e064cd6b4b45d63ee9396193df87f4d44) --- src/common/config.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/config.cc b/src/common/config.cc index 0ee7f58c240d6..0e28a83b0a44c 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -879,7 +879,7 @@ int md_config_t::set_val_raw(const char *val, const config_option *opt) switch (opt->type) { case OPT_INT: { std::string err; - int f = strict_strtol(val, 10, &err); + int f = strict_sistrtoll(val, &err); if (!err.empty()) return -EINVAL; *(int*)opt->conf_ptr(this) = f; @@ -887,7 +887,7 @@ int md_config_t::set_val_raw(const char *val, const config_option *opt) } case OPT_LONGLONG: { std::string err; - long long f = strict_strtoll(val, 10, &err); + long long f = strict_sistrtoll(val, &err); if (!err.empty()) return -EINVAL; *(long long*)opt->conf_ptr(this) = f; @@ -917,7 +917,7 @@ int md_config_t::set_val_raw(const char *val, const config_option *opt) return 0; case OPT_U32: { std::string err; - int f = strict_strtol(val, 10, &err); + int f = strict_sistrtoll(val, &err); if (!err.empty()) return -EINVAL; *(uint32_t*)opt->conf_ptr(this) = f; @@ -925,7 +925,7 @@ int md_config_t::set_val_raw(const char *val, const config_option *opt) } case OPT_U64: { std::string err; - long long f = strict_strtoll(val, 10, &err); + long long f = strict_sistrtoll(val, &err); if (!err.empty()) return -EINVAL; *(uint64_t*)opt->conf_ptr(this) = f; -- 2.39.5