]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/config: do not use magic number in set_mon_vals()
authorKefu Chai <kchai@redhat.com>
Fri, 27 Jul 2018 06:18:24 +0000 (14:18 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 28 Jul 2018 13:01:52 +0000 (21:01 +0800)
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 <kchai@redhat.com>
src/common/config.cc
src/common/config.h

index 26d3c4da78f11971799c87c1a60982fc84fdb4e9..0678b9d05d8d9f623e0b60fca7436edc199b8e9b 100644 (file)
@@ -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)
index 85b814f30d09ee6aa6949e921781eafcd52c150d..503e57b14739a06629cd86bc990be2a238399a11 100644 (file)
@@ -288,6 +288,8 @@ private:
                       std::vector<const char*>& 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,