]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/config.cc: allow integer values to be parsed as SI units
authorJoao Eduardo Luis <joao.luis@inktank.com>
Fri, 23 May 2014 16:01:38 +0000 (17:01 +0100)
committerSage Weil <sage@redhat.com>
Sat, 16 Aug 2014 04:01:04 +0000 (21:01 -0700)
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 <joao.luis@inktank.com>
(cherry picked from commit 5500437e064cd6b4b45d63ee9396193df87f4d44)

src/common/config.cc

index 0ee7f58c240d65a2c6d09f73dec8dbd966e58fac..0e28a83b0a44cfcc82b1a1f6d47a8151674ff551 100644 (file)
@@ -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;