From: Radoslaw Zarzynski Date: Tue, 13 Feb 2018 15:09:55 +0000 (+0100) Subject: log: prohibit negative values for debug_* configurables. X-Git-Tag: v13.0.2~150^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F20290%2Fhead;p=ceph.git log: prohibit negative values for debug_* configurables. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/common/config.cc b/src/common/config.cc index e16db0fe3226..6ab7fc47f5fc 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -325,8 +325,13 @@ int md_config_t::parse_config_files_impl(const std::list &conf_file int log, gather; int r = sscanf(val.c_str(), "%d/%d", &log, &gather); if (r >= 1) { - if (r < 2) + if (r < 2) { gather = log; + } + if (log < 0 || gather < 0) { + cerr << "ERROR for " << as_option << "." + << "log nor gather levels cannot be negative!"; + } // cout << "config subsys " << subsys.get_name(o) << " log " << log << " gather " << gather << std::endl; subsys.set_log_level(o, log); subsys.set_gather_level(o, gather); diff --git a/src/log/SubsystemMap.h b/src/log/SubsystemMap.h index 508263d1ba6e..94d5d382b55d 100644 --- a/src/log/SubsystemMap.h +++ b/src/log/SubsystemMap.h @@ -71,14 +71,21 @@ public: bool should_gather() { static_assert(SubV < get_num(), "wrong subsystem ID"); static_assert(LvlV >= -1 && LvlV <= 200); - return LvlV <= m_gather_levels[SubV]; + + if constexpr (LvlV <= 0) { + // handle the -1 and 0 levels entirely at compile-time. + // Such debugs are intended be gathered regardless even + // of the user configuration. + return true; + } else { + return LvlV <= static_cast(m_gather_levels[SubV]); + } } bool should_gather(const unsigned sub, int level) { assert(sub < m_subsys.size()); - return level <= m_gather_levels[sub]; + return level <= static_cast(m_gather_levels[sub]); } - // TODO(rzarzynski): verify the -1 case void set_log_level(unsigned subsys, uint8_t log) { assert(subsys < m_subsys.size());