]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/config: normalize the default value
authorSage Weil <sage@redhat.com>
Wed, 31 Jan 2018 21:50:00 +0000 (15:50 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:50 +0000 (14:44 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config.cc

index 5693dd5d32a2965b00c9485997ba4f9ebaf64477..8665707c9583c6a7123c5f340314413811cc704d 100644 (file)
@@ -188,8 +188,9 @@ md_config_t::md_config_t(bool is_daemon)
       // We call pre_validate as a sanity check, but also to get any
       // side effect (value modification) from the validator.
       std::string *def_str = boost::get<std::string>(&default_val);
+      std::string val = *def_str;
       std::string err;
-      if (opt.pre_validate(def_str, &err) != 0) {
+      if (opt.pre_validate(&val, &err) != 0) {
         std::cerr << "Default value " << opt.name << "=" << *def_str << " is "
                      "invalid: " << err << std::endl;
 
@@ -198,6 +199,11 @@ md_config_t::md_config_t(bool is_daemon)
         // past a pull request: crash out.
         ceph_abort();
       }
+      if (val != *def_str) {
+       // if the validator normalizes the string into a different form than
+       // what was compiled in, use that.
+       set_val_default(opt.name, val);
+      }
     }
   }