From 4683b9bba92ba70ef9ab7c169c2f9addd256c141 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 31 Jan 2018 15:50:00 -0600 Subject: [PATCH] common/config: normalize the default value Signed-off-by: Sage Weil --- src/common/config.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/config.cc b/src/common/config.cc index 5693dd5d32a..8665707c958 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -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(&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); + } } } -- 2.39.5