From 24a90d2d3a2bea5a377a674982f23666ad0f6aa8 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 27 Jul 2018 14:18:24 +0800 Subject: [PATCH] common/config: do not use magic number in set_mon_vals() before this change, we compare the retcode of _set_val() with 1, and 0, which are pratically magic numbers. after this change, we use ConfigValues::set_value_result_t for non-error retcode. Signed-off-by: Kefu Chai --- src/common/config.cc | 14 +++++++------- src/common/config.h | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/common/config.cc b/src/common/config.cc index 26d3c4da78f..0678b9d05d8 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -297,10 +297,11 @@ int md_config_t::set_mon_vals(CephContext *cct, lderr(cct) << __func__ << " failed to set " << i.first << " = " << i.second << ": " << err << dendl; ignored_mon_values.emplace(i); - } else if (r == 0) { + } else if (r == ConfigValues::SET_NO_CHANGE || + r == ConfigValues::SET_NO_EFFECT) { ldout(cct,20) << __func__ << " " << i.first << " = " << i.second << " (no change)" << dendl; - } else if (r == 1) { + } else if (r == ConfigValues::SET_HAVE_EFFECT) { ldout(cct,10) << __func__ << " " << i.first << " = " << i.second << dendl; } else { ceph_abort(); @@ -1285,17 +1286,16 @@ int md_config_t::_set_val( auto result = values.set_value(opt.name, std::move(new_value), level); switch (result) { case ConfigValues::SET_NO_CHANGE: - return 0; + break; case ConfigValues::SET_NO_EFFECT: values_bl.clear(); - return 0; + break; case ConfigValues::SET_HAVE_EFFECT: - // fallthrough - default: values_bl.clear(); _refresh(values, opt); - return 1; + break; } + return result; } void md_config_t::_refresh(ConfigValues& values, const Option& opt) diff --git a/src/common/config.h b/src/common/config.h index 85b814f30d0..503e57b1473 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -288,6 +288,8 @@ private: std::vector& args, std::ostream *oss); + // @returns negative number for an error, otherwise a + // @c ConfigValues::set_value_result_t is returned. int _set_val( ConfigValues& values, const ConfigTracker& tracker, -- 2.39.5