diff --git a/src/lib/cc/simple_parser.cc b/src/lib/cc/simple_parser.cc index dbde486748..07c68e6e7c 100644 --- a/src/lib/cc/simple_parser.cc +++ b/src/lib/cc/simple_parser.cc @@ -101,6 +101,7 @@ SimpleParser::getInteger(isc::data::ConstElementPtr scope, const std::string& na << ") is not within expected range: (" << min << " - " << max << ")"); } + return (tmp); } @@ -163,6 +164,7 @@ SimpleParser::getPosition(const std::string& name, const data::ConstElementPtr p if (!elem) { return (parent->getPosition()); } + return (elem->getPosition()); } @@ -359,8 +361,9 @@ SimpleParser::parseIntTriplet(const ConstElementPtr& scope, << min_value << ") and max-" << name << " (" << max_value << ")"); } + return (util::Triplet(min_value, value, max_value)); } -}; // end of isc::dhcp namespace -}; // end of isc namespace +} // end of isc::dhcp namespace +} // end of isc namespace diff --git a/src/lib/cc/simple_parser.h b/src/lib/cc/simple_parser.h index b91ba54b3b..2d0fac60b0 100644 --- a/src/lib/cc/simple_parser.h +++ b/src/lib/cc/simple_parser.h @@ -66,7 +66,7 @@ typedef std::vector ParamsList; /// they're defined in a single place (the DhcpConfigParser had the defaults /// spread out in multiple files in multiple directories). class SimpleParser { - public: +public: /// @brief Checks that all required keywords are present. /// @@ -333,7 +333,7 @@ public: const std::string& name); }; -}; -}; +} +} #endif diff --git a/src/lib/dhcpsrv/cfg_globals.cc b/src/lib/dhcpsrv/cfg_globals.cc index 9b030f66a9..8d6d5a3356 100644 --- a/src/lib/dhcpsrv/cfg_globals.cc +++ b/src/lib/dhcpsrv/cfg_globals.cc @@ -81,7 +81,7 @@ struct CfgGlobalsChecks { for (auto it = CfgGlobals::nameToIndex.cbegin(); it != CfgGlobals::nameToIndex.cend(); ++it) { int idx = it->second; - if ((idx < 0) || (idx > CfgGlobals::MAX_INDEX)) { + if ((idx < 0) || (idx >= CfgGlobals::SIZE)) { isc_throw(Unexpected, "invalid index " << idx << " for name " << it->first); } @@ -93,7 +93,7 @@ struct CfgGlobalsChecks { } // No name should be empty. - for (int idx = 0; idx <= CfgGlobals::MAX_INDEX; ++idx) { + for (int idx = 0; idx < CfgGlobals::SIZE; ++idx) { if (names[idx].empty()) { isc_throw(Unexpected, "missing name for " << idx); } @@ -118,7 +118,7 @@ CfgGlobals::get(const std::string& name) const { ConstElementPtr CfgGlobals::get(int index) const { - if ((index < 0) || (index > MAX_INDEX)) { + if ((index < 0) || (index >= CfgGlobals::SIZE)) { isc_throw(OutOfRange, "invalid global parameter index " << index); } return (values_[index]); @@ -135,7 +135,7 @@ CfgGlobals::set(const std::string& name, ConstElementPtr value) { void CfgGlobals::set(int index, ConstElementPtr value) { - if ((index < 0) || (index > MAX_INDEX)) { + if ((index < 0) || (index >= CfgGlobals::SIZE)) { isc_throw(OutOfRange, "invalid global parameter index " << index); } values_[index] = value; @@ -143,7 +143,7 @@ CfgGlobals::set(int index, ConstElementPtr value) { void CfgGlobals::clear() { - for (int idx = 0; idx <= MAX_INDEX; ++idx) { + for (int idx = 0; idx < CfgGlobals::SIZE; ++idx) { if (values_[idx]) { values_[idx] = ConstElementPtr(); } diff --git a/src/lib/dhcpsrv/cfg_globals.h b/src/lib/dhcpsrv/cfg_globals.h index fa051756a9..1f7dfae4cc 100644 --- a/src/lib/dhcpsrv/cfg_globals.h +++ b/src/lib/dhcpsrv/cfg_globals.h @@ -84,17 +84,12 @@ public: DATA_DIRECTORY, PREFERRED_LIFETIME, MIN_PREFERRED_LIFETIME, - MAX_PREFERRED_LIFETIME + MAX_PREFERRED_LIFETIME, + + // Size sentinel. + SIZE }; - /// @brief Last index. - /// - /// @note: please update when a new element is appended to the Index enum. - static const int MAX_INDEX = MAX_PREFERRED_LIFETIME; - - /// @brief Size of configured global objects. - static const size_t SIZE = MAX_INDEX + 1; - /// @brief Name to index map. static const std::map nameToIndex;