diff --git a/doc/examples/kea6/all-options.json b/doc/examples/kea6/all-options.json index 369454fc7dd33b9426ba9ba3bbfc68e10ff8da99..295442ab4e53ef7d3fdba9acffaff1f4674d2a4a 100644 --- a/doc/examples/kea6/all-options.json +++ b/doc/examples/kea6/all-options.json @@ -1187,7 +1187,7 @@ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | OPTION_PD_EXCLUDE | option-len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | prefix-len | IPv6 subnet ID (1 to 16 octets) ~ + | prefix-len | IPv6 subnet ID (1 to 16 octets) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Prefix Exclude Option diff --git a/src/bin/agent/ca_cfg_mgr.cc b/src/bin/agent/ca_cfg_mgr.cc index f2f8caa92af346a926bb934347655550e0f942e8..d147e39a93e67f80350de1f3315bf8d6cc81b140 100644 --- a/src/bin/agent/ca_cfg_mgr.cc +++ b/src/bin/agent/ca_cfg_mgr.cc @@ -39,9 +39,6 @@ CtrlAgentCfgMgr::CtrlAgentCfgMgr() : DCfgMgrBase(ConfigPtr(new CtrlAgentCfgContext())) { } -CtrlAgentCfgMgr::~CtrlAgentCfgMgr() { -} - std::string CtrlAgentCfgMgr::getConfigSummary(const uint32_t /*selection*/) { diff --git a/src/bin/agent/ca_cfg_mgr.h b/src/bin/agent/ca_cfg_mgr.h index 943a8b4269949090caf9e01a04c7308d7a9063cc..065d1e5d2f186fe09b431299c4b163fb430ae063 100644 --- a/src/bin/agent/ca_cfg_mgr.h +++ b/src/bin/agent/ca_cfg_mgr.h @@ -257,7 +257,7 @@ public: CtrlAgentCfgMgr(); /// @brief Destructor - virtual ~CtrlAgentCfgMgr(); + virtual ~CtrlAgentCfgMgr() = default; /// @brief Convenience method that returns the Control Agent configuration /// context. diff --git a/src/bin/agent/ca_controller.cc b/src/bin/agent/ca_controller.cc index f8408315b4ac1852d747810f773ae06172763b56..20eff7397e129b0f2dea75d45c15eb8fd42271ea 100644 --- a/src/bin/agent/ca_controller.cc +++ b/src/bin/agent/ca_controller.cc @@ -98,9 +98,6 @@ CtrlAgentController::CtrlAgentController() : DControllerBase(agent_app_name_, agent_bin_name_) { } -CtrlAgentController::~CtrlAgentController() { -} - CtrlAgentProcessPtr CtrlAgentController::getCtrlAgentProcess() { return (boost::dynamic_pointer_cast(getProcess())); diff --git a/src/bin/agent/ca_controller.h b/src/bin/agent/ca_controller.h index 7d6b5aee3ef19237dc46e81443b870200021bc75..db67c28babb78739f885ad30596a3a30fc0807d7 100644 --- a/src/bin/agent/ca_controller.h +++ b/src/bin/agent/ca_controller.h @@ -31,7 +31,7 @@ public: static process::DControllerBasePtr& instance(); /// @brief Destructor - virtual ~CtrlAgentController(); + virtual ~CtrlAgentController() = default; /// @brief Returns pointer to an instance of the underlying process object. CtrlAgentProcessPtr getCtrlAgentProcess(); diff --git a/src/bin/agent/ca_process.cc b/src/bin/agent/ca_process.cc index 8c47377a781c3d747d235e131addf1459f5956a8..2b1f0f339618d6f69cd70efa066a0a1a9f8649fb 100644 --- a/src/bin/agent/ca_process.cc +++ b/src/bin/agent/ca_process.cc @@ -32,9 +32,6 @@ CtrlAgentProcess::CtrlAgentProcess(const char* name, http_listeners_() { } -CtrlAgentProcess::~CtrlAgentProcess() { -} - void CtrlAgentProcess::init() { } diff --git a/src/bin/agent/ca_process.h b/src/bin/agent/ca_process.h index 3e6e08418bfb7dd8499e4e464253fb4b49e18efe..acc8f643cc7583c64e719d6dbb07649ead8ef891 100644 --- a/src/bin/agent/ca_process.h +++ b/src/bin/agent/ca_process.h @@ -31,6 +31,7 @@ namespace agent { /// instructs the agent to start a specific service. class CtrlAgentProcess : public process::DProcessBase { public: + /// @brief Constructor /// /// @param name name is a text label for the process. Generally used @@ -40,7 +41,7 @@ public: CtrlAgentProcess(const char* name, const asiolink::IOServicePtr& io_service); /// @brief Destructor - virtual ~CtrlAgentProcess(); + virtual ~CtrlAgentProcess() = default; /// @brief Initialize the Control Agent process. /// @@ -149,7 +150,7 @@ private: /// @brief Defines a shared pointer to CtrlAgentProcess. typedef boost::shared_ptr CtrlAgentProcessPtr; -}; // namespace isc::agent -}; // namespace isc +} // namespace isc::agent +} // namespace isc #endif // CTRL_AGENT_PROCESS_H diff --git a/src/bin/agent/main.cc b/src/bin/agent/main.cc index 01fee6acb23ee4b798939c9ab3d40676a89cc7dd..2794b21640f7682b69b636d1bef90bb00f02d3cf 100644 --- a/src/bin/agent/main.cc +++ b/src/bin/agent/main.cc @@ -38,6 +38,8 @@ int main(int argc, char* argv[]) { } catch (const isc::Exception& ex) { std::cerr << "Service failed: " << ex.what() << std::endl; ret = EXIT_FAILURE; + } catch (...) { + ret = EXIT_FAILURE; } return (ret); diff --git a/src/bin/agent/parser_context.cc b/src/bin/agent/parser_context.cc index 18b2586e03e330a4a165cd2ca392ce2863a7fefc..26a9401da550065d54955af816144a45aaff027d 100644 --- a/src/bin/agent/parser_context.cc +++ b/src/bin/agent/parser_context.cc @@ -18,17 +18,11 @@ namespace isc { namespace agent { ParserContext::ParserContext() - : sfile_(0), ctx_(NO_KEYWORDS), trace_scanning_(false), trace_parsing_(false) -{ -} - -ParserContext::~ParserContext() -{ + : sfile_(0), ctx_(NO_KEYWORDS), trace_scanning_(false), trace_parsing_(false) { } isc::data::ElementPtr -ParserContext::parseString(const std::string& str, ParserType parser_type) -{ +ParserContext::parseString(const std::string& str, ParserType parser_type) { scanStringBegin(str, parser_type); return (parseCommon()); } @@ -71,8 +65,7 @@ ParserContext::parseCommon() { void ParserContext::error(const isc::agent::location& loc, const std::string& what, - size_t pos) -{ + size_t pos) { if (pos == 0) { isc_throw(ParseError, loc << ": " << what); } else { @@ -81,20 +74,17 @@ ParserContext::error(const isc::agent::location& loc, } void -ParserContext::error(const std::string& what) -{ +ParserContext::error(const std::string& what) { isc_throw(ParseError, what); } void -ParserContext::fatal(const std::string& what) -{ +ParserContext::fatal(const std::string& what) { isc_throw(ParseError, what); } isc::data::Element::Position -ParserContext::loc2pos(isc::agent::location& loc) -{ +ParserContext::loc2pos(isc::agent::location& loc) { const std::string& file = *loc.begin.filename; const uint32_t line = loc.begin.line; const uint32_t pos = loc.begin.column; @@ -104,8 +94,7 @@ ParserContext::loc2pos(isc::agent::location& loc) void ParserContext::require(const std::string& name, isc::data::Element::Position open_loc, - isc::data::Element::Position close_loc) -{ + isc::data::Element::Position close_loc) { ConstElementPtr value = stack_.back()->get(name); if (!value) { isc_throw(ParseError, @@ -118,8 +107,7 @@ ParserContext::require(const std::string& name, void ParserContext::unique(const std::string& name, - isc::data::Element::Position loc) -{ + isc::data::Element::Position loc) { ConstElementPtr value = stack_.back()->get(name); if (value) { if (ctx_ != NO_KEYWORDS) { @@ -135,15 +123,13 @@ ParserContext::unique(const std::string& name, } void -ParserContext::enter(const LexerContext& ctx) -{ +ParserContext::enter(const LexerContext& ctx) { cstack_.push_back(ctx_); ctx_ = ctx; } void -ParserContext::leave() -{ +ParserContext::leave() { if (cstack_.empty()) { fatal("unbalanced syntactic context"); } @@ -152,8 +138,7 @@ ParserContext::leave() } const std::string -ParserContext::contextName() -{ +ParserContext::contextName() { switch (ctx_) { case NO_KEYWORDS: return ("__no keywords__"); diff --git a/src/bin/agent/parser_context.h b/src/bin/agent/parser_context.h index b0b1406a5cb9360a58516ec983360469d70935d0..a17b1b11f55615a155f1eacc360feebd2e0d50c7 100644 --- a/src/bin/agent/parser_context.h +++ b/src/bin/agent/parser_context.h @@ -33,8 +33,7 @@ namespace agent { /// parse only content of the Control-agent object, which is a subset /// of full grammar (this will be very useful for unit-tests to not duplicate /// unnecessary parts of the config file). -class ParserContext -{ +class ParserContext { public: /// @brief Defines currently supported scopes @@ -59,8 +58,8 @@ public: /// @brief Default constructor. ParserContext(); - /// @brief destructor - virtual ~ParserContext(); + /// @brief destructor. + virtual ~ParserContext() = default; /// @brief JSON elements being parsed. std::vector stack_; diff --git a/src/bin/agent/tests/basic_auth_library.cc b/src/bin/agent/tests/basic_auth_library.cc index 924d656bc543f29c4dad6d3bec142bc68f43ab93..8d694a63f30f7c33e17fe113d447797e38c84db0 100644 --- a/src/bin/agent/tests/basic_auth_library.cc +++ b/src/bin/agent/tests/basic_auth_library.cc @@ -84,7 +84,7 @@ public: Impl(); /// @brief Destructor. - ~Impl(); + ~Impl() = default; /// @brief Configure. /// @@ -102,9 +102,6 @@ Impl::Impl() : config_(new BasicHttpAuthConfig()), creator_(new ResponseCreator()) { } -Impl::~Impl() { -} - void Impl::configure(ConstElementPtr config) { config_->parse(config); diff --git a/src/bin/agent/tests/ca_command_mgr_unittests.cc b/src/bin/agent/tests/ca_command_mgr_unittests.cc index 6353916be140e904732828058539de9797072e12..9913d9157190ab483170ed48e9df9b4d5188edac 100644 --- a/src/bin/agent/tests/ca_command_mgr_unittests.cc +++ b/src/bin/agent/tests/ca_command_mgr_unittests.cc @@ -58,8 +58,11 @@ public: /// /// Deregisters all commands except 'list-commands'. virtual ~CtrlAgentCommandMgrTest() { - mgr_.deregisterAll(); - removeUnixSocketFile(); + try { + mgr_.deregisterAll(); + removeUnixSocketFile(); + } catch (...) { + } } /// @brief Verifies received answer diff --git a/src/bin/agent/tests/ca_process_unittests.cc b/src/bin/agent/tests/ca_process_unittests.cc index 37e06f66edf8485eecc75922143a0d1d6f86e628..1f90c072ec278e387c04e4e50be5a9b0573bf388 100644 --- a/src/bin/agent/tests/ca_process_unittests.cc +++ b/src/bin/agent/tests/ca_process_unittests.cc @@ -25,6 +25,7 @@ namespace { /// @brief CtrlAgentProcess test fixture class. class CtrlAgentProcessTest : public CtrlAgentProcess, public ::testing::Test { public: + /// @brief Constructor CtrlAgentProcessTest() : CtrlAgentProcess("agent-test", @@ -35,8 +36,7 @@ public: } /// @brief Destructor - virtual ~CtrlAgentProcessTest() { - } + virtual ~CtrlAgentProcessTest() = default; /// @brief Callback that will invoke shutdown method. void genShutdownCallback() { @@ -86,5 +86,4 @@ TEST_F(CtrlAgentProcessTest, shutdown) { elapsed.total_milliseconds() <= 400); } - } diff --git a/src/bin/agent/tests/ca_response_creator_unittests.cc b/src/bin/agent/tests/ca_response_creator_unittests.cc index a50a15c49b7bb582338732ce64dee19895cf46cb..56b58049a3e6ac5deb543263b90f768438264769 100644 --- a/src/bin/agent/tests/ca_response_creator_unittests.cc +++ b/src/bin/agent/tests/ca_response_creator_unittests.cc @@ -71,9 +71,12 @@ public: /// /// Removes registered commands from the command manager. virtual ~CtrlAgentResponseCreatorTest() { - CtrlAgentCommandMgr::instance().deregisterAll(); - HooksManager::prepareUnloadLibraries(); - static_cast(HooksManager::unloadLibraries()); + try { + CtrlAgentCommandMgr::instance().deregisterAll(); + HooksManager::prepareUnloadLibraries(); + static_cast(HooksManager::unloadLibraries()); + } catch (...) { + } } /// @brief Fills request context with required data to create new request. diff --git a/src/bin/agent/tests/get_config_unittest.cc b/src/bin/agent/tests/get_config_unittest.cc index 2d557294edc44429e4fb80b3dac5758099751f18..feded55ed5656449fd480def1155efd18241db9b 100644 --- a/src/bin/agent/tests/get_config_unittest.cc +++ b/src/bin/agent/tests/get_config_unittest.cc @@ -120,6 +120,8 @@ public: /// Test fixture class class CtrlAgentGetCfgTest : public ConfigParseTest { public: + + /// @brief Constructor CtrlAgentGetCfgTest() : rcode_(-1) { srv_.reset(new NakedAgentCfgMgr()); @@ -127,8 +129,12 @@ public: resetConfiguration(); } + /// @brief Destructor ~CtrlAgentGetCfgTest() { - resetConfiguration(); + try { + resetConfiguration(); + } catch (...) { + } } /// @brief Parse and Execute configuration diff --git a/src/bin/d2/d2_cfg_mgr.cc b/src/bin/d2/d2_cfg_mgr.cc index da1ae21ca54f9948350459bf9c26ccab38320255..41eb9b4d74ef1791f8597a63cc3e7a726beaf454 100644 --- a/src/bin/d2/d2_cfg_mgr.cc +++ b/src/bin/d2/d2_cfg_mgr.cc @@ -55,9 +55,6 @@ D2CfgContext::D2CfgContext(const D2CfgContext& rhs) : ConfigBase(rhs) { control_socket_ = rhs.control_socket_; } -D2CfgContext::~D2CfgContext() { -} - ElementPtr D2CfgContext::toElement() const { ElementPtr d2 = ConfigBase::toElement(); @@ -117,9 +114,6 @@ const char* D2CfgMgr::IPV6_REV_ZONE_SUFFIX = "ip6.arpa."; D2CfgMgr::D2CfgMgr() : DCfgMgrBase(ConfigPtr(new D2CfgContext())) { } -D2CfgMgr::~D2CfgMgr() { -} - ConfigPtr D2CfgMgr::createNewContext() { return (ConfigPtr(new D2CfgContext())); diff --git a/src/bin/d2/d2_cfg_mgr.h b/src/bin/d2/d2_cfg_mgr.h index 199d4354867a9b8e47cc874c1d86d090cbdfd98e..8a7e085a98b148d066778d031209af9263c68361 100644 --- a/src/bin/d2/d2_cfg_mgr.h +++ b/src/bin/d2/d2_cfg_mgr.h @@ -32,11 +32,12 @@ typedef boost::shared_ptr D2CfgContextPtr; /// It is derived from the context base class, ConfigBase. class D2CfgContext : public process::ConfigBase { public: + /// @brief Constructor D2CfgContext(); /// @brief Destructor - virtual ~D2CfgContext(); + virtual ~D2CfgContext() = default; /// @brief Creates a clone of this context object. /// @@ -144,6 +145,7 @@ typedef boost::shared_ptr DdnsDomainListMgrPtr; /// and retrieving the information on demand. class D2CfgMgr : public process::DCfgMgrBase { public: + /// @brief Reverse zone suffix added to IPv4 addresses for reverse lookups /// @todo This should be configurable. static const char* IPV4_REV_ZONE_SUFFIX; @@ -156,7 +158,7 @@ public: D2CfgMgr(); /// @brief Destructor - virtual ~D2CfgMgr(); + virtual ~D2CfgMgr() = default; /// @brief Convenience method that returns the D2 configuration context. /// @@ -318,7 +320,7 @@ protected: typedef boost::shared_ptr D2CfgMgrPtr; -}; // end of isc::d2 namespace -}; // end of isc namespace +} // end of isc::d2 namespace +} // end of isc namespace #endif // D2_CFG_MGR_H diff --git a/src/bin/d2/d2_config.cc b/src/bin/d2/d2_config.cc index 74ff793f958e2a375642f543fe9a20a71d825053..f4f3caf66e34575b4583ffa933c992396d5fc55c 100644 --- a/src/bin/d2/d2_config.cc +++ b/src/bin/d2/d2_config.cc @@ -48,8 +48,6 @@ D2Params::D2Params() validateContents(); } -D2Params::~D2Params(){}; - void D2Params::validateContents() { if ((ip_address_.toText() == "0.0.0.0") || (ip_address_.toText() == "::")) { @@ -139,9 +137,6 @@ TSIGKeyInfo::TSIGKeyInfo(const std::string& name, const std::string& algorithm, remakeKey(); } -TSIGKeyInfo::~TSIGKeyInfo() { -} - const dns::Name& TSIGKeyInfo::stringToAlgorithmName(const std::string& algorithm_id) { if (boost::iequals(algorithm_id, HMAC_MD5_STR)) { @@ -207,9 +202,6 @@ DnsServerInfo::DnsServerInfo(const std::string& hostname, enabled_(enabled) { } -DnsServerInfo::~DnsServerInfo() { -} - std::string DnsServerInfo::toText() const { std::ostringstream stream; @@ -248,9 +240,6 @@ DdnsDomain::DdnsDomain(const std::string& name, tsig_key_info_(tsig_key_info) { } -DdnsDomain::~DdnsDomain() { -} - const std::string DdnsDomain::getKeyName() const { if (tsig_key_info_) { @@ -294,10 +283,6 @@ DdnsDomainListMgr::DdnsDomainListMgr(const std::string& name) : name_(name), domains_(new DdnsDomainMap()) { } - -DdnsDomainListMgr::~DdnsDomainListMgr () { -} - void DdnsDomainListMgr::setDomains(DdnsDomainMapPtr domains) { if (!domains) { diff --git a/src/bin/d2/d2_config.h b/src/bin/d2/d2_config.h index d15a39ec3f6f35a7e2f26ccc8b43f53888b3e4da..807aa36f2aaa6c3f0a37b67a575080896d25c485 100644 --- a/src/bin/d2/d2_config.h +++ b/src/bin/d2/d2_config.h @@ -141,6 +141,7 @@ public: /// @brief Acts as a storage vault for D2 global scalar parameters class D2Params { public: + /// @brief Constructor /// /// @param ip_address IP address at which D2 should listen for NCRs @@ -167,7 +168,7 @@ public: D2Params(); /// @brief Destructor - virtual ~D2Params(); + virtual ~D2Params() = default; /// @brief Return the IP address D2 listens on. const isc::asiolink::IOAddress& getIpAddress() const { @@ -309,7 +310,7 @@ public: const std::string& secret, uint32_t digestbits = 0); /// @brief Destructor - virtual ~TSIGKeyInfo(); + virtual ~TSIGKeyInfo() = default; /// @brief Getter which returns the key's name. /// @@ -437,10 +438,10 @@ public: DnsServerInfo(const std::string& hostname, isc::asiolink::IOAddress ip_address, uint32_t port = STANDARD_DNS_PORT, - bool enabled=true); + bool enabled = true); /// @brief Destructor - virtual ~DnsServerInfo(); + virtual ~DnsServerInfo() = default; /// @brief Getter which returns the server's hostname. /// @@ -529,6 +530,7 @@ typedef boost::shared_ptr DnsServerInfoStoragePtr; /// validation and matching capabilities. class DdnsDomain : public isc::data::UserContext, public isc::data::CfgToElement { public: + /// @brief Constructor /// /// @param name is the domain name of the domain. @@ -540,7 +542,7 @@ public: const TSIGKeyInfoPtr& tsig_key_info = TSIGKeyInfoPtr()); /// @brief Destructor - virtual ~DdnsDomain(); + virtual ~DdnsDomain() = default; /// @brief Getter which returns the domain's name. /// @@ -621,7 +623,7 @@ public: DdnsDomainListMgr(const std::string& name); /// @brief Destructor - virtual ~DdnsDomainListMgr (); + virtual ~DdnsDomainListMgr() = default; /// @brief Matches a given name to a domain based on a longest match /// scheme. @@ -710,12 +712,10 @@ class DScalarContext : public process::ConfigBase { public: /// @brief Constructor - DScalarContext() { - }; + DScalarContext() = default; /// @brief Destructor - virtual ~DScalarContext() { - } + virtual ~DScalarContext() = default; /// @brief Creates a clone of a DStubContext. /// @@ -891,8 +891,7 @@ public: const TSIGKeyInfoMapPtr keys); }; - -}; // end of isc::d2 namespace -}; // end of isc namespace +} // end of isc::d2 namespace +} // end of isc namespace #endif // D2_CONFIG_H diff --git a/src/bin/d2/d2_controller.cc b/src/bin/d2/d2_controller.cc index dc31b552b7676d387e5ccc71f8a40afdffde83ae..604c52dff6dc349234ad0e216ca047c1f11d8549 100644 --- a/src/bin/d2/d2_controller.cc +++ b/src/bin/d2/d2_controller.cc @@ -120,9 +120,6 @@ D2Controller::parseFile(const std::string& file_name) { return (elements); } -D2Controller::~D2Controller() { -} - // Refer to config_report so it will be embedded in the binary. const char* const* d2_config_report = isc::detail::config_report; diff --git a/src/bin/d2/d2_controller.h b/src/bin/d2/d2_controller.h index 6f61735828a53fc93cebc916b5840fdc9bcaefad..cb2f42d4cfffbad0f1c73ccaa16d0e68e1c9e778 100644 --- a/src/bin/d2/d2_controller.h +++ b/src/bin/d2/d2_controller.h @@ -36,7 +36,7 @@ public: static process::DControllerBasePtr& instance(); /// @brief Destructor. - virtual ~D2Controller(); + virtual ~D2Controller() = default; /// @brief Defines the application name, this is passed into base class /// and appears in log statements. @@ -79,15 +79,13 @@ private: /// @throw BadValue if the file is empty virtual isc::data::ConstElementPtr parseFile(const std::string& file_name); +protected: /// @brief Constructor is declared private to maintain the integrity of /// the singleton instance. D2Controller(); - - /// To facilitate unit testing. - friend class NakedD2Controller; }; -}; // namespace isc::d2 -}; // namespace isc +} // namespace isc::d2 +} // namespace isc #endif diff --git a/src/bin/d2/d2_process.cc b/src/bin/d2/d2_process.cc index f1838d52daf9cd323c5abbf8fb493f79ab574b26..64de96f21a67f5c0d98b476aa0aa252e716f56d5 100644 --- a/src/bin/d2/d2_process.cc +++ b/src/bin/d2/d2_process.cc @@ -376,9 +376,6 @@ D2Process::reconfigureQueueMgr() { } } -D2Process::~D2Process() { -}; - D2CfgMgrPtr D2Process::getD2CfgMgr() { // The base class gives a base class pointer to our configuration manager. diff --git a/src/bin/d2/d2_process.h b/src/bin/d2/d2_process.h index 5ca34222d3616a0166532c5acf6c6f80b510f268..bf66bb634d37a269165518ba40e01c04df002e74 100644 --- a/src/bin/d2/d2_process.h +++ b/src/bin/d2/d2_process.h @@ -160,7 +160,7 @@ public: bool check_only = false); /// @brief Destructor - virtual ~D2Process(); + virtual ~D2Process() = default; protected: /// @brief Monitors current queue manager state, takes action accordingly @@ -312,13 +312,12 @@ private: /// @brief Current socket control configuration. isc::data::ConstElementPtr current_control_socket_; - }; /// @brief Defines a shared pointer to D2Process. typedef boost::shared_ptr D2ProcessPtr; -}; // namespace isc::d2 -}; // namespace isc +} // namespace isc::d2 +} // namespace isc #endif diff --git a/src/bin/d2/d2_queue_mgr.cc b/src/bin/d2/d2_queue_mgr.cc index c16880851e382d1295d580581807344077e7b8a5..f3e7c9f6dfe3b24ac7391470ba1e20dcc7c530b7 100644 --- a/src/bin/d2/d2_queue_mgr.cc +++ b/src/bin/d2/d2_queue_mgr.cc @@ -26,9 +26,6 @@ D2QueueMgr::D2QueueMgr(asiolink::IOServicePtr& io_service, const size_t max_queu setMaxQueueSize(max_queue_size); } -D2QueueMgr::~D2QueueMgr() { -} - void D2QueueMgr::operator()(const dhcp_ddns::NameChangeListener::Result result, dhcp_ddns::NameChangeRequestPtr& ncr) { diff --git a/src/bin/d2/d2_queue_mgr.h b/src/bin/d2/d2_queue_mgr.h index bbd95ea01656778ad8c02f3ab3b10139b3711478..23ce0280cb5bcd980f72b795f8566cb4ca02b7f5 100644 --- a/src/bin/d2/d2_queue_mgr.h +++ b/src/bin/d2/d2_queue_mgr.h @@ -163,7 +163,7 @@ public: const size_t max_queue_size = MAX_QUEUE_DEFAULT); /// @brief Destructor - virtual ~D2QueueMgr(); + virtual ~D2QueueMgr() = default; /// @brief Initializes the listener as a UDP listener. /// diff --git a/src/bin/d2/d2_update_mgr.cc b/src/bin/d2/d2_update_mgr.cc index 223430e9c9f3e453879fdc74fccb36cd682548dc..88c3ab144664ae9380071a2fa2117843eff2e773 100644 --- a/src/bin/d2/d2_update_mgr.cc +++ b/src/bin/d2/d2_update_mgr.cc @@ -43,7 +43,10 @@ D2UpdateMgr::D2UpdateMgr(D2QueueMgrPtr& queue_mgr, D2CfgMgrPtr& cfg_mgr, } D2UpdateMgr::~D2UpdateMgr() { - transaction_list_.clear(); + try { + transaction_list_.clear(); + } catch (...) { + } } void D2UpdateMgr::sweep() { diff --git a/src/bin/d2/dns_client.cc b/src/bin/d2/dns_client.cc index 73ffa610549112a03df0ee7e3a9d8377e6010d92..e1e98ca7c9464e65b888587e22cbd0882d5f7e52 100644 --- a/src/bin/d2/dns_client.cc +++ b/src/bin/d2/dns_client.cc @@ -56,11 +56,13 @@ public: // TSIG context used to sign outbound and verify inbound messages. dns::TSIGContextPtr tsig_context_; - // Constructor and Destructor + // Constructor DNSClientImpl(D2UpdateMessagePtr& response_placeholder, DNSClient::Callback* callback, const DNSClient::Protocol proto); - virtual ~DNSClientImpl(); + + // Destructor + virtual ~DNSClientImpl() = default; // This internal callback is called when the DNS update message exchange is // complete. It further invokes the external callback provided by a caller. @@ -117,9 +119,6 @@ DNSClientImpl::DNSClientImpl(D2UpdateMessagePtr& response_placeholder, } } -DNSClientImpl::~DNSClientImpl() { -} - void DNSClientImpl::operator()(asiodns::IOFetch::Result result) { // Get the status from IO. If no success, we just call user's callback @@ -234,10 +233,6 @@ DNSClient::DNSClient(D2UpdateMessagePtr& response_placeholder, : impl_(new DNSClientImpl(response_placeholder, callback, proto)) { } -DNSClient::~DNSClient() { - delete (impl_); -} - unsigned int DNSClient::getMaxTimeout() { static const unsigned int max_timeout = std::numeric_limits::max(); diff --git a/src/bin/d2/dns_client.h b/src/bin/d2/dns_client.h index 41423be88946fb9955c86af6182a9a54b03e41ee..ded999f07b21eef037309f788de029233f93ca72 100644 --- a/src/bin/d2/dns_client.h +++ b/src/bin/d2/dns_client.h @@ -24,6 +24,9 @@ typedef boost::shared_ptr DNSClientPtr; /// DNSClient class implementation. class DNSClientImpl; +/// @brief Defines a smart pointer to a DNSClientImpl. +typedef boost::shared_ptr DNSClientImplPtr; + /// @brief The @c DNSClient class handles communication with the DNS server. /// /// Communication with the DNS server is asynchronous. Caller must provide a @@ -73,8 +76,12 @@ public: /// exchange is complete (@see @c DNSClient). class Callback { public: + + // @brief Constructor. + Callback() = default; + /// @brief Virtual destructor. - virtual ~Callback() { } + virtual ~Callback() = default; /// @brief Function operator implementing a callback. /// @@ -96,7 +103,7 @@ public: const Protocol proto = UDP); /// @brief Virtual destructor, does nothing. - ~DNSClient(); + ~DNSClient() = default; /// /// @name Copy constructor and assignment operator @@ -149,7 +156,8 @@ public: const dns::TSIGKeyPtr& tsig_key = dns::TSIGKeyPtr()); private: - DNSClientImpl* impl_; ///< Pointer to DNSClient implementation. + /// @brief Smart pointer to DNSClient implementation. + DNSClientImplPtr impl_; }; } // namespace d2 diff --git a/src/bin/d2/main.cc b/src/bin/d2/main.cc index 233d00465d2b1bf64344ed0020b5b22fad8585bc..ae40b0a1d1d3b5067f0f582502467986701e96a4 100644 --- a/src/bin/d2/main.cc +++ b/src/bin/d2/main.cc @@ -47,6 +47,8 @@ int main(int argc, char* argv[]) { } catch (const isc::Exception& ex) { std::cerr << "Service failed: " << ex.what() << std::endl; ret = EXIT_FAILURE; + } catch (...) { + ret = EXIT_FAILURE; } return (ret); diff --git a/src/bin/d2/nc_add.cc b/src/bin/d2/nc_add.cc index b4692a8614ca1d4c5d1e9e795a429f40f785fea4..2d9ada04137c58b59f39ae9ef2e400d1e0d1c84e 100644 --- a/src/bin/d2/nc_add.cc +++ b/src/bin/d2/nc_add.cc @@ -41,9 +41,6 @@ NameAddTransaction(asiolink::IOServicePtr& io_service, } } -NameAddTransaction::~NameAddTransaction(){ -} - void NameAddTransaction::defineEvents() { // Call superclass impl first. diff --git a/src/bin/d2/nc_add.h b/src/bin/d2/nc_add.h index 0f9929abd12c9e0c3ec5eccb8e04b305f84a9a6e..1dfa0181006103d3eff2bba1db67ac2fb32fc0a3 100644 --- a/src/bin/d2/nc_add.h +++ b/src/bin/d2/nc_add.h @@ -90,7 +90,7 @@ public: D2CfgMgrPtr& cfg_mgr); /// @brief Destructor - virtual ~NameAddTransaction(); + virtual ~NameAddTransaction() = default; protected: /// @brief Adds events defined by NameAddTransaction to the event set. diff --git a/src/bin/d2/nc_remove.cc b/src/bin/d2/nc_remove.cc index cd0b14bb59dc0a1be3eea51dcfcc92fa3b312446..9e359a34684bb95ddbbe2f380ecc9d13289789a2 100644 --- a/src/bin/d2/nc_remove.cc +++ b/src/bin/d2/nc_remove.cc @@ -38,9 +38,6 @@ NameRemoveTransaction(asiolink::IOServicePtr& io_service, } } -NameRemoveTransaction::~NameRemoveTransaction(){ -} - void NameRemoveTransaction::defineEvents() { // Call superclass impl first. diff --git a/src/bin/d2/nc_remove.h b/src/bin/d2/nc_remove.h index 1584cb0025d6131100ad26ec3b62c0aa19129251..5d2213f15a64d3b51a00cede80b77a80b91ffe9a 100644 --- a/src/bin/d2/nc_remove.h +++ b/src/bin/d2/nc_remove.h @@ -86,7 +86,7 @@ public: D2CfgMgrPtr& cfg_mgr); /// @brief Destructor - virtual ~NameRemoveTransaction(); + virtual ~NameRemoveTransaction() = default; protected: /// @brief Adds events defined by NameRemoveTransaction to the event set. diff --git a/src/bin/d2/nc_trans.cc b/src/bin/d2/nc_trans.cc index d10b5c313c76018ff9a4d8a1cce0deef0192a296..62ab4d5c0025706d4a6d996c0b1cb94ab75ec6b9 100644 --- a/src/bin/d2/nc_trans.cc +++ b/src/bin/d2/nc_trans.cc @@ -80,9 +80,6 @@ NameChangeTransaction(asiolink::IOServicePtr& io_service, } } -NameChangeTransaction::~NameChangeTransaction(){ -} - void NameChangeTransaction::startTransaction() { LOG_DEBUG(d2_to_dns_logger, isc::log::DBGLVL_TRACE_DETAIL, diff --git a/src/bin/d2/nc_trans.h b/src/bin/d2/nc_trans.h index 4634027f0370f29777131a424db73958e483ed2d..2aa4465bb3b6f50ab61fe8c9e2ea82709ce84a83 100644 --- a/src/bin/d2/nc_trans.h +++ b/src/bin/d2/nc_trans.h @@ -173,7 +173,7 @@ public: D2CfgMgrPtr& cfg_mgr); /// @brief Destructor - virtual ~NameChangeTransaction(); + virtual ~NameChangeTransaction() = default; /// @brief Begins execution of the transaction. /// diff --git a/src/bin/d2/parser_context.cc b/src/bin/d2/parser_context.cc index fce0c9f79ba53d6926aac11675e7b8d6f6d1e9ee..f5f3864ac49b16da6c4f7649aa3813e5ca01c4c4 100644 --- a/src/bin/d2/parser_context.cc +++ b/src/bin/d2/parser_context.cc @@ -18,13 +18,11 @@ namespace isc { namespace d2 { D2ParserContext::D2ParserContext() - : sfile_(0), ctx_(NO_KEYWORD), trace_scanning_(false), trace_parsing_(false) -{ + : sfile_(0), ctx_(NO_KEYWORD), trace_scanning_(false), trace_parsing_(false) { } isc::data::ElementPtr -D2ParserContext::parseString(const std::string& str, ParserType parser_type) -{ +D2ParserContext::parseString(const std::string& str, ParserType parser_type) { scanStringBegin(str, parser_type); return (parseCommon()); } @@ -67,8 +65,7 @@ D2ParserContext::parseCommon() { void D2ParserContext::error(const isc::d2::location& loc, const std::string& what, - size_t pos) -{ + size_t pos) { if (pos == 0) { isc_throw(D2ParseError, loc << ": " << what); } else { @@ -77,20 +74,17 @@ D2ParserContext::error(const isc::d2::location& loc, } void -D2ParserContext::error (const std::string& what) -{ +D2ParserContext::error (const std::string& what) { isc_throw(D2ParseError, what); } void -D2ParserContext::fatal (const std::string& what) -{ +D2ParserContext::fatal (const std::string& what) { isc_throw(D2ParseError, what); } isc::data::Element::Position -D2ParserContext::loc2pos(isc::d2::location& loc) -{ +D2ParserContext::loc2pos(isc::d2::location& loc) { const std::string& file = *loc.begin.filename; const uint32_t line = loc.begin.line; const uint32_t pos = loc.begin.column; @@ -99,8 +93,7 @@ D2ParserContext::loc2pos(isc::d2::location& loc) void D2ParserContext::unique(const std::string& name, - isc::data::Element::Position loc) -{ + isc::data::Element::Position loc) { ConstElementPtr value = stack_.back()->get(name); if (value) { if (ctx_ != NO_KEYWORD) { @@ -116,15 +109,13 @@ D2ParserContext::unique(const std::string& name, } void -D2ParserContext::enter(const ParserContext& ctx) -{ +D2ParserContext::enter(const ParserContext& ctx) { cstack_.push_back(ctx_); ctx_ = ctx; } void -D2ParserContext::leave() -{ +D2ParserContext::leave() { if (cstack_.empty()) { fatal("unbalanced syntactic context"); } @@ -134,8 +125,7 @@ D2ParserContext::leave() } const std::string -D2ParserContext::contextName() -{ +D2ParserContext::contextName() { switch (ctx_) { case NO_KEYWORD: return ("__no keyword__"); diff --git a/src/bin/d2/parser_context.h b/src/bin/d2/parser_context.h index 0d596cf56fafe025283bdd241ce2714571002223..6fd342dd3dfd15f746157be3b9ea2eb555bf4aeb 100644 --- a/src/bin/d2/parser_context.h +++ b/src/bin/d2/parser_context.h @@ -32,8 +32,7 @@ public: }; /// @brief Evaluation context, an interface to the expression evaluation. -class D2ParserContext -{ +class D2ParserContext { public: /// @brief Defines currently supported scopes diff --git a/src/bin/d2/simple_add.cc b/src/bin/d2/simple_add.cc index 6ca7a3cfe2ddde0e93918a661f939da8ae6b6b60..e7e4030c0f317d03fe0e26b4edffc973d3994d2c 100644 --- a/src/bin/d2/simple_add.cc +++ b/src/bin/d2/simple_add.cc @@ -40,9 +40,6 @@ SimpleAddTransaction(asiolink::IOServicePtr& io_service, } } -SimpleAddTransaction::~SimpleAddTransaction(){ -} - void SimpleAddTransaction::defineEvents() { // Call superclass impl first. diff --git a/src/bin/d2/simple_add.h b/src/bin/d2/simple_add.h index 7bf7b6c605472d73c43f4df004f74b2adec58960..a1ab2188f38fcdac93a5b3df348c38ea4c7aa613 100644 --- a/src/bin/d2/simple_add.h +++ b/src/bin/d2/simple_add.h @@ -82,7 +82,7 @@ public: D2CfgMgrPtr& cfg_mgr); /// @brief Destructor - virtual ~SimpleAddTransaction(); + virtual ~SimpleAddTransaction() = default; protected: /// @brief Adds events defined by SimpleAddTransaction to the event set. diff --git a/src/bin/d2/simple_remove.cc b/src/bin/d2/simple_remove.cc index 63de0e3ab1552e81ce8c8afa43f1eb4c44d33d2c..bb6cd4ccf78dccb07362b81d9893f0f96513a7dc 100644 --- a/src/bin/d2/simple_remove.cc +++ b/src/bin/d2/simple_remove.cc @@ -37,9 +37,6 @@ SimpleRemoveTransaction(asiolink::IOServicePtr& io_service, } } -SimpleRemoveTransaction::~SimpleRemoveTransaction(){ -} - void SimpleRemoveTransaction::defineEvents() { // Call superclass impl first. diff --git a/src/bin/d2/simple_remove.h b/src/bin/d2/simple_remove.h index ce6d52514556a96878e4bded96e06b16201644b6..9f481d54a0208c479f2efbca58f55d157dae7edc 100644 --- a/src/bin/d2/simple_remove.h +++ b/src/bin/d2/simple_remove.h @@ -81,7 +81,7 @@ public: D2CfgMgrPtr& cfg_mgr); /// @brief Destructor - virtual ~SimpleRemoveTransaction(); + virtual ~SimpleRemoveTransaction() = default; protected: /// @brief Adds events defined by SimpleRemoveTransaction to the event set. @@ -345,7 +345,6 @@ protected: /// @brief Defines a pointer to a SimpleRemoveTransaction. typedef boost::shared_ptr SimpleRemoveTransactionPtr; - } // namespace isc::d2 } // namespace isc #endif diff --git a/src/bin/d2/tests/d2_cfg_mgr_unittests.cc b/src/bin/d2/tests/d2_cfg_mgr_unittests.cc index a2c901234ec4aacb5cb743f954ce22e0ece59463..4b30d2eb9af49fcc7dd32c980ae75169160bce90 100644 --- a/src/bin/d2/tests/d2_cfg_mgr_unittests.cc +++ b/src/bin/d2/tests/d2_cfg_mgr_unittests.cc @@ -45,12 +45,11 @@ class D2CfgMgrTest : public ConfigParseTest { public: /// @brief Constructor - D2CfgMgrTest():cfg_mgr_(new D2CfgMgr()), d2_params_() { + D2CfgMgrTest() : cfg_mgr_(new D2CfgMgr()), d2_params_() { } /// @brief Destructor - ~D2CfgMgrTest() { - } + ~D2CfgMgrTest() = default; /// @brief Configuration manager instance. D2CfgMgrPtr cfg_mgr_; diff --git a/src/bin/d2/tests/d2_command_unittest.cc b/src/bin/d2/tests/d2_command_unittest.cc index 5192e7831bbb862d748ec72bf6a7df3dd363b3c3..ae7b2b3b08f2b7a3bf1350bf9c5ce3a696691f34 100644 --- a/src/bin/d2/tests/d2_command_unittest.cc +++ b/src/bin/d2/tests/d2_command_unittest.cc @@ -54,7 +54,13 @@ public: return (controller_ptr); } - virtual ~NakedD2Controller() { deregisterCommands(); } + /// @brief Destructor + virtual ~NakedD2Controller() { + try { + deregisterCommands(); + } catch (...) { + } + } using DControllerBase::getIOService; using DControllerBase::initProcess; @@ -64,11 +70,13 @@ public: } private: - NakedD2Controller() { } + + /// @brief Constructor + NakedD2Controller() = default; }; -}; // namespace isc::d2 -}; // namespace isc +} // namespace isc::d2 +} // namespace isc namespace { @@ -88,7 +96,10 @@ public: /// /// Stops IO service. ~IOServiceWork() { - io_service_->stop(); + try { + io_service_->stop(); + } catch (...) { + } } private: @@ -117,7 +128,7 @@ public: /// @brief Configuration file. static const char* CFG_TEST_FILE; - /// @brief Default constructor. + /// @brief Constructor. /// /// Sets socket path to its default value. CtrlChannelD2Test() @@ -133,16 +144,19 @@ public: /// @brief Destructor. ~CtrlChannelD2Test() { - // Deregister & co. - server_.reset(); + try { + // Deregister & co. + server_.reset(); - // Remove files. - ::remove(CFG_TEST_FILE); - ::remove(socket_path_.c_str()); + // Remove files. + ::remove(CFG_TEST_FILE); + ::remove(socket_path_.c_str()); - // Reset command manager. - CommandMgr::instance().deregisterAll(); - CommandMgr::instance().setConnectionTimeout(TIMEOUT_DHCP_SERVER_RECEIVE_COMMAND); + // Reset command manager. + CommandMgr::instance().deregisterAll(); + CommandMgr::instance().setConnectionTimeout(TIMEOUT_DHCP_SERVER_RECEIVE_COMMAND); + } catch (...) { + } } /// @brief Returns pointer to the server's IO service. diff --git a/src/bin/d2/tests/d2_process_unittests.cc b/src/bin/d2/tests/d2_process_unittests.cc index 5a60b464a976fa47d0c503f0ebcc0e18d75967be..c03ae3f0e4a44f4de896fd1b956024b37f20d0db 100644 --- a/src/bin/d2/tests/d2_process_unittests.cc +++ b/src/bin/d2/tests/d2_process_unittests.cc @@ -65,8 +65,7 @@ public: } /// @brief Destructor - virtual ~D2ProcessTest() { - } + virtual ~D2ProcessTest() = default; /// @brief Callback that will invoke shutdown method. void genShutdownCallback() { diff --git a/src/bin/d2/tests/d2_simple_parser_unittest.cc b/src/bin/d2/tests/d2_simple_parser_unittest.cc index 686d7fae8c5397ca37fcec3dcd4314a98d9ec09e..6c0005f711174b18c3db05e3b081a1c6700c00fa 100644 --- a/src/bin/d2/tests/d2_simple_parser_unittest.cc +++ b/src/bin/d2/tests/d2_simple_parser_unittest.cc @@ -163,7 +163,10 @@ public: /// @brief Destructor virtual ~D2SimpleParserTest() { - reset(); + try { + reset(); + } catch (...) { + } } /// @brief Parses JSON text and compares the results against an expected @@ -301,6 +304,7 @@ TEST_F(D2SimpleParserTest, globalD2Defaults) { /// @brief Test fixture class for testing TSIGKeyInfo parsing. class TSIGKeyInfoParserTest : public D2SimpleParserTest { public: + /// @brief Constructor TSIGKeyInfoParserTest() : D2SimpleParserTest(D2ParserContext::PARSER_TSIG_KEY) { @@ -313,7 +317,10 @@ public: /// @brief Destructor virtual ~TSIGKeyInfoParserTest() { - reset(); + try { + reset(); + } catch (...) { + } }; /// @brief Adds TSIG Key default values to the given TSIG Key element @@ -342,10 +349,10 @@ public: TSIGKeyInfoPtr key_; }; - /// @brief Test fixture class for testing TSIGKeyInfo list parsing. class TSIGKeyInfoListParserTest : public D2SimpleParserTest { public: + /// @brief Constructor TSIGKeyInfoListParserTest() : D2SimpleParserTest(D2ParserContext::PARSER_TSIG_KEYS) { @@ -353,7 +360,10 @@ public: /// @brief Destructor virtual ~TSIGKeyInfoListParserTest() { - reset(); + try { + reset(); + } catch (...) { + } } /// @brief Free up the keys created by parsing @@ -391,6 +401,7 @@ public: /// @brief Test fixture class for testing DnsServerInfo parsing. class DnsServerInfoParserTest : public D2SimpleParserTest { public: + /// @brief Constructor DnsServerInfoParserTest() : D2SimpleParserTest(D2ParserContext::PARSER_DNS_SERVER) { @@ -398,7 +409,10 @@ public: /// @brief Destructor virtual ~DnsServerInfoParserTest() { - reset(); + try { + reset(); + } catch (...) { + } } /// @brief Free up the server created by parsing @@ -442,7 +456,10 @@ public: /// @brief Destructor virtual ~DnsServerInfoListParserTest() { - reset(); + try { + reset(); + } catch (...) { + } } /// @brief Free up the servers created by parsing @@ -477,7 +494,6 @@ public: DnsServerInfoStoragePtr servers_; }; - /// @brief Test fixture class for testing DDnsDomain parsing. class DdnsDomainParserTest : public D2SimpleParserTest { public: @@ -490,7 +506,10 @@ public: /// @brief Destructor virtual ~DdnsDomainParserTest() { - reset(); + try { + reset(); + } catch (...) { + } } /// @brief Free up the domain created by parsing @@ -541,6 +560,7 @@ public: class DdnsDomainListParserTest : public DdnsDomainParserTest { public: + /// @brief Constructor DdnsDomainListParserTest() // We need the list context type to parse lists correctly @@ -549,7 +569,10 @@ public: /// @brief Destructor virtual ~DdnsDomainListParserTest() { - reset(); + try { + reset(); + } catch (...) { + } } /// @brief Free up domains created by parsing @@ -1168,4 +1191,4 @@ TEST_F(DdnsDomainListParserTest, duplicateDomain) { "Duplicate domain specified:example.com (:1:115)"); } -}; +} diff --git a/src/bin/d2/tests/d2_update_message_unittests.cc b/src/bin/d2/tests/d2_update_message_unittests.cc index 6e6fa5d94984535b73b0f632b32cddcb3c64deba..6d137e199c07eeae714b193b6c20bda68e21eeec 100644 --- a/src/bin/d2/tests/d2_update_message_unittests.cc +++ b/src/bin/d2/tests/d2_update_message_unittests.cc @@ -28,15 +28,16 @@ namespace { /// @brief Test fixture class for testing D2UpdateMessage object class D2UpdateMessageTest : public ::testing::Test { public: + /// @brief Constructor // // Does nothing. - D2UpdateMessageTest() { } + D2UpdateMessageTest() = default; /// @brief Destructor // // Does nothing. - ~D2UpdateMessageTest() { }; + ~D2UpdateMessageTest() = default; /// @brief Returns string representation of the name encoded in wire format. // @@ -692,5 +693,4 @@ TEST_F(D2UpdateMessageTest, allValidTSIG) { } } - } // End of anonymous namespace diff --git a/src/bin/d2/tests/d2_update_mgr_unittests.cc b/src/bin/d2/tests/d2_update_mgr_unittests.cc index a89de3e27369c5f0d95336e27dc385848634e366..3223db39e639bdf81397be8961bd3a58fd9cc1fb 100644 --- a/src/bin/d2/tests/d2_update_mgr_unittests.cc +++ b/src/bin/d2/tests/d2_update_mgr_unittests.cc @@ -35,6 +35,7 @@ namespace { /// they can be invoked directly in test routines. class D2UpdateMgrWrapper : public D2UpdateMgr { public: + /// @brief Constructor /// /// Parameters match those needed by D2UpdateMgr. @@ -45,8 +46,7 @@ public: } /// @brief Destructor - virtual ~D2UpdateMgrWrapper() { - } + virtual ~D2UpdateMgrWrapper() = default; // Expose the protected methods to be tested. using D2UpdateMgr::checkFinishedTransactions; @@ -72,6 +72,7 @@ public: std::vector canned_ncrs_; size_t canned_count_; + /// @brief Constructor D2UpdateMgrTest() { queue_mgr_.reset(new D2QueueMgr(io_service_)); cfg_mgr_.reset(new D2CfgMgr()); @@ -81,8 +82,8 @@ public: makeCannedConfig(); } - ~D2UpdateMgrTest() { - } + /// @brief Destructor + ~D2UpdateMgrTest() = default; /// @brief Creates a list of valid NameChangeRequest. /// diff --git a/src/bin/d2/tests/dns_client_unittests.cc b/src/bin/d2/tests/dns_client_unittests.cc index 02bbc569c8ebb37413f3c56638d632295523ba59..c639528a25df5951da9a259ddd2af47443bbf130 100644 --- a/src/bin/d2/tests/dns_client_unittests.cc +++ b/src/bin/d2/tests/dns_client_unittests.cc @@ -92,8 +92,11 @@ public: // // Sets the asiodns logging level back to DEBUG. virtual ~DNSClientTest() { - asiodns::logger.setSeverity(isc::log::DEBUG); - }; + try { + asiodns::logger.setSeverity(isc::log::DEBUG); + } catch (...) { + } + } /// @brief Exchange completion callback // @@ -558,4 +561,4 @@ TEST_F(DNSClientTest, DISABLED_concurrentSendReceive) { runSendReceiveTest(false, true); } -} // End of anonymous namespace +} // end of anonymous namespace diff --git a/src/bin/d2/tests/get_config_unittest.cc b/src/bin/d2/tests/get_config_unittest.cc index f1f914e754e88187a216812b21301a47ecb317d1..a598db36ab481bbfe69d9d0b074e2e33a4409323 100644 --- a/src/bin/d2/tests/get_config_unittest.cc +++ b/src/bin/d2/tests/get_config_unittest.cc @@ -100,6 +100,8 @@ parseDHCPDDNS(const std::string& in, bool verbose = false) { /// Test fixture class class D2GetConfigTest : public ConfigParseTest { public: + + /// @brief Constructor D2GetConfigTest() : rcode_(-1) { srv_.reset(new D2CfgMgr()); @@ -109,8 +111,12 @@ public: resetConfiguration(); } + /// @brief Destructor ~D2GetConfigTest() { - resetConfiguration(); + try { + resetConfiguration(); + } catch (...) { + } } /// @brief Parse and Execute configuration diff --git a/src/bin/d2/tests/nc_add_unittests.cc b/src/bin/d2/tests/nc_add_unittests.cc index a6a906478ae8a7fc133b1664b03107fb5b5ec5f6..34e5caae8cf7dc2a437552493225435558384f7f 100644 --- a/src/bin/d2/tests/nc_add_unittests.cc +++ b/src/bin/d2/tests/nc_add_unittests.cc @@ -25,6 +25,8 @@ namespace { // to protected methods. class NameAddStub : public NameAddTransaction { public: + + /// @brief Constructor NameAddStub(asiolink::IOServicePtr& io_service, dhcp_ddns::NameChangeRequestPtr& ncr, DdnsDomainPtr& forward_domain, @@ -36,8 +38,8 @@ public: simulate_build_request_exception_(false) { } - virtual ~NameAddStub() { - } + /// @brief Destructor + virtual ~NameAddStub() = default; /// @brief Simulates sending update requests to the DNS server /// @@ -184,11 +186,11 @@ typedef boost::shared_ptr NameAddStubPtr; class NameAddTransactionTest : public TransactionTest { public: - NameAddTransactionTest() { - } + /// @brief Constructor + NameAddTransactionTest() = default; - virtual ~NameAddTransactionTest() { - } + /// @brief Destructor + virtual ~NameAddTransactionTest() = default; /// @brief Creates a transaction which requests an IPv4 DNS update. /// @@ -1784,5 +1786,4 @@ TEST_F(NameAddTransactionTest, replacingRevPtrsHandler_BuildRequestException) { name_add->getNextEvent()); } - } diff --git a/src/bin/d2/tests/nc_remove_unittests.cc b/src/bin/d2/tests/nc_remove_unittests.cc index 4a1ee5c22dfb4f1605758304a5ef52319683cfea..3ed69e7d35750fa744e4298f2af9f908b23148be 100644 --- a/src/bin/d2/tests/nc_remove_unittests.cc +++ b/src/bin/d2/tests/nc_remove_unittests.cc @@ -26,6 +26,8 @@ namespace { // to protected methods. class NameRemoveStub : public NameRemoveTransaction { public: + + /// @brief Constructor NameRemoveStub(asiolink::IOServicePtr& io_service, dhcp_ddns::NameChangeRequestPtr& ncr, DdnsDomainPtr& forward_domain, @@ -37,8 +39,8 @@ public: simulate_build_request_exception_(false) { } - virtual ~NameRemoveStub() { - } + /// @brief Destructor + virtual ~NameRemoveStub() = default; /// @brief Simulates sending update requests to the DNS server /// @@ -184,11 +186,12 @@ typedef boost::shared_ptr NameRemoveStubPtr; /// aspects of NameRemoveTransaction. class NameRemoveTransactionTest : public TransactionTest { public: - NameRemoveTransactionTest() { - } - virtual ~NameRemoveTransactionTest() { - } + /// @brief Constructor + NameRemoveTransactionTest() = default; + + /// @brief Destructor + virtual ~NameRemoveTransactionTest() = default; /// @brief Creates a transaction which requests an IPv4 DNS update. /// diff --git a/src/bin/d2/tests/nc_test_utils.cc b/src/bin/d2/tests/nc_test_utils.cc index f6392e07a22ddc99137ade653d42cefe36f8ddc0..28ed0db5793bccb2c48fed8535bb2fe4ec5b7029 100644 --- a/src/bin/d2/tests/nc_test_utils.cc +++ b/src/bin/d2/tests/nc_test_utils.cc @@ -82,10 +82,6 @@ FauxServer::FauxServer(asiolink::IOService& io_service, server_socket_->bind(endpoint.getASIOEndpoint()); } - -FauxServer::~FauxServer() { -} - void FauxServer::receive (const ResponseMode& response_mode, const dns::Rcode& response_rcode) { @@ -219,9 +215,6 @@ TimedIO::TimedIO() timer_(*io_service_), run_time_(0) { } -TimedIO::~TimedIO() { -} - int TimedIO::runTimedIO(int run_time) { run_time_ = run_time; @@ -250,9 +243,6 @@ const unsigned int TransactionTest::FWD_AND_REV_CHG = REVERSE_CHG | FORWARD_CHG; TransactionTest::TransactionTest() : ncr_(), cfg_mgr_(new D2CfgMgr()) { } -TransactionTest::~TransactionTest() { -} - void TransactionTest::setupForIPv4Transaction(dhcp_ddns::NameChangeType chg_type, int change_mask, diff --git a/src/bin/d2/tests/nc_test_utils.h b/src/bin/d2/tests/nc_test_utils.h index 26eacd82d05b15e745bf58c3cdac06347ff23921..e6726b35eded83354a6a1ce077636a4b51d86ef6 100644 --- a/src/bin/d2/tests/nc_test_utils.h +++ b/src/bin/d2/tests/nc_test_utils.h @@ -79,7 +79,7 @@ public: FauxServer(asiolink::IOService& io_service, DnsServerInfo& server); /// @brief Destructor - virtual ~FauxServer(); + virtual ~FauxServer() = default; /// @brief Initiates an asynchronous receive /// @@ -141,7 +141,7 @@ public: TimedIO(); // Destructor - virtual ~TimedIO(); + virtual ~TimedIO() = default; /// @brief IO Timer expiration handler /// @@ -182,8 +182,11 @@ public: static const unsigned int REVERSE_CHG; // Only reverse change. static const unsigned int FWD_AND_REV_CHG; // Both forward and reverse. + /// @brief Constructor TransactionTest(); - virtual ~TransactionTest(); + + /// @brief Destructor + virtual ~TransactionTest() = default; /// @brief Creates a transaction which requests an IPv4 DNS update. /// diff --git a/src/bin/d2/tests/nc_trans_unittests.cc b/src/bin/d2/tests/nc_trans_unittests.cc index 47444772305e6380c0b95e5be2610895eb1ecd87..e865a3ab750659be597ba3d7a6f587956e2032fe 100644 --- a/src/bin/d2/tests/nc_trans_unittests.cc +++ b/src/bin/d2/tests/nc_trans_unittests.cc @@ -60,8 +60,7 @@ public: } /// @brief Destructor - virtual ~NameChangeStub() { - } + virtual ~NameChangeStub() = default; /// @brief DNSClient callback /// Overrides the callback in NameChangeTransaction to allow testing @@ -268,11 +267,12 @@ typedef boost::shared_ptr NameChangeStubPtr; /// aspects of NameChangeTransaction. class NameChangeTransactionTest : public TransactionTest { public: - NameChangeTransactionTest() { - } - virtual ~NameChangeTransactionTest() { - } + /// @brief Constructor + NameChangeTransactionTest() = default; + + /// @brief Destructor + virtual ~NameChangeTransactionTest() = default; /// @brief Instantiates a NameChangeStub test transaction @@ -1267,4 +1267,4 @@ TEST_F(NameChangeTransactionTest, addPtrRdata) { EXPECT_EQ(ncr->getFqdn(), rdata_it->getCurrent().toText()); } -}; // anonymous namespace +} // anonymous namespace diff --git a/src/bin/d2/tests/simple_add_unittests.cc b/src/bin/d2/tests/simple_add_unittests.cc index 2d7a884c4efc6d58e4aca5300482c440c1aa4701..3a8818d8d315b61eab1e9141f83284bff2584b54 100644 --- a/src/bin/d2/tests/simple_add_unittests.cc +++ b/src/bin/d2/tests/simple_add_unittests.cc @@ -25,6 +25,8 @@ namespace { // to protected methods. class SimpleAddStub : public SimpleAddTransaction { public: + + /// @brief Constructor SimpleAddStub(asiolink::IOServicePtr& io_service, dhcp_ddns::NameChangeRequestPtr& ncr, DdnsDomainPtr& forward_domain, @@ -36,8 +38,8 @@ public: simulate_build_request_exception_(false) { } - virtual ~SimpleAddStub() { - } + /// @brief Destructor + virtual ~SimpleAddStub() = default; /// @brief Simulates sending update requests to the DNS server /// @@ -182,11 +184,11 @@ typedef boost::shared_ptr SimpleAddStubPtr; class SimpleAddTransactionTest : public TransactionTest { public: - SimpleAddTransactionTest() { - } + /// @brief Constructor + SimpleAddTransactionTest() = default; - virtual ~SimpleAddTransactionTest() { - } + /// @brief Destructor + virtual ~SimpleAddTransactionTest() = default; /// @brief Creates a transaction which requests an IPv4 DNS update. /// diff --git a/src/bin/d2/tests/simple_remove_unittests.cc b/src/bin/d2/tests/simple_remove_unittests.cc index 2e4238e5533bea026d4c46b0dd7e85cd59702881..b26a023d47a654023d0f8dcb18f0aebb156eb195 100644 --- a/src/bin/d2/tests/simple_remove_unittests.cc +++ b/src/bin/d2/tests/simple_remove_unittests.cc @@ -26,6 +26,8 @@ namespace { // to protected methods. class SimpleRemoveStub : public SimpleRemoveTransaction { public: + + /// @brief Constructor SimpleRemoveStub(asiolink::IOServicePtr& io_service, dhcp_ddns::NameChangeRequestPtr& ncr, DdnsDomainPtr& forward_domain, @@ -37,8 +39,8 @@ public: simulate_build_request_exception_(false) { } - virtual ~SimpleRemoveStub() { - } + /// @brief Destructor + virtual ~SimpleRemoveStub() = default; /// @brief Simulates sending update requests to the DNS server /// @@ -182,11 +184,12 @@ typedef boost::shared_ptr SimpleRemoveStubPtr; /// aspects of SimpleRemoveTransaction. class SimpleRemoveTransactionTest : public TransactionTest { public: - SimpleRemoveTransactionTest() { - } - virtual ~SimpleRemoveTransactionTest() { - } + /// @brief Constructor + SimpleRemoveTransactionTest() = default; + + /// @brief Destructor + virtual ~SimpleRemoveTransactionTest() = default; /// @brief Creates a transaction which requests an IPv4 DNS update. /// diff --git a/src/bin/dhcp4/client_handler.cc b/src/bin/dhcp4/client_handler.cc index f116df3ad6bca7f8605010de7350f5962f9a5479..b9b7bca8a857d2974615a3c0a89aad347767ccd2 100644 --- a/src/bin/dhcp4/client_handler.cc +++ b/src/bin/dhcp4/client_handler.cc @@ -131,31 +131,30 @@ ClientHandler::del(const HWAddrPtr& hwaddr) { clients_hwaddr_.erase(it); } -ClientHandler::ClientHandler() - : client_(), locked_client_id_(), locked_hwaddr_() { -} - ClientHandler::~ClientHandler() { - bool unlocked = false; - lock_guard lk(mutex_); - if (locked_client_id_) { - unlocked = true; - unLockById(); - } - if (locked_hwaddr_) { - unlocked = true; - unLockByHWAddr(); - } - if (!unlocked || !client_ || !client_->cont_) { - return; - } - // Try to process next query. As the caller holds the mutex of - // the handler class the continuation will be resumed after. - MultiThreadingMgr& mt_mgr = MultiThreadingMgr::instance(); - if (mt_mgr.getMode()) { - if (!mt_mgr.getThreadPool().addFront(client_->cont_)) { - LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_PACKET_QUEUE_FULL); + try { + bool unlocked = false; + lock_guard lk(mutex_); + if (locked_client_id_) { + unlocked = true; + unLockById(); + } + if (locked_hwaddr_) { + unlocked = true; + unLockByHWAddr(); + } + if (!unlocked || !client_ || !client_->cont_) { + return; + } + // Try to process next query. As the caller holds the mutex of + // the handler class the continuation will be resumed after. + MultiThreadingMgr& mt_mgr = MultiThreadingMgr::instance(); + if (mt_mgr.getMode()) { + if (!mt_mgr.getThreadPool().addFront(client_->cont_)) { + LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_PACKET_QUEUE_FULL); + } } + } catch (...) { } } diff --git a/src/bin/dhcp4/client_handler.h b/src/bin/dhcp4/client_handler.h index 9b2b0c0e2d42291c48b6779d62143df33ad86e1d..6cbab444cb3cb360b78d62237eec0ab4ea67f43c 100644 --- a/src/bin/dhcp4/client_handler.h +++ b/src/bin/dhcp4/client_handler.h @@ -188,7 +188,7 @@ public: /// Public interface. /// @brief Constructor. - ClientHandler(); + ClientHandler() = default; /// @brief Destructor. /// diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 6c943ead563a6e34764ad0343dcf92a47729cc47..7c4029992d5fc435f9cbd45d6d2c5da04b5895c6 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -671,41 +671,44 @@ void Dhcpv4Srv::setPacketStatisticsDefaults() { } Dhcpv4Srv::~Dhcpv4Srv() { - // Discard any parked packets - discardPackets(); - try { - stopD2(); - } catch (const std::exception& ex) { - // Highly unlikely, but lets Report it but go on - LOG_ERROR(dhcp4_logger, DHCP4_SRV_D2STOP_ERROR).arg(ex.what()); - } + // Discard any parked packets + discardPackets(); - try { - Dhcp4to6Ipc::instance().close(); - } catch (const std::exception& ex) { - // Highly unlikely, but lets Report it but go on - LOG_ERROR(dhcp4_logger, DHCP4_SRV_DHCP4O6_ERROR).arg(ex.what()); - } - - IfaceMgr::instance().closeSockets(); - - // The lease manager was instantiated during DHCPv4Srv configuration, - // so we should clean up after ourselves. - LeaseMgrFactory::destroy(); - - // Explicitly unload hooks - HooksManager::prepareUnloadLibraries(); - if (!HooksManager::unloadLibraries()) { - auto names = HooksManager::getLibraryNames(); - std::string msg; - if (!names.empty()) { - msg = names[0]; - for (size_t i = 1; i < names.size(); ++i) { - msg += std::string(", ") + names[i]; + try { + stopD2(); + } catch (const std::exception& ex) { + // Highly unlikely, but lets Report it but go on + LOG_ERROR(dhcp4_logger, DHCP4_SRV_D2STOP_ERROR).arg(ex.what()); + } + + try { + Dhcp4to6Ipc::instance().close(); + } catch (const std::exception& ex) { + // Highly unlikely, but lets Report it but go on + LOG_ERROR(dhcp4_logger, DHCP4_SRV_DHCP4O6_ERROR).arg(ex.what()); + } + + IfaceMgr::instance().closeSockets(); + + // The lease manager was instantiated during DHCPv4Srv configuration, + // so we should clean up after ourselves. + LeaseMgrFactory::destroy(); + + // Explicitly unload hooks + HooksManager::prepareUnloadLibraries(); + if (!HooksManager::unloadLibraries()) { + auto names = HooksManager::getLibraryNames(); + std::string msg; + if (!names.empty()) { + msg = names[0]; + for (size_t i = 1; i < names.size(); ++i) { + msg += std::string(", ") + names[i]; + } } + LOG_ERROR(dhcp4_logger, DHCP4_SRV_UNLOAD_LIBRARIES_ERROR).arg(msg); } - LOG_ERROR(dhcp4_logger, DHCP4_SRV_UNLOAD_LIBRARIES_ERROR).arg(msg); + } catch (...) { } } diff --git a/src/bin/dhcp4/dhcp4to6_ipc.cc b/src/bin/dhcp4/dhcp4to6_ipc.cc index 074fde6618b479ca1fb5fe61af7d01dab60ca5a0..f3ad045e3842d5ee9e044d81ad354904a2a39e48 100644 --- a/src/bin/dhcp4/dhcp4to6_ipc.cc +++ b/src/bin/dhcp4/dhcp4to6_ipc.cc @@ -27,8 +27,6 @@ using namespace isc::hooks; namespace isc { namespace dhcp { -Dhcp4to6Ipc::Dhcp4to6Ipc() : Dhcp4o6IpcBase() {} - Dhcp4to6Ipc& Dhcp4to6Ipc::instance() { static Dhcp4to6Ipc dhcp4to6_ipc; return (dhcp4to6_ipc); diff --git a/src/bin/dhcp4/dhcp4to6_ipc.h b/src/bin/dhcp4/dhcp4to6_ipc.h index a2e86f071711c4ef33b45a81551ed14716ea97c4..8645d1183d47eb2625c022cc8cabc255c0f7b361 100644 --- a/src/bin/dhcp4/dhcp4to6_ipc.h +++ b/src/bin/dhcp4/dhcp4to6_ipc.h @@ -22,13 +22,14 @@ namespace dhcp { /// @brief Handles DHCPv4-over-DHCPv6 IPC on the DHCPv4 server side class Dhcp4to6Ipc : public Dhcp4o6IpcBase { protected: + /// @brief Constructor /// /// Default constructor - Dhcp4to6Ipc(); + Dhcp4to6Ipc() = default; /// @brief Destructor. - virtual ~Dhcp4to6Ipc() { } + virtual ~Dhcp4to6Ipc() = default; public: /// @brief Returns pointer to the sole instance of Dhcp4to6Ipc diff --git a/src/bin/dhcp4/main.cc b/src/bin/dhcp4/main.cc index a79f40989bfd09afc4b5be7f03e41a10989ebdde..d7dc4a6d0a521931771687333c7d9d04f3964b6b 100644 --- a/src/bin/dhcp4/main.cc +++ b/src/bin/dhcp4/main.cc @@ -68,231 +68,236 @@ usage() { int main(int argc, char* argv[]) { - int ch; - // The default. Any other values are useful for testing only. - int server_port_number = DHCP4_SERVER_PORT; - // Not zero values are useful for testing only. - int client_port_number = 0; - bool verbose_mode = false; // Should server be verbose? - bool check_mode = false; // Check syntax - - // The standard config file - std::string config_file(""); - - while ((ch = getopt(argc, argv, "dvVWc:p:P:t:")) != -1) { - switch (ch) { - case 'd': - verbose_mode = true; - break; - - case 'v': - cout << Dhcpv4Srv::getVersion(false) << endl; - return (EXIT_SUCCESS); - - case 'V': - cout << Dhcpv4Srv::getVersion(true) << endl; - return (EXIT_SUCCESS); - - case 'W': - cout << isc::detail::getConfigReport() << endl; - return (EXIT_SUCCESS); - - case 't': - check_mode = true; - // falls through - - case 'c': // config file - config_file = optarg; - break; - - case 'p': // server port number - try { - server_port_number = boost::lexical_cast(optarg); - } catch (const boost::bad_lexical_cast &) { - cerr << "Failed to parse server port number: [" << optarg - << "], 1-65535 allowed." << endl; - usage(); - } - if (server_port_number <= 0 || server_port_number > 65535) { - cerr << "Failed to parse server port number: [" << optarg - << "], 1-65535 allowed." << endl; - usage(); - } - break; + try { + int ch; + // The default. Any other values are useful for testing only. + int server_port_number = DHCP4_SERVER_PORT; + // Not zero values are useful for testing only. + int client_port_number = 0; + bool verbose_mode = false; // Should server be verbose? + bool check_mode = false; // Check syntax + + // The standard config file + std::string config_file(""); + + while ((ch = getopt(argc, argv, "dvVWc:p:P:t:")) != -1) { + switch (ch) { + case 'd': + verbose_mode = true; + break; + + case 'v': + cout << Dhcpv4Srv::getVersion(false) << endl; + return (EXIT_SUCCESS); - case 'P': // client port number - try { - client_port_number = boost::lexical_cast(optarg); - } catch (const boost::bad_lexical_cast &) { - cerr << "Failed to parse client port number: [" << optarg - << "], 1-65535 allowed." << endl; - usage(); - } - if (client_port_number <= 0 || client_port_number > 65535) { - cerr << "Failed to parse client port number: [" << optarg - << "], 1-65535 allowed." << endl; + case 'V': + cout << Dhcpv4Srv::getVersion(true) << endl; + return (EXIT_SUCCESS); + + case 'W': + cout << isc::detail::getConfigReport() << endl; + return (EXIT_SUCCESS); + + case 't': + check_mode = true; + // falls through + + case 'c': // config file + config_file = optarg; + break; + + case 'p': // server port number + try { + server_port_number = boost::lexical_cast(optarg); + } catch (const boost::bad_lexical_cast &) { + cerr << "Failed to parse server port number: [" << optarg + << "], 1-65535 allowed." << endl; + usage(); + } + if (server_port_number <= 0 || server_port_number > 65535) { + cerr << "Failed to parse server port number: [" << optarg + << "], 1-65535 allowed." << endl; + usage(); + } + break; + + case 'P': // client port number + try { + client_port_number = boost::lexical_cast(optarg); + } catch (const boost::bad_lexical_cast &) { + cerr << "Failed to parse client port number: [" << optarg + << "], 1-65535 allowed." << endl; + usage(); + } + if (client_port_number <= 0 || client_port_number > 65535) { + cerr << "Failed to parse client port number: [" << optarg + << "], 1-65535 allowed." << endl; + usage(); + } + break; + + default: usage(); } - break; + } - default: + // Check for extraneous parameters. + if (argc > optind) { usage(); } - } - // Check for extraneous parameters. - if (argc > optind) { - usage(); - } + // Configuration file is required. + if (config_file.empty()) { + cerr << "Configuration file not specified." << endl; + usage(); + } - // Configuration file is required. - if (config_file.empty()) { - cerr << "Configuration file not specified." << endl; - usage(); - } + // This is the DHCPv4 server + CfgMgr::instance().setFamily(AF_INET); - // This is the DHCPv4 server - CfgMgr::instance().setFamily(AF_INET); + if (check_mode) { + try { + // We need to initialize logging, in case any error messages are to be printed. + // This is just a test, so we don't care about lockfile. + setenv("KEA_LOCKFILE_DIR", "none", 0); + Daemon::setDefaultLoggerName(DHCP4_ROOT_LOGGER_NAME); + Daemon::loggerInit(DHCP4_ROOT_LOGGER_NAME, verbose_mode); + + // Check the syntax first. + Parser4Context parser; + ConstElementPtr json; + json = parser.parseFile(config_file, Parser4Context::PARSER_DHCP4); + if (!json) { + cerr << "No configuration found" << endl; + return (EXIT_FAILURE); + } + if (verbose_mode) { + cerr << "Syntax check OK" << endl; + } + + // Check the logic next. + ConstElementPtr dhcp4 = json->get("Dhcp4"); + if (!dhcp4) { + cerr << "Missing mandatory Dhcp4 element" << endl; + return (EXIT_FAILURE); + } + ControlledDhcpv4Srv server(0); + ConstElementPtr answer; + + // Now we pass the Dhcp4 configuration to the server, but + // tell it to check the configuration only (check_only = true) + answer = configureDhcp4Server(server, dhcp4, true); + + int status_code = 0; + answer = isc::config::parseAnswer(status_code, answer); + if (status_code == 0) { + return (EXIT_SUCCESS); + } else { + cerr << "Error encountered: " << answer->stringValue() << endl; + return (EXIT_FAILURE); + } + } catch (const std::exception& ex) { + cerr << "Syntax check failed with: " << ex.what() << endl; + } + return (EXIT_FAILURE); + } - if (check_mode) { + int ret = EXIT_SUCCESS; try { - // We need to initialize logging, in case any error messages are to be printed. - // This is just a test, so we don't care about lockfile. - setenv("KEA_LOCKFILE_DIR", "none", 0); + // It is important that we set a default logger name because this name + // will be used when the user doesn't provide the logging configuration + // in the Kea configuration file. Daemon::setDefaultLoggerName(DHCP4_ROOT_LOGGER_NAME); + + // Initialize logging. If verbose, we'll use maximum verbosity. Daemon::loggerInit(DHCP4_ROOT_LOGGER_NAME, verbose_mode); + LOG_DEBUG(dhcp4_logger, DBG_DHCP4_START, DHCP4_START_INFO) + .arg(getpid()) + .arg(server_port_number) + .arg(client_port_number) + .arg(verbose_mode ? "yes" : "no"); - // Check the syntax first. - Parser4Context parser; - ConstElementPtr json; - json = parser.parseFile(config_file, Parser4Context::PARSER_DHCP4); - if (!json) { - cerr << "No configuration found" << endl; - return (EXIT_FAILURE); - } - if (verbose_mode) { - cerr << "Syntax check OK" << endl; - } + LOG_INFO(dhcp4_logger, DHCP4_STARTING) + .arg(VERSION) + .arg(PACKAGE_VERSION_TYPE); - // Check the logic next. - ConstElementPtr dhcp4 = json->get("Dhcp4"); - if (!dhcp4) { - cerr << "Missing mandatory Dhcp4 element" << endl; - return (EXIT_FAILURE); + if (string(PACKAGE_VERSION_TYPE) == "development") { + LOG_WARN(dhcp4_logger, DHCP4_DEVELOPMENT_VERSION); } - ControlledDhcpv4Srv server(0); - ConstElementPtr answer; - // Now we pass the Dhcp4 configuration to the server, but - // tell it to check the configuration only (check_only = true) - answer = configureDhcp4Server(server, dhcp4, true); + // Create the server instance. + ControlledDhcpv4Srv server(server_port_number, client_port_number); + + // Remember verbose-mode + server.setVerbose(verbose_mode); + + // Create our PID file. + server.setProcName(DHCP4_NAME); + server.setConfigFile(config_file); + server.createPIDFile(); + + try { + // Initialize the server. + server.init(config_file); + } catch (const std::exception& ex) { + + try { + // Let's log out what went wrong. + isc::log::LoggerManager log_manager; + log_manager.process(); + LOG_ERROR(dhcp4_logger, DHCP4_INIT_FAIL).arg(ex.what()); + } catch (...) { + // The exception thrown during the initialization could + // originate from logger subsystem. Therefore LOG_ERROR() + // may fail as well. + cerr << "Failed to initialize server: " << ex.what() << endl; + } - int status_code = 0; - answer = isc::config::parseAnswer(status_code, answer); - if (status_code == 0) { - return (EXIT_SUCCESS); - } else { - cerr << "Error encountered: " << answer->stringValue() << endl; return (EXIT_FAILURE); } - } catch (const std::exception& ex) { - cerr << "Syntax check failed with: " << ex.what() << endl; - } - return (EXIT_FAILURE); - } - int ret = EXIT_SUCCESS; - try { - // It is important that we set a default logger name because this name - // will be used when the user doesn't provide the logging configuration - // in the Kea configuration file. - Daemon::setDefaultLoggerName(DHCP4_ROOT_LOGGER_NAME); - - // Initialize logging. If verbose, we'll use maximum verbosity. - Daemon::loggerInit(DHCP4_ROOT_LOGGER_NAME, verbose_mode); - LOG_DEBUG(dhcp4_logger, DBG_DHCP4_START, DHCP4_START_INFO) - .arg(getpid()) - .arg(server_port_number) - .arg(client_port_number) - .arg(verbose_mode ? "yes" : "no"); - - LOG_INFO(dhcp4_logger, DHCP4_STARTING) - .arg(VERSION) - .arg(PACKAGE_VERSION_TYPE); - - if (string(PACKAGE_VERSION_TYPE) == "development") { - LOG_WARN(dhcp4_logger, DHCP4_DEVELOPMENT_VERSION); - } + // Tell the admin we are ready to process packets + LOG_INFO(dhcp4_logger, DHCP4_STARTED).arg(VERSION); - // Create the server instance. - ControlledDhcpv4Srv server(server_port_number, client_port_number); + // And run the main loop of the server. + ret = server.run(); - // Remember verbose-mode - server.setVerbose(verbose_mode); + LOG_INFO(dhcp4_logger, DHCP4_SHUTDOWN); - // Create our PID file. - server.setProcName(DHCP4_NAME); - server.setConfigFile(config_file); - server.createPIDFile(); + } catch (const isc::process::DaemonPIDExists& ex) { + // First, we print the error on stderr (that should always work) + cerr << DHCP4_NAME << " already running? " << ex.what() + << endl; - try { - // Initialize the server. - server.init(config_file); + // Let's also try to log it using logging system, but we're not + // sure if it's usable (the exception may have been thrown from + // the logger subsystem) + try { + LOG_FATAL(dhcp4_logger, DHCP4_ALREADY_RUNNING) + .arg(DHCP4_NAME).arg(ex.what()); + } catch (...) { + // Already logged so ignore + } + ret = EXIT_FAILURE; } catch (const std::exception& ex) { + // First, we print the error on stderr (that should always work) + cerr << DHCP4_NAME << ": Fatal error during start up: " << ex.what() + << endl; + // Let's also try to log it using logging system, but we're not + // sure if it's usable (the exception may have been thrown from + // the logger subsystem) try { - // Let's log out what went wrong. - isc::log::LoggerManager log_manager; - log_manager.process(); - LOG_ERROR(dhcp4_logger, DHCP4_INIT_FAIL).arg(ex.what()); + LOG_FATAL(dhcp4_logger, DHCP4_SERVER_FAILED).arg(ex.what()); } catch (...) { - // The exception thrown during the initialization could - // originate from logger subsystem. Therefore LOG_ERROR() - // may fail as well. - cerr << "Failed to initialize server: " << ex.what() << endl; + // Already logged so ignore } - - return (EXIT_FAILURE); + ret = EXIT_FAILURE; } - // Tell the admin we are ready to process packets - LOG_INFO(dhcp4_logger, DHCP4_STARTED).arg(VERSION); - - // And run the main loop of the server. - ret = server.run(); - - LOG_INFO(dhcp4_logger, DHCP4_SHUTDOWN); - - } catch (const isc::process::DaemonPIDExists& ex) { - // First, we print the error on stderr (that should always work) - cerr << DHCP4_NAME << " already running? " << ex.what() - << endl; - - // Let's also try to log it using logging system, but we're not - // sure if it's usable (the exception may have been thrown from - // the logger subsystem) - try { - LOG_FATAL(dhcp4_logger, DHCP4_ALREADY_RUNNING) - .arg(DHCP4_NAME).arg(ex.what()); - } catch (...) { - // Already logged so ignore - } - ret = EXIT_FAILURE; - } catch (const std::exception& ex) { - // First, we print the error on stderr (that should always work) - cerr << DHCP4_NAME << ": Fatal error during start up: " << ex.what() - << endl; - - // Let's also try to log it using logging system, but we're not - // sure if it's usable (the exception may have been thrown from - // the logger subsystem) - try { - LOG_FATAL(dhcp4_logger, DHCP4_SERVER_FAILED).arg(ex.what()); - } catch (...) { - // Already logged so ignore - } - ret = EXIT_FAILURE; + return (ret); + } catch (...) { } - return (ret); + return (EXIT_FAILURE); } diff --git a/src/bin/dhcp4/parser_context.cc b/src/bin/dhcp4/parser_context.cc index ff9673b81b18df1aaaa9f4071b246b63a5ca99fd..a7367b6573101f48f9386569d86f65cab81b1281 100644 --- a/src/bin/dhcp4/parser_context.cc +++ b/src/bin/dhcp4/parser_context.cc @@ -22,9 +22,6 @@ Parser4Context::Parser4Context() trace_parsing_(false) { } -Parser4Context::~Parser4Context() { -} - isc::data::ElementPtr Parser4Context::parseString(const std::string& str, ParserType parser_type) { scanStringBegin(str, parser_type); diff --git a/src/bin/dhcp4/parser_context.h b/src/bin/dhcp4/parser_context.h index 538800ebf766b73a708f6fe4380ef470fb0157a6..8787b43f0e0e98f8cbeafeed70a23b94bfa07ece 100644 --- a/src/bin/dhcp4/parser_context.h +++ b/src/bin/dhcp4/parser_context.h @@ -32,8 +32,7 @@ public: }; /// @brief Evaluation context, an interface to the expression evaluation. -class Parser4Context -{ +class Parser4Context { public: /// @brief Defines currently supported scopes @@ -95,7 +94,7 @@ public: Parser4Context(); /// @brief destructor - virtual ~Parser4Context(); + virtual ~Parser4Context() = default; /// @brief JSON elements being parsed. std::vector stack_; @@ -396,7 +395,7 @@ public: isc::data::ElementPtr parseCommon(); }; -}; // end of isc::eval namespace -}; // end of isc namespace +} // end of isc::eval namespace +} // end of isc namespace #endif diff --git a/src/bin/dhcp4/tests/classify_unittest.cc b/src/bin/dhcp4/tests/classify_unittest.cc index eb11c257631a18a762dd7c360697fe0471b3e6f5..fd7a42cd694a93be1b7f977f53bbf7ba6b6afc2f 100644 --- a/src/bin/dhcp4/tests/classify_unittest.cc +++ b/src/bin/dhcp4/tests/classify_unittest.cc @@ -388,9 +388,7 @@ public: } /// @brief Destructor. - /// - ~ClassifyTest() { - } + ~ClassifyTest() = default; /// @brief Does client exchanges and checks if fixed fields have expected values. /// diff --git a/src/bin/dhcp4/tests/client_handler_unittest.cc b/src/bin/dhcp4/tests/client_handler_unittest.cc index 50b3ba5e67aac52844afdec9def8594b440a4510..93543b319337ca102f6e19ab4c6fdccca04d1279 100644 --- a/src/bin/dhcp4/tests/client_handler_unittest.cc +++ b/src/bin/dhcp4/tests/client_handler_unittest.cc @@ -36,8 +36,11 @@ public: /// /// Removes statistics. ~ClientHandleTest() { - MultiThreadingMgr::instance().apply(false, 0, 0); - StatsMgr::instance().removeAll(); + try { + MultiThreadingMgr::instance().apply(false, 0, 0); + StatsMgr::instance().removeAll(); + } catch (...) { + } } /// @brief Generates a client-id option. diff --git a/src/bin/dhcp4/tests/config_backend_unittest.cc b/src/bin/dhcp4/tests/config_backend_unittest.cc index 751aef448adbd844fdf12a537232a7c4b0ac02f7..0f5ac1561b9939a2e6a255edc1f2448d7200ea7f 100644 --- a/src/bin/dhcp4/tests/config_backend_unittest.cc +++ b/src/bin/dhcp4/tests/config_backend_unittest.cc @@ -87,7 +87,7 @@ protected: public: - /// Constructor + /// @brief Constructor Dhcp4CBTest() : rcode_(-1), db1_selector("db1"), db2_selector("db1") { // Open port 0 means to not do anything at all. We don't want to @@ -99,10 +99,13 @@ public: resetConfiguration(); } - /// Destructor + /// @brief Destructor virtual ~Dhcp4CBTest() { - resetConfiguration(); - }; + try { + resetConfiguration(); + } catch (...) { + } + } /// @brief Reset configuration singletons. void resetConfiguration() { diff --git a/src/bin/dhcp4/tests/config_parser_unittest.cc b/src/bin/dhcp4/tests/config_parser_unittest.cc index bbbb976361e44f796e86e80fd6987ed13fc37f14..84ef17c4598c5e340c55b76598f28bfc9525a9ba 100644 --- a/src/bin/dhcp4/tests/config_parser_unittest.cc +++ b/src/bin/dhcp4/tests/config_parser_unittest.cc @@ -276,6 +276,8 @@ protected: } public: + + /// @brief Constructor Dhcp4ParserTest() : rcode_(-1) { // Open port 0 means to not do anything at all. We don't want to @@ -286,8 +288,6 @@ public: resetConfiguration(); } -public: - // Checks if the result of DHCP server configuration has // expected code (0 for success, other for failures). // Also stores result in rcode_ and comment_. @@ -348,13 +348,17 @@ public: } } + /// @brief Destructor ~Dhcp4ParserTest() { - resetConfiguration(); + try { + resetConfiguration(); - // ... and delete the hooks library marker files if present - static_cast(remove(LOAD_MARKER_FILE)); - static_cast(remove(UNLOAD_MARKER_FILE)); - }; + // ... and delete the hooks library marker files if present + static_cast(remove(LOAD_MARKER_FILE)); + static_cast(remove(UNLOAD_MARKER_FILE)); + } catch (...) { + } + } /// @brief Returns an interface configuration used by the most of the /// unit tests. diff --git a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc index 176dff5ed9ce8fae99c9a53d2914489ed2af37f9..69344abd34b8ff07061b78310bf9a6ed51576c30 100644 --- a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc @@ -74,7 +74,10 @@ public: /// /// Stops IO service. ~IOServiceWork() { - io_service_->stop(); + try { + io_service_->stop(); + } catch (...) { + } } private: @@ -123,16 +126,19 @@ public: /// @brief Destructor ~CtrlChannelDhcpv4SrvTest() { - LeaseMgrFactory::destroy(); - StatsMgr::instance().removeAll(); + try { + LeaseMgrFactory::destroy(); + StatsMgr::instance().removeAll(); - CommandMgr::instance().closeCommandSocket(); - CommandMgr::instance().deregisterAll(); - CommandMgr::instance().setConnectionTimeout(TIMEOUT_DHCP_SERVER_RECEIVE_COMMAND); + CommandMgr::instance().closeCommandSocket(); + CommandMgr::instance().deregisterAll(); + CommandMgr::instance().setConnectionTimeout(TIMEOUT_DHCP_SERVER_RECEIVE_COMMAND); - server_.reset(); - MultiThreadingMgr::instance().setMode(false); - }; + server_.reset(); + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } + } /// @brief Returns pointer to the server's IO service. /// @@ -1979,4 +1985,4 @@ TEST_F(CtrlChannelDhcpv4SrvTest, connectionTimeoutNoData) { "\"Connection over control channel timed out\" }", response); } -} // End of anonymous namespace +} // end of anonymous namespace diff --git a/src/bin/dhcp4/tests/d2_unittest.cc b/src/bin/dhcp4/tests/d2_unittest.cc index 0a11144fd4a747874d7864049722d91960f98f66..24c7713baad5e302ebe41b8f470b99b6bca5e403 100644 --- a/src/bin/dhcp4/tests/d2_unittest.cc +++ b/src/bin/dhcp4/tests/d2_unittest.cc @@ -39,7 +39,10 @@ Dhcp4SrvD2Test::Dhcp4SrvD2Test() : rcode_(-1) { } Dhcp4SrvD2Test::~Dhcp4SrvD2Test() { - reset(); + try { + reset(); + } catch (...) { + } } dhcp_ddns::NameChangeRequestPtr diff --git a/src/bin/dhcp4/tests/d2_unittest.h b/src/bin/dhcp4/tests/d2_unittest.h index 20474e352efc24a4f82f639fd574eed3b67a1846..62376eded7b0bebe050b73dfbfe9529c907a49aa 100644 --- a/src/bin/dhcp4/tests/d2_unittest.h +++ b/src/bin/dhcp4/tests/d2_unittest.h @@ -32,8 +32,7 @@ public: } /// @brief virtual Destructor. - virtual ~D2Dhcpv4Srv() { - } + virtual ~D2Dhcpv4Srv() = default; /// @brief Override the error handler. virtual void d2ClientErrorHandler(const dhcp_ddns::NameChangeSender:: @@ -108,8 +107,8 @@ public: D2Dhcpv4Srv srv_; }; -}; // end of isc::dhcp::test namespace -}; // end of isc::dhcp namespace -}; // end of isc namespace +} // end of isc::dhcp::test namespace +} // end of isc::dhcp namespace +} // end of isc namespace #endif // D2_UNITTEST_H diff --git a/src/bin/dhcp4/tests/dhcp4_test_utils.cc b/src/bin/dhcp4/tests/dhcp4_test_utils.cc index 3a4353c6dac152252baf96c8b2e12dad595db24d..6ebb2003b647474824941ab2cc4e1205b446595c 100644 --- a/src/bin/dhcp4/tests/dhcp4_test_utils.cc +++ b/src/bin/dhcp4/tests/dhcp4_test_utils.cc @@ -44,16 +44,19 @@ BaseServerTest::BaseServerTest() } BaseServerTest::~BaseServerTest() { - // Remove default lease file. - std::ostringstream s2; - s2 << CfgMgr::instance().getDataDir() << "/" << "kea-leases4.csv"; - static_cast(::remove(s2.str().c_str())); + try { + // Remove default lease file. + std::ostringstream s2; + s2 << CfgMgr::instance().getDataDir() << "/" << "kea-leases4.csv"; + static_cast(::remove(s2.str().c_str())); - // Revert to original data directory. - CfgMgr::instance().setDataDir(original_datadir_); + // Revert to original data directory. + CfgMgr::instance().setDataDir(original_datadir_); - // Revert to unit test logging, in case the test reconfigured it. - isc::log::initLogger(); + // Revert to unit test logging, in case the test reconfigured it. + isc::log::initLogger(); + } catch (...) { + } } Dhcpv4SrvTest::Dhcpv4SrvTest() @@ -87,17 +90,19 @@ Dhcpv4SrvTest::Dhcpv4SrvTest() } Dhcpv4SrvTest::~Dhcpv4SrvTest() { + try { + // Make sure that we revert to default value + CfgMgr::instance().clear(); - // Make sure that we revert to default value - CfgMgr::instance().clear(); + LibDHCP::clearRuntimeOptionDefs(); - LibDHCP::clearRuntimeOptionDefs(); + // Let's wipe all existing statistics. + isc::stats::StatsMgr::instance().removeAll(); - // Let's wipe all existing statistics. - isc::stats::StatsMgr::instance().removeAll(); - - // Reset the thread pool. - MultiThreadingMgr::instance().apply(false, 0, 0); + // Reset the thread pool. + MultiThreadingMgr::instance().apply(false, 0, 0); + } catch (...) { + } } void Dhcpv4SrvTest::addPrlOption(Pkt4Ptr& pkt) { diff --git a/src/bin/dhcp4/tests/dhcp4_test_utils.h b/src/bin/dhcp4/tests/dhcp4_test_utils.h index 7d35a16907ce48b4c192d3ec46575aeb9de737d8..ad0aec2ec649c61d54f684e5ce638350600a9c08 100644 --- a/src/bin/dhcp4/tests/dhcp4_test_utils.h +++ b/src/bin/dhcp4/tests/dhcp4_test_utils.h @@ -208,8 +208,8 @@ public: fake_received_.push_back(pkt); } - virtual ~NakedDhcpv4Srv() { - } + /// @brief Destructor + virtual ~NakedDhcpv4Srv() = default; /// @brief Runs processing DHCPREQUEST. /// @@ -301,7 +301,6 @@ private: /// @brief Holds the original data directory. std::string original_datadir_; - }; class Dhcpv4SrvTest : public BaseServerTest { @@ -314,12 +313,20 @@ public: class Dhcpv4SrvMTTestGuard { public: + + /// @brief Constructor Dhcpv4SrvMTTestGuard(Dhcpv4SrvTest& test, bool mt_enabled) : test_(test) { test_.setMultiThreading(mt_enabled); } + + /// @brief Destructor ~Dhcpv4SrvMTTestGuard() { - test_.setMultiThreading(false); + try { + test_.setMultiThreading(false); + } catch (...) { + } } + Dhcpv4SrvTest& test_; }; diff --git a/src/bin/dhcp4/tests/dhcp4to6_ipc_unittest.cc b/src/bin/dhcp4/tests/dhcp4to6_ipc_unittest.cc index 2a47d718219306a0ea5ad066e73093993c99cb1c..c5fc41b7726dd2b0886210be40fbff12d7bc08b2 100644 --- a/src/bin/dhcp4/tests/dhcp4to6_ipc_unittest.cc +++ b/src/bin/dhcp4/tests/dhcp4to6_ipc_unittest.cc @@ -75,12 +75,15 @@ public: /// /// Various cleanups. virtual ~Dhcp4to6IpcTest() { - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("buffer4_send"); - callback_recv_pkt_.reset(); - callback_sent_pkt_.reset(); - bool status = HooksManager::unloadLibraries(); - if (!status) { - cerr << "(fixture dtor) unloadLibraries failed" << endl; + try { + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("buffer4_send"); + callback_recv_pkt_.reset(); + callback_sent_pkt_.reset(); + bool status = HooksManager::unloadLibraries(); + if (!status) { + cerr << "(fixture dtor) unloadLibraries failed" << endl; + } + } catch (...) { } } diff --git a/src/bin/dhcp4/tests/dora_unittest.cc b/src/bin/dhcp4/tests/dora_unittest.cc index 0faf40fe0a3e21e2027db48ba5d11f33059c24e8..8bc32086ef9edaa74bb7ff3f1bca610a6f094d9c 100644 --- a/src/bin/dhcp4/tests/dora_unittest.cc +++ b/src/bin/dhcp4/tests/dora_unittest.cc @@ -594,8 +594,11 @@ public: /// /// Cleans up statistics after the test. ~DORATest() { - // Let's wipe all existing statistics. - isc::stats::StatsMgr::instance().removeAll(); + try { + // Let's wipe all existing statistics. + isc::stats::StatsMgr::instance().removeAll(); + } catch (...) { + } } /// @brief Test that server returns the same lease for the client which is @@ -2698,6 +2701,7 @@ TEST_F(DORATest, storeExtendedInfoDisabledMultiThreading) { /// @brief Test fixture class for the test utilizing MySQL database backend. class DORAMySQLTest : public DORATest { public: + /// @brief Constructor. /// /// Recreates MySQL schema for a test. @@ -2710,8 +2714,11 @@ public: /// /// Destroys MySQL schema. virtual ~DORAMySQLTest() { - // If data wipe enabled, delete transient data otherwise destroy the schema. - db::test::destroyMySQLSchema(); + try { + // If data wipe enabled, delete transient data otherwise destroy the schema. + db::test::destroyMySQLSchema(); + } catch (...) { + } } }; @@ -2741,6 +2748,7 @@ TEST_F(DORAMySQLTest, multiStageBootMultiThreading) { /// @brief Test fixture class for the test utilizing PostgreSQL database backend. class DORAPgSQLTest : public DORATest { public: + /// @brief Constructor. /// /// Recreates PgSQL schema for a test. @@ -2753,8 +2761,11 @@ public: /// /// Destroys PgSQL schema. virtual ~DORAPgSQLTest() { - // If data wipe enabled, delete transient data otherwise destroy the schema - db::test::destroyPgSQLSchema(); + try { + // If data wipe enabled, delete transient data otherwise destroy the schema + db::test::destroyPgSQLSchema(); + } catch (...) { + } } }; @@ -2783,6 +2794,7 @@ TEST_F(DORAPgSQLTest, multiStageBootMultiThreading) { // --with-cql. class DORACQLTest : public DORATest { public: + /// @brief Constructor. /// /// Recreates CQL schema for a test. @@ -2795,8 +2807,11 @@ public: /// /// Destroys CQL schema. virtual ~DORACQLTest() { - // If data wipe enabled, delete transient data otherwise destroy the schema - db::test::destroyCqlSchema(); + try { + // If data wipe enabled, delete transient data otherwise destroy the schema + db::test::destroyCqlSchema(); + } catch (...) { + } } }; diff --git a/src/bin/dhcp4/tests/fqdn_unittest.cc b/src/bin/dhcp4/tests/fqdn_unittest.cc index cb9a3e9a431f97f7533776ce87a708d80cdb0ac0..257ae00e7648af4b42cd44969cbec754f0ad0523 100644 --- a/src/bin/dhcp4/tests/fqdn_unittest.cc +++ b/src/bin/dhcp4/tests/fqdn_unittest.cc @@ -332,21 +332,25 @@ public: NAME_NOT_REPLACED }; + /// @brief Constructor NameDhcpv4SrvTest() : Dhcpv4SrvTest(), d2_mgr_(CfgMgr::instance().getD2ClientMgr()), - iface_mgr_test_config_(true) - { + iface_mgr_test_config_(true) { srv_ = boost::make_shared(0); IfaceMgr::instance().openSockets4(); // Config DDNS to be enabled, all controls off enableD2(); } + /// @brief Destructor virtual ~NameDhcpv4SrvTest() { - // CfgMgr singleton doesn't get wiped between tests, so we'll - // disable D2 explicitly between tests. - disableD2(); + try { + // CfgMgr singleton doesn't get wiped between tests, so we'll + // disable D2 explicitly between tests. + disableD2(); + } catch (...) { + } } /// @brief Sets the server's DDNS configuration to ddns updates disabled. diff --git a/src/bin/dhcp4/tests/get_config_unittest.cc b/src/bin/dhcp4/tests/get_config_unittest.cc index 56d8a4443ee1e264f3106187dd976135be5f3ebf..b092416aa50ce680235d12131e9a098711b9579e 100644 --- a/src/bin/dhcp4/tests/get_config_unittest.cc +++ b/src/bin/dhcp4/tests/get_config_unittest.cc @@ -11308,6 +11308,8 @@ namespace { /// Test fixture class (code from Dhcp4ParserTest) class Dhcp4GetConfigTest : public ::testing::TestWithParam { public: + + /// @brief Constructor Dhcp4GetConfigTest() : rcode_(-1) { // Open port 0 means to not do anything at all. We don't want to @@ -11318,9 +11320,13 @@ public: resetConfiguration(); } + /// @brief Destructor ~Dhcp4GetConfigTest() { - resetConfiguration(); - }; + try { + resetConfiguration(); + } catch (...) { + } + } /// @brief Parse and Execute configuration /// diff --git a/src/bin/dhcp4/tests/get_config_unittest.cc.skel b/src/bin/dhcp4/tests/get_config_unittest.cc.skel index cc4a64a349a1bd85f6ee89f1255118f0ee7b5aa8..3a47a1ab1a699cc52bf4a0f8c783362c7ba34bd0 100644 --- a/src/bin/dhcp4/tests/get_config_unittest.cc.skel +++ b/src/bin/dhcp4/tests/get_config_unittest.cc.skel @@ -165,6 +165,8 @@ namespace { /// Test fixture class (code from Dhcp4ParserTest) class Dhcp4GetConfigTest : public ::testing::TestWithParam { public: + + /// @brief Constructor Dhcp4GetConfigTest() : rcode_(-1) { // Open port 0 means to not do anything at all. We don't want to @@ -175,9 +177,13 @@ public: resetConfiguration(); } + /// @brief Destructor ~Dhcp4GetConfigTest() { - resetConfiguration(); - }; + try { + resetConfiguration(); + } catch (...) { + } + } /// @brief Parse and Execute configuration /// diff --git a/src/bin/dhcp4/tests/hooks_unittest.cc b/src/bin/dhcp4/tests/hooks_unittest.cc index f96653339ab236ce079b2dcdaa80c46fb56f64cd..41c801dae1502f8cce388077c6420521a4243a0e 100644 --- a/src/bin/dhcp4/tests/hooks_unittest.cc +++ b/src/bin/dhcp4/tests/hooks_unittest.cc @@ -99,10 +99,9 @@ const uint8_t dummySname[] = "Lorem ipsum dolor sit amet, consectetur " /// fields are declared static. It is still better to keep them as /// one class rather than unrelated collection of global objects. class HooksDhcpv4SrvTest : public Dhcpv4SrvTest { - public: - /// @brief creates Dhcpv4Srv and prepares buffers for callouts + /// @brief Constructor creates Dhcpv4Srv and prepares buffers for callouts HooksDhcpv4SrvTest() { HooksManager::setTestMode(false); bool status = HooksManager::unloadLibraries(); @@ -119,27 +118,30 @@ public: io_service_ = boost::make_shared(); } - /// @brief destructor (deletes Dhcpv4Srv) + /// @brief Destructor (deletes Dhcpv4Srv) virtual ~HooksDhcpv4SrvTest() { - // clear static buffers - resetCalloutBuffers(); - - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("dhcp4_srv_configured"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("buffer4_receive"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("buffer4_send"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("pkt4_receive"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("pkt4_send"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("subnet4_select"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease4_renew"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease4_release"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease4_decline"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("host4_identifier"); - - delete srv_; - HooksManager::setTestMode(false); - bool status = HooksManager::unloadLibraries(); - if (!status) { - cerr << "(fixture dtor) unloadLibraries failed" << endl; + try { + // clear static buffers + resetCalloutBuffers(); + + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("dhcp4_srv_configured"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("buffer4_receive"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("buffer4_send"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("pkt4_receive"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("pkt4_send"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("subnet4_select"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease4_renew"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease4_release"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease4_decline"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("host4_identifier"); + + delete srv_; + HooksManager::setTestMode(false); + bool status = HooksManager::unloadLibraries(); + if (!status) { + cerr << "(fixture dtor) unloadLibraries failed" << endl; + } + } catch (...) { } } @@ -868,9 +870,11 @@ bool HooksDhcpv4SrvTest::callback_resp_options_copy_; /// @brief Fixture class used to do basic library load/unload tests class LoadUnloadDhcpv4SrvTest : public ::testing::Test { public: + /// @brief Pointer to the tested server object boost::shared_ptr server_; + /// @brief Constructor LoadUnloadDhcpv4SrvTest() { reset(); MultiThreadingMgr::instance().setMode(false); @@ -878,10 +882,13 @@ public: /// @brief Destructor ~LoadUnloadDhcpv4SrvTest() { - server_.reset(); - reset(); - MultiThreadingMgr::instance().setMode(false); - }; + try { + server_.reset(); + reset(); + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } + } /// @brief Reset hooks data /// diff --git a/src/bin/dhcp4/tests/host_unittest.cc b/src/bin/dhcp4/tests/host_unittest.cc index 6502f68fa2f1fe7b8ed9bdfaa9557619d08307e6..16e13b2c1ce346468f923226d965e4fd3b3abc00 100644 --- a/src/bin/dhcp4/tests/host_unittest.cc +++ b/src/bin/dhcp4/tests/host_unittest.cc @@ -410,8 +410,11 @@ public: /// /// Cleans up statistics after the test. ~HostTest() { - // Let's wipe all existing statistics. - isc::stats::StatsMgr::instance().removeAll(); + try { + // Let's wipe all existing statistics. + isc::stats::StatsMgr::instance().removeAll(); + } catch (...) { + } } /// @brief Interface Manager's fake configuration control. diff --git a/src/bin/dhcp4/tests/inform_unittest.cc b/src/bin/dhcp4/tests/inform_unittest.cc index f6d83fd360715e1533613196e75ba4d67f449965..eff7c9018bc946943abfd7b1e03162bd308420cd 100644 --- a/src/bin/dhcp4/tests/inform_unittest.cc +++ b/src/bin/dhcp4/tests/inform_unittest.cc @@ -143,13 +143,15 @@ public: /// /// Cleans up statistics after the test. ~InformTest() { - // Let's wipe all existing statistics. - isc::stats::StatsMgr::instance().removeAll(); + try { + // Let's wipe all existing statistics. + isc::stats::StatsMgr::instance().removeAll(); + } catch (...) { + } } /// @brief Interface Manager's fake configuration control. IfaceMgrTestConfig iface_mgr_test_config_; - }; // Test that directly connected client's DHCPINFORM message is processed and diff --git a/src/bin/dhcp4/tests/kea_controller_unittest.cc b/src/bin/dhcp4/tests/kea_controller_unittest.cc index 55495ef1215b3e56421c7e0d700de7adb81ca47e..174b4fb90acb7296732434762695640d04d50a7a 100644 --- a/src/bin/dhcp4/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp4/tests/kea_controller_unittest.cc @@ -196,14 +196,19 @@ public: /// near future. class JSONFileBackendTest : public isc::dhcp::test::BaseServerTest { public: - JSONFileBackendTest() { - } + /// @brief Constructor + JSONFileBackendTest() = default; + + /// @brief Destructor ~JSONFileBackendTest() { - LeaseMgrFactory::destroy(); - static_cast(remove(TEST_FILE)); - static_cast(remove(TEST_INCLUDE)); - }; + try { + LeaseMgrFactory::destroy(); + static_cast(remove(TEST_FILE)); + static_cast(remove(TEST_INCLUDE)); + } catch (...) { + } + } /// @brief writes specified content to a well known file /// @@ -969,8 +974,11 @@ public: /// /// Destroys MySQL schema. virtual ~JSONFileBackendMySQLTest() { - // If data wipe enabled, delete transient data otherwise destroy the schema. - destroyMySQLSchema(); + try { + // If data wipe enabled, delete transient data otherwise destroy the schema. + destroyMySQLSchema(); + } catch (...) { + } } /// @brief Creates server configuration with specified backend type. diff --git a/src/bin/dhcp4/tests/out_of_range_unittest.cc b/src/bin/dhcp4/tests/out_of_range_unittest.cc index 850002da2e0ab0c8bdb99239572f598a282e448b..620ea291053e7b4b7ba5737a3707b01f608c6cd2 100644 --- a/src/bin/dhcp4/tests/out_of_range_unittest.cc +++ b/src/bin/dhcp4/tests/out_of_range_unittest.cc @@ -205,8 +205,7 @@ public: /// @brief Destructor. /// /// Cleans up statistics after the test. - ~OutOfRangeTest() { - } + ~OutOfRangeTest() = default; void configure(const std::string& config, Dhcp4Client& client) { NakedDhcpv4Srv& server = *client.getServer(); diff --git a/src/bin/dhcp4/tests/shared_network_unittest.cc b/src/bin/dhcp4/tests/shared_network_unittest.cc index 60eb4550e750802aa7f74dc646c1bbd1971e2488..960ce0438ad373632b3b6995f403bdcf5182f943 100644 --- a/src/bin/dhcp4/tests/shared_network_unittest.cc +++ b/src/bin/dhcp4/tests/shared_network_unittest.cc @@ -1322,7 +1322,10 @@ public: /// @brief Destructor. virtual ~Dhcpv4SharedNetworkTest() { - StatsMgr::instance().removeAll(); + try { + StatsMgr::instance().removeAll(); + } catch (...) { + } } /// @brief Interface Manager's fake configuration control. diff --git a/src/bin/dhcp6/client_handler.cc b/src/bin/dhcp6/client_handler.cc index f160392d122a1a858b877c3837fc9fa1acf2bde6..f1cbd62ffb3422ec45b508c40c0684ce95623758 100644 --- a/src/bin/dhcp6/client_handler.cc +++ b/src/bin/dhcp6/client_handler.cc @@ -71,13 +71,13 @@ ClientHandler::del(const DuidPtr& duid) { clients_.erase(duid->getDuid()); } -ClientHandler::ClientHandler() : client_(), locked_() { -} - ClientHandler::~ClientHandler() { - if (locked_) { - lock_guard lk(mutex_); - unLock(); + try { + if (locked_) { + lock_guard lk(mutex_); + unLock(); + } + } catch (...) { } } diff --git a/src/bin/dhcp6/client_handler.h b/src/bin/dhcp6/client_handler.h index 175c0a19d5d6d3646dea012e3d27090cfbce44c8..7c5c7b753048a6f118d87d4fdb1b16cfdaecb479 100644 --- a/src/bin/dhcp6/client_handler.h +++ b/src/bin/dhcp6/client_handler.h @@ -129,7 +129,7 @@ public: /// Public interface. /// @brief Constructor. - ClientHandler(); + ClientHandler() = default; /// @brief Destructor. /// diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index b593d07293d255cdf0d875fac3ef6c1469180004..fa0bd573d1a278dfd499a95682fa81b81fc4dea5 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -261,39 +261,42 @@ void Dhcpv6Srv::setPacketStatisticsDefaults() { } Dhcpv6Srv::~Dhcpv6Srv() { - // Discard any parked packets - discardPackets(); - try { - stopD2(); - } catch (const std::exception& ex) { - // Highly unlikely, but lets Report it but go on - LOG_ERROR(dhcp6_logger, DHCP6_SRV_D2STOP_ERROR).arg(ex.what()); - } + // Discard any parked packets + discardPackets(); - try { - Dhcp6to4Ipc::instance().close(); - } catch (const std::exception& ex) { - // Highly unlikely, but lets Report it but go on - // LOG_ERROR(dhcp6_logger, DHCP6_SRV_DHCP4O6_ERROR).arg(ex.what()); - } + try { + stopD2(); + } catch (const std::exception& ex) { + // Highly unlikely, but lets Report it but go on + LOG_ERROR(dhcp6_logger, DHCP6_SRV_D2STOP_ERROR).arg(ex.what()); + } - IfaceMgr::instance().closeSockets(); + try { + Dhcp6to4Ipc::instance().close(); + } catch (const std::exception& ex) { + // Highly unlikely, but lets Report it but go on + // LOG_ERROR(dhcp6_logger, DHCP6_SRV_DHCP4O6_ERROR).arg(ex.what()); + } + + IfaceMgr::instance().closeSockets(); - LeaseMgrFactory::destroy(); + LeaseMgrFactory::destroy(); - // Explicitly unload hooks - HooksManager::prepareUnloadLibraries(); - if (!HooksManager::unloadLibraries()) { - auto names = HooksManager::getLibraryNames(); - std::string msg; - if (!names.empty()) { - msg = names[0]; - for (size_t i = 1; i < names.size(); ++i) { - msg += std::string(", ") + names[i]; + // Explicitly unload hooks + HooksManager::prepareUnloadLibraries(); + if (!HooksManager::unloadLibraries()) { + auto names = HooksManager::getLibraryNames(); + std::string msg; + if (!names.empty()) { + msg = names[0]; + for (size_t i = 1; i < names.size(); ++i) { + msg += std::string(", ") + names[i]; + } } + LOG_ERROR(dhcp6_logger, DHCP6_SRV_UNLOAD_LIBRARIES_ERROR).arg(msg); } - LOG_ERROR(dhcp6_logger, DHCP6_SRV_UNLOAD_LIBRARIES_ERROR).arg(msg); + } catch (...) { } } diff --git a/src/bin/dhcp6/dhcp6to4_ipc.cc b/src/bin/dhcp6/dhcp6to4_ipc.cc index 68b497023808a399e14444a8caaf71fa44e6511f..fa5297e09734dd602d26df7db0ca72e2a817e305 100644 --- a/src/bin/dhcp6/dhcp6to4_ipc.cc +++ b/src/bin/dhcp6/dhcp6to4_ipc.cc @@ -29,8 +29,6 @@ namespace dhcp { uint16_t Dhcp6to4Ipc::client_port = 0; -Dhcp6to4Ipc::Dhcp6to4Ipc() : Dhcp4o6IpcBase() {} - Dhcp6to4Ipc& Dhcp6to4Ipc::instance() { static Dhcp6to4Ipc dhcp6to4_ipc; return (dhcp6to4_ipc); diff --git a/src/bin/dhcp6/dhcp6to4_ipc.h b/src/bin/dhcp6/dhcp6to4_ipc.h index 1d393e988479f7f9b26971ff6f76411c3b4db398..31919e8ae783a4820b04a7473acff351d5b951a2 100644 --- a/src/bin/dhcp6/dhcp6to4_ipc.h +++ b/src/bin/dhcp6/dhcp6to4_ipc.h @@ -20,13 +20,14 @@ namespace dhcp { /// @brief Handles DHCPv4-over-DHCPv6 IPC on the DHCPv6 server side class Dhcp6to4Ipc : public Dhcp4o6IpcBase { protected: + /// @brief Constructor /// /// Default constructor - Dhcp6to4Ipc(); + Dhcp6to4Ipc() = default; /// @brief Destructor. - virtual ~Dhcp6to4Ipc() { } + virtual ~Dhcp6to4Ipc() = default; public: /// @brief Returns pointer to the sole instance of Dhcp6to4Ipc diff --git a/src/bin/dhcp6/main.cc b/src/bin/dhcp6/main.cc index a216aa5dad725c20e2b1a150c74d0317a43cca6a..6e37bc4b78a642fcb2caa70442fc193e459e0ba4 100644 --- a/src/bin/dhcp6/main.cc +++ b/src/bin/dhcp6/main.cc @@ -52,7 +52,7 @@ usage() { cerr << endl; cerr << "Usage: " << DHCP6_NAME << " -[v|V|W] [-d] [-{c|t} cfgfile] [-p number] [-P number]" << endl; - cerr << " -v: print version number and exit." << endl; + cerr << " -v: print version number and exit" << endl; cerr << " -V: print extended version and exit" << endl; cerr << " -W: display the configuration report and exit" << endl; cerr << " -d: debug mode with extra verbosity (former -v)" << endl; @@ -68,231 +68,236 @@ usage() { int main(int argc, char* argv[]) { - int ch; - // The default. Any other values are useful for testing only. - int server_port_number = DHCP6_SERVER_PORT; - // Not zero values are useful for testing only. - int client_port_number = 0; - bool verbose_mode = false; // Should server be verbose? - bool check_mode = false; // Check syntax - - // The standard config file - std::string config_file(""); - - while ((ch = getopt(argc, argv, "dvVWc:p:P:t:")) != -1) { - switch (ch) { - case 'd': - verbose_mode = true; - break; - - case 'v': - cout << Dhcpv6Srv::getVersion(false) << endl; - return (EXIT_SUCCESS); - - case 'V': - cout << Dhcpv6Srv::getVersion(true) << endl; - return (EXIT_SUCCESS); - - case 'W': - cout << isc::detail::getConfigReport() << endl; - return (EXIT_SUCCESS); - - case 't': - check_mode = true; - // falls through - - case 'c': // config file - config_file = optarg; - break; - - case 'p': // server port number - try { - server_port_number = boost::lexical_cast(optarg); - } catch (const boost::bad_lexical_cast &) { - cerr << "Failed to parse server port number: [" << optarg - << "], 1-65535 allowed." << endl; - usage(); - } - if (server_port_number <= 0 || server_port_number > 65535) { - cerr << "Failed to parse server port number: [" << optarg - << "], 1-65535 allowed." << endl; - usage(); - } - break; + try { + int ch; + // The default. Any other values are useful for testing only. + int server_port_number = DHCP6_SERVER_PORT; + // Not zero values are useful for testing only. + int client_port_number = 0; + bool verbose_mode = false; // Should server be verbose? + bool check_mode = false; // Check syntax + + // The standard config file + std::string config_file(""); + + while ((ch = getopt(argc, argv, "dvVWc:p:P:t:")) != -1) { + switch (ch) { + case 'd': + verbose_mode = true; + break; + + case 'v': + cout << Dhcpv6Srv::getVersion(false) << endl; + return (EXIT_SUCCESS); - case 'P': // client port number - try { - client_port_number = boost::lexical_cast(optarg); - } catch (const boost::bad_lexical_cast &) { - cerr << "Failed to parse client port number: [" << optarg - << "], 1-65535 allowed." << endl; - usage(); - } - if (client_port_number <= 0 || client_port_number > 65535) { - cerr << "Failed to parse client port number: [" << optarg - << "], 1-65535 allowed." << endl; + case 'V': + cout << Dhcpv6Srv::getVersion(true) << endl; + return (EXIT_SUCCESS); + + case 'W': + cout << isc::detail::getConfigReport() << endl; + return (EXIT_SUCCESS); + + case 't': + check_mode = true; + // falls through + + case 'c': // config file + config_file = optarg; + break; + + case 'p': // server port number + try { + server_port_number = boost::lexical_cast(optarg); + } catch (const boost::bad_lexical_cast &) { + cerr << "Failed to parse server port number: [" << optarg + << "], 1-65535 allowed." << endl; + usage(); + } + if (server_port_number <= 0 || server_port_number > 65535) { + cerr << "Failed to parse server port number: [" << optarg + << "], 1-65535 allowed." << endl; + usage(); + } + break; + + case 'P': // client port number + try { + client_port_number = boost::lexical_cast(optarg); + } catch (const boost::bad_lexical_cast &) { + cerr << "Failed to parse client port number: [" << optarg + << "], 1-65535 allowed." << endl; + usage(); + } + if (client_port_number <= 0 || client_port_number > 65535) { + cerr << "Failed to parse client port number: [" << optarg + << "], 1-65535 allowed." << endl; + usage(); + } + break; + + default: usage(); } - break; + } - default: + // Check for extraneous parameters. + if (argc > optind) { usage(); } - } - // Check for extraneous parameters. - if (argc > optind) { - usage(); - } + // Configuration file is required. + if (config_file.empty()) { + cerr << "Configuration file not specified." << endl; + usage(); + } - // Configuration file is required. - if (config_file.empty()) { - cerr << "Configuration file not specified." << endl; - usage(); - } + // This is the DHCPv6 server + CfgMgr::instance().setFamily(AF_INET6); - // This is the DHCPv6 server - CfgMgr::instance().setFamily(AF_INET6); + if (check_mode) { + try { + // We need to initialize logging, in case any error messages are to be printed. + // This is just a test, so we don't care about lockfile. + setenv("KEA_LOCKFILE_DIR", "none", 0); + Daemon::setDefaultLoggerName(DHCP6_ROOT_LOGGER_NAME); + Daemon::loggerInit(DHCP6_ROOT_LOGGER_NAME, verbose_mode); + + // Check the syntax first. + Parser6Context parser; + ConstElementPtr json; + json = parser.parseFile(config_file, Parser6Context::PARSER_DHCP6); + if (!json) { + cerr << "No configuration found" << endl; + return (EXIT_FAILURE); + } + if (verbose_mode) { + cerr << "Syntax check OK" << endl; + } + + // Check the logic next. + ConstElementPtr dhcp6 = json->get("Dhcp6"); + if (!dhcp6) { + cerr << "Missing mandatory Dhcp6 element" << endl; + return (EXIT_FAILURE); + } + ControlledDhcpv6Srv server(0); + ConstElementPtr answer; + + // Now we pass the Dhcp6 configuration to the server, but + // tell it to check the configuration only (check_only = true) + answer = configureDhcp6Server(server, dhcp6, true); + + int status_code = 0; + answer = isc::config::parseAnswer(status_code, answer); + if (status_code == 0) { + return (EXIT_SUCCESS); + } else { + cerr << "Error encountered: " << answer->stringValue() << endl; + return (EXIT_FAILURE); + } + } catch (const std::exception& ex) { + cerr << "Syntax check failed with: " << ex.what() << endl; + } + return (EXIT_FAILURE); + } - if (check_mode) { + int ret = EXIT_SUCCESS; try { - // We need to initialize logging, in case any error messages are to be printed. - // This is just a test, so we don't care about lockfile. - setenv("KEA_LOCKFILE_DIR", "none", 0); + // It is important that we set a default logger name because this name + // will be used when the user doesn't provide the logging configuration + // in the Kea configuration file. Daemon::setDefaultLoggerName(DHCP6_ROOT_LOGGER_NAME); - Daemon::loggerInit(DHCP6_ROOT_LOGGER_NAME, verbose_mode); - // Check the syntax first. - Parser6Context parser; - ConstElementPtr json; - json = parser.parseFile(config_file, Parser6Context::PARSER_DHCP6); - if (!json) { - cerr << "No configuration found" << endl; - return (EXIT_FAILURE); - } - if (verbose_mode) { - cerr << "Syntax check OK" << endl; + // Initialize logging. If verbose, we'll use maximum verbosity. + Daemon::loggerInit(DHCP6_ROOT_LOGGER_NAME, verbose_mode); + LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_START_INFO) + .arg(getpid()) + .arg(server_port_number) + .arg(client_port_number) + .arg(verbose_mode ? "yes" : "no"); + + LOG_INFO(dhcp6_logger, DHCP6_STARTING) + .arg(VERSION) + .arg(PACKAGE_VERSION_TYPE); + + if (string(PACKAGE_VERSION_TYPE) == "development") { + LOG_WARN(dhcp6_logger, DHCP6_DEVELOPMENT_VERSION); } - // Check the logic next. - ConstElementPtr dhcp6 = json->get("Dhcp6"); - if (!dhcp6) { - cerr << "Missing mandatory Dhcp6 element" << endl; - return (EXIT_FAILURE); - } - ControlledDhcpv6Srv server(0); - ConstElementPtr answer; + // Create the server instance. + ControlledDhcpv6Srv server(server_port_number, client_port_number); - // Now we pass the Dhcp6 configuration to the server, but - // tell it to check the configuration only (check_only = true) - answer = configureDhcp6Server(server, dhcp6, true); + // Remember verbose-mode + server.setVerbose(verbose_mode); + + // Create our PID file. + server.setProcName(DHCP6_NAME); + server.setConfigFile(config_file); + server.createPIDFile(); + + try { + // Initialize the server. + server.init(config_file); + } catch (const std::exception& ex) { + + try { + // Let's log out what went wrong. + isc::log::LoggerManager log_manager; + log_manager.process(); + LOG_ERROR(dhcp6_logger, DHCP6_INIT_FAIL).arg(ex.what()); + } catch (...) { + // The exception thrown during the initialization could + // originate from logger subsystem. Therefore LOG_ERROR() + // may fail as well. + cerr << "Failed to initialize server: " << ex.what() << endl; + } - int status_code = 0; - answer = isc::config::parseAnswer(status_code, answer); - if (status_code == 0) { - return (EXIT_SUCCESS); - } else { - cerr << "Error encountered: " << answer->stringValue() << endl; return (EXIT_FAILURE); } - } catch (const std::exception& ex) { - cerr << "Syntax check failed with: " << ex.what() << endl; - } - return (EXIT_FAILURE); - } - int ret = EXIT_SUCCESS; - try { - // It is important that we set a default logger name because this name - // will be used when the user doesn't provide the logging configuration - // in the Kea configuration file. - Daemon::setDefaultLoggerName(DHCP6_ROOT_LOGGER_NAME); - - // Initialize logging. If verbose, we'll use maximum verbosity. - Daemon::loggerInit(DHCP6_ROOT_LOGGER_NAME, verbose_mode); - LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_START_INFO) - .arg(getpid()) - .arg(server_port_number) - .arg(client_port_number) - .arg(verbose_mode ? "yes" : "no"); - - LOG_INFO(dhcp6_logger, DHCP6_STARTING) - .arg(VERSION) - .arg(PACKAGE_VERSION_TYPE); - - if (string(PACKAGE_VERSION_TYPE) == "development") { - LOG_WARN(dhcp6_logger, DHCP6_DEVELOPMENT_VERSION); - } + // Tell the admin we are ready to process packets + LOG_INFO(dhcp6_logger, DHCP6_STARTED).arg(VERSION); - // Create the server instance. - ControlledDhcpv6Srv server(server_port_number, client_port_number); + // And run the main loop of the server. + ret = server.run(); - // Remember verbose-mode - server.setVerbose(verbose_mode); + LOG_INFO(dhcp6_logger, DHCP6_SHUTDOWN); - // Create our PID file. - server.setProcName(DHCP6_NAME); - server.setConfigFile(config_file); - server.createPIDFile(); + } catch (const isc::process::DaemonPIDExists& ex) { + // First, we print the error on stderr (that should always work) + cerr << DHCP6_NAME << " already running? " << ex.what() + << endl; - try { - // Initialize the server. - server.init(config_file); + // Let's also try to log it using logging system, but we're not + // sure if it's usable (the exception may have been thrown from + // the logger subsystem) + try { + LOG_FATAL(dhcp6_logger, DHCP6_ALREADY_RUNNING) + .arg(DHCP6_NAME).arg(ex.what()); + } catch (...) { + // Already logged so ignore + } + ret = EXIT_FAILURE; } catch (const std::exception& ex) { + // First, we print the error on stderr (that should always work) + cerr << DHCP6_NAME << ": Fatal error during start up: " << ex.what() + << endl; + // Let's also try to log it using logging system, but we're not + // sure if it's usable (the exception may have been thrown from + // the logger subsystem) try { - // Let's log out what went wrong. - isc::log::LoggerManager log_manager; - log_manager.process(); - LOG_ERROR(dhcp6_logger, DHCP6_INIT_FAIL).arg(ex.what()); + LOG_FATAL(dhcp6_logger, DHCP6_SERVER_FAILED).arg(ex.what()); } catch (...) { - // The exception thrown during the initialization could - // originate from logger subsystem. Therefore LOG_ERROR() may - // fail as well. - cerr << "Failed to initialize server: " << ex.what() << endl; + // Already logged so ignore } - - return (EXIT_FAILURE); + ret = EXIT_FAILURE; } - // Tell the admin we are ready to process packets - LOG_INFO(dhcp6_logger, DHCP6_STARTED).arg(VERSION); - - // And run the main loop of the server. - ret = server.run(); - - LOG_INFO(dhcp6_logger, DHCP6_SHUTDOWN); - - } catch (const isc::process::DaemonPIDExists& ex) { - // First, we print the error on stderr (that should always work) - cerr << DHCP6_NAME << " already running? " << ex.what() - << endl; - - // Let's also try to log it using logging system, but we're not - // sure if it's usable (the exception may have been thrown from - // the logger subsystem) - try { - LOG_FATAL(dhcp6_logger, DHCP6_ALREADY_RUNNING) - .arg(DHCP6_NAME).arg(ex.what()); - } catch (...) { - // Already logged so ignore - } - ret = EXIT_FAILURE; - } catch (const std::exception& ex) { - // First, we print the error on stderr (that should always work) - cerr << DHCP6_NAME << "Fatal error during start up: " << ex.what() - << endl; - - // Let's also try to log it using logging system, but we're not - // sure if it's usable (the exception may have been thrown from - // the logger subsystem) - try { - LOG_FATAL(dhcp6_logger, DHCP6_SERVER_FAILED).arg(ex.what()); - } catch (...) { - // Already logged so ignore - } - ret = EXIT_FAILURE; + return (ret); + } catch (...) { } - return (ret); + return (EXIT_FAILURE); } diff --git a/src/bin/dhcp6/parser_context.cc b/src/bin/dhcp6/parser_context.cc index 2a0694b3703bbdc7caf227087eb250a544125de3..40b44061ef527fa0df7f2db1fc8c94217ec233f8 100644 --- a/src/bin/dhcp6/parser_context.cc +++ b/src/bin/dhcp6/parser_context.cc @@ -22,9 +22,6 @@ Parser6Context::Parser6Context() trace_parsing_(false) { } -Parser6Context::~Parser6Context() { -} - isc::data::ElementPtr Parser6Context::parseString(const std::string& str, ParserType parser_type) { scanStringBegin(str, parser_type); diff --git a/src/bin/dhcp6/parser_context.h b/src/bin/dhcp6/parser_context.h index 1b89f747c322efb6b48db5cd67085029677940b0..aa22f1f556c15e68e3d17a4dc4848cbef9ceeb8d 100644 --- a/src/bin/dhcp6/parser_context.h +++ b/src/bin/dhcp6/parser_context.h @@ -32,8 +32,7 @@ public: }; /// @brief Evaluation context, an interface to the expression evaluation. -class Parser6Context -{ +class Parser6Context { public: /// @brief Defines currently supported scopes @@ -98,7 +97,7 @@ public: Parser6Context(); /// @brief destructor - virtual ~Parser6Context(); + virtual ~Parser6Context() = default; /// @brief JSON elements being parsed. std::vector stack_; @@ -402,7 +401,7 @@ public: isc::data::ElementPtr parseCommon(); }; -}; // end of isc::eval namespace -}; // end of isc namespace +} // end of isc::eval namespace +} // end of isc namespace #endif diff --git a/src/bin/dhcp6/tests/client_handler_unittest.cc b/src/bin/dhcp6/tests/client_handler_unittest.cc index 6eed4c4bbdfb1b13d77e6cf0b16556859ca1bff0..3345313921177f80d51e7efb13d03c7d628c0dd9 100644 --- a/src/bin/dhcp6/tests/client_handler_unittest.cc +++ b/src/bin/dhcp6/tests/client_handler_unittest.cc @@ -36,8 +36,11 @@ public: /// /// Removes statistics. ~ClientHandleTest() { - MultiThreadingMgr::instance().apply(false, 0, 0); - StatsMgr::instance().removeAll(); + try { + MultiThreadingMgr::instance().apply(false, 0, 0); + StatsMgr::instance().removeAll(); + } catch (...) { + } } /// @brief Generates a client-id option. diff --git a/src/bin/dhcp6/tests/config_backend_unittest.cc b/src/bin/dhcp6/tests/config_backend_unittest.cc index 879cf877c163a7df7ec35f5bea77f7d55316d686..2775ca719686309ed3e8172ace551122d18ee59d 100644 --- a/src/bin/dhcp6/tests/config_backend_unittest.cc +++ b/src/bin/dhcp6/tests/config_backend_unittest.cc @@ -89,7 +89,7 @@ protected: public: - /// Constructor + /// @brief Constructor Dhcp6CBTest() : rcode_(-1), db1_selector("db1"), db2_selector("db1") { // Open port 0 means to not do anything at all. We don't want to @@ -102,10 +102,13 @@ public: CfgMgr::instance().setFamily(AF_INET6); } - /// Destructor + /// @brief Destructor virtual ~Dhcp6CBTest() { - resetConfiguration(); - }; + try { + resetConfiguration(); + } catch (...) { + } + } /// @brief Reset configuration singletons. void resetConfiguration() { diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc index be3895ac0c3571d4338b6defdaa46b6c73f5a7a1..d9499c52a359793edc7334e5d1a4019f7c484dd7 100644 --- a/src/bin/dhcp6/tests/config_parser_unittest.cc +++ b/src/bin/dhcp6/tests/config_parser_unittest.cc @@ -362,6 +362,8 @@ protected: } public: + + /// @brief Constructor Dhcp6ParserTest() :rcode_(-1), srv_(0) { // srv_(0) means to not open any sockets. We don't want to // deal with sockets here, just check if configuration handling @@ -388,14 +390,18 @@ public: resetConfiguration(); } + /// @brief Destructor ~Dhcp6ParserTest() { - // Reset configuration database after each test. - resetConfiguration(); + try { + // Reset configuration database after each test. + resetConfiguration(); - // ... and delete the hooks library marker files if present - static_cast(remove(LOAD_MARKER_FILE)); - static_cast(remove(UNLOAD_MARKER_FILE)); - }; + // ... and delete the hooks library marker files if present + static_cast(remove(LOAD_MARKER_FILE)); + static_cast(remove(UNLOAD_MARKER_FILE)); + } catch (...) { + } + } // Checks if config_result (result of DHCP server configuration) has // expected code (0 for success, other for failures). diff --git a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc index ca9f4c981af8b096ecd8b4e5b9be5d297600b168..e0ebe6337dd7e2100104919f06a313cf68303f65 100644 --- a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc @@ -71,7 +71,10 @@ public: /// /// Stops IO service. ~IOServiceWork() { - io_service_->stop(); + try { + io_service_->stop(); + } catch (...) { + } } private: @@ -98,20 +101,25 @@ const size_t DEFAULT_CONNECTION_TIMEOUT = 10000; class CtrlDhcpv6SrvTest : public BaseServerTest { public: + + /// @brief Constructor CtrlDhcpv6SrvTest() : BaseServerTest() { reset(); } + /// @brief Destructor virtual ~CtrlDhcpv6SrvTest() { - LeaseMgrFactory::destroy(); - StatsMgr::instance().removeAll(); - CommandMgr::instance().deregisterAll(); - CommandMgr::instance().setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT); - - reset(); - }; - + try { + LeaseMgrFactory::destroy(); + StatsMgr::instance().removeAll(); + CommandMgr::instance().deregisterAll(); + CommandMgr::instance().setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT); + + reset(); + } catch (...) { + } + } /// @brief Reset hooks data /// @@ -156,10 +164,13 @@ public: /// @brief Destructor ~CtrlChannelDhcpv6SrvTest() { - server_.reset(); - reset(); - MultiThreadingMgr::instance().setMode(false); - }; + try { + server_.reset(); + reset(); + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } + } /// @brief Returns pointer to the server's IO service. /// @@ -2007,4 +2018,4 @@ TEST_F(CtrlChannelDhcpv6SrvTest, connectionTimeoutNoData) { "\"Connection over control channel timed out\" }", response); } -} // End of anonymous namespace +} // end of anonymous namespace diff --git a/src/bin/dhcp6/tests/d2_unittest.cc b/src/bin/dhcp6/tests/d2_unittest.cc index ef58d21d5a053dfb275b4ebc9afa493c58567c46..e1ba97bf309ccd5b490e0d5cbbaa18d83a6e7c3f 100644 --- a/src/bin/dhcp6/tests/d2_unittest.cc +++ b/src/bin/dhcp6/tests/d2_unittest.cc @@ -41,7 +41,10 @@ Dhcp6SrvD2Test::Dhcp6SrvD2Test() : rcode_(-1) { } Dhcp6SrvD2Test::~Dhcp6SrvD2Test() { - reset(); + try { + reset(); + } catch (...) { + } } dhcp_ddns::NameChangeRequestPtr diff --git a/src/bin/dhcp6/tests/d2_unittest.h b/src/bin/dhcp6/tests/d2_unittest.h index 55b94620ccfe84cf0483a97ab095cf21c0ab2022..f7d57d740f97cae45c58046b3a6bee40bbe2d266 100644 --- a/src/bin/dhcp6/tests/d2_unittest.h +++ b/src/bin/dhcp6/tests/d2_unittest.h @@ -32,8 +32,7 @@ public: } /// @brief virtual Destructor. - virtual ~D2Dhcpv6Srv() { - } + virtual ~D2Dhcpv6Srv() = default; /// @brief Override the error handler. virtual void d2ClientErrorHandler(const dhcp_ddns::NameChangeSender:: @@ -107,8 +106,8 @@ public: D2Dhcpv6Srv srv_; }; -}; // end of isc::dhcp::test namespace -}; // end of isc::dhcp namespace -}; // end of isc namespace +} // end of isc::dhcp::test namespace +} // end of isc::dhcp namespace +} // end of isc namespace #endif // D2_UNITTEST_H diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.cc b/src/bin/dhcp6/tests/dhcp6_test_utils.cc index 7c132a75675af669f8dc36d9df2f86481d283b7c..304ed5e0caf8353bf58c1b4138752f5f5a724b1e 100644 --- a/src/bin/dhcp6/tests/dhcp6_test_utils.cc +++ b/src/bin/dhcp6/tests/dhcp6_test_utils.cc @@ -37,21 +37,24 @@ BaseServerTest::BaseServerTest() } BaseServerTest::~BaseServerTest() { - // Remove test DUID file. - std::ostringstream s; - s << CfgMgr::instance().getDataDir() << "/" << DUID_FILE; - static_cast(::remove(s.str().c_str())); - - // Remove default lease file. - std::ostringstream s2; - s2 << CfgMgr::instance().getDataDir() << "/" << "kea-leases6.csv"; - static_cast(::remove(s2.str().c_str())); - - // Revert to original data directory. - CfgMgr::instance().setDataDir(original_datadir_); - - // Revert to unit test logging in case the test reconfigured logging. - isc::log::initLogger(); + try { + // Remove test DUID file. + std::ostringstream s; + s << CfgMgr::instance().getDataDir() << "/" << DUID_FILE; + static_cast(::remove(s.str().c_str())); + + // Remove default lease file. + std::ostringstream s2; + s2 << CfgMgr::instance().getDataDir() << "/" << "kea-leases6.csv"; + static_cast(::remove(s2.str().c_str())); + + // Revert to original data directory. + CfgMgr::instance().setDataDir(original_datadir_); + + // Revert to unit test logging in case the test reconfigured logging. + isc::log::initLogger(); + } catch (...) { + } } Dhcpv6SrvTest::Dhcpv6SrvTest() @@ -81,11 +84,14 @@ Dhcpv6SrvTest::Dhcpv6SrvTest() } Dhcpv6SrvTest::~Dhcpv6SrvTest() { - isc::dhcp::CfgMgr::instance().clear(); + try { + isc::dhcp::CfgMgr::instance().clear(); - // Reset the thread pool. - MultiThreadingMgr::instance().apply(false, 0, 0); -}; + // Reset the thread pool. + MultiThreadingMgr::instance().apply(false, 0, 0); + } catch (...) { + } +} // Checks that server response (ADVERTISE or REPLY) contains proper IA_NA option // It returns IAADDR option for each chaining with checkIAAddr method. @@ -875,25 +881,28 @@ NakedDhcpv6SrvTest::NakedDhcpv6SrvTest() } NakedDhcpv6SrvTest::~NakedDhcpv6SrvTest() { - // Let's wipe all existing statistics. - isc::stats::StatsMgr::instance().removeAll(); - - // Let's clean up if there is such a file. - static_cast(remove(DUID_FILE)); - isc::hooks::HooksManager::preCalloutsLibraryHandle() - .deregisterAllCallouts("buffer6_receive"); - isc::hooks::HooksManager::preCalloutsLibraryHandle() - .deregisterAllCallouts("buffer6_send"); - isc::hooks::HooksManager::preCalloutsLibraryHandle() - .deregisterAllCallouts("lease6_renew"); - isc::hooks::HooksManager::preCalloutsLibraryHandle() - .deregisterAllCallouts("lease6_release"); - isc::hooks::HooksManager::preCalloutsLibraryHandle() - .deregisterAllCallouts("pkt6_receive"); - isc::hooks::HooksManager::preCalloutsLibraryHandle() - .deregisterAllCallouts("pkt6_send"); - isc::hooks::HooksManager::preCalloutsLibraryHandle() - .deregisterAllCallouts("subnet6_select"); + try { + // Let's wipe all existing statistics. + isc::stats::StatsMgr::instance().removeAll(); + + // Let's clean up if there is such a file. + static_cast(remove(DUID_FILE)); + isc::hooks::HooksManager::preCalloutsLibraryHandle() + .deregisterAllCallouts("buffer6_receive"); + isc::hooks::HooksManager::preCalloutsLibraryHandle() + .deregisterAllCallouts("buffer6_send"); + isc::hooks::HooksManager::preCalloutsLibraryHandle() + .deregisterAllCallouts("lease6_renew"); + isc::hooks::HooksManager::preCalloutsLibraryHandle() + .deregisterAllCallouts("lease6_release"); + isc::hooks::HooksManager::preCalloutsLibraryHandle() + .deregisterAllCallouts("pkt6_receive"); + isc::hooks::HooksManager::preCalloutsLibraryHandle() + .deregisterAllCallouts("pkt6_send"); + isc::hooks::HooksManager::preCalloutsLibraryHandle() + .deregisterAllCallouts("subnet6_select"); + } catch (...) { + } } // Generate IA_NA option with specified parameters diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.h b/src/bin/dhcp6/tests/dhcp6_test_utils.h index f894b213f1be3d6f1134c93dc1b5fbc95ce1a8c1..e66bf0de7edf949615db8539f87928d9f40f4537 100644 --- a/src/bin/dhcp6/tests/dhcp6_test_utils.h +++ b/src/bin/dhcp6/tests/dhcp6_test_utils.h @@ -134,6 +134,8 @@ private: /// @brief "naked" Dhcpv6Srv class that exposes internal members class NakedDhcpv6Srv: public isc::dhcp::Dhcpv6Srv { public: + + /// @brief Constructor NakedDhcpv6Srv(uint16_t port) : isc::dhcp::Dhcpv6Srv(port) { // Open the "memfile" database for leases std::string memfile = "type=memfile universe=6 persist=false"; @@ -219,9 +221,13 @@ public: fake_received_.push_back(pkt); } + /// @brief Destructor virtual ~NakedDhcpv6Srv() { - // Close the lease database - isc::dhcp::LeaseMgrFactory::destroy(); + try { + // Close the lease database + isc::dhcp::LeaseMgrFactory::destroy(); + } catch (...) { + } } /// @brief Processes incoming Request message. @@ -503,6 +509,7 @@ public: EXPECT_EQ(expected_transid, rsp->getTransid()); } + /// @brief Destructor virtual ~NakedDhcpv6SrvTest(); // A DUID used in most tests (typically as client-id) @@ -543,12 +550,20 @@ public: class Dhcpv6SrvMTTestGuard { public: + + /// @brief Constructor Dhcpv6SrvMTTestGuard(Dhcpv6SrvTest& test, bool mt_enabled) : test_(test) { test_.setMultiThreading(mt_enabled); } + + /// @brief Destructor ~Dhcpv6SrvMTTestGuard() { - test_.setMultiThreading(false); + try{ + test_.setMultiThreading(false); + } catch (...) { + } } + Dhcpv6SrvTest& test_; }; diff --git a/src/bin/dhcp6/tests/dhcp6to4_ipc_unittest.cc b/src/bin/dhcp6/tests/dhcp6to4_ipc_unittest.cc index ce7e077f7c6dfc704252e34b9970103a46a45130..6815d71afb29fbcc11b1ca0ac752ab1d5a58e6df 100644 --- a/src/bin/dhcp6/tests/dhcp6to4_ipc_unittest.cc +++ b/src/bin/dhcp6/tests/dhcp6to4_ipc_unittest.cc @@ -64,12 +64,15 @@ public: /// /// Various cleanups. virtual ~Dhcp6to4IpcTest() { - Dhcp6to4Ipc::client_port = 0; - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("buffer6_send"); - callback_pkt_.reset(); - bool status = HooksManager::unloadLibraries(); - if (!status) { - std::cerr << "(fixture dtor) unloadLibraries failed" << std::endl; + try { + Dhcp6to4Ipc::client_port = 0; + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("buffer6_send"); + callback_pkt_.reset(); + bool status = HooksManager::unloadLibraries(); + if (!status) { + std::cerr << "(fixture dtor) unloadLibraries failed" << std::endl; + } + } catch (...) { } } diff --git a/src/bin/dhcp6/tests/fqdn_unittest.cc b/src/bin/dhcp6/tests/fqdn_unittest.cc index 2e2910ef9f1e4d9cd69af1e8de4ee413d99dcb76..889c4db52b99ec96d596269d8fc4d3915776d136 100644 --- a/src/bin/dhcp6/tests/fqdn_unittest.cc +++ b/src/bin/dhcp6/tests/fqdn_unittest.cc @@ -88,10 +88,13 @@ public: /// @brief Destructor virtual ~FqdnDhcpv6SrvTest() { - // Default constructor creates a config with DHCP-DDNS updates - // disabled. - D2ClientConfigPtr cfg(new D2ClientConfig()); - CfgMgr::instance().setD2ClientConfig(cfg); + try { + // Default constructor creates a config with DHCP-DDNS updates + // disabled. + D2ClientConfigPtr cfg(new D2ClientConfig()); + CfgMgr::instance().setD2ClientConfig(cfg); + } catch (...) { + } } /// @brief Sets the server's DDNS configuration to ddns updates disabled. diff --git a/src/bin/dhcp6/tests/get_config_unittest.cc b/src/bin/dhcp6/tests/get_config_unittest.cc index 46ba9b8e9db7b056b1578f3a15e25192f76170ef..3712ac270c0a664fa5dadf92c137bf9cdb15d793 100644 --- a/src/bin/dhcp6/tests/get_config_unittest.cc +++ b/src/bin/dhcp6/tests/get_config_unittest.cc @@ -9861,6 +9861,8 @@ namespace { /// Test fixture class (code from Dhcp6ParserTest) class Dhcp6GetConfigTest : public ::testing::TestWithParam { public: + + /// @brief Constructor Dhcp6GetConfigTest() : rcode_(-1), srv_(0) { // srv_(0) means to not open any sockets. We don't want to // deal with sockets here, just check if configuration handling @@ -9870,10 +9872,14 @@ public: resetConfiguration(); } + /// @brief Destructor ~Dhcp6GetConfigTest() { - // Reset configuration database after each test. - resetConfiguration(); - }; + try { + // Reset configuration database after each test. + resetConfiguration(); + } catch (...) { + } + } /// @brief Parse and Execute configuration /// diff --git a/src/bin/dhcp6/tests/get_config_unittest.cc.skel b/src/bin/dhcp6/tests/get_config_unittest.cc.skel index 0945e09fa6021e860a224e992c533185f8c7f1af..47c01260a81d87ef91c21b1254aa299613c001bd 100644 --- a/src/bin/dhcp6/tests/get_config_unittest.cc.skel +++ b/src/bin/dhcp6/tests/get_config_unittest.cc.skel @@ -166,6 +166,8 @@ namespace { /// Test fixture class (code from Dhcp6ParserTest) class Dhcp6GetConfigTest : public ::testing::TestWithParam { public: + + /// @brief Constructor Dhcp6GetConfigTest() : rcode_(-1), srv_(0) { // srv_(0) means to not open any sockets. We don't want to // deal with sockets here, just check if configuration handling @@ -175,10 +177,14 @@ public: resetConfiguration(); } + /// @brief Destructor ~Dhcp6GetConfigTest() { - // Reset configuration database after each test. - resetConfiguration(); - }; + try { + // Reset configuration database after each test. + resetConfiguration(); + } catch (...) { + } + } /// @brief Parse and Execute configuration /// diff --git a/src/bin/dhcp6/tests/hooks_unittest.cc b/src/bin/dhcp6/tests/hooks_unittest.cc index 8d64e3a6c3922ee3ded0826db64315ac637321ad..f0c0c4080aa85e2b635076c229ada31e342919d2 100644 --- a/src/bin/dhcp6/tests/hooks_unittest.cc +++ b/src/bin/dhcp6/tests/hooks_unittest.cc @@ -113,10 +113,9 @@ TEST_F(Dhcpv6SrvTest, Hooks) { /// fields are declared static. It is still better to keep them as /// one class rather than unrelated collection of global objects. class HooksDhcpv6SrvTest : public Dhcpv6SrvTest { - public: - /// @brief creates Dhcpv6Srv and prepares buffers for callouts + /// @brief Constructor creates Dhcpv6Srv and prepares buffers for callouts HooksDhcpv6SrvTest() : Dhcpv6SrvTest() { @@ -138,27 +137,30 @@ public: HooksManager::unloadLibraries(); } - /// @brief destructor (deletes Dhcpv6Srv) + /// @brief Destructor (deletes Dhcpv6Srv) ~HooksDhcpv6SrvTest() { - // Clear static buffers - resetCalloutBuffers(); - - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("buffer6_receive"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("pkt6_receive"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("pkt6_send"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("buffer6_send"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("subnet6_select"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("leases6_committed"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease6_renew"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease6_release"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease6_rebind"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease6_decline"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("host6_identifier"); - - HooksManager::setTestMode(false); - bool status = HooksManager::unloadLibraries(); - if (!status) { - cerr << "(fixture dtor) unloadLibraries failed" << endl; + try { + // Clear static buffers + resetCalloutBuffers(); + + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("buffer6_receive"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("pkt6_receive"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("pkt6_send"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("buffer6_send"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("subnet6_select"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("leases6_committed"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease6_renew"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease6_release"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease6_rebind"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("lease6_decline"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("host6_identifier"); + + HooksManager::setTestMode(false); + bool status = HooksManager::unloadLibraries(); + if (!status) { + cerr << "(fixture dtor) unloadLibraries failed" << endl; + } + } catch (...) { } } @@ -982,9 +984,11 @@ bool HooksDhcpv6SrvTest::callback_resp_options_copy_; /// @brief Fixture class used to do basic library load/unload tests class LoadUnloadDhcpv6SrvTest : public Dhcpv6SrvTest { public: + /// @brief Pointer to the tested server object boost::shared_ptr server_; + /// @brief Constructor LoadUnloadDhcpv6SrvTest() : Dhcpv6SrvTest() { reset(); @@ -993,10 +997,13 @@ public: /// @brief Destructor ~LoadUnloadDhcpv6SrvTest() { - server_.reset(); - reset(); - MultiThreadingMgr::instance().setMode(false); - }; + try { + server_.reset(); + reset(); + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } + } /// @brief Reset hooks data /// diff --git a/src/bin/dhcp6/tests/infrequest_unittest.cc b/src/bin/dhcp6/tests/infrequest_unittest.cc index a264b09c2fa1ffd95c8fc81b7b7154862ce3cbb8..c9417acb56e0df888835dce7ccde995279d66ad8 100644 --- a/src/bin/dhcp6/tests/infrequest_unittest.cc +++ b/src/bin/dhcp6/tests/infrequest_unittest.cc @@ -112,6 +112,7 @@ const char* CONFIGS[] = { /// Request-Reply. class InfRequestTest : public Dhcpv6SrvTest { public: + /// @brief Constructor. /// /// Sets up fake interfaces. @@ -127,8 +128,11 @@ public: /// /// Removes any statistics that may have been set. ~InfRequestTest() { - // Let's wipe all existing statistics. - isc::stats::StatsMgr::instance().removeAll(); + try { + // Let's wipe all existing statistics. + isc::stats::StatsMgr::instance().removeAll(); + } catch (...) { + } } /// @brief Interface Manager's fake configuration control. diff --git a/src/bin/dhcp6/tests/kea_controller_unittest.cc b/src/bin/dhcp6/tests/kea_controller_unittest.cc index a1249132726ee83278c20436e9f950fd7f570f07..4b7a228dea6b063a5e9af3476c5ea82e0481eb06 100644 --- a/src/bin/dhcp6/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp6/tests/kea_controller_unittest.cc @@ -188,16 +188,22 @@ public: class JSONFileBackendTest : public dhcp::test::BaseServerTest { public: + + /// @brief Constructor JSONFileBackendTest() : BaseServerTest() { } + /// @brief Destructor ~JSONFileBackendTest() { - LeaseMgrFactory::destroy(); - isc::log::setDefaultLoggingOutput(); - static_cast(remove(TEST_FILE)); - static_cast(remove(TEST_INCLUDE)); - }; + try { + LeaseMgrFactory::destroy(); + isc::log::setDefaultLoggingOutput(); + static_cast(remove(TEST_FILE)); + static_cast(remove(TEST_INCLUDE)); + } catch (...) { + } + } void writeFile(const std::string& file_name, const std::string& content) { static_cast(remove(file_name.c_str())); @@ -954,8 +960,11 @@ public: /// /// Destroys MySQL schema. virtual ~JSONFileBackendMySQLTest() { - // If data wipe enabled, delete transient data otherwise destroy the schema. - destroyMySQLSchema(); + try { + // If data wipe enabled, delete transient data otherwise destroy the schema. + destroyMySQLSchema(); + } catch (...) { + } } /// @brief Creates server configuration with specified backend type. @@ -1077,4 +1086,4 @@ TEST_F(JSONFileBackendMySQLTest, reconfigureBackendMemfileToMySQL) { #endif -} // End of anonymous namespace +} // end of anonymous namespace diff --git a/src/bin/dhcp6/tests/sarr_unittest.cc b/src/bin/dhcp6/tests/sarr_unittest.cc index cd485eed9397ecde3693bdbd13b7ef3f362789fa..89efb02852abc7b2594e3460b4bbdb831a579c0b 100644 --- a/src/bin/dhcp6/tests/sarr_unittest.cc +++ b/src/bin/dhcp6/tests/sarr_unittest.cc @@ -221,6 +221,7 @@ const char* CONFIGS[] = { /// Request-Reply and 2-way exchange: Solicit-Reply. class SARRTest : public Dhcpv6SrvTest { public: + /// @brief Constructor. /// /// Sets up fake interfaces. @@ -235,11 +236,14 @@ public: /// /// Clear the DHCP-DDNS configuration. virtual ~SARRTest() { - D2ClientConfigPtr cfg(new D2ClientConfig()); - CfgMgr::instance().setD2ClientConfig(cfg); - - // Let's wipe all existing statistics. - isc::stats::StatsMgr::instance().removeAll(); + try { + D2ClientConfigPtr cfg(new D2ClientConfig()); + CfgMgr::instance().setD2ClientConfig(cfg); + + // Let's wipe all existing statistics. + isc::stats::StatsMgr::instance().removeAll(); + } catch (...) { + } } /// @brief Check that server processes correctly a prefix hint sent by the diff --git a/src/bin/dhcp6/tests/shared_network_unittest.cc b/src/bin/dhcp6/tests/shared_network_unittest.cc index 63aee55e00c1b491c4ea0399ebf3bff513baf135..a7b8258790e1fd94b640760cf1554d1c90383cb9 100644 --- a/src/bin/dhcp6/tests/shared_network_unittest.cc +++ b/src/bin/dhcp6/tests/shared_network_unittest.cc @@ -1491,7 +1491,10 @@ public: /// @brief Destructor. virtual ~Dhcpv6SharedNetworkTest() { - StatsMgr::instance().removeAll(); + try { + StatsMgr::instance().removeAll(); + } catch (...) { + } } /// @brief Interface Manager's fake configuration control. diff --git a/src/bin/lfc/lfc_controller.cc b/src/bin/lfc/lfc_controller.cc index ebd95cf23683e11fcefb99479b293a47ab21d6cf..aec68fce82b46f653aae861828bdefbc2a6e93aa 100644 --- a/src/bin/lfc/lfc_controller.cc +++ b/src/bin/lfc/lfc_controller.cc @@ -55,9 +55,6 @@ LFCController::LFCController() copy_file_(""), output_file_(""), finish_file_(""), pid_file_("") { } -LFCController::~LFCController() { -} - void LFCController::launch(int argc, char* argv[], const bool test_mode) { bool do_rotate = true; diff --git a/src/bin/lfc/lfc_controller.h b/src/bin/lfc/lfc_controller.h index d58b418358d5481560714ab11d685ceb068bf6f3..dba8c7aa39f0e752603360b42a09c49d5f7ee747 100644 --- a/src/bin/lfc/lfc_controller.h +++ b/src/bin/lfc/lfc_controller.h @@ -48,7 +48,7 @@ public: LFCController(); /// @brief Destructor - ~LFCController(); + ~LFCController() = default; /// @brief Acts as the primary entry point to start execution /// of the process. @@ -197,7 +197,7 @@ private: void startLogger(const bool test_mode) const; }; -}; // namespace isc::lfc -}; // namespace isc +} // namespace isc::lfc +} // namespace isc #endif // LFC_CONTROLLER_H diff --git a/src/bin/lfc/main.cc b/src/bin/lfc/main.cc index 36023428c7d509ac94b7fcfc5acd6f466da5f709..e0cd2681f3c0824d24e74c4fc5e6fe5cd7d1c9a6 100644 --- a/src/bin/lfc/main.cc +++ b/src/bin/lfc/main.cc @@ -24,19 +24,20 @@ using namespace isc::lfc; /// The exit value of the program will be EXIT_SUCCESS if there were no /// errors, EXIT_FAILURE otherwise. int main(int argc, char* argv[]) { - // Ask scheduling to not give too much resources to LFC. - // First parameter means to change only the process priority. - // Second parameter (0) means the calling process. - // Third parameter 4 is a bit below the default priority of 0 in - // a range of -20 (highest priority) and 19 or 20 (lowest priority). - static_cast(setpriority(PRIO_PROCESS, 0, 4)); - int ret = EXIT_SUCCESS; - LFCController lfc_controller; + try { + // Ask scheduling to not give too much resources to LFC. + // First parameter means to change only the process priority. + // Second parameter (0) means the calling process. + // Third parameter 4 is a bit below the default priority of 0 in + // a range of -20 (highest priority) and 19 or 20 (lowest priority). + static_cast(setpriority(PRIO_PROCESS, 0, 4)); + + LFCController lfc_controller; + + // Launch the controller passing in command line arguments. + // Exit program with the controller's return code. - // Launch the controller passing in command line arguments. - // Exit program with the controller's return code. - try { // 'false' value disables test mode. lfc_controller.launch(argc, argv, false); @@ -47,6 +48,8 @@ int main(int argc, char* argv[]) { } catch (const std::exception& ex) { std::cerr << "Service failed: " << ex.what() << std::endl; ret = EXIT_FAILURE; + } catch (...) { + ret = EXIT_FAILURE; } return (ret); diff --git a/src/bin/netconf/control_socket.h b/src/bin/netconf/control_socket.h index a075cb73aed0101c15fb422d854333dacbc32aeb..e1c1e5185e45a471dda524862ed76bcf22f5c369 100644 --- a/src/bin/netconf/control_socket.h +++ b/src/bin/netconf/control_socket.h @@ -44,8 +44,7 @@ public: } /// @brief Destructor (does nothing). - virtual ~ControlSocketBase() { - } + virtual ~ControlSocketBase() = default; /// @brief Getter which returns the socket type. /// diff --git a/src/bin/netconf/http_control_socket.cc b/src/bin/netconf/http_control_socket.cc index dbe46440ea935600f98c76595efbb7d02a824396..ec1f9ae569016e204a1582379397e292d85dd4d5 100644 --- a/src/bin/netconf/http_control_socket.cc +++ b/src/bin/netconf/http_control_socket.cc @@ -37,9 +37,6 @@ HttpControlSocket::HttpControlSocket(CfgControlSocketPtr ctrl_sock) : ControlSocketBase(ctrl_sock) { } -HttpControlSocket::~HttpControlSocket() { -} - ConstElementPtr HttpControlSocket::configGet(const string& service) { if (service == "ca") { diff --git a/src/bin/netconf/http_control_socket.h b/src/bin/netconf/http_control_socket.h index 48023733cefc1aa5dfed638cc08697c541bb7b36..c37b65fc450ba1267fa6ef39967d0ffb06e8c5cc 100644 --- a/src/bin/netconf/http_control_socket.h +++ b/src/bin/netconf/http_control_socket.h @@ -29,7 +29,7 @@ public: HttpControlSocket(CfgControlSocketPtr ctrl_sock); /// @brief Destructor (does nothing). - virtual ~HttpControlSocket(); + virtual ~HttpControlSocket() = default; /// @brief Get configuration. /// diff --git a/src/bin/netconf/main.cc b/src/bin/netconf/main.cc index 30155b0909d0722c04a476ca2b7b534d829af642..4b56478ccb876b96bdfcb391081f35e7e8b47a75 100644 --- a/src/bin/netconf/main.cc +++ b/src/bin/netconf/main.cc @@ -18,7 +18,7 @@ int main(int argc, char* argv[]) { // Launch the controller passing in command line arguments. // Exit program with the controller's return code. - try { + try { // Instantiate/fetch the application controller singleton. DControllerBasePtr& controller = NetconfController::instance(); @@ -38,6 +38,8 @@ int main(int argc, char* argv[]) { } catch (const isc::Exception& ex) { std::cerr << "Service failed: " << ex.what() << std::endl; ret = EXIT_FAILURE; + } catch (...) { + ret = EXIT_FAILURE; } return (ret); diff --git a/src/bin/netconf/netconf.cc b/src/bin/netconf/netconf.cc index ef279793225a8893dcc9fc9cad53345f41697aa2..ecaae1b87c1c48b3ec298404eb1184ecb4591b9f 100644 --- a/src/bin/netconf/netconf.cc +++ b/src/bin/netconf/netconf.cc @@ -125,11 +125,14 @@ public: namespace isc { namespace netconf { -NetconfAgent::NetconfAgent() { +NetconfAgent::NetconfAgent() : cancel_(false) { } NetconfAgent::~NetconfAgent() { - clear(); + try { + clear(); + } catch (...) { + } } void diff --git a/src/bin/netconf/netconf.h b/src/bin/netconf/netconf.h index 125c5a7b1ac99548868515db8199769bbb11589d..adc103f4b9345040f8ac9f86d4e898acba753fb2 100644 --- a/src/bin/netconf/netconf.h +++ b/src/bin/netconf/netconf.h @@ -44,6 +44,7 @@ typedef boost::shared_ptr NetconfAgentPtr; /// - on shutdown close subscriptions. class NetconfAgent { public: + /// @brief Constructor. NetconfAgent(); diff --git a/src/bin/netconf/netconf_cfg_mgr.cc b/src/bin/netconf/netconf_cfg_mgr.cc index ad9b02a490dc3ca5fddfe09a35f18ef70baa06a8..1f889a73d5a03457a584bbbe3b38c332432a796b 100644 --- a/src/bin/netconf/netconf_cfg_mgr.cc +++ b/src/bin/netconf/netconf_cfg_mgr.cc @@ -50,9 +50,6 @@ NetconfCfgMgr::NetconfCfgMgr() : DCfgMgrBase(ConfigPtr(new NetconfConfig())) { } -NetconfCfgMgr::~NetconfCfgMgr() { -} - std::string NetconfCfgMgr::getConfigSummary(const uint32_t /*selection*/) { diff --git a/src/bin/netconf/netconf_cfg_mgr.h b/src/bin/netconf/netconf_cfg_mgr.h index ef4a082684ef6fc389f1e650cfa7254c13104619..ca9e80c52b4d274977bd9b0783cecb34b79f238a 100644 --- a/src/bin/netconf/netconf_cfg_mgr.h +++ b/src/bin/netconf/netconf_cfg_mgr.h @@ -128,7 +128,7 @@ public: NetconfCfgMgr(); /// @brief Destructor - virtual ~NetconfCfgMgr(); + virtual ~NetconfCfgMgr() = default; /// @brief Convenience method that returns the Netconf configuration /// context. diff --git a/src/bin/netconf/netconf_config.cc b/src/bin/netconf/netconf_config.cc index 79f68ffa347568b500123d433a42f8f8ae4a74a1..653ce4f2af2191771709546714667366001604b4 100644 --- a/src/bin/netconf/netconf_config.cc +++ b/src/bin/netconf/netconf_config.cc @@ -33,9 +33,6 @@ CfgControlSocket::CfgControlSocket(Type type, const string& name, : type_(type), name_(name), url_(url) { } -CfgControlSocket::~CfgControlSocket() { -} - CfgControlSocket::Type CfgControlSocket::stringToType(const string& type) { if (type == "unix") { @@ -83,9 +80,6 @@ CfgServer::CfgServer(const string& model, CfgControlSocketPtr ctrl_sock) validate_changes_(true), control_socket_(ctrl_sock) { } -CfgServer::~CfgServer() { -} - string CfgServer::toText() const { ostringstream s; diff --git a/src/bin/netconf/netconf_config.h b/src/bin/netconf/netconf_config.h index 7ffaf6141c98aa83d1123da6bea6be31c3d883c6..b81ad8dc1b46e69788e0df56aa012a3ebde8f9a5 100644 --- a/src/bin/netconf/netconf_config.h +++ b/src/bin/netconf/netconf_config.h @@ -67,8 +67,7 @@ namespace netconf { /// /// Acts as a storage class containing the basic attributes which /// describe a Control Socket. -class CfgControlSocket : public isc::data::UserContext, - public isc::data::CfgToElement { +class CfgControlSocket : public isc::data::UserContext, public isc::data::CfgToElement { public: /// @brief Defines the list of possible constrol socket types. enum Type { @@ -86,7 +85,7 @@ public: const isc::http::Url& url); /// @brief Destructor (doing nothing). - virtual ~CfgControlSocket(); + virtual ~CfgControlSocket() = default; /// @brief Getter which returns the socket type. /// @@ -149,6 +148,7 @@ typedef boost::shared_ptr CfgControlSocketPtr; /// the Control Socket which describe a Managed CfgServer. class CfgServer : public isc::data::UserContext, public isc::data::CfgToElement { public: + /// @brief Constructor. /// /// @param model The model name. @@ -156,7 +156,7 @@ public: CfgServer(const std::string& model, CfgControlSocketPtr ctrl_sock); /// @brief Destructor (doing nothing). - virtual ~CfgServer(); + virtual ~CfgServer() = default; /// @brief Getter which returns the model name. /// @@ -301,7 +301,7 @@ public: CfgServerPtr parse(data::ConstElementPtr server_config); }; -}; // end of isc::netconf namespace -}; // end of isc namespace +} // end of isc::netconf namespace +} // end of isc namespace #endif // NETCONF_CONFIG_H diff --git a/src/bin/netconf/netconf_controller.cc b/src/bin/netconf/netconf_controller.cc index 1e79b5f55c7731909a1625d112b24382a5b71160..43162a4535c6715b13b256d3719054dca6a7e2c6 100644 --- a/src/bin/netconf/netconf_controller.cc +++ b/src/bin/netconf/netconf_controller.cc @@ -62,9 +62,6 @@ NetconfController::NetconfController() : DControllerBase(netconf_app_name_, netconf_bin_name_) { } -NetconfController::~NetconfController() { -} - NetconfProcessPtr NetconfController::getNetconfProcess() { return (boost::dynamic_pointer_cast(getProcess())); diff --git a/src/bin/netconf/netconf_controller.h b/src/bin/netconf/netconf_controller.h index c4e14828cf775d8a693b72457a8439908942342c..c6ef2bf6f44a43cd83bed32f3771a14998ccbd8f 100644 --- a/src/bin/netconf/netconf_controller.h +++ b/src/bin/netconf/netconf_controller.h @@ -31,7 +31,7 @@ public: static process::DControllerBasePtr& instance(); /// @brief Destructor - virtual ~NetconfController(); + virtual ~NetconfController() = default; /// @brief Returns pointer to an instance of the underlying process object. NetconfProcessPtr getNetconfProcess(); diff --git a/src/bin/netconf/netconf_process.cc b/src/bin/netconf/netconf_process.cc index 72eb04f6801bf36c012d435f4c4afb5a9c08a070..273629710e6feca617f2c2169efcef644820bb11 100644 --- a/src/bin/netconf/netconf_process.cc +++ b/src/bin/netconf/netconf_process.cc @@ -33,9 +33,6 @@ NetconfProcess::NetconfProcess(const char* name, : DProcessBase(name, io_service, DCfgMgrBasePtr(new NetconfCfgMgr())) { } -NetconfProcess::~NetconfProcess() { -} - void NetconfProcess::init() { } diff --git a/src/bin/netconf/netconf_process.h b/src/bin/netconf/netconf_process.h index eaa40bce332ab0e319c8026093c6c851cf0bfeea..356278da270c65b41c9ed88a7b7eab71ecb38cf5 100644 --- a/src/bin/netconf/netconf_process.h +++ b/src/bin/netconf/netconf_process.h @@ -24,6 +24,7 @@ namespace netconf { /// to JSON commands sent to the respective Kea servers. class NetconfProcess : public process::DProcessBase { public: + /// @brief Constructor /// /// @param name name is a text label for the process. Generally used @@ -33,7 +34,7 @@ public: NetconfProcess(const char* name, const asiolink::IOServicePtr& io_service); /// @brief Destructor - virtual ~NetconfProcess(); + virtual ~NetconfProcess() = default; /// @brief Initialize the Netconf process. /// @@ -103,7 +104,7 @@ private: /// @brief Defines a shared pointer to NetconfProcess. typedef boost::shared_ptr NetconfProcessPtr; -}; // namespace isc::netconf -}; // namespace isc +} // namespace isc::netconf +} // namespace isc #endif // NETCONF_PROCESS_H diff --git a/src/bin/netconf/parser_context.cc b/src/bin/netconf/parser_context.cc index 24fc650407fb0ebfdbd9b60325d8d9be825d9232..06963e8379f7b3362c0c137d9db9ada111b2c85a 100644 --- a/src/bin/netconf/parser_context.cc +++ b/src/bin/netconf/parser_context.cc @@ -18,17 +18,11 @@ namespace isc { namespace netconf { ParserContext::ParserContext() - : sfile_(0), ctx_(NO_KEYWORDS), trace_scanning_(false), trace_parsing_(false) -{ -} - -ParserContext::~ParserContext() -{ + : sfile_(0), ctx_(NO_KEYWORDS), trace_scanning_(false), trace_parsing_(false) { } isc::data::ElementPtr -ParserContext::parseString(const std::string& str, ParserType parser_type) -{ +ParserContext::parseString(const std::string& str, ParserType parser_type) { scanStringBegin(str, parser_type); return (parseCommon()); } @@ -71,8 +65,7 @@ ParserContext::parseCommon() { void ParserContext::error(const isc::netconf::location& loc, const std::string& what, - size_t pos) -{ + size_t pos) { if (pos == 0) { isc_throw(ParseError, loc << ": " << what); } else { @@ -81,20 +74,17 @@ ParserContext::error(const isc::netconf::location& loc, } void -ParserContext::error(const std::string& what) -{ +ParserContext::error(const std::string& what) { isc_throw(ParseError, what); } void -ParserContext::fatal(const std::string& what) -{ +ParserContext::fatal(const std::string& what) { isc_throw(ParseError, what); } isc::data::Element::Position -ParserContext::loc2pos(isc::netconf::location& loc) -{ +ParserContext::loc2pos(isc::netconf::location& loc) { const std::string& file = *loc.begin.filename; const uint32_t line = loc.begin.line; const uint32_t pos = loc.begin.column; @@ -104,8 +94,7 @@ ParserContext::loc2pos(isc::netconf::location& loc) void ParserContext::require(const std::string& name, isc::data::Element::Position open_loc, - isc::data::Element::Position close_loc) -{ + isc::data::Element::Position close_loc) { ConstElementPtr value = stack_.back()->get(name); if (!value) { isc_throw(ParseError, @@ -118,8 +107,7 @@ ParserContext::require(const std::string& name, void ParserContext::unique(const std::string& name, - isc::data::Element::Position loc) -{ + isc::data::Element::Position loc) { ConstElementPtr value = stack_.back()->get(name); if (value) { if (ctx_ != NO_KEYWORDS) { @@ -135,15 +123,13 @@ ParserContext::unique(const std::string& name, } void -ParserContext::enter(const LexerContext& ctx) -{ +ParserContext::enter(const LexerContext& ctx) { cstack_.push_back(ctx_); ctx_ = ctx; } void -ParserContext::leave() -{ +ParserContext::leave() { if (cstack_.empty()) { fatal("unbalanced syntactic context"); } @@ -152,8 +138,7 @@ ParserContext::leave() } const std::string -ParserContext::contextName() -{ +ParserContext::contextName() { switch (ctx_) { case NO_KEYWORDS: return ("__no keywords__"); diff --git a/src/bin/netconf/parser_context.h b/src/bin/netconf/parser_context.h index 22be5d0f63b1ac1cfb14beffc7fa2318f92d5476..267e698cb9ec8a2361c7f8fd5654ba197d344f77 100644 --- a/src/bin/netconf/parser_context.h +++ b/src/bin/netconf/parser_context.h @@ -34,8 +34,7 @@ namespace netconf { /// parse only content of the Netconf-agent object, which is a subset /// of full grammar (this will be very useful for unit-tests to not duplicate /// unnecessary parts of the config file). -class ParserContext -{ +class ParserContext { public: /// @brief Defines currently supported scopes @@ -61,7 +60,7 @@ public: ParserContext(); /// @brief destructor - virtual ~ParserContext(); + virtual ~ParserContext() = default; /// @brief JSON elements being parsed. std::vector stack_; diff --git a/src/bin/netconf/stdout_control_socket.cc b/src/bin/netconf/stdout_control_socket.cc index 382c391c5c6ee6669538b7c2552dc6d51cf34ac4..e506bdb75dc92c414fb37e8e76c638858a286d56 100644 --- a/src/bin/netconf/stdout_control_socket.cc +++ b/src/bin/netconf/stdout_control_socket.cc @@ -33,9 +33,6 @@ StdoutControlSocket::StdoutControlSocket(CfgControlSocketPtr ctrl_sock, : ControlSocketBase(ctrl_sock), output_(output) { } -StdoutControlSocket::~StdoutControlSocket() { -} - ConstElementPtr StdoutControlSocket::configGet(const string& /*service*/) { isc_throw(NotImplemented, "No config-get for stdout control socket"); diff --git a/src/bin/netconf/stdout_control_socket.h b/src/bin/netconf/stdout_control_socket.h index 9b0d1f343d9e24ff328885507efacd49692d7c2f..017a68086ba755928ba1813717868556e90b2f6e 100644 --- a/src/bin/netconf/stdout_control_socket.h +++ b/src/bin/netconf/stdout_control_socket.h @@ -32,7 +32,7 @@ public: StdoutControlSocket(CfgControlSocketPtr ctrl_sock); /// @brief Destructor (does nothing). - virtual ~StdoutControlSocket(); + virtual ~StdoutControlSocket() = default; /// @brief Get configuration. /// diff --git a/src/bin/netconf/tests/control_socket_unittests.cc b/src/bin/netconf/tests/control_socket_unittests.cc index 9e7700a1115b66b83678b303674873b3d28ed6dc..86868c1bbafa210a5ac2ea3e6a43067b8dcc411c 100644 --- a/src/bin/netconf/tests/control_socket_unittests.cc +++ b/src/bin/netconf/tests/control_socket_unittests.cc @@ -45,6 +45,7 @@ typedef boost::shared_ptr ThreadPtr; /// This class exposes the constructor taking the output stream. class TestStdoutControlSocket : public StdoutControlSocket { public: + /// @brief Constructor. /// /// @param ctrl_sock The control socket configuration. @@ -54,8 +55,7 @@ public: } /// @brief Destructor. - virtual ~TestStdoutControlSocket() { - } + virtual ~TestStdoutControlSocket() = default; }; /// @brief Type definition for the pointer to the @c TestStdoutControlSocket. @@ -146,15 +146,18 @@ public: /// @brief Destructor. virtual ~UnixControlSocketTest() { - if (thread_) { - thread_->join(); - thread_.reset(); + try { + if (thread_) { + thread_->join(); + thread_.reset(); + } + // io_service must be stopped after the thread returns, + // otherwise the thread may never return if it is + // waiting for the completion of some asynchronous tasks. + io_service_.stop(); + removeUnixSocketFile(); + } catch (...) { } - // io_service must be stopped after the thread returns, - // otherwise the thread may never return if it is - // waiting for the completion of some asynchronous tasks. - io_service_.stop(); - removeUnixSocketFile(); } /// @brief Returns socket file path. @@ -504,20 +507,24 @@ public: /// @brief Test fixture class for http control sockets. class HttpControlSocketTest : public ThreadedTest { public: - HttpControlSocketTest() - : ThreadedTest(), io_service_() { + + /// @brief Constructor. + HttpControlSocketTest() : ThreadedTest(), done_(false) { } /// @brief Destructor. virtual ~HttpControlSocketTest() { - if (thread_) { - thread_->join(); - thread_.reset(); + try { + if (thread_) { + thread_->join(); + thread_.reset(); + } + // io_service must be stopped after the thread returns, + // otherwise the thread may never return if it is + // waiting for the completion of some asynchronous tasks. + io_service_.stop(); + } catch (...) { } - // io_service must be stopped after the thread returns, - // otherwise the thread may never return if it is - // waiting for the completion of some asynchronous tasks. - io_service_.stop(); } /// @brief Returns socket URL. @@ -600,9 +607,6 @@ public: /// @brief Done flag (stopping thread). bool done_; - - /// @brief Finished flag (stopped thread). - bool finished_; }; /// @brief Create the reflecting listener. diff --git a/src/bin/netconf/tests/get_config_unittest.cc b/src/bin/netconf/tests/get_config_unittest.cc index 77dd2ab6cd11fdda8d310b78cd389b515c24345c..2956d4e8564da04b3ca624ca303021c9599337ad 100644 --- a/src/bin/netconf/tests/get_config_unittest.cc +++ b/src/bin/netconf/tests/get_config_unittest.cc @@ -120,6 +120,8 @@ public: /// Test fixture class class NetconfGetCfgTest : public ConfigParseTest { public: + + /// @brief Constructor NetconfGetCfgTest() : rcode_(-1) { srv_.reset(new NakedNetconfCfgMgr()); @@ -127,8 +129,12 @@ public: resetConfiguration(); } + /// @brief Destructor ~NetconfGetCfgTest() { - resetConfiguration(); + try { + resetConfiguration(); + } catch (...) { + } } /// @brief Parse and Execute configuration diff --git a/src/bin/netconf/tests/netconf_process_unittests.cc b/src/bin/netconf/tests/netconf_process_unittests.cc index c16b7e72339e0ef964eff985e78804e32de72a60..257b53b433fb22797e034ab383728c58d1166c73 100644 --- a/src/bin/netconf/tests/netconf_process_unittests.cc +++ b/src/bin/netconf/tests/netconf_process_unittests.cc @@ -25,6 +25,7 @@ namespace { /// @brief NetconfProcess test fixture class. class NetconfProcessTest : public NetconfProcess, public ::testing::Test { public: + /// @brief Constructor NetconfProcessTest() : NetconfProcess("netconf-test", @@ -33,8 +34,7 @@ public: } /// @brief Destructor - virtual ~NetconfProcessTest() { - } + virtual ~NetconfProcessTest() = default; /// @brief Callback that will invoke shutdown method. void genShutdownCallback() { diff --git a/src/bin/netconf/tests/netconf_unittests.cc b/src/bin/netconf/tests/netconf_unittests.cc index 49bab0834982180a2bfc1b86d46a25b44bf52d9c..14e01f2fdb0a71b06972ef9f05182b113b0b26f2 100644 --- a/src/bin/netconf/tests/netconf_unittests.cc +++ b/src/bin/netconf/tests/netconf_unittests.cc @@ -51,13 +51,12 @@ typedef boost::shared_ptr ThreadPtr; /// @brief Test version of the NetconfAgent class. class NakedNetconfAgent : public NetconfAgent { public: + /// @brief Constructor. - NakedNetconfAgent() { - } + NakedNetconfAgent() = default; /// @brief Destructor. - virtual ~NakedNetconfAgent() { - } + virtual ~NakedNetconfAgent() = default; /// Export protected methods and fields. using NetconfAgent::keaConfig; @@ -105,24 +104,27 @@ public: /// @brief Destructor. virtual ~NetconfAgentTest() { - NetconfProcess::shut_down = true; - if (thread_) { - thread_->join(); - thread_.reset(); - } - // io_service must be stopped after the thread returns, - // otherwise the thread may never return if it is - // waiting for the completion of some asynchronous tasks. - io_service_->stop(); - io_service_.reset(); - if (agent_) { - clearYang(agent_); - agent_->clear(); + try { + NetconfProcess::shut_down = true; + if (thread_) { + thread_->join(); + thread_.reset(); + } + // io_service must be stopped after the thread returns, + // otherwise the thread may never return if it is + // waiting for the completion of some asynchronous tasks. + io_service_->stop(); + io_service_.reset(); + if (agent_) { + clearYang(agent_); + agent_->clear(); + } + agent_.reset(); + requests_.clear(); + responses_.clear(); + removeUnixSocketFile(); + } catch (...) { } - agent_.reset(); - requests_.clear(); - responses_.clear(); - removeUnixSocketFile(); } /// @brief Returns socket file path. @@ -176,6 +178,7 @@ public: /// @brief Special test fixture for logging tests. class NetconfAgentLogTest : public dhcp::test::LogContentTest { public: + /// @brief Constructor. NetconfAgentLogTest() : io_service_(new IOService()), @@ -186,19 +189,22 @@ public: /// @brief Destructor. virtual ~NetconfAgentLogTest() { - NetconfProcess::shut_down = true; - // io_service must be stopped to make the thread to return. - io_service_->stop(); - io_service_.reset(); - if (thread_) { - thread_->join(); - thread_.reset(); - } - if (agent_) { - clearYang(agent_); - agent_->clear(); + try { + NetconfProcess::shut_down = true; + // io_service must be stopped to make the thread to return. + io_service_->stop(); + io_service_.reset(); + if (thread_) { + thread_->join(); + thread_.reset(); + } + if (agent_) { + clearYang(agent_); + agent_->clear(); + } + agent_.reset(); + } catch (...) { } - agent_.reset(); } /// @brief IOService object. diff --git a/src/bin/netconf/unix_control_socket.cc b/src/bin/netconf/unix_control_socket.cc index 93a807eb1d69dadb09ac401a0fbce237d7fd4b5b..c4aabafdee347a4753fce154da3ba86557c5472c 100644 --- a/src/bin/netconf/unix_control_socket.cc +++ b/src/bin/netconf/unix_control_socket.cc @@ -34,9 +34,6 @@ UnixControlSocket::UnixControlSocket(CfgControlSocketPtr ctrl_sock) : ControlSocketBase(ctrl_sock) { } -UnixControlSocket::~UnixControlSocket() { -} - ConstElementPtr UnixControlSocket::configGet(const string& /*service*/) { return (sendCommand(createCommand("config-get"))); diff --git a/src/bin/netconf/unix_control_socket.h b/src/bin/netconf/unix_control_socket.h index 09fe7c1e99521128ed20780b9ead6b2352e8eed8..e0c2b17fde12d816c4a596582485d49b6ef27690 100644 --- a/src/bin/netconf/unix_control_socket.h +++ b/src/bin/netconf/unix_control_socket.h @@ -29,7 +29,7 @@ public: UnixControlSocket(CfgControlSocketPtr ctrl_sock); /// @brief Destructor (does nothing). - virtual ~UnixControlSocket(); + virtual ~UnixControlSocket() = default; /// @brief Get configuration. /// diff --git a/src/bin/perfdhcp/abstract_scen.h b/src/bin/perfdhcp/abstract_scen.h index 99f64041b2e9afaac2e4821645f8024515c11e6c..f2b4ba2afe5c0dd246026f5fb4f3dff5136cd551 100644 --- a/src/bin/perfdhcp/abstract_scen.h +++ b/src/bin/perfdhcp/abstract_scen.h @@ -20,14 +20,13 @@ namespace perfdhcp { /// This class must be inherited by scenario classes. class AbstractScen : public boost::noncopyable { public: + /// \brief Default and the only constructor of AbstractScen. /// /// \param options reference to command options, /// \param socket reference to a socket. AbstractScen(CommandOptions& options, BasePerfSocket &socket) : - options_(options), - tc_(options, socket) - { + options_(options), tc_(options, socket) { if (options_.getIpVersion() == 4) { stage1_xchg_ = ExchangeType::DO; stage2_xchg_ = ExchangeType::RA; @@ -45,7 +44,7 @@ public: virtual int run() = 0; /// \brief Trivial virtual destructor. - virtual ~AbstractScen() {}; + virtual ~AbstractScen() = default; protected: CommandOptions& options_; ///< Reference to commandline options. @@ -57,7 +56,6 @@ protected: ExchangeType stage2_xchg_; }; - } } diff --git a/src/bin/perfdhcp/main.cc b/src/bin/perfdhcp/main.cc index 9a1dbcee9fde012560e0a3768a41fd8953971dba..99bf22e0c0d8f3cdce939a26e737a3365738f961 100644 --- a/src/bin/perfdhcp/main.cc +++ b/src/bin/perfdhcp/main.cc @@ -19,10 +19,11 @@ using namespace isc::perfdhcp; int main(int argc, char* argv[]) { - CommandOptions command_options; - std::string diags(command_options.getDiags()); int ret_code = 0; + std::string diags; try { + CommandOptions command_options; + diags = command_options.getDiags(); // If parser returns true it means that user specified // 'h' or 'v' command line option. Program shows the // help or version message and exits here. @@ -33,17 +34,7 @@ main(int argc, char* argv[]) { if (command_options.parse(argc, argv, true)) { return (ret_code); } - } catch (const isc::Exception& e) { - ret_code = 1; - command_options.usage(); - std::cerr << "\nERROR: parsing command line options: " - << e.what() << std::endl; - if (diags.find('e') != std::string::npos) { - std::cerr << "Fatal error" << std::endl; - } - return (ret_code); - } - try{ + auto scenario = command_options.getScenario(); PerfSocket socket(command_options); if (scenario == Scenario::BASIC) { @@ -59,6 +50,8 @@ main(int argc, char* argv[]) { if (diags.find('e') != std::string::npos) { std::cerr << "Fatal error" << std::endl; } + } catch (...) { + ret_code = 1; } return (ret_code); } diff --git a/src/bin/perfdhcp/perf_socket.cc b/src/bin/perfdhcp/perf_socket.cc index aa67796a1deeea952dc96d622cbf8625e828e413..2aecbf491c3bf79bf372e93fe1845bfa677a1903 100644 --- a/src/bin/perfdhcp/perf_socket.cc +++ b/src/bin/perfdhcp/perf_socket.cc @@ -25,7 +25,6 @@ PerfSocket::PerfSocket(CommandOptions& options) { initSocketData(); } - int PerfSocket::openSocket(CommandOptions& options) const { std::string localname = options.getLocalName(); @@ -126,9 +125,12 @@ PerfSocket::openSocket(CommandOptions& options) const { } PerfSocket::~PerfSocket() { - IfacePtr iface = IfaceMgr::instance().getIface(ifindex_); - if (iface) { - iface->delSocket(sockfd_); + try { + IfacePtr iface = IfaceMgr::instance().getIface(ifindex_); + if (iface) { + iface->delSocket(sockfd_); + } + } catch (...) { } } diff --git a/src/bin/perfdhcp/receiver.cc b/src/bin/perfdhcp/receiver.cc index 2bad42689175cb6ca8f5d381c886a6318ce7d318..64e54b45f0924cc6df391cbee44351af3bb2c4f1 100644 --- a/src/bin/perfdhcp/receiver.cc +++ b/src/bin/perfdhcp/receiver.cc @@ -47,10 +47,13 @@ Receiver::stop() { } Receiver::~Receiver() { - if (single_threaded_) { - return; + try { + if (single_threaded_) { + return; + } + stop(); + } catch (...) { } - stop(); } diff --git a/src/bin/perfdhcp/receiver.h b/src/bin/perfdhcp/receiver.h index 22709485097df15c060311354f6f45ea018984a5..79b6c2b1f4b642713d1d7831878420d98fc0a287 100644 --- a/src/bin/perfdhcp/receiver.h +++ b/src/bin/perfdhcp/receiver.h @@ -53,7 +53,8 @@ private: uint8_t ip_version_; public: - /// \brief Receiver constructor. + + /// \brief Constructor. /// /// \param socket A socket for receiving packets. /// \param single_threaded A flag indicating running mode. diff --git a/src/bin/perfdhcp/stats_mgr.h b/src/bin/perfdhcp/stats_mgr.h index 0ca1695ad268ae7f8b9979fd894468541f0cff56..1090af484836961b87605a737376e426cc8aa612 100644 --- a/src/bin/perfdhcp/stats_mgr.h +++ b/src/bin/perfdhcp/stats_mgr.h @@ -103,7 +103,7 @@ public: /// /// Method returns counter name. /// - /// \return counter name. + /// \return counter name. const std::string& getName() const { return(name_); } private: @@ -112,7 +112,8 @@ private: /// Default constructor is private because we don't want client /// class to call it because we want client class to specify /// counter's name. - CustomCounter() { }; + CustomCounter() : counter_(0) { + } uint64_t counter_; ///< Counter's value. std::string name_; ///< Counter's name. diff --git a/src/bin/perfdhcp/test_control.h b/src/bin/perfdhcp/test_control.h index e6a4c24432354770116c0d371347cae2fae6a3d3..304c783a3d60117aa69483d58d14b034db62ec22 100644 --- a/src/bin/perfdhcp/test_control.h +++ b/src/bin/perfdhcp/test_control.h @@ -141,8 +141,11 @@ public: class NumberGenerator { public: + /// \brief Constructor. + NumberGenerator() = default; + /// \brief Destructor. - virtual ~NumberGenerator() { } + virtual ~NumberGenerator() = default; /// \brief Generate number. /// diff --git a/src/bin/perfdhcp/tests/command_options_helper.h b/src/bin/perfdhcp/tests/command_options_helper.h index dd8e5127b5bd7351c74fe128f042d1964a07c8dd..fd956370e5f1b99ac2f8aa2dc6e53be7c1e6cd60 100644 --- a/src/bin/perfdhcp/tests/command_options_helper.h +++ b/src/bin/perfdhcp/tests/command_options_helper.h @@ -41,34 +41,43 @@ public: /// allocated for this array is freed at the end o the scope. class ArgvPtr { public: + /// \brief Constructor. /// /// \param argv array of C-strings. /// \param number of C-strings in the array. - ArgvPtr(char** argv, int argc) : argv_(argv), argc_(argc) { } + ArgvPtr(char** argv, int argc) : argv_(argv), argc_(argc) { + } /// \brief Destructor. /// /// Deallocates wrapped array of C-strings. ~ArgvPtr() { - if (argv_ != NULL) { - for(int i = 0; i < argc_; ++i) { - delete[] (argv_[i]); - argv_[i] = NULL; + try { + if (argv_ != NULL) { + for(int i = 0; i < argc_; ++i) { + delete[] (argv_[i]); + argv_[i] = NULL; + } + delete[] (argv_); } - delete[] (argv_); + } catch (...) { } } /// \brief Return the array of C-strings. /// /// \return array of C-strings. - char** getArgv() const { return (argv_); } + char** getArgv() const { + return (argv_); + } /// \brief Return C-strings counter. /// /// \return C-strings counter. - int getArgc() const { return(argc_); } + int getArgc() const { + return (argc_); + } public: char** argv_; ///< array of C-strings being wrapped. diff --git a/src/hooks/dhcp/bootp/tests/bootp_unittests.cc b/src/hooks/dhcp/bootp/tests/bootp_unittests.cc index 70327ea5212bce7f5e87b4f1b631929d22016e41..b7da1569019b783ee0e30471f634d50b31825a5f 100644 --- a/src/hooks/dhcp/bootp/tests/bootp_unittests.cc +++ b/src/hooks/dhcp/bootp/tests/bootp_unittests.cc @@ -40,12 +40,11 @@ public: } /// @brief Destructor. - virtual ~BootpTest() { - } + virtual ~BootpTest() = default; /// @brief Fetches the callout manager instance. boost::shared_ptrgetCalloutManager() { - return(co_manager_); + return (co_manager_); } /// @brief Tests buffer4_receive callout. diff --git a/src/hooks/dhcp/flex_option/flex_option.cc b/src/hooks/dhcp/flex_option/flex_option.cc index a4835b4482b7d2ca2b0cf5f0ce8b3140fb4d1af3..02d98c7fa5617cf8e5b8e0dae495a78ce905654d 100644 --- a/src/hooks/dhcp/flex_option/flex_option.cc +++ b/src/hooks/dhcp/flex_option/flex_option.cc @@ -79,14 +79,11 @@ FlexOptionImpl::OptionConfig::OptionConfig(uint16_t code, : code_(code), def_(def), action_(NONE) { } -FlexOptionImpl::OptionConfig::~OptionConfig() { -} - -FlexOptionImpl::FlexOptionImpl() { -} - FlexOptionImpl::~FlexOptionImpl() { - option_config_map_.clear(); + try { + option_config_map_.clear(); + } catch (...) { + } } void diff --git a/src/hooks/dhcp/flex_option/flex_option.h b/src/hooks/dhcp/flex_option/flex_option.h index fd028189c5f3070dfb8d6a4ca51984a7bf95f195..24335cbfb660f97049cfc55fd66e9179a263ab51 100644 --- a/src/hooks/dhcp/flex_option/flex_option.h +++ b/src/hooks/dhcp/flex_option/flex_option.h @@ -52,6 +52,7 @@ public: /// Per option configuration. class OptionConfig { public: + /// @brief Constructor. /// /// @param code the option code. @@ -59,7 +60,7 @@ public: OptionConfig(uint16_t code, isc::dhcp::OptionDefinitionPtr def); /// @brief Destructor. - virtual ~OptionConfig(); + virtual ~OptionConfig() = default; /// @brief Return option code. /// @@ -142,7 +143,7 @@ public: typedef std::map OptionConfigMap; /// @brief Constructor. - FlexOptionImpl(); + FlexOptionImpl() = default; /// @brief Destructor. ~FlexOptionImpl(); diff --git a/src/hooks/dhcp/flex_option/libloadtests/callout_unittests.cc b/src/hooks/dhcp/flex_option/libloadtests/callout_unittests.cc index db1cb67ffeaff1911e7a6c7f81c1291223c58d21..5bfe39adbf6a1c759b8c9e974a5c95a21b9ed784 100644 --- a/src/hooks/dhcp/flex_option/libloadtests/callout_unittests.cc +++ b/src/hooks/dhcp/flex_option/libloadtests/callout_unittests.cc @@ -53,15 +53,20 @@ TestHooks testHooks; /// @brief Test fixture for testing callouts called by the flex-option library class CalloutTest : public ::testing::Test { public: + /// @brief Constructor CalloutTest() { reset(); } /// @brief Destructor + /// /// Removes files that may be left over from previous tests virtual ~CalloutTest() { - reset(); + try { + reset(); + } catch (...) { + } } /// @brief Removes files that may be left over from previous tests diff --git a/src/hooks/dhcp/flex_option/libloadtests/load_unload_unittests.cc b/src/hooks/dhcp/flex_option/libloadtests/load_unload_unittests.cc index d9a386a9bdb36002d45d665ef1853b6f87b121c8..78027fb1bb97d908d292ec0b345e96b1b7ecb093 100644 --- a/src/hooks/dhcp/flex_option/libloadtests/load_unload_unittests.cc +++ b/src/hooks/dhcp/flex_option/libloadtests/load_unload_unittests.cc @@ -29,15 +29,20 @@ namespace { /// @brief Test fixture for testing loading and unloading the flex-option library class LibLoadTest : public ::testing::Test { public: + /// @brief Constructor LibLoadTest() { reset(); } /// @brief Destructor + /// /// Removes files that may be left over from previous tests virtual ~LibLoadTest() { - reset(); + try { + reset(); + } catch (...) { + } } /// @brief Removes files that may be left over from previous tests diff --git a/src/hooks/dhcp/flex_option/tests/flex_option_unittests.cc b/src/hooks/dhcp/flex_option/tests/flex_option_unittests.cc index c5fb04c1ec7fef36e689edc350bff9dae1ac299a..e0ea1ac091ae879876ab2e394b2a9d4acc54abd8 100644 --- a/src/hooks/dhcp/flex_option/tests/flex_option_unittests.cc +++ b/src/hooks/dhcp/flex_option/tests/flex_option_unittests.cc @@ -67,6 +67,7 @@ typedef boost::shared_ptr TestFlexOptionImplPtr; /// @brief Test fixture for testing the Flex Option library. class FlexOptionTest : public ::testing::Test { public: + /// @brief Constructor. FlexOptionTest() { impl_.reset(new TestFlexOptionImpl()); @@ -75,8 +76,10 @@ public: /// @brief Destructor. virtual ~FlexOptionTest() { - CfgMgr::instance().setFamily(AF_INET); - impl_.reset(); + try { + CfgMgr::instance().setFamily(AF_INET); + } catch (...) { + } } /// @brief Flex Option implementation. diff --git a/src/hooks/dhcp/high_availability/communication_state.cc b/src/hooks/dhcp/high_availability/communication_state.cc index 4c564c2491d17e574b1da95d6eceecc9641e53a4..ac5b58a172a0cad5113e91a2b86a4c0dbeed6650 100644 --- a/src/hooks/dhcp/high_availability/communication_state.cc +++ b/src/hooks/dhcp/high_availability/communication_state.cc @@ -63,7 +63,10 @@ CommunicationState::CommunicationState(const IOServicePtr& io_service, } CommunicationState::~CommunicationState() { - stopHeartbeat(); + try { + stopHeartbeat(); + } catch (...) { + } } void diff --git a/src/hooks/dhcp/high_availability/ha_impl.cc b/src/hooks/dhcp/high_availability/ha_impl.cc index eb5b5d219ee9d49d7f236bda5215bc55340eb8c8..14b246d7d4989b8944172ec01723521fd6a46139 100644 --- a/src/hooks/dhcp/high_availability/ha_impl.cc +++ b/src/hooks/dhcp/high_availability/ha_impl.cc @@ -50,10 +50,13 @@ HAImpl::startService(const IOServicePtr& io_service, } HAImpl::~HAImpl() { - if (service_) { - // Shut down the services explicitly, we need finer control - // than relying on destruction order. - service_->stopClientAndListener(); + try { + if (service_) { + // Shut down the services explicitly, we need finer control + // than relying on destruction order. + service_->stopClientAndListener(); + } + } catch (...) { } } diff --git a/src/hooks/dhcp/high_availability/ha_impl.h b/src/hooks/dhcp/high_availability/ha_impl.h index 60dd3bb77f9e7a3bbabf196b11ecfd43ef80353f..ac95548d6b7c018a8d6d7cb1ede7d45ed4c2fdf6 100644 --- a/src/hooks/dhcp/high_availability/ha_impl.h +++ b/src/hooks/dhcp/high_availability/ha_impl.h @@ -171,7 +171,6 @@ protected: /// @brief Pointer to the high availability service (state machine). HAServicePtr service_; - }; /// @brief Pointer to the High Availability hooks library implementation. diff --git a/src/hooks/dhcp/high_availability/ha_service.cc b/src/hooks/dhcp/high_availability/ha_service.cc index 387d31b88a733d162fcd03274bf668d939709dc9..1da7cc842bfa6bca96fbb2a75d8b13af40c1d456 100644 --- a/src/hooks/dhcp/high_availability/ha_service.cc +++ b/src/hooks/dhcp/high_availability/ha_service.cc @@ -106,10 +106,13 @@ HAService::HAService(const IOServicePtr& io_service, const NetworkStatePtr& netw } HAService::~HAService() { - // Stop client and/or listener. - stopClientAndListener(); + try { + // Stop client and/or listener. + stopClientAndListener(); - network_state_->reset(NetworkState::Origin::HA_COMMAND); + network_state_->reset(NetworkState::Origin::HA_COMMAND); + } catch (...) { + } } void diff --git a/src/hooks/dhcp/high_availability/libloadtests/close_unittests.cc b/src/hooks/dhcp/high_availability/libloadtests/close_unittests.cc index 1c122d12ade34fecb9b1f3df7b0f53d216af31d8..25e0f35341afd2d72447b2d8f08ed26c72ecce7c 100644 --- a/src/hooks/dhcp/high_availability/libloadtests/close_unittests.cc +++ b/src/hooks/dhcp/high_availability/libloadtests/close_unittests.cc @@ -100,16 +100,19 @@ TestHooks testHooks; /// @brief Test fixture for testing closing the HA library class CloseHATest : public ::testing::Test { public: + /// @brief Constructor - CloseHATest() { - } + CloseHATest() = default; /// @brief Destructor virtual ~CloseHATest() { - HooksManager::prepareUnloadLibraries(); - bool status = HooksManager::unloadLibraries(); - if (!status) { - cerr << "(fixture dtor) unloadLibraries failed" << endl; + try { + HooksManager::prepareUnloadLibraries(); + bool status = HooksManager::unloadLibraries(); + if (!status) { + cerr << "(fixture dtor) unloadLibraries failed" << endl; + } + } catch (...) { } } diff --git a/src/hooks/dhcp/high_availability/libloadtests/load_unload_unittests.cc b/src/hooks/dhcp/high_availability/libloadtests/load_unload_unittests.cc index 13b579f7d41efe1b3c2718bbb64a475513457cd0..938bca6814e9ad9ab8c619ad3ec3f8d0d2712da7 100644 --- a/src/hooks/dhcp/high_availability/libloadtests/load_unload_unittests.cc +++ b/src/hooks/dhcp/high_availability/libloadtests/load_unload_unittests.cc @@ -32,6 +32,7 @@ namespace { /// @brief Test fixture for testing loading and unloading the HA library class LibLoadTest : public ::testing::Test { public: + /// @brief Constructor LibLoadTest() { reset(); @@ -40,7 +41,10 @@ public: /// @brief Destructor /// Removes files that may be left over from previous tests virtual ~LibLoadTest() { - reset(); + try { + reset(); + } catch (...) { + } } /// @brief Removes files that may be left over from previous tests diff --git a/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc b/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc index 12a8ff84b8cc3abdd3c3a19565afe7311d871299..40dec39ee07ea5dad94845d92de2070b32c8a176 100644 --- a/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc @@ -51,8 +51,11 @@ public: /// @brief Destructor. ~CommunicationStateTest() { - MultiThreadingMgr::instance().setMode(false); - io_service_->poll(); + try { + MultiThreadingMgr::instance().setMode(false); + io_service_->poll(); + } catch (...) { + } } /// @brief Verifies that the partner state is set and retrieved correctly. diff --git a/src/hooks/dhcp/high_availability/tests/ha_config_unittest.cc b/src/hooks/dhcp/high_availability/tests/ha_config_unittest.cc index 8c965af248c563e4490b0a544c0ac830981754a1..a1fc75bf432e8b0e603bcb5276419150f9bfe10c 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_config_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_config_unittest.cc @@ -80,6 +80,7 @@ public: } result.replace(where, from.size(), repl); } + return (result); } }; diff --git a/src/hooks/dhcp/high_availability/tests/ha_mt_unittest.cc b/src/hooks/dhcp/high_availability/tests/ha_mt_unittest.cc index 53f2c82d0ad396ddc7912a18ffafde24c7ec2a1c..0c9332f0aa82691a8cde267a754831021fc06c6c 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_mt_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_mt_unittest.cc @@ -131,9 +131,12 @@ public: /// /// Stops all test servers. ~HAMtServiceTest() { - io_service_->get_io_service().reset(); - io_service_->poll(); - MultiThreadingMgr::instance().setMode(false); + try { + io_service_->get_io_service().reset(); + io_service_->poll(); + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } /// @brief Callback function invoke upon test timeout. diff --git a/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc b/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc index 99588dd8cf75fd78fb887d921d9d7e9c8911fe0d..c85812d5532ff832b4923d462dbeb49f063e2098 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc @@ -614,12 +614,15 @@ public: /// /// Stops all test servers. ~HAServiceTest() { - listener_->stop(); - listener2_->stop(); - listener3_->stop(); - io_service_->get_io_service().reset(); - io_service_->poll(); - MultiThreadingMgr::instance().setMode(false); + try { + listener_->stop(); + listener2_->stop(); + listener3_->stop(); + io_service_->get_io_service().reset(); + io_service_->poll(); + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } /// @brief Callback function invoke upon test timeout. diff --git a/src/hooks/dhcp/high_availability/tests/ha_test.cc b/src/hooks/dhcp/high_availability/tests/ha_test.cc index 7dd35bbe33d5a086ad013f3d12aff35b34edefea..1794fa65551a4a2f8680404dcdec2c8b029c8a04 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_test.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_test.cc @@ -55,9 +55,6 @@ HATest::HATest() network_state_(new NetworkState(NetworkState::DHCPv4)) { } -HATest::~HATest() { -} - void HATest::startHAService() { if (HooksManager::calloutsPresent(Hooks.hooks_index_dhcp4_srv_configured_)) { diff --git a/src/hooks/dhcp/high_availability/tests/ha_test.h b/src/hooks/dhcp/high_availability/tests/ha_test.h index 8c244c8af17879c857dc05114c4026fef45e7024..22cddaf01197ad0e0fef04abf8fdf8b9b75cc810 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_test.h +++ b/src/hooks/dhcp/high_availability/tests/ha_test.h @@ -84,7 +84,7 @@ public: HATest(); /// @brief Destructor. - virtual ~HATest(); + virtual ~HATest() = default; /// @brief Calls dhcp4_srv_configured callout to set IO service pointer. void startHAService(); diff --git a/src/hooks/dhcp/high_availability/tests/query_filter_unittest.cc b/src/hooks/dhcp/high_availability/tests/query_filter_unittest.cc index 2e162d4f5675edea2e2ffb06ddc07aa6d8320b3e..7da87645274a639131f62dd69ffaf417c157ca4a 100644 --- a/src/hooks/dhcp/high_availability/tests/query_filter_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/query_filter_unittest.cc @@ -32,6 +32,7 @@ namespace { /// @brief Test fixture class for @c QueryFilter class. class QueryFilterTest : public HATest { public: + /// @brief Constructor. QueryFilterTest() { MultiThreadingMgr::instance().setMode(false); @@ -39,7 +40,10 @@ public: /// @brief Destructor. ~QueryFilterTest() { - MultiThreadingMgr::instance().setMode(false); + try { + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } /// @brief This test verifies that client identifier is used for load diff --git a/src/hooks/dhcp/lease_cmds/lease_parser.h b/src/hooks/dhcp/lease_cmds/lease_parser.h index 2220d4993328e2c990d488227030c59d61f2a7ab..a84d426d0a02b3d8228dd53193be743bb68c58e6 100644 --- a/src/hooks/dhcp/lease_cmds/lease_parser.h +++ b/src/hooks/dhcp/lease_cmds/lease_parser.h @@ -50,8 +50,11 @@ public: const isc::data::ConstElementPtr& lease_info, bool& force_create); - /// @brief virtual dtor (does nothing) - virtual ~Lease4Parser() {} + /// @brief Constructor + Lease4Parser() = default; + + /// @brief virtual Destructor (does nothing) + virtual ~Lease4Parser() = default; }; /// @brief Parser for Lease6 structure @@ -90,11 +93,14 @@ public: const isc::data::ConstElementPtr& lease_info, bool& force_create); - /// @brief virtual dtor (does nothing) - virtual ~Lease6Parser() {} + /// @brief Constructor + Lease6Parser() = default; + + /// @brief virtual Destructor (does nothing) + virtual ~Lease6Parser() = default; }; -}; // end of isc::dhcp namespace -}; // end of isc namespace +} // end of isc::dhcp namespace +} // end of isc namespace #endif diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc index 71ad0e2088155aae2726b5dbdeea3d53f55b053c..5b8974b9eaeb2f7731bc7840ef1a3d548618d7be 100644 --- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc +++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc @@ -47,6 +47,7 @@ constexpr time_t DEC_2030_TIME = 1923222072; /// @brief Test fixture for testing loading and unloading the flex-id library class LibLoadTest : public ::testing::Test { public: + /// @brief Constructor LibLoadTest(std::string lib_filename) : lib_name_(lib_filename) { @@ -57,7 +58,10 @@ public: /// @brief Destructor /// Removes files that may be left over from previous tests virtual ~LibLoadTest() { - unloadLibs(); + try { + unloadLibs(); + } catch (...) { + } } /// @brief Adds library/parameters to list of libraries to be loaded @@ -285,13 +289,16 @@ public: /// /// Removes library (if any), destroys lease manager (if any). virtual ~LeaseCmdsTest() { - // destroys lease manager first because the other order triggers - // a clang/boost bug - LeaseMgrFactory::destroy(); - disableD2(); - unloadLibs(); - lmptr_ = 0; - StatsMgr::instance().removeAll(); + try { + // destroys lease manager first because the other order triggers + // a clang/boost bug + LeaseMgrFactory::destroy(); + disableD2(); + unloadLibs(); + lmptr_ = 0; + StatsMgr::instance().removeAll(); + } catch (...) { + } } /// @brief Initializes lease manager (and optionally populates it with a lease) diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc index 309291da94b994a1dbad5c16e049cbf219f195ef..bde14b464485f41a1209fe88b0394b08c83ba79f 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc @@ -156,7 +156,7 @@ public: parameters); /// @brief Destructor. - ~MySqlConfigBackendDHCPv4Impl(); + ~MySqlConfigBackendDHCPv4Impl() = default; /// @brief Sends query to retrieve global parameter. /// @@ -3018,9 +3018,6 @@ MySqlConfigBackendDHCPv4Impl::MySqlConfigBackendDHCPv4Impl(const DatabaseConnect conn_.makeReconnectCtl(timer_name_); } -MySqlConfigBackendDHCPv4Impl::~MySqlConfigBackendDHCPv4Impl() { -} - MySqlConfigBackendDHCPv4::MySqlConfigBackendDHCPv4(const DatabaseConnection::ParameterMap& parameters) : impl_(new MySqlConfigBackendDHCPv4Impl(parameters)), base_impl_(impl_) { } diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc index 21036525f9042628db8bac345e21779f41e705d7..cfa397bcf81e7bce230932fcd7f3f3349f809520 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc @@ -164,7 +164,7 @@ public: parameters); /// @brief Destructor. - ~MySqlConfigBackendDHCPv6Impl(); + ~MySqlConfigBackendDHCPv6Impl() = default; /// @brief Sends query to retrieve global parameter. /// @@ -3491,9 +3491,6 @@ MySqlConfigBackendDHCPv6Impl::MySqlConfigBackendDHCPv6Impl(const DatabaseConnect conn_.makeReconnectCtl(timer_name_); } -MySqlConfigBackendDHCPv6Impl::~MySqlConfigBackendDHCPv6Impl() { -} - MySqlConfigBackendDHCPv6::MySqlConfigBackendDHCPv6(const DatabaseConnection::ParameterMap& parameters) : impl_(new MySqlConfigBackendDHCPv6Impl(parameters)), base_impl_(impl_) { } diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc index c9b596939a11bae27fdeb3104c61c86d4f4bdf04..8341765f36705c9913294f9b82cc453248a2f8ad 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc @@ -41,7 +41,10 @@ ScopedAuditRevision::ScopedAuditRevision(MySqlConfigBackendImpl* impl, MySqlConfigBackendImpl:: ScopedAuditRevision::~ScopedAuditRevision() { - impl_->clearAuditRevision(); + try { + impl_->clearAuditRevision(); + } catch (...) { + } } MySqlConfigBackendImpl:: @@ -68,14 +71,17 @@ MySqlConfigBackendImpl(const DatabaseConnection::ParameterMap& parameters, } MySqlConfigBackendImpl::~MySqlConfigBackendImpl() { - // Free up the prepared statements, ignoring errors. (What would we do - // about them? We're destroying this object and are not really concerned - // with errors on a database connection that is about to go away.) - for (int i = 0; i < conn_.statements_.size(); ++i) { - if (conn_.statements_[i] != NULL) { - (void) mysql_stmt_close(conn_.statements_[i]); - conn_.statements_[i] = NULL; + try { + // Free up the prepared statements, ignoring errors. (What would we do + // about them? We're destroying this object and are not really concerned + // with errors on a database connection that is about to go away.) + for (int i = 0; i < conn_.statements_.size(); ++i) { + if (conn_.statements_[i] != NULL) { + (void) mysql_stmt_close(conn_.statements_[i]); + conn_.statements_[i] = NULL; + } } + } catch (...) { } } diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_mgr_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_mgr_unittest.cc index fe94b556bce307972f3401b023fd78658db4676b..7f54fe24cebd408d48ec541a4152d02da742308f 100644 --- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_mgr_unittest.cc +++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_mgr_unittest.cc @@ -24,6 +24,7 @@ namespace { /// @brief Test fixture class for @c MySqlConfigBackendDHCPv4Mgr. class MySqlConfigBackendDHCPv4MgrTest : public GenericBackendTest { public: + /// @brief Constructor. MySqlConfigBackendDHCPv4MgrTest() { // Recreate a fresh mgr. @@ -35,11 +36,14 @@ public: /// @brief Destructor. virtual ~MySqlConfigBackendDHCPv4MgrTest() { - // Destroy the mgr. - ConfigBackendDHCPv4Mgr::destroy(); - - // If data wipe enabled, delete transient data otherwise destroy the schema. - destroyMySQLSchema(); + try { + // Destroy the mgr. + ConfigBackendDHCPv4Mgr::destroy(); + + // If data wipe enabled, delete transient data otherwise destroy the schema. + destroyMySQLSchema(); + } catch (...) { + } } }; diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc index 1a546e072543c54beb73a9a0d3b9f64ff660e54b..43df3678b124737449292ffbbb50268688b9334f 100644 --- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc +++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc @@ -110,9 +110,12 @@ public: /// @brief Destructor. virtual ~MySqlConfigBackendDHCPv4Test() { - cbptr_.reset(); - // If data wipe enabled, delete transient data otherwise destroy the schema. - destroyMySQLSchema(); + try { + cbptr_.reset(); + // If data wipe enabled, delete transient data otherwise destroy the schema. + destroyMySQLSchema(); + } catch (...) { + } } /// @brief Counts rows in a selected table in MySQL database. @@ -4164,6 +4167,8 @@ TEST_F(MySqlConfigBackendDHCPv4Test, multipleAuditEntries) { class MySqlConfigBackendDHCPv4DbLostCallbackTest : public ::testing::Test { public: + + /// @brief Constructor MySqlConfigBackendDHCPv4DbLostCallbackTest() : db_lost_callback_called_(0), db_recovered_callback_called_(0), db_failed_callback_called_(0), @@ -4176,13 +4181,17 @@ public: isc::dhcp::CfgMgr::instance().clear(); } + /// @brief Destructor virtual ~MySqlConfigBackendDHCPv4DbLostCallbackTest() { - isc::db::DatabaseConnection::db_lost_callback_ = 0; - isc::db::DatabaseConnection::db_recovered_callback_ = 0; - isc::db::DatabaseConnection::db_failed_callback_ = 0; - isc::dhcp::MySqlConfigBackendImpl::setIOService(isc::asiolink::IOServicePtr()); - isc::dhcp::TimerMgr::instance()->unregisterTimers(); - isc::dhcp::CfgMgr::instance().clear(); + try { + isc::db::DatabaseConnection::db_lost_callback_ = 0; + isc::db::DatabaseConnection::db_recovered_callback_ = 0; + isc::db::DatabaseConnection::db_failed_callback_ = 0; + isc::dhcp::MySqlConfigBackendImpl::setIOService(isc::asiolink::IOServicePtr()); + isc::dhcp::TimerMgr::instance()->unregisterTimers(); + isc::dhcp::CfgMgr::instance().clear(); + } catch (...) { + } } /// @brief Prepares the class for a test. diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_mgr_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_mgr_unittest.cc index fe1252f21c493872dd4aa18f667a3c50cb793808..bba0a84820d7737eab6ac3c279dba2aed059573e 100644 --- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_mgr_unittest.cc +++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_mgr_unittest.cc @@ -24,6 +24,7 @@ namespace { /// @brief Test fixture class for @c MySqlConfigBackendDHCPv6Mgr. class MySqlConfigBackendDHCPv6MgrTest : public GenericBackendTest { public: + /// @brief Constructor. MySqlConfigBackendDHCPv6MgrTest() { // Recreate a fresh mgr. @@ -35,11 +36,14 @@ public: /// @brief Destructor. virtual ~MySqlConfigBackendDHCPv6MgrTest() { - // Destroy the mgr. - ConfigBackendDHCPv6Mgr::destroy(); - - // If data wipe enabled, delete transient data otherwise destroy the schema. - destroyMySQLSchema(); + try { + // Destroy the mgr. + ConfigBackendDHCPv6Mgr::destroy(); + + // If data wipe enabled, delete transient data otherwise destroy the schema. + destroyMySQLSchema(); + } catch (...) { + } } }; diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc index d66f61066988592ff8c972e9ec1f94c4488b3d48..f70d697cd395886833e83288c956e1fab05c2e06 100644 --- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc +++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc @@ -109,9 +109,12 @@ public: /// @brief Destructor. virtual ~MySqlConfigBackendDHCPv6Test() { - cbptr_.reset(); - // If data wipe enabled, delete transient data otherwise destroy the schema. - destroyMySQLSchema(); + try { + cbptr_.reset(); + // If data wipe enabled, delete transient data otherwise destroy the schema. + destroyMySQLSchema(); + } catch (...) { + } } /// @brief Counts rows in a selected table in MySQL database. @@ -4339,6 +4342,8 @@ TEST_F(MySqlConfigBackendDHCPv6Test, multipleAuditEntries) { class MySqlConfigBackendDHCPv6DbLostCallbackTest : public ::testing::Test { public: + + /// @brief Constructor MySqlConfigBackendDHCPv6DbLostCallbackTest() : db_lost_callback_called_(0), db_recovered_callback_called_(0), db_failed_callback_called_(0), @@ -4351,13 +4356,17 @@ public: isc::dhcp::CfgMgr::instance().clear(); } + /// @brief Destructor virtual ~MySqlConfigBackendDHCPv6DbLostCallbackTest() { - isc::db::DatabaseConnection::db_lost_callback_ = 0; - isc::db::DatabaseConnection::db_recovered_callback_ = 0; - isc::db::DatabaseConnection::db_failed_callback_ = 0; - isc::dhcp::MySqlConfigBackendImpl::setIOService(isc::asiolink::IOServicePtr()); - isc::dhcp::TimerMgr::instance()->unregisterTimers(); - isc::dhcp::CfgMgr::instance().clear(); + try { + isc::db::DatabaseConnection::db_lost_callback_ = 0; + isc::db::DatabaseConnection::db_recovered_callback_ = 0; + isc::db::DatabaseConnection::db_failed_callback_ = 0; + isc::dhcp::MySqlConfigBackendImpl::setIOService(isc::asiolink::IOServicePtr()); + isc::dhcp::TimerMgr::instance()->unregisterTimers(); + isc::dhcp::CfgMgr::instance().clear(); + } catch (...) { + } } /// @brief Prepares the class for a test. diff --git a/src/hooks/dhcp/run_script/libloadtests/load_unload_unittests.cc b/src/hooks/dhcp/run_script/libloadtests/load_unload_unittests.cc index b924b8ddf713ddcce4b279214f47ecd98d9c0024..de7cb234e3e2fdeeb7d0ec3277ffe2cc5601b9b1 100644 --- a/src/hooks/dhcp/run_script/libloadtests/load_unload_unittests.cc +++ b/src/hooks/dhcp/run_script/libloadtests/load_unload_unittests.cc @@ -28,6 +28,7 @@ namespace { /// @brief Test fixture for testing loading and unloading the RunScript library. class LibLoadTest : public ::testing::Test { public: + /// @brief Constructor LibLoadTest() { reset(); @@ -37,7 +38,10 @@ public: /// /// Removes files that may be left over from previous tests virtual ~LibLoadTest() { - reset(); + try { + reset(); + } catch (...) { + } } /// @brief Removes files that may be left over from previous tests diff --git a/src/hooks/dhcp/run_script/run_script.h b/src/hooks/dhcp/run_script/run_script.h index 4fd370c7b1cd7b555d34b67de7e409b68fbc55f6..f2a878636d2284c9c4f5e27967eb1902eee540ba 100644 --- a/src/hooks/dhcp/run_script/run_script.h +++ b/src/hooks/dhcp/run_script/run_script.h @@ -24,6 +24,7 @@ namespace run_script { /// @brief Run Script implementation. class RunScriptImpl { public: + /// @brief Constructor. RunScriptImpl(); @@ -236,4 +237,5 @@ typedef boost::shared_ptr RunScriptImplPtr; } // namespace run_script } // namespace isc + #endif diff --git a/src/hooks/dhcp/run_script/tests/run_script_unittests.cc b/src/hooks/dhcp/run_script/tests/run_script_unittests.cc index 06e1daf0718e2d09f09111ebe4f99e7feb953166..1c09546a729b050d2607dba439162732768f5056 100644 --- a/src/hooks/dhcp/run_script/tests/run_script_unittests.cc +++ b/src/hooks/dhcp/run_script/tests/run_script_unittests.cc @@ -705,8 +705,11 @@ public: /// @brief Destructor. ~RunScriptTest() { - RunScriptImpl::setIOService(IOServicePtr()); - clearLogFile(); + try { + RunScriptImpl::setIOService(IOServicePtr()); + clearLogFile(); + } catch (...) { + } } /// @brief Clear the test file if it exists. @@ -736,7 +739,7 @@ public: /// @brief Fetches the callout manager instance. boost::shared_ptrgetCalloutManager() { - return(co_manager_); + return (co_manager_); } private: diff --git a/src/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc b/src/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc index 58e5fcefa3953e1dcd68d7b503897d97a1c8d94b..2b7baf0df43167f525c3fc74e67de66b7759a89f 100644 --- a/src/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc +++ b/src/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc @@ -36,6 +36,7 @@ namespace { /// @brief Test fixture for testing loading and unloading the library class LibLoadTest : public ::testing::Test { public: + /// @brief Constructor LibLoadTest(std::string lib_filename) : lib_name_(lib_filename), start_time_(second_clock::universal_time()) { @@ -46,7 +47,10 @@ public: /// @brief Destructor /// Removes files that may be left over from previous tests virtual ~LibLoadTest() { - unloadLibs(); + try { + unloadLibs(); + } catch (...) { + } } /// @brief Adds library/parameters to list of libraries to be loaded @@ -337,11 +341,14 @@ public: /// /// Removes library (if any), destroys lease manager (if any). virtual ~StatCmdsTest() { - // destroys lease manager first because the other order triggers - // a clang/boost bug - LeaseMgrFactory::destroy(); - unloadLibs(); - lmptr_ = 0; + try { + // destroys lease manager first because the other order triggers + // a clang/boost bug + LeaseMgrFactory::destroy(); + unloadLibs(); + lmptr_ = 0; + } catch (...) { + } } /// @brief Initializes lease manager for v6 operation diff --git a/src/hooks/dhcp/user_chk/user.cc b/src/hooks/dhcp/user_chk/user.cc index 531a486d23c283240f5a2fb68603246654e1c40c..70416d8410f022561434992de56938d34c5f1704 100644 --- a/src/hooks/dhcp/user_chk/user.cc +++ b/src/hooks/dhcp/user_chk/user.cc @@ -67,9 +67,6 @@ UserId::UserId(UserIdType id_type, const std::string & id_str) : id_ = addr_bytes; } -UserId::~UserId() { -} - const std::vector& UserId::getId() const { return (id_); @@ -164,9 +161,6 @@ User::User(UserId::UserIdType id_type, const std::string& id_str) : user_id_(id_type, id_str) { } -User::~User() { -} - const PropertyMap& User::getProperties() const { return (properties_); diff --git a/src/hooks/dhcp/user_chk/user.h b/src/hooks/dhcp/user_chk/user.h index 879c81580e4615f658bb6222c8bf8bbc910fabd7..b2f277b5173c689f507fbb62cca54a56e384a101 100644 --- a/src/hooks/dhcp/user_chk/user.h +++ b/src/hooks/dhcp/user_chk/user.h @@ -38,6 +38,7 @@ public: /// @brief Defines the text label hardware address id type. static const char* HW_ADDRESS_STR; + /// @brief Define the text label DUID id type. static const char* DUID_STR; @@ -66,7 +67,7 @@ public: UserId(UserIdType id_type, const std::string& id_str); /// @brief Destructor. - ~UserId(); + ~UserId() = default; /// @brief Returns a const reference to the actual id value const std::vector& getId() const; @@ -181,7 +182,7 @@ public: User(UserId::UserIdType id_type, const std::string& id_str); /// @brief Destructor - ~User(); + ~User() = default; /// @brief Returns a reference to the map of properties. /// diff --git a/src/hooks/dhcp/user_chk/user_data_source.h b/src/hooks/dhcp/user_chk/user_data_source.h index c9a3571e66aaa880924ce3fb4aa4a73b2fb820ba..0505c9e677e41a58133b54d4268df325eea04a42 100644 --- a/src/hooks/dhcp/user_chk/user_data_source.h +++ b/src/hooks/dhcp/user_chk/user_data_source.h @@ -25,11 +25,12 @@ public: /// from an IO source such as a file. class UserDataSource { public: + /// @brief Constructor. - UserDataSource() {}; + UserDataSource() = default; /// @brief Virtual Destructor. - virtual ~UserDataSource() {}; + virtual ~UserDataSource() = default; /// @brief Opens the data source. /// diff --git a/src/hooks/dhcp/user_chk/user_file.cc b/src/hooks/dhcp/user_chk/user_file.cc index 96cb6a0fc40e15aa8cac054289633d63ca95b156..a94b04a2e3cea91189cc777bf7c0c1ba5d7c2bd8 100644 --- a/src/hooks/dhcp/user_chk/user_file.cc +++ b/src/hooks/dhcp/user_chk/user_file.cc @@ -22,9 +22,12 @@ UserFile::UserFile(const std::string& fname) : fname_(fname), file_() { } } -UserFile::~UserFile(){ - close(); -}; +UserFile::~UserFile() { + try { + close(); + } catch (...) { + } +} void UserFile::open() { diff --git a/src/hooks/dhcp/user_chk/user_registry.cc b/src/hooks/dhcp/user_chk/user_registry.cc index b0d3f3f6418860795634204a40611b0679822d00..a7ba924b3141f3ee40c55e8b69b4de2dafeb8f9c 100644 --- a/src/hooks/dhcp/user_chk/user_registry.cc +++ b/src/hooks/dhcp/user_chk/user_registry.cc @@ -11,12 +11,6 @@ namespace user_chk { -UserRegistry::UserRegistry() { -} - -UserRegistry::~UserRegistry(){ -} - void UserRegistry::addUser(UserPtr& user) { if (!user) { diff --git a/src/hooks/dhcp/user_chk/user_registry.h b/src/hooks/dhcp/user_chk/user_registry.h index d99c0c7262bd0fa48d19964ba70a6a9728d4d1af..db9ff44e589c92223342d00d0b75a6e11570feb4 100644 --- a/src/hooks/dhcp/user_chk/user_registry.h +++ b/src/hooks/dhcp/user_chk/user_registry.h @@ -37,13 +37,14 @@ typedef std::map UserMap; /// may be updated by loading it from a data source, such as a file. class UserRegistry { public: + /// @brief Constructor /// /// Creates a new registry with an empty list of users and no data source. - UserRegistry(); + UserRegistry() = default; /// @brief Destructor - ~UserRegistry(); + ~UserRegistry() = default; /// @brief Adds a given user to the registry. /// diff --git a/src/lib/asiodns/io_fetch.h b/src/lib/asiodns/io_fetch.h index c6e909f286593093b78f80ca49e72ee2f6b3ccd3..d7c3d163d2336219416c9c7690988fc33775045f 100644 --- a/src/lib/asiodns/io_fetch.h +++ b/src/lib/asiodns/io_fetch.h @@ -97,13 +97,12 @@ public: /// This is an abstract class. class Callback { public: + /// \brief Default Constructor - Callback() - {} + Callback() = default; /// \brief Virtual Destructor - virtual ~Callback() - {} + virtual ~Callback() = default; /// \brief Callback method /// diff --git a/src/lib/asiolink/botan_boost_tls.cc b/src/lib/asiolink/botan_boost_tls.cc index 7d698cc73bef00ad4cbbe749c7714ba6e949cfb7..29babbfbcd44d18eca59ae694029313d8e6f5b7f 100644 --- a/src/lib/asiolink/botan_boost_tls.cc +++ b/src/lib/asiolink/botan_boost_tls.cc @@ -31,13 +31,13 @@ using KeaCertificateStoreFile = Botan::Flatfile_Certificate_Store; // Class of Kea credential managers. class KeaCredentialsManager : public Botan::Credentials_Manager { public: + // Constructor. KeaCredentialsManager() : store_(), use_stores_(true), certs_(), key_() { } // Destructor. - virtual ~KeaCredentialsManager() { - } + virtual ~KeaCredentialsManager() = default; // CA certificate stores. // nullptr means do not require or check peer certificate. @@ -145,13 +145,13 @@ public: // Use Strict_Policy? class KeaPolicy : public Botan::TLS::Default_Policy { public: + // Constructor. KeaPolicy() : prefer_rsa_(true) { } // Destructor. - virtual ~KeaPolicy() { - } + virtual ~KeaPolicy() = default; // Allowed signature methods in preference order. std::vector allowed_signature_methods() const override { @@ -197,13 +197,13 @@ KeaPolicy::AllowedSignatureMethodsECDSA = { "ECDSA", "RSA", "DSA" }; // Class of Botan TLS context implementations. class TlsContextImpl { public: + // Constructor. TlsContextImpl() : cred_mgr_(), rng_(), sess_mgr_(), policy_() { } // Destructor. - virtual ~TlsContextImpl() { - } + virtual ~TlsContextImpl() = default; // Get the peer certificate requirement mode. virtual bool getCertRequired() const { @@ -286,9 +286,6 @@ public: std::unique_ptr context_; }; -TlsContext::~TlsContext() { -} - TlsContext::TlsContext(TlsRole role) : TlsContextBase(role), impl_(new TlsContextImpl()) { } diff --git a/src/lib/asiolink/botan_boost_tls.h b/src/lib/asiolink/botan_boost_tls.h index 9037ebc35379b9b8eb033f26b5d95ef41d35ae65..416756a05972c77c64ed7beb587380016f042041 100644 --- a/src/lib/asiolink/botan_boost_tls.h +++ b/src/lib/asiolink/botan_boost_tls.h @@ -45,7 +45,7 @@ public: /// /// @note The destructor can't be defined here because a unique /// pointer to an incomplete type is used. - virtual ~TlsContext(); + virtual ~TlsContext() = default; /// @brief Create a fresh context. /// @@ -116,8 +116,7 @@ TlsStreamBase(IOService& service, TlsContextPtr context) /// /// @tparam callback The callback. template -class TlsStream : public TlsStreamBase -{ +class TlsStream : public TlsStreamBase { public: /// @brief Type of the base. @@ -133,7 +132,7 @@ public: } /// @brief Destructor. - virtual ~TlsStream() { } + virtual ~TlsStream() = default; /// @brief TLS Handshake. /// diff --git a/src/lib/asiolink/botan_tls.h b/src/lib/asiolink/botan_tls.h index 1735cc757c447323d4358e1507d8c41b6c834a3c..89c99658494b33c7b133d59a5318d15f2ea3290c 100644 --- a/src/lib/asiolink/botan_tls.h +++ b/src/lib/asiolink/botan_tls.h @@ -28,7 +28,7 @@ class TlsContext : public TlsContextBase { public: /// @brief Destructor. - virtual ~TlsContext() { } + virtual ~TlsContext() = default; /// @brief Create a fresh context. /// @@ -119,7 +119,7 @@ public: } /// @brief Destructor. - virtual ~TlsStream() { } + virtual ~TlsStream() = default; /// @brief TLS Handshake. virtual void handshake(Callback&) { diff --git a/src/lib/asiolink/common_tls.h b/src/lib/asiolink/common_tls.h index b119760ebf45c7e5a9c31e10f4cfc82f7da5621c..47f4d376df65e56c6f67be48af7dd77eb465fd30 100644 --- a/src/lib/asiolink/common_tls.h +++ b/src/lib/asiolink/common_tls.h @@ -39,13 +39,15 @@ typedef boost::shared_ptr TlsContextPtr; /// @brief TLS context base class. class TlsContextBase : private boost::noncopyable { public: + /// @brief Destructor. - virtual ~TlsContextBase() { } + virtual ~TlsContextBase() = default; /// @brief Create a fresh context. /// /// @param role The TLS role client or server. - explicit TlsContextBase(TlsRole role) : role_(role) { } + explicit TlsContextBase(TlsRole role) : role_(role) { + } /// @brief Returns the role. TlsRole getRole() const { @@ -134,7 +136,7 @@ public: TlsStreamBase(IOService& service, TlsContextPtr context); /// @brief Destructor. - virtual ~TlsStreamBase() { } + virtual ~TlsStreamBase() = default; /// @brief Returns the role. TlsRole getRole() const { diff --git a/src/lib/asiolink/interval_timer.cc b/src/lib/asiolink/interval_timer.cc index 2cda9b0085b7ec74737dd8ad2fc588f52dbf34ea..5d731606ddf9923e93da259b9c3f72fe9fb752cf 100644 --- a/src/lib/asiolink/interval_timer.cc +++ b/src/lib/asiolink/interval_timer.cc @@ -106,7 +106,10 @@ IntervalTimerImpl::IntervalTimerImpl(IOService& io_service) : } IntervalTimerImpl::~IntervalTimerImpl() { - interval_ = INVALIDATED_INTERVAL; + try { + interval_ = INVALIDATED_INTERVAL; + } catch (...) { + } } void @@ -177,8 +180,11 @@ IntervalTimer::IntervalTimer(IOService& io_service) : } IntervalTimer::~IntervalTimer() { - // Cancel the timer to make sure cbfunc_() will not be called any more. - cancel(); + try { + // Cancel the timer to make sure cbfunc_() will not be called any more. + cancel(); + } catch (...) { + } } void diff --git a/src/lib/asiolink/io_acceptor.h b/src/lib/asiolink/io_acceptor.h index eab0d8302211245092356c94e8bd6d5923f35497..56de45faf099cfa1852fea00ff1e262a47ab9557 100644 --- a/src/lib/asiolink/io_acceptor.h +++ b/src/lib/asiolink/io_acceptor.h @@ -43,7 +43,7 @@ public: } /// @brief Destructor. - virtual ~IOAcceptor() { } + virtual ~IOAcceptor() = default; /// @brief Returns file descriptor of the underlying socket. virtual int getNative() const { diff --git a/src/lib/asiolink/io_asio_socket.h b/src/lib/asiolink/io_asio_socket.h index 29ca97f22681277d9a6da1f1a587ce15c1ac5185..ce7de7731f8f450f5617f311cc9efbf8da82c0ab 100644 --- a/src/lib/asiolink/io_asio_socket.h +++ b/src/lib/asiolink/io_asio_socket.h @@ -99,14 +99,16 @@ private: IOAsioSocket(const IOAsioSocket& source); IOAsioSocket& operator=(const IOAsioSocket& source); protected: + /// \brief The default constructor. /// /// This is intentionally defined as \c protected as this base class /// should never be instantiated (except as part of a derived class). - IOAsioSocket() {} + IOAsioSocket() = default; public: + /// The destructor. - virtual ~IOAsioSocket() {} + virtual ~IOAsioSocket() = default; //@} /// \brief Return the "native" representation of the socket. diff --git a/src/lib/asiolink/io_endpoint.h b/src/lib/asiolink/io_endpoint.h index 8421a305ee4dd0137d50891095bf0c57eebb219a..611a64c3db74bf4d384be2a6e6e70ba04f8dfffe 100644 --- a/src/lib/asiolink/io_endpoint.h +++ b/src/lib/asiolink/io_endpoint.h @@ -46,14 +46,16 @@ private: IOEndpoint(const IOEndpoint& source); IOEndpoint& operator=(const IOEndpoint& source); protected: + /// \brief The default constructor. /// /// This is intentionally defined as \c protected as this base class /// should never be instantiated (except as part of a derived class). - IOEndpoint() {} + IOEndpoint() = default; public: + /// The destructor. - virtual ~IOEndpoint() {} + virtual ~IOEndpoint() = default; //@} /// \brief Returns the address of the endpoint. diff --git a/src/lib/asiolink/io_service.cc b/src/lib/asiolink/io_service.cc index aad5dc7070ae7b18e9bf0927ece8a190963ba823..69a2be103e1ff2ba17f7f2b83b92c7adad719c23 100644 --- a/src/lib/asiolink/io_service.cc +++ b/src/lib/asiolink/io_service.cc @@ -44,14 +44,15 @@ private: IOServiceImpl(const IOService& source); IOServiceImpl& operator=(const IOService& source); public: + /// \brief The constructor IOServiceImpl() : io_service_(), work_(new boost::asio::io_service::work(io_service_)) { - }; + } /// \brief The destructor. - ~IOServiceImpl() {}; + ~IOServiceImpl() = default; //@} /// \brief Start the underlying event loop. @@ -60,7 +61,7 @@ public: /// the \c stop() method is called via some handler. void run() { io_service_.run(); - }; + } /// \brief Run the underlying event loop for a single event. /// @@ -69,7 +70,7 @@ public: /// it is run, it will block until one is.) void run_one() { io_service_.run_one(); - }; + } /// \brief Run the underlying event loop for a ready events. /// @@ -77,7 +78,7 @@ public: /// It will return immediately if there are no ready events. void poll() { io_service_.poll(); - }; + } /// \brief Stop the underlying event loop. /// @@ -130,9 +131,6 @@ private: IOService::IOService() : io_impl_(new IOServiceImpl()) { } -IOService::~IOService() { -} - void IOService::run() { io_impl_->run(); diff --git a/src/lib/asiolink/io_service.h b/src/lib/asiolink/io_service.h index 4bcedf1cb762061ce4bb10b6f3f28838924ffc0f..e06247ff454ba4430d734673597d5e9e59d7496f 100644 --- a/src/lib/asiolink/io_service.h +++ b/src/lib/asiolink/io_service.h @@ -41,10 +41,12 @@ private: IOService(const IOService& source); IOService& operator=(const IOService& source); public: + /// \brief The constructor IOService(); + /// \brief The destructor. - ~IOService(); + ~IOService() = default; //@} /// \brief Start the underlying event loop. diff --git a/src/lib/asiolink/io_service_signal.cc b/src/lib/asiolink/io_service_signal.cc index 95fc8a6be978a9ee7d28e57548e09805027c80b1..ffe1fb8105f6a839e015c073d466f2ffd17a53bd 100644 --- a/src/lib/asiolink/io_service_signal.cc +++ b/src/lib/asiolink/io_service_signal.cc @@ -23,6 +23,7 @@ namespace asiolink { class IOSignalSetImpl : public boost::enable_shared_from_this, public boost::noncopyable { public: + /// @brief Constructor. /// /// @param io_service the process IO service. diff --git a/src/lib/asiolink/io_service_signal.h b/src/lib/asiolink/io_service_signal.h index b078ce405a9cb451aaa1c9861dccf8759d439d87..eec561a177ffdf61f9111be57a3c21c7117bfbaa 100644 --- a/src/lib/asiolink/io_service_signal.h +++ b/src/lib/asiolink/io_service_signal.h @@ -25,6 +25,7 @@ class IOSignalSetImpl; /// as a ready event with a callback using boost ASIO. class IOSignalSet { public: + /// @brief Constructor. /// /// @param io_service IOService to which to send the signal. diff --git a/src/lib/asiolink/io_socket.h b/src/lib/asiolink/io_socket.h index 9c9cee16fdb5dc23f2edae4f33391fdd7a0a76cc..147b21d36cfaf3b34dec96c304cd1d53e745f6c2 100644 --- a/src/lib/asiolink/io_socket.h +++ b/src/lib/asiolink/io_socket.h @@ -55,14 +55,16 @@ private: IOSocket(const IOSocket& source); IOSocket& operator=(const IOSocket& source); protected: + /// \brief The default constructor. /// /// This is intentionally defined as \c protected as this base class /// should never be instantiated (except as part of a derived class). - IOSocket() {} + IOSocket() = default; public: + /// The destructor. - virtual ~IOSocket() {} + virtual ~IOSocket() = default; //@} /// \brief Return the "native" representation of the socket. diff --git a/src/lib/asiolink/openssl_tls.h b/src/lib/asiolink/openssl_tls.h index e94b308862e4ff65c1626476d5f0da2d8583a96f..a049ae7a5771caa8fb1c879f78a864438618d6c4 100644 --- a/src/lib/asiolink/openssl_tls.h +++ b/src/lib/asiolink/openssl_tls.h @@ -37,7 +37,7 @@ class TlsContext : public TlsContextBase { public: /// @brief Destructor. - virtual ~TlsContext() { } + virtual ~TlsContext() = default; /// @brief Create a fresh context. /// @@ -133,7 +133,7 @@ public: } /// @brief Destructor. - virtual ~TlsStream() { } + virtual ~TlsStream() = default; /// @brief TLS Handshake. /// diff --git a/src/lib/asiolink/process_spawn.cc b/src/lib/asiolink/process_spawn.cc index 2b819183d3b17b1635dd433b6a77acd5ebfba314..d38c9ed6d6d38e485e37bf6dcbf759329a67b5a6 100644 --- a/src/lib/asiolink/process_spawn.cc +++ b/src/lib/asiolink/process_spawn.cc @@ -228,10 +228,13 @@ ProcessSpawnImpl::ProcessSpawnImpl(IOServicePtr io_service, } ProcessSpawnImpl::~ProcessSpawnImpl() { - io_signal_set_->remove(SIGCHLD); - if (store_) { - lock_guard lk(mutex_); - process_collection_.erase(this); + try { + io_signal_set_->remove(SIGCHLD); + if (store_) { + lock_guard lk(mutex_); + process_collection_.erase(this); + } + } catch (...) { } } diff --git a/src/lib/asiolink/tcp_endpoint.h b/src/lib/asiolink/tcp_endpoint.h index 7cbb73b2ab45718c01131c529cccaf6841101e76..573ff8ac369ecdb8052168f36d1ffe475092061e 100644 --- a/src/lib/asiolink/tcp_endpoint.h +++ b/src/lib/asiolink/tcp_endpoint.h @@ -22,6 +22,7 @@ namespace asiolink { /// Other notes about \c TCPEndpoint applies to this class, too. class TCPEndpoint : public IOEndpoint { public: + /// /// \name Constructors and Destructor. /// @@ -69,7 +70,12 @@ public: {} /// \brief The destructor. - virtual ~TCPEndpoint() { delete asio_endpoint_placeholder_; } + virtual ~TCPEndpoint() { + try { + delete asio_endpoint_placeholder_; + } catch (...) { + } + } //@} virtual IOAddress getAddress() const { diff --git a/src/lib/asiolink/tcp_socket.h b/src/lib/asiolink/tcp_socket.h index 72d98b3488291e8ffbf039b939c4d558f04b743d..fcce11a7dd540c8da3a75d881626516f7528b0ac 100644 --- a/src/lib/asiolink/tcp_socket.h +++ b/src/lib/asiolink/tcp_socket.h @@ -71,7 +71,7 @@ public: TCPSocket(IOService& service); /// \brief Destructor - virtual ~TCPSocket(); + virtual ~TCPSocket() = default; /// \brief Return file descriptor of underlying socket virtual int getNative() const { @@ -263,15 +263,7 @@ TCPSocket::TCPSocket(boost::asio::ip::tcp::socket& socket) : template TCPSocket::TCPSocket(IOService& service) : socket_ptr_(new boost::asio::ip::tcp::socket(service.get_io_service())), - socket_(*socket_ptr_) -{ -} - -// Destructor. - -template -TCPSocket::~TCPSocket() -{ + socket_(*socket_ptr_) { } // Open the socket. diff --git a/src/lib/asiolink/tests/interval_timer_unittest.cc b/src/lib/asiolink/tests/interval_timer_unittest.cc index 95dfaf7f3179360c79dfe4dfdd482046bd1146e0..f52f0d2e8657afd4a439e0fde7b428d72633271a 100644 --- a/src/lib/asiolink/tests/interval_timer_unittest.cc +++ b/src/lib/asiolink/tests/interval_timer_unittest.cc @@ -24,28 +24,39 @@ using namespace isc::asiolink; // or not. class IntervalTimerTest : public ::testing::Test { protected: + + /// @brief Constructor IntervalTimerTest() : - io_service_(), timer_called_(false), timer_cancel_success_(false) - {} - ~IntervalTimerTest() {} + io_service_(), timer_called_(false), timer_cancel_success_(false) { + } + + /// @brief Destructor + ~IntervalTimerTest() = default; + class TimerCallBack : public std::unary_function { public: - TimerCallBack(IntervalTimerTest* test_obj) : test_obj_(test_obj) {} + /// @brief Constructor + TimerCallBack(IntervalTimerTest* test_obj) : test_obj_(test_obj) { + } + void operator()() const { test_obj_->timer_called_ = true; test_obj_->io_service_.stop(); return; } + private: IntervalTimerTest* test_obj_; }; + class TimerCallBackCounter : public std::unary_function { public: + /// @brief Constructor TimerCallBackCounter(IntervalTimerTest* test_obj) : - test_obj_(test_obj) - { + test_obj_(test_obj) { counter_ = 0; } + void operator()() { ++counter_; return; @@ -54,14 +65,17 @@ protected: private: IntervalTimerTest* test_obj_; }; + class TimerCallBackCancelDeleter : public std::unary_function { public: + /// @brief Constructor TimerCallBackCancelDeleter(IntervalTimerTest* test_obj, IntervalTimer* timer, TimerCallBackCounter& counter) : test_obj_(test_obj), timer_(timer), counter_(counter), count_(0), - prev_counter_(-1) - {} + prev_counter_(-1) { + } + void operator()() { ++count_; if (count_ == 1) { @@ -89,11 +103,14 @@ protected: int count_; int prev_counter_; }; + class TimerCallBackCanceller { public: + /// @brief Constructor TimerCallBackCanceller(unsigned int& counter, IntervalTimer& itimer) : - counter_(counter), itimer_(itimer) - {} + counter_(counter), itimer_(itimer) { + } + void operator()() { ++counter_; itimer_.cancel(); @@ -102,12 +119,15 @@ protected: unsigned int& counter_; IntervalTimer& itimer_; }; + class TimerCallBackOverwriter : public std::unary_function { public: + /// @brief Constructor TimerCallBackOverwriter(IntervalTimerTest* test_obj, IntervalTimer& timer) - : test_obj_(test_obj), timer_(timer), count_(0) - {} + : test_obj_(test_obj), timer_(timer), count_(0) { + } + void operator()() { ++count_; if (count_ == 1) { @@ -128,11 +148,14 @@ protected: IntervalTimer& timer_; int count_; }; + class TimerCallBackAccumulator: public std::unary_function { public: + /// @brief Constructor TimerCallBackAccumulator(IntervalTimerTest* test_obj, int &counter) : test_obj_(test_obj), counter_(counter) { } + void operator()() { ++counter_; return; diff --git a/src/lib/asiolink/tests/io_service_signal_unittests.cc b/src/lib/asiolink/tests/io_service_signal_unittests.cc index 5f35359e64d0e55472735331ef3958eee069edcc..a550eb9fc732da0653a43cd5a8d9ca2040a438d7 100644 --- a/src/lib/asiolink/tests/io_service_signal_unittests.cc +++ b/src/lib/asiolink/tests/io_service_signal_unittests.cc @@ -61,7 +61,7 @@ public: } /// @brief Destructor. - ~IOSignalTest() {} + ~IOSignalTest() = default; /// @brief Method used as the IOSignalSet handler. /// diff --git a/src/lib/asiolink/tests/process_spawn_unittest.cc b/src/lib/asiolink/tests/process_spawn_unittest.cc index 478fb92a6094f53186e988f48f932a8fa54d819a..514c459cdb1ad1162ed01df33c949ab91bcf25b2 100644 --- a/src/lib/asiolink/tests/process_spawn_unittest.cc +++ b/src/lib/asiolink/tests/process_spawn_unittest.cc @@ -58,7 +58,7 @@ public: } /// @brief Destructor. - ~ProcessSpawnTest() {} + ~ProcessSpawnTest() = default; /// @brief Method used as the IOSignalSet handler. /// diff --git a/src/lib/asiolink/tests/tcp_acceptor_unittest.cc b/src/lib/asiolink/tests/tcp_acceptor_unittest.cc index d674146fd3993948f146d3c3d9b9a2d8780978ae..10f6ccb81f1a5aaf9629941cd8f9863d02c79cdf 100644 --- a/src/lib/asiolink/tests/tcp_acceptor_unittest.cc +++ b/src/lib/asiolink/tests/tcp_acceptor_unittest.cc @@ -71,7 +71,10 @@ public: /// /// Closes the underlying socket if it is open. ~TCPClient() { - close(); + try { + close(); + } catch (...) { + } } /// @brief Connect to the test server address and port. @@ -156,7 +159,10 @@ public: /// /// Closes socket. ~Acceptor() { - socket_.close(); + try { + socket_.close(); + } catch (...) { + } } /// @brief Asynchronous accept new connection. @@ -211,8 +217,7 @@ public: } /// @brief Destructor. - virtual ~TCPAcceptorTest() { - } + virtual ~TCPAcceptorTest() = default; /// @brief Specifies how many new connections are expected before the IO /// service is stopped. diff --git a/src/lib/asiolink/tests/tcp_socket_unittest.cc b/src/lib/asiolink/tests/tcp_socket_unittest.cc index 7531af6a8ab5fde97dd3b1c8fcefb89a925a859c..22585cc8c83399fcc8c678951123a04c35a272b7 100644 --- a/src/lib/asiolink/tests/tcp_socket_unittest.cc +++ b/src/lib/asiolink/tests/tcp_socket_unittest.cc @@ -70,8 +70,8 @@ public: struct PrivateData { PrivateData() : error_code_(), length_(0), cumulative_(0), expected_(0), offset_(0), - name_(""), queued_(NONE), called_(NONE), data_(MIN_SIZE, 0) - {} + name_(""), queued_(NONE), called_(NONE), data_(MIN_SIZE, 0) { + } boost::system::error_code error_code_; ///< Completion error code size_t length_; ///< Bytes transferred in this I/O @@ -96,16 +96,14 @@ public: /// data. /// /// @param which Which of the two callback objects this is - TCPCallback(std::string which) : ptr_(new PrivateData()) - { + TCPCallback(std::string which) : ptr_(new PrivateData()) { ptr_->name_ = which; } /// @brief Destructor /// /// No code needed, destroying the shared pointer destroys the private data. - virtual ~TCPCallback() - {} + virtual ~TCPCallback() = default; /// @brief Client Callback Function /// @@ -115,8 +113,7 @@ public: /// @param ec I/O completion error code passed to callback function. /// @param length Number of bytes transferred void operator()(boost::system::error_code ec = boost::system::error_code(), - size_t length = 0) - { + size_t length = 0) { setCode(ec.value()); ptr_->called_ = ptr_->queued_; ptr_->length_ = length; diff --git a/src/lib/asiolink/tests/tls_acceptor_unittest.cc b/src/lib/asiolink/tests/tls_acceptor_unittest.cc index 06f06311a9891a1c570e229549b457b93c329416..41c912f204f59f6863813a5860315eeb2df3eeac 100644 --- a/src/lib/asiolink/tests/tls_acceptor_unittest.cc +++ b/src/lib/asiolink/tests/tls_acceptor_unittest.cc @@ -72,7 +72,10 @@ public: /// /// Closes the underlying socket if it is open. ~TLSClient() { - close(); + try { + close(); + } catch (...) { + } } /// @brief Connect to the test server address and port. @@ -161,7 +164,10 @@ public: /// /// Closes socket. ~Acceptor() { - socket_.close(); + try { + socket_.close(); + } catch (...) { + } } /// @brief Asynchronous accept new connection. @@ -216,8 +222,7 @@ public: } /// @brief Destructor. - virtual ~TLSAcceptorTest() { - } + virtual ~TLSAcceptorTest() = default; /// @brief Specifies how many new connections are expected before the IO /// service is stopped. diff --git a/src/lib/asiolink/tests/tls_socket_unittest.cc b/src/lib/asiolink/tests/tls_socket_unittest.cc index c2572c02d02fd2bdb097172a63ed532451e3f6dd..c20aebfe2100d4e2126858c5c1ea71da7040f126 100644 --- a/src/lib/asiolink/tests/tls_socket_unittest.cc +++ b/src/lib/asiolink/tests/tls_socket_unittest.cc @@ -72,8 +72,8 @@ public: struct PrivateData { PrivateData() : error_code_(), length_(0), cumulative_(0), expected_(0), offset_(0), - name_(""), queued_(NONE), called_(NONE), data_(MIN_SIZE, 0) - {} + name_(""), queued_(NONE), called_(NONE), data_(MIN_SIZE, 0) { + } boost::system::error_code error_code_; ///< Completion error code size_t length_; ///< Bytes transferred in this I/O @@ -98,16 +98,14 @@ public: /// data. /// /// @param which Which of the two callback objects this is - TLSCallback(std::string which) : ptr_(new PrivateData()) - { + TLSCallback(std::string which) : ptr_(new PrivateData()) { ptr_->name_ = which; } /// @brief Destructor /// /// No code needed, destroying the shared pointer destroys the private data. - virtual ~TLSCallback() - {} + virtual ~TLSCallback() = default; /// @brief Client Callback Function /// @@ -117,8 +115,7 @@ public: /// @param ec I/O completion error code passed to callback function. /// @param length Number of bytes transferred void operator()(boost::system::error_code ec = boost::system::error_code(), - size_t length = 0) - { + size_t length = 0) { setCode(ec.value()); ptr_->called_ = ptr_->queued_; ptr_->length_ = length; diff --git a/src/lib/asiolink/tests/tls_unittest.cc b/src/lib/asiolink/tests/tls_unittest.cc index 8533f5ab374239f120b79a3af9d753a452725ae8..43b0ce365c96c75c77b114056bc2d0d9c7346af3 100644 --- a/src/lib/asiolink/tests/tls_unittest.cc +++ b/src/lib/asiolink/tests/tls_unittest.cc @@ -46,13 +46,15 @@ const char KEA_TLS_CHECK_VERBOSE[] = "KEA_TLS_CHECK_VERBOSE"; /// @brief Test TLS context class exposing protected methods. class TestTlsContext : public TlsContext { public: + /// @brief Constructor. /// /// @param role The TLS role client or server. - explicit TestTlsContext(TlsRole role) : TlsContext(role) { } + explicit TestTlsContext(TlsRole role) : TlsContext(role) { + } /// @brief Destructor. - virtual ~TestTlsContext() { } + virtual ~TestTlsContext() = default; /// @brief Make protected methods visible in tests. using TlsContext::setCertRequired; @@ -68,13 +70,13 @@ public: /// @brief State part. class State { public: + /// @brief Constructor. State() : called_(false), error_code_() { } /// @brief Destructor. - virtual ~State() { - } + virtual ~State() = default; /// @brief Called flag. /// @@ -103,8 +105,7 @@ public: } /// @brief Destructor. - virtual ~TestCallback() { - } + virtual ~TestCallback() = default; /// @brief Callback function (one argument). /// diff --git a/src/lib/asiolink/tests/udp_socket_unittest.cc b/src/lib/asiolink/tests/udp_socket_unittest.cc index 1fb96160ab5a04e085781cdb0156aff8c26c1197..16e79c63122ae8a4164273ade35497deda32af76 100644 --- a/src/lib/asiolink/tests/udp_socket_unittest.cc +++ b/src/lib/asiolink/tests/udp_socket_unittest.cc @@ -57,8 +57,8 @@ public: struct PrivateData { PrivateData() : - error_code_(), length_(0), called_(false), name_("") - {} + error_code_(), length_(0), called_(false), name_("") { + } boost::system::error_code error_code_; ///< Completion error code size_t length_; ///< Number of bytes transferred @@ -78,16 +78,14 @@ public: /// data. /// /// \param which Which of the two callback objects this is - UDPCallback(const std::string& which) : ptr_(new PrivateData()) - { + UDPCallback(const std::string& which) : ptr_(new PrivateData()) { setName(which); } /// \brief Destructor /// /// No code needed, destroying the shared pointer destroys the private data. - virtual ~UDPCallback() - {} + virtual ~UDPCallback() = default; /// \brief Callback Function /// diff --git a/src/lib/asiolink/tests/unix_domain_socket_unittest.cc b/src/lib/asiolink/tests/unix_domain_socket_unittest.cc index a147e3bb8c8419808de606da0bfd91ed2f1dc9df..2b90636a2e01eec68e7b603a739f2911d0d6a6f6 100644 --- a/src/lib/asiolink/tests/unix_domain_socket_unittest.cc +++ b/src/lib/asiolink/tests/unix_domain_socket_unittest.cc @@ -46,7 +46,10 @@ public: /// /// Removes unix socket descriptor after the test. virtual ~UnixDomainSocketTest() { - removeUnixSocketFile(); + try { + removeUnixSocketFile(); + } catch (...) { + } } /// @brief Returns socket file path. diff --git a/src/lib/asiolink/testutils/test_server_unix_socket.cc b/src/lib/asiolink/testutils/test_server_unix_socket.cc index 7f7007d01822edc3fcabc318fdebb4e1ef2e1365..702dde7e180d6c15691b8f7956a33e66ec5ed2ff 100644 --- a/src/lib/asiolink/testutils/test_server_unix_socket.cc +++ b/src/lib/asiolink/testutils/test_server_unix_socket.cc @@ -149,7 +149,10 @@ public: /// @brief Destructor. ~ConnectionPool() { - stopAll(); + try { + stopAll(); + } catch (...) { + } } /// @brief Creates new unix domain socket and returns it. @@ -237,7 +240,10 @@ TestServerUnixSocket::TestServerUnixSocket(IOService& io_service, } TestServerUnixSocket::~TestServerUnixSocket() { - server_acceptor_.close(); + try { + server_acceptor_.close(); + } catch (...) { + } } void diff --git a/src/lib/asiolink/testutils/timed_signal.h b/src/lib/asiolink/testutils/timed_signal.h index 3af545df387ca154ab36c6eb6bfa4ed56101bca7..e9bd5ae384ee973459dba9987d0d05e9c2907f93 100644 --- a/src/lib/asiolink/testutils/timed_signal.h +++ b/src/lib/asiolink/testutils/timed_signal.h @@ -23,6 +23,7 @@ namespace test { /// send (raise) the signal to the current process. class TimedSignal { public: + /// @brief Constructor /// /// @param io_service IOService to run the timer @@ -47,7 +48,10 @@ public: /// @brief Destructor. ~TimedSignal() { - cancel(); + try { + cancel(); + } catch (...) { + } } /// @brief Callback for the TimeSignal's internal timer. diff --git a/src/lib/asiolink/tls_acceptor.h b/src/lib/asiolink/tls_acceptor.h index c5755592c081f81108251154e65c7b68b0698354..75c2528f11874b0f36ccde9d27aac25d0c86651b 100644 --- a/src/lib/asiolink/tls_acceptor.h +++ b/src/lib/asiolink/tls_acceptor.h @@ -38,7 +38,7 @@ public: } /// @brief Destructor. - virtual ~TLSAcceptor() { } + virtual ~TLSAcceptor() = default; /// @brief Asynchronously accept new connection. /// diff --git a/src/lib/asiolink/tls_socket.h b/src/lib/asiolink/tls_socket.h index cdd2f78d0c020a140daa07d1487df319a7d50756..7b2bfbf01b1849153786d2ed40efff7684a3c1df 100644 --- a/src/lib/asiolink/tls_socket.h +++ b/src/lib/asiolink/tls_socket.h @@ -45,7 +45,7 @@ public: TLSSocket(IOService& service, TlsContextPtr context); /// @brief Destructor. - virtual ~TLSSocket() { } + virtual ~TLSSocket() = default; /// @brief Return file descriptor of underlying socket. virtual int getNative() const { diff --git a/src/lib/asiolink/udp_endpoint.h b/src/lib/asiolink/udp_endpoint.h index 894032b2216065bc631ac68524ab9101460a2c7e..caa4a68519e1a61a9415925cc0b22065c422a7e4 100644 --- a/src/lib/asiolink/udp_endpoint.h +++ b/src/lib/asiolink/udp_endpoint.h @@ -22,6 +22,7 @@ namespace asiolink { /// Other notes about \c TCPEndpoint applies to this class, too. class UDPEndpoint : public IOEndpoint { public: + /// /// \name Constructors and Destructor. /// @@ -69,7 +70,12 @@ public: {} /// \brief The destructor. - virtual ~UDPEndpoint() { delete asio_endpoint_placeholder_; } + virtual ~UDPEndpoint() { + try { + delete asio_endpoint_placeholder_; + } catch (...) { + } + } //@} virtual IOAddress getAddress() const { diff --git a/src/lib/asiolink/udp_socket.h b/src/lib/asiolink/udp_socket.h index 66815ed018fda2026c0268d8d30cc0ce0fd501d1..c1d0b0fee8c192da78808a4cdca24f946738c976 100644 --- a/src/lib/asiolink/udp_socket.h +++ b/src/lib/asiolink/udp_socket.h @@ -59,7 +59,7 @@ public: UDPSocket(IOService& service); /// \brief Destructor - virtual ~UDPSocket(); + virtual ~UDPSocket() = default; /// \brief Return file descriptor of underlying socket virtual int getNative() const { @@ -174,15 +174,7 @@ UDPSocket::UDPSocket(boost::asio::ip::udp::socket& socket) : template UDPSocket::UDPSocket(IOService& service) : socket_ptr_(new boost::asio::ip::udp::socket(service.get_io_service())), - socket_(*socket_ptr_), isopen_(false) -{ -} - -// Destructor. - -template -UDPSocket::~UDPSocket() -{ + socket_(*socket_ptr_), isopen_(false) { } // Open the socket. diff --git a/src/lib/asiolink/unix_domain_socket.cc b/src/lib/asiolink/unix_domain_socket.cc index ca9e15ce30a695c539a858388405f6e3b5701367..5fdb996c413e74bbc2ab799818fe3b6108ab5f55 100644 --- a/src/lib/asiolink/unix_domain_socket.cc +++ b/src/lib/asiolink/unix_domain_socket.cc @@ -33,7 +33,10 @@ public: /// /// Closes the socket. ~UnixDomainSocketImpl() { - close(); + try { + close(); + } catch (...) { + } } /// @brief Asynchronously connects to an endpoint. diff --git a/src/lib/cc/cfg_to_element.h b/src/lib/cc/cfg_to_element.h index 480dd1fa7485c8e8be067af26bb2224c486cad85..5097331e3e45ceb833e0064084a3635398aff9bf 100644 --- a/src/lib/cc/cfg_to_element.h +++ b/src/lib/cc/cfg_to_element.h @@ -27,8 +27,12 @@ namespace data { /// @brief Abstract class for configuration Cfg_* classes /// struct CfgToElement { + + /// Constructor + CfgToElement() = default; + /// Destructor - virtual ~CfgToElement() { } + virtual ~CfgToElement() = default; /// @brief Unparse a configuration object /// @@ -42,7 +46,7 @@ struct CfgToElement { virtual isc::data::ElementPtr toElement() const = 0; }; -}; // namespace isc::dhcp -}; // namespace isc +} // namespace isc::dhcp +} // namespace isc #endif // CFG_TO_ELEMENT_H diff --git a/src/lib/cc/data.h b/src/lib/cc/data.h index 4403b5179e94541b6e929bac738447ff523341fa..de85e0424cde20e7731d56c8810130ac42cf1169 100644 --- a/src/lib/cc/data.h +++ b/src/lib/cc/data.h @@ -15,7 +15,8 @@ #include #include -namespace isc { namespace data { +namespace isc { +namespace data { class Element; // todo: describe the rationale behind ElementPtr? @@ -64,7 +65,6 @@ public: /// the type in question. /// class Element { - public: /// @brief Represents the position of the data element within a /// configuration string. @@ -143,14 +143,14 @@ protected: : type_(t), position_(pos) { } - public: // any is a special type used in list specifications, specifying // that the elements can be of any type enum types { integer, real, boolean, null, string, list, map, any }; - // base class; make dtor virtual - virtual ~Element() {}; + + /// @brief Destructor. + virtual ~Element() = default; /// @return the type of this element int getType() const { return (type_); } @@ -815,7 +815,10 @@ std::ostream& operator<<(std::ostream& out, const Element& e); bool operator==(const Element& a, const Element& b); bool operator!=(const Element& a, const Element& b); -} } + +} +} + #endif // ISC_DATA_H // Local Variables: diff --git a/src/lib/cc/tests/data_file_unittests.cc b/src/lib/cc/tests/data_file_unittests.cc index a7f1b8dcd7cd17724b4c596a2d1dd854c0883538..4422c5194f6d75c36dbea6f40033beabcfffb85e 100644 --- a/src/lib/cc/tests/data_file_unittests.cc +++ b/src/lib/cc/tests/data_file_unittests.cc @@ -33,9 +33,15 @@ public: write_me.close(); } - /// destructor + /// @brief Constructor + DataFileTest() = default; + + /// @brief Destructor ~DataFileTest() { - static_cast(remove(TEMP_FILE)); + try { + static_cast(remove(TEMP_FILE)); + } catch (...) { + } } /// Name of the temporary file @@ -95,4 +101,4 @@ TEST_F(DataFileTest, readFileError) { EXPECT_THROW(Element::fromJSONFile("no-such-file.txt"), isc::InvalidOperation); } -}; +} diff --git a/src/lib/config/base_command_mgr.h b/src/lib/config/base_command_mgr.h index 9cc5a7f987501601102ad9ab5d16902623143cd7..e22166002691e0acce4633fadb520b3729ba52ea 100644 --- a/src/lib/config/base_command_mgr.h +++ b/src/lib/config/base_command_mgr.h @@ -103,7 +103,7 @@ public: BaseCommandMgr(); /// @brief Destructor. - virtual ~BaseCommandMgr() { }; + virtual ~BaseCommandMgr() = default; /// @brief Triggers command processing. /// diff --git a/src/lib/config/cmd_http_listener.cc b/src/lib/config/cmd_http_listener.cc index 7063e17b4eb3f1ec3b99bdb7f3d675662dcd8933..19b81738bb06b762726288e9e7e9947302a4d91b 100644 --- a/src/lib/config/cmd_http_listener.cc +++ b/src/lib/config/cmd_http_listener.cc @@ -33,7 +33,10 @@ CmdHttpListener::CmdHttpListener(const IOAddress& address, const uint16_t port, } CmdHttpListener::~CmdHttpListener() { - stop(); + try { + stop(); + } catch (...) { + } } void diff --git a/src/lib/config/cmd_http_listener.h b/src/lib/config/cmd_http_listener.h index 4b1f414218ba8365d643a37fd14d9886a398abcf..b03a202f30716ddbee3950872a12c4a963a0abc1 100644 --- a/src/lib/config/cmd_http_listener.h +++ b/src/lib/config/cmd_http_listener.h @@ -31,6 +31,7 @@ namespace config { /// is (or will be) enabled when creating instances of this class. class CmdHttpListener { public: + /// @brief Constructor CmdHttpListener(const asiolink::IOAddress& address, const uint16_t port, const uint16_t thread_pool_size = 1); diff --git a/src/lib/config/command_mgr.cc b/src/lib/config/command_mgr.cc index 39cd471db74c06dc7ba5d53820154fb0dee079c3..29825d5b7418169f12bb9ce366e4a87049e4d1a3 100644 --- a/src/lib/config/command_mgr.cc +++ b/src/lib/config/command_mgr.cc @@ -90,7 +90,10 @@ public: /// /// Cancels timeout timer if one is scheduled. ~Connection() { - timeout_timer_.cancel(); + try { + timeout_timer_.cancel(); + } catch (...) { + } } /// @brief This method schedules timer or reschedules existing timer. @@ -644,7 +647,6 @@ CommandMgr::getControlSocketFD() { return (impl_->acceptor_ ? impl_->acceptor_->getNative() : -1); } - CommandMgr& CommandMgr::instance() { static CommandMgr cmd_mgr; @@ -661,6 +663,5 @@ CommandMgr::setConnectionTimeout(const long timeout) { impl_->timeout_ = timeout; } - -}; // end of isc::config -}; // end of isc +} // end of isc::config +} // end of isc diff --git a/src/lib/config/tests/client_connection_unittests.cc b/src/lib/config/tests/client_connection_unittests.cc index 3ecca820719ee1743ba5b90002a71633a27761e0..b112569a1c0efcbaddb3bd1a3f5c5dff1a4510e9 100644 --- a/src/lib/config/tests/client_connection_unittests.cc +++ b/src/lib/config/tests/client_connection_unittests.cc @@ -43,7 +43,10 @@ public: /// /// Removes unix socket descriptor after the test. virtual ~ClientConnectionTest() { - removeUnixSocketFile(); + try { + removeUnixSocketFile(); + } catch (...) { + } } /// @brief Returns socket file path. diff --git a/src/lib/config/tests/cmd_http_listener_unittests.cc b/src/lib/config/tests/cmd_http_listener_unittests.cc index 32b4b5ecafc28f675eeade4985f2a86266257ae3..e1341312d96ddbfeed342b46406d732c15c0874c 100644 --- a/src/lib/config/tests/cmd_http_listener_unittests.cc +++ b/src/lib/config/tests/cmd_http_listener_unittests.cc @@ -70,19 +70,22 @@ public: /// /// Removes HTTP clients, unregisters commands, disables MT. virtual ~CmdHttpListenerTest() { - // Wipe out the listener. - listener_.reset(); + try { + // Wipe out the listener. + listener_.reset(); - // Destroy all remaining clients. - for (auto const& client : clients_) { - client->close(); - } + // Destroy all remaining clients. + for (auto const& client : clients_) { + client->close(); + } - // Deregisters commands. - config::CommandMgr::instance().deregisterAll(); + // Deregisters commands. + config::CommandMgr::instance().deregisterAll(); - // Disable multi-threading. - MultiThreadingMgr::instance().setMode(false); + // Disable multi-threading. + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } /// @brief Constructs a complete HTTP POST given a request body. diff --git a/src/lib/config/tests/cmd_response_creator_unittests.cc b/src/lib/config/tests/cmd_response_creator_unittests.cc index d2126e5e88ea7de4bc70fb48dcab173240b3d466..e3dc55e0da7cf13489ec8310155fbb0142ad9d5d 100644 --- a/src/lib/config/tests/cmd_response_creator_unittests.cc +++ b/src/lib/config/tests/cmd_response_creator_unittests.cc @@ -47,7 +47,10 @@ public: /// /// Removes registered commands from the command manager. virtual ~CmdResponseCreatorTest() { - config::CommandMgr::instance().deregisterAll(); + try { + config::CommandMgr::instance().deregisterAll(); + } catch (...) { + } } /// @brief SetUp function that wraps call to initCreator. diff --git a/src/lib/config/tests/command_mgr_unittests.cc b/src/lib/config/tests/command_mgr_unittests.cc index b607d3e4144ce275e043af1890205f8754366401..82d1fb966bac5f110b3786906227cda44e449d19 100644 --- a/src/lib/config/tests/command_mgr_unittests.cc +++ b/src/lib/config/tests/command_mgr_unittests.cc @@ -52,9 +52,12 @@ public: /// Default destructor virtual ~CommandMgrTest() { - CommandMgr::instance().deregisterAll(); - CommandMgr::instance().closeCommandSocket(); - resetCalloutIndicators(); + try { + CommandMgr::instance().deregisterAll(); + CommandMgr::instance().closeCommandSocket(); + resetCalloutIndicators(); + } catch (...) { + } } /// @brief Returns socket path (using either hardcoded path or env variable) diff --git a/src/lib/config_backend/base_config_backend.h b/src/lib/config_backend/base_config_backend.h index 821a035509273bf21161c2bc7d5b10dde9ed6cff..5853afe0dd6482c1242ebe7407d25edb1293f1d5 100644 --- a/src/lib/config_backend/base_config_backend.h +++ b/src/lib/config_backend/base_config_backend.h @@ -35,7 +35,7 @@ class BaseConfigBackend { public: /// @brief Virtual destructor. - virtual ~BaseConfigBackend() { } + virtual ~BaseConfigBackend() = default; /// @brief Returns backend type in the textual format. /// diff --git a/src/lib/config_backend/base_config_backend_pool.h b/src/lib/config_backend/base_config_backend_pool.h index 1c836771a06d79ab27a09dc185bcb7362aab9f7d..337adfd144519fe068b111258b3fe54f25d12e03 100644 --- a/src/lib/config_backend/base_config_backend_pool.h +++ b/src/lib/config_backend/base_config_backend_pool.h @@ -48,7 +48,7 @@ public: typedef boost::shared_ptr ConfigBackendTypePtr; /// @brief Virtual destructor. - virtual ~BaseConfigBackendPool() { } + virtual ~BaseConfigBackendPool() = default; /// @brief Adds a backend to the pool. /// diff --git a/src/lib/config_backend/tests/config_backend_mgr_unittest.cc b/src/lib/config_backend/tests/config_backend_mgr_unittest.cc index a635a3e1a6726c5cebcf7acbf02b64c3ec2e341e..375d21029960525b6fd8f8ae488dc61c994c40c1 100644 --- a/src/lib/config_backend/tests/config_backend_mgr_unittest.cc +++ b/src/lib/config_backend/tests/config_backend_mgr_unittest.cc @@ -335,7 +335,10 @@ public: /// /// Removes backend instances. ~ConfigBackendMgrTest() { - config_mgr_.delAllBackends(); + try { + config_mgr_.delAllBackends(); + } catch (...) { + } } /// @brief Creates example database backend called "mysql". diff --git a/src/lib/cql/cql_connection.cc b/src/lib/cql/cql_connection.cc index e16a3fdc5db6757d9b76a5cab3b5d3b21954cac5..a9cb4577b26523f53995c159aeb487d9ec1754ee 100644 --- a/src/lib/cql/cql_connection.cc +++ b/src/lib/cql/cql_connection.cc @@ -36,42 +36,45 @@ CqlConnection::CqlConnection(const ParameterMap& parameters) } CqlConnection::~CqlConnection() { - // Free up the prepared statements, ignoring errors. Session and connection - // resources are deallocated. - CassError rc = CASS_OK; - std::string error; - - // Let's free the prepared statements. - for (StatementMapEntry s : statements_) { - CqlTaggedStatement statement = s.second; - if (statement.prepared_statement_) { - cass_prepared_free(statement.prepared_statement_); + try { + // Free up the prepared statements, ignoring errors. Session and connection + // resources are deallocated. + CassError rc = CASS_OK; + std::string error; + + // Let's free the prepared statements. + for (StatementMapEntry s : statements_) { + CqlTaggedStatement statement = s.second; + if (statement.prepared_statement_) { + cass_prepared_free(statement.prepared_statement_); + } } - } - // If there's a session, tear it down and free the resources. - if (session_) { - cass_schema_meta_free(schema_meta_); - CassFuture* close_future = cass_session_close(session_); - cass_future_wait(close_future); - error = checkFutureError( - "CqlConnection::~CqlConnection(): cass_session_close() != CASS_OK", - close_future); - rc = cass_future_error_code(close_future); - cass_future_free(close_future); - cass_session_free(session_); - session_ = NULL; - } + // If there's a session, tear it down and free the resources. + if (session_) { + cass_schema_meta_free(schema_meta_); + CassFuture* close_future = cass_session_close(session_); + cass_future_wait(close_future); + error = checkFutureError( + "CqlConnection::~CqlConnection(): cass_session_close() != CASS_OK", + close_future); + rc = cass_future_error_code(close_future); + cass_future_free(close_future); + cass_session_free(session_); + session_ = NULL; + } - // Free the cluster if there's one. - if (cluster_) { - cass_cluster_free(cluster_); - cluster_ = NULL; - } + // Free the cluster if there's one. + if (cluster_) { + cass_cluster_free(cluster_); + cluster_ = NULL; + } - if (rc != CASS_OK) { - // We're closing the connection anyway. Let's not throw at this stage. - DB_LOG_ERROR(CQL_DEALLOC_ERROR).arg(error); + if (rc != CASS_OK) { + // We're closing the connection anyway. Let's not throw at this stage. + DB_LOG_ERROR(CQL_DEALLOC_ERROR).arg(error); + } + } catch (...) { } } diff --git a/src/lib/cql/cql_exchange.cc b/src/lib/cql/cql_exchange.cc index 1dd00c017a5c283b5eb389d61b07666e14b291d4..6b3ba4274d827cb47bff111dcf1f0b1bc9d5c989 100644 --- a/src/lib/cql/cql_exchange.cc +++ b/src/lib/cql/cql_exchange.cc @@ -147,16 +147,6 @@ Udt::Udt(const CqlConnection& connection, const std::string& name) << " is not a UDT as expected. "); } } - -Udt::~Udt() { - /// @todo: Need to get back to this issue. This is likely a memory leak. - // - // Bug: it seems that if there is no call to - // cass_user_type_set_*(cass_user_type_), then - // cass_user_type_free(cass_user_type_) might SIGSEGV, so we never - // free. Udt objects should have application scope though. - // cass_user_type_free(cass_user_type_); -} /// @} /// @brief AnyArray method implementations @@ -733,12 +723,6 @@ CqlCommon::getData(const CassRow* row, AnyArray& data) { } } -CqlExchange::CqlExchange() { -} - -CqlExchange::~CqlExchange() { -} - void CqlExchange::convertToDatabaseTime(const time_t& cltt, const uint32_t& valid_lifetime, @@ -984,12 +968,6 @@ StatementMap CqlVersionExchange::tagged_statements_ = { {GET_VERSION, {GET_VERSION, "SELECT version, minor FROM schema_version "}} }; -CqlVersionExchange::CqlVersionExchange() { -} - -CqlVersionExchange::~CqlVersionExchange() { -} - void CqlVersionExchange::createBindForSelect(AnyArray& data, StatementTag) { data.clear(); // Start with a fresh array. diff --git a/src/lib/cql/cql_exchange.h b/src/lib/cql/cql_exchange.h index 5bf8d6962bc5eca1de8d2b8b4a5a43dbad2dffbe..c05552ff667895d7222fc9b9385bb87bc6fe5cc9 100644 --- a/src/lib/cql/cql_exchange.h +++ b/src/lib/cql/cql_exchange.h @@ -60,11 +60,20 @@ public: // @brief Representation of a Cassandra User Defined Type class Udt : public AnyArray { public: + /// @brief Parameterized constructor Udt(const CqlConnection& connection, const std::string& name); /// @brief Destructor - ~Udt(); + /// + /// @todo: Need to get back to this issue. This is likely a memory leak. + /// + /// Bug: it seems that if there is no call to + /// cass_user_type_set_*(cass_user_type_), then + /// cass_user_type_free(cass_user_type_) might SIGSEGV, so we never + /// free. Udt objects should have application scope though. + /// cass_user_type_free(cass_user_type_); + ~Udt() = default; /// @brief Frees the underlying container. void freeUserType(); @@ -141,13 +150,14 @@ struct CqlFunction { /// the same exchange if they have the same columns. class CqlExchange : public virtual SqlExchange { public: + /// @brief Constructor /// /// Empty body. Derived constructors specify table columns. - CqlExchange(); + CqlExchange() = default; /// @brief Destructor - virtual ~CqlExchange(); + virtual ~CqlExchange() = default; /// @name Time conversion: /// @{ @@ -235,13 +245,14 @@ public: /// @brief Exchange used to retrieve schema version from the keyspace. class CqlVersionExchange : public virtual CqlExchange { public: + /// @brief Constructor /// /// Specifies table columns. - CqlVersionExchange(); + CqlVersionExchange() = default; /// @brief Destructor - virtual ~CqlVersionExchange(); + virtual ~CqlVersionExchange() = default; /// @brief Create BIND array to receive C++ data. /// diff --git a/src/lib/cql/sql_common.h b/src/lib/cql/sql_common.h index a9e7e3865dd6dcc5884205b88bc99ccb2562768c..84a1bc83ec7663e9781783d7f4463d1a1d472fd2 100644 --- a/src/lib/cql/sql_common.h +++ b/src/lib/cql/sql_common.h @@ -41,13 +41,12 @@ enum ExchangeDataType { /// @brief Base class for backend exchanges. class SqlExchange { public: + /// @brief Constructor - SqlExchange() { - } + SqlExchange() = default; /// @brief Destructor - virtual ~SqlExchange() { - } + virtual ~SqlExchange() = default; }; } // namespace db diff --git a/src/lib/cql/tests/cql_connection_unittest.cc b/src/lib/cql/tests/cql_connection_unittest.cc index 4d7a323c30ef9d2cea1efb20edca0d216c9d5f0d..7f97c1d9421b80a9ba66902bf82e604bd132092b 100644 --- a/src/lib/cql/tests/cql_connection_unittest.cc +++ b/src/lib/cql/tests/cql_connection_unittest.cc @@ -27,13 +27,12 @@ using isc::db::CqlConnection; class CqlConnectionTest { public: + /// @brief Constructor - CqlConnectionTest() { - } + CqlConnectionTest() = default; /// @brief Destructor - virtual ~CqlConnectionTest() { - } + virtual ~CqlConnectionTest() = default; }; /// @brief Check that the key is properly hashed for StatementMap. diff --git a/src/lib/cryptolink/botan_hash.cc b/src/lib/cryptolink/botan_hash.cc index 06dca6d05d5dce07dae8e381da0bf0905bf01a91..82546f3238d6977d391d96b65813dd98371b9b0d 100644 --- a/src/lib/cryptolink/botan_hash.cc +++ b/src/lib/cryptolink/botan_hash.cc @@ -69,7 +69,7 @@ public: } /// @brief Destructor - ~HashImpl() { } + ~HashImpl() = default; /// @brief Returns the HashAlgorithm of the object HashAlgorithm getHashAlgorithm() const { @@ -156,13 +156,15 @@ private: boost::scoped_ptr hash_; }; -Hash::Hash(const HashAlgorithm hash_algorithm) -{ +Hash::Hash(const HashAlgorithm hash_algorithm) { impl_ = new HashImpl(hash_algorithm); } Hash::~Hash() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } HashAlgorithm diff --git a/src/lib/cryptolink/botan_hmac.cc b/src/lib/cryptolink/botan_hmac.cc index 88efb2efc0844f813c6959ff82a08003e46003b1..471227e64ea0d1612a6937454acd2bb3632e545a 100644 --- a/src/lib/cryptolink/botan_hmac.cc +++ b/src/lib/cryptolink/botan_hmac.cc @@ -23,6 +23,7 @@ namespace cryptolink { /// of the HMAC corresponding method. class HMACImpl { public: + /// @brief Constructor from a secret and a hash algorithm /// /// See constructor of the @ref isc::cryptolink::HMAC class for details. @@ -82,8 +83,7 @@ public: } /// @brief Destructor - ~HMACImpl() { - } + ~HMACImpl() = default; /// @brief Returns the HashAlgorithm of the object HashAlgorithm getHashAlgorithm() const { @@ -197,13 +197,15 @@ private: }; HMAC::HMAC(const void* secret, size_t secret_length, - const HashAlgorithm hash_algorithm) -{ + const HashAlgorithm hash_algorithm) { impl_ = new HMACImpl(secret, secret_length, hash_algorithm); } HMAC::~HMAC() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } HashAlgorithm diff --git a/src/lib/cryptolink/botan_link.cc b/src/lib/cryptolink/botan_link.cc index 714663d507f2d781e12b0b7c39c0622f359a4c6c..b70dd62c625f4a7755ddad6dff2c7689ec68feff 100644 --- a/src/lib/cryptolink/botan_link.cc +++ b/src/lib/cryptolink/botan_link.cc @@ -24,18 +24,23 @@ class CryptoLinkImpl { }; CryptoLink::~CryptoLink() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } /// \brief Botan implementation of RNG. class RNGImpl : public RNG { public: + + /// @brief Constructor RNGImpl() { rng.reset(new Botan::AutoSeeded_RNG()); } - ~RNGImpl() { - } + /// @brief Destructor + ~RNGImpl() = default; private: std::vector random(size_t len) { diff --git a/src/lib/cryptolink/crypto_hash.h b/src/lib/cryptolink/crypto_hash.h index f5ea3fade5db287cb49efeeef2d6d4c27878f0fb..44165d8efeba1e4e1fe2f3493af72f3ce2cf778a 100644 --- a/src/lib/cryptolink/crypto_hash.h +++ b/src/lib/cryptolink/crypto_hash.h @@ -26,6 +26,7 @@ class HashImpl; /// class Hash : private boost::noncopyable { private: + /// \brief Constructor from a hash algorithm /// /// \exception UnsupportedAlgorithmException if the given algorithm @@ -39,6 +40,7 @@ private: friend Hash* CryptoLink::createHash(const HashAlgorithm); public: + /// \brief Destructor ~Hash(); diff --git a/src/lib/cryptolink/crypto_hmac.h b/src/lib/cryptolink/crypto_hmac.h index 5c7bffee61ecaeca680df78c3c1181bf6b147ea8..bbdae6c0214adb56312e163dabff78d1b6fa15a7 100644 --- a/src/lib/cryptolink/crypto_hmac.h +++ b/src/lib/cryptolink/crypto_hmac.h @@ -26,6 +26,7 @@ class HMACImpl; /// class HMAC : private boost::noncopyable { private: + /// \brief Constructor from a secret and a hash algorithm /// /// \exception UnsupportedAlgorithmException if the given algorithm @@ -49,6 +50,7 @@ private: const HashAlgorithm); public: + /// \brief Destructor ~HMAC(); diff --git a/src/lib/cryptolink/crypto_rng.cc b/src/lib/cryptolink/crypto_rng.cc index 54dacce40878bea9d7be27d668b2a938447dec0e..8433a8843bcbc02a834dfadcf9b3c7b717fdb429 100644 --- a/src/lib/cryptolink/crypto_rng.cc +++ b/src/lib/cryptolink/crypto_rng.cc @@ -16,15 +16,8 @@ namespace isc { namespace cryptolink { -RNG::RNG() { -} - -RNG::~RNG() { -} - std::vector -random(size_t len) -{ +random(size_t len) { RNGPtr rng(CryptoLink::getCryptoLink().getRNG()); return (rng->random(len)); } diff --git a/src/lib/cryptolink/crypto_rng.h b/src/lib/cryptolink/crypto_rng.h index 916321e7ca4c488c71782a0c97697319f1db437c..11d6fd13d662936f840137f564217ea52a1455c5 100644 --- a/src/lib/cryptolink/crypto_rng.h +++ b/src/lib/cryptolink/crypto_rng.h @@ -21,14 +21,15 @@ namespace cryptolink { /// class RNG : private boost::noncopyable { public: + /// \brief Constructor from a Random Number Generator /// /// \exception LibraryError if there was any unexpected exception /// in the underlying library - RNG(); + RNG() = default; /// \brief Destructor - virtual ~RNG(); + virtual ~RNG() = default; /// \brief Generate random value. /// diff --git a/src/lib/cryptolink/cryptolink.h b/src/lib/cryptolink/cryptolink.h index 41f1b620ffb9c687a0243886e026d8860c2ff005..199a328397ddf887767f38cd5a1c61fd0ab24b88 100644 --- a/src/lib/cryptolink/cryptolink.h +++ b/src/lib/cryptolink/cryptolink.h @@ -227,9 +227,14 @@ private: // the 'real' instance getter is private static CryptoLink& getCryptoLinkInternal(); - // To prevent people constructing their own, we make the constructor - // private too. - CryptoLink() : impl_(NULL) {} + /// @brief Constructor + /// + /// To prevent people constructing their own, we make the constructor + /// private too. + CryptoLink() : impl_(NULL) { + } + + /// @brief Destructor ~CryptoLink(); CryptoLinkImpl* impl_; diff --git a/src/lib/cryptolink/openssl_common.h b/src/lib/cryptolink/openssl_common.h index 7e47e698f541855e17f3ef330941472a3692d24b..10082015f9778d992abb3d01654398fef0bc04c8 100644 --- a/src/lib/cryptolink/openssl_common.h +++ b/src/lib/cryptolink/openssl_common.h @@ -37,38 +37,41 @@ public: SecBuf(const std::vector& x) : vec_(x) {} ~SecBuf() { + try { #if defined(__has_feature) #if __has_feature(address_sanitizer) - // Make the address sanitizer happy assuming this won't reallocate - vec_.resize(vec_.capacity()); + // Make the address sanitizer happy assuming this won't reallocate + vec_.resize(vec_.capacity()); #endif #endif - std::memset(&vec_[0], 0, vec_.capacity() * sizeof(T)); - }; + std::memset(&vec_[0], 0, vec_.capacity() * sizeof(T)); + } catch (...) { + } + } iterator begin() { return (vec_.begin()); - }; + } const_iterator begin() const { return (vec_.begin()); - }; + } iterator end() { return (vec_.end()); - }; + } const_iterator end() const { return (vec_.end()); - }; + } size_t size() const { return (vec_.size()); - }; + } void resize(size_t sz) { vec_.resize(sz); - }; + } void clear() { #if defined(__has_feature) @@ -86,15 +89,15 @@ public: vec_ = x.vec_; } return (*this); - }; + } T& operator[](size_t n) { return (vec_[n]); - }; + } const T& operator[](size_t n) const { return (vec_[n]); - }; + } // constant time comparison against timing attacks // (same type than XXX::verify() so const void* (vs. const T*) x) @@ -104,7 +107,7 @@ public: for (size_t i = 0; i < len; ++i) ret = ret && (vec_[i] == p[i]); return ret; - }; + } private: std::vector vec_; diff --git a/src/lib/cryptolink/openssl_hash.cc b/src/lib/cryptolink/openssl_hash.cc index 68f2285e1547d114a3fea56d123c1146b5b14379..f0a635b4fb74c408e73010a6ea2c20c5b6f8715d 100644 --- a/src/lib/cryptolink/openssl_hash.cc +++ b/src/lib/cryptolink/openssl_hash.cc @@ -73,10 +73,13 @@ public: /// @brief Destructor ~HashImpl() { - if (md_) { - EVP_MD_CTX_free(md_); + try { + if (md_) { + EVP_MD_CTX_free(md_); + } + md_ = 0; + } catch (...) { } - md_ = 0; } /// @brief Returns the HashAlgorithm of the object @@ -145,13 +148,15 @@ private: EVP_MD_CTX* md_; }; -Hash::Hash(const HashAlgorithm hash_algorithm) -{ +Hash::Hash(const HashAlgorithm hash_algorithm) { impl_ = new HashImpl(hash_algorithm); } Hash::~Hash() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } HashAlgorithm diff --git a/src/lib/cryptolink/openssl_hmac.cc b/src/lib/cryptolink/openssl_hmac.cc index 7d046858890efc4c534d0894ad92f2ff68e58ae2..51d9b2fc0e793ac75e2b4f4ec21e428eef4fb38c 100644 --- a/src/lib/cryptolink/openssl_hmac.cc +++ b/src/lib/cryptolink/openssl_hmac.cc @@ -26,6 +26,7 @@ namespace cryptolink { /// of the HMAC corresponding method. class HMACImpl { public: + /// @brief Constructor from a secret and a hash algorithm /// /// See constructor of the @ref isc::cryptolink::HMAC class for details. @@ -60,10 +61,13 @@ public: /// @brief Destructor ~HMACImpl() { - if (md_) { - HMAC_CTX_free(md_); + try { + if (md_) { + HMAC_CTX_free(md_); + } + md_ = 0; + } catch (...) { } - md_ = 0; } /// @brief Returns the HashAlgorithm of the object @@ -177,13 +181,15 @@ private: }; HMAC::HMAC(const void* secret, size_t secret_length, - const HashAlgorithm hash_algorithm) -{ + const HashAlgorithm hash_algorithm) { impl_ = new HMACImpl(secret, secret_length, hash_algorithm); } HMAC::~HMAC() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } HashAlgorithm diff --git a/src/lib/cryptolink/openssl_link.cc b/src/lib/cryptolink/openssl_link.cc index 1a573f7c41756552613eeab9b428656b802ba392..60f33d3980a14babde789528bd030985f224bd13 100644 --- a/src/lib/cryptolink/openssl_link.cc +++ b/src/lib/cryptolink/openssl_link.cc @@ -22,15 +22,21 @@ class CryptoLinkImpl { }; CryptoLink::~CryptoLink() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } /// \brief OpenSSL implementation of RNG. class RNGImpl : public RNG { public: - RNGImpl() { } - ~RNGImpl() { } + /// @brief Constructor + RNGImpl() = default; + + /// @brief Destructor + ~RNGImpl() = default; private: std::vector random(size_t len) { diff --git a/src/lib/database/database_connection.h b/src/lib/database/database_connection.h index de25b5c91a45009f13954ae507eacbcfed1c9ee6..e80e11c252749657edf54fa35365302085329845 100644 --- a/src/lib/database/database_connection.h +++ b/src/lib/database/database_connection.h @@ -243,7 +243,7 @@ public: } /// @brief Destructor - virtual ~DatabaseConnection(){}; + virtual ~DatabaseConnection() = default; /// @brief Instantiates a ReconnectCtl based on the connection's /// reconnect parameters diff --git a/src/lib/database/dbaccess_parser.cc b/src/lib/database/dbaccess_parser.cc index 5a0802aa6b42fd75186d102a512f50810086016a..6a302dfc1b0e372f7a1afc065de7b78539a538b4 100644 --- a/src/lib/database/dbaccess_parser.cc +++ b/src/lib/database/dbaccess_parser.cc @@ -22,12 +22,6 @@ using namespace isc::data; namespace isc { namespace db { - -// Factory function to build the parser -DbAccessParser::DbAccessParser() - : values_() { -} - // Parse the configuration and check that the various keywords are consistent. void DbAccessParser::parse(std::string& access_string, diff --git a/src/lib/database/dbaccess_parser.h b/src/lib/database/dbaccess_parser.h index ce0c9e2e889d175a48de68a9ca0fc616e40265b1..7aaab24f92d748768e1ce905e0699e68fbe72ced 100644 --- a/src/lib/database/dbaccess_parser.h +++ b/src/lib/database/dbaccess_parser.h @@ -24,12 +24,12 @@ namespace db { /// "config-database" elements, and comprises a map of strings. class DbAccessParser: public isc::data::SimpleParser { public: + /// @brief Constructor - DbAccessParser(); + DbAccessParser() = default; - /// The destructor. - virtual ~DbAccessParser() - {} + /// @brief Destructor. + virtual ~DbAccessParser() = default; /// @brief Parse configuration value. /// diff --git a/src/lib/database/tests/database_connection_unittest.cc b/src/lib/database/tests/database_connection_unittest.cc index fcc8ef3fef3871f018917a92b25943d2295eb60c..5b0c0204a4827948a47303f1936fefec2d22589c 100644 --- a/src/lib/database/tests/database_connection_unittest.cc +++ b/src/lib/database/tests/database_connection_unittest.cc @@ -21,6 +21,7 @@ namespace ph = std::placeholders; /// @brief Test fixture for exercising DbLostCallback invocation class DatabaseConnectionCallbackTest : public ::testing::Test { public: + /// Constructor DatabaseConnectionCallbackTest() : db_reconnect_ctl_(0) { @@ -31,9 +32,12 @@ public: /// Destructor ~DatabaseConnectionCallbackTest() { - DatabaseConnection::db_lost_callback_ = 0; - DatabaseConnection::db_recovered_callback_ = 0; - DatabaseConnection::db_failed_callback_ = 0; + try { + DatabaseConnection::db_lost_callback_ = 0; + DatabaseConnection::db_recovered_callback_ = 0; + DatabaseConnection::db_failed_callback_ = 0; + } catch (...) { + } } /// @brief Callback to register with a DatabaseConnection diff --git a/src/lib/database/tests/dbaccess_parser_unittest.cc b/src/lib/database/tests/dbaccess_parser_unittest.cc index dca15890f5f5ff596ed7f9d950a99778d9ce2dd1..b9e59b8575de278e4a0d791876599b2266964c11 100644 --- a/src/lib/database/tests/dbaccess_parser_unittest.cc +++ b/src/lib/database/tests/dbaccess_parser_unittest.cc @@ -28,16 +28,20 @@ namespace { /// @brief Database Access Parser test fixture class class DbAccessParserTest : public ::testing::Test { public: + /// @brief Constructor - DbAccessParserTest() { - } + DbAccessParserTest() = default; + /// @brief Destructor /// /// As some of the tests have the side-effect of altering the logging /// settings (when the parser's "parse" method is called), ensure that /// the logging is reset to the default after each test completes. ~DbAccessParserTest() { - isc::log::setDefaultLoggingOutput(); + try { + isc::log::setDefaultLoggingOutput(); + } catch (...) { + } } /// @brief Build JSON String @@ -184,13 +188,10 @@ class TestDbAccessParser : public DbAccessParser { public: /// @brief Constructor - TestDbAccessParser() - : DbAccessParser() - {} + TestDbAccessParser() = default; /// @brief Destructor - virtual ~TestDbAccessParser() - {} + virtual ~TestDbAccessParser() = default; /// @brief Parse configuration value /// @@ -749,4 +750,4 @@ TEST_F(DbAccessParserTest, multipleHost) { config2); } -}; // Anonymous namespace +} // Anonymous namespace diff --git a/src/lib/dhcp/iface_mgr.cc b/src/lib/dhcp/iface_mgr.cc index 40e11635abae5ce3614b4b05c7a5092ac25090b4..475b1baf6c00fd80af1e826988cb614821e13c88 100644 --- a/src/lib/dhcp/iface_mgr.cc +++ b/src/lib/dhcp/iface_mgr.cc @@ -312,7 +312,10 @@ void IfaceMgr::stopDHCPReceiver() { } IfaceMgr::~IfaceMgr() { - closeSockets(); + try { + closeSockets(); + } catch (...) { + } } bool diff --git a/src/lib/dhcp/iface_mgr.h b/src/lib/dhcp/iface_mgr.h index b9924e9eb0373899db765420b975fd9275227268..fe90d28a7c6cd18bce78c18b18e033635d068a6c 100644 --- a/src/lib/dhcp/iface_mgr.h +++ b/src/lib/dhcp/iface_mgr.h @@ -148,7 +148,7 @@ public: Iface(const std::string& name, unsigned int ifindex); /// @brief Destructor. - ~Iface() { } + ~Iface() = default; /// @brief Closes all open sockets on interface. void closeSockets(); @@ -1563,7 +1563,7 @@ private: isc::util::WatchedThreadPtr dhcp_receiver_; }; -}; // namespace isc::dhcp -}; // namespace isc +} // namespace isc::dhcp +} // namespace isc #endif // IFACE_MGR_H diff --git a/src/lib/dhcp/iface_mgr_linux.cc b/src/lib/dhcp/iface_mgr_linux.cc index 6b1fddcb125aee331e185f3a14a47c7b410498b9..247169833dea5ac58d572f18ce852834cd854a23 100644 --- a/src/lib/dhcp/iface_mgr_linux.cc +++ b/src/lib/dhcp/iface_mgr_linux.cc @@ -53,8 +53,7 @@ namespace { /// /// See IfaceMgr::detectIfaces() (Linux implementation, towards the end of this /// file) for example usage. -class Netlink -{ +class Netlink { public: /// @brief Holds pointers to netlink messages. @@ -85,13 +84,18 @@ public: /// }; typedef boost::array RTattribPtrs; + /// @brief Constructor Netlink() : fd_(-1), seq_(0), dump_(0) { memset(&local_, 0, sizeof(struct sockaddr_nl)); memset(&peer_, 0, sizeof(struct sockaddr_nl)); } + /// @brief Destructor ~Netlink() { - rtnl_close_socket(); + try { + rtnl_close_socket(); + } catch (...) { + } } diff --git a/src/lib/dhcp/option.cc b/src/lib/dhcp/option.cc index 52a6da7ecf8024e2309d6f5b49a182f30791cbed..949a58feb555fbecbaea2d6a94ce04a12aa7340b 100644 --- a/src/lib/dhcp/option.cc +++ b/src/lib/dhcp/option.cc @@ -398,10 +398,6 @@ bool Option::equals(const Option& other) const { (getData() == other.getData()) ); } -Option::~Option() { - -} - bool Option::lenient_parsing_; } // end of isc::dhcp namespace diff --git a/src/lib/dhcp/option.h b/src/lib/dhcp/option.h index 720e4fd434348d8c998e6758ec7b1898708069b8..cd58a3c5324a5a8e45f53cf50a185bf7884e553c 100644 --- a/src/lib/dhcp/option.h +++ b/src/lib/dhcp/option.h @@ -81,7 +81,6 @@ public: /// defines option universe DHCPv4 or DHCPv6 enum Universe { V4, V6 }; - /// @brief a factory function prototype /// /// @param u option universe (DHCPv4 or DHCPv6) @@ -131,7 +130,7 @@ public: return factory(u, type, OptionBuffer()); } - /// @brief ctor, used for options constructed, usually during transmission + /// @brief Constructor, used for options constructed, usually during transmission /// /// @param u option universe (DHCPv4 or DHCPv6) /// @param type option type @@ -424,8 +423,10 @@ public: return (encapsulated_space_); } + /// @brief Destructor. + /// /// just to force that every option has virtual dtor - virtual ~Option(); + virtual ~Option() = default; /// @brief Checks if options are equal. /// diff --git a/src/lib/dhcp/option4_client_fqdn.cc b/src/lib/dhcp/option4_client_fqdn.cc index 00608e0aa6150a15336fcf20d8ca9ac94fd07951..d9e443e44ffbb01e8e2e86f1cdec6054a75a969c 100644 --- a/src/lib/dhcp/option4_client_fqdn.cc +++ b/src/lib/dhcp/option4_client_fqdn.cc @@ -348,7 +348,10 @@ Option4ClientFqdn::Option4ClientFqdn(OptionBufferConstIter first, } Option4ClientFqdn::~Option4ClientFqdn() { - delete(impl_); + try { + delete (impl_); + } catch (...) { + } } Option4ClientFqdn::Option4ClientFqdn(const Option4ClientFqdn& source) diff --git a/src/lib/dhcp/option6_client_fqdn.cc b/src/lib/dhcp/option6_client_fqdn.cc index 65b0c1b6ecc9072124e35abe418e332d1f70d69b..a0ed41424c5e05652fdb8ff49160407d7259b3d0 100644 --- a/src/lib/dhcp/option6_client_fqdn.cc +++ b/src/lib/dhcp/option6_client_fqdn.cc @@ -287,7 +287,10 @@ Option6ClientFqdn::Option6ClientFqdn(OptionBufferConstIter first, } Option6ClientFqdn::~Option6ClientFqdn() { - delete(impl_); + try { + delete (impl_); + } catch (...) { + } } Option6ClientFqdn::Option6ClientFqdn(const Option6ClientFqdn& source) diff --git a/src/lib/dhcp/packet_queue.h b/src/lib/dhcp/packet_queue.h index f75591024669139f2dffe912bfe2d2bcd298c967..bb8ab17e1f920c5d23fc2a8370425ba2649b5fd8 100644 --- a/src/lib/dhcp/packet_queue.h +++ b/src/lib/dhcp/packet_queue.h @@ -55,10 +55,11 @@ public: /// queue. It is the logical name used to register queue /// implementations. explicit PacketQueue(const std::string& queue_type) - : queue_type_(queue_type) {} + : queue_type_(queue_type) { + } /// Virtual destructor - virtual ~PacketQueue(){}; + virtual ~PacketQueue() = default; /// @brief Adds a packet to the queue /// @@ -136,7 +137,7 @@ typedef boost::shared_ptr> PacketQueue4Ptr; /// DHCPv6 packet queue factories. typedef boost::shared_ptr> PacketQueue6Ptr; -}; // namespace isc::dhcp -}; // namespace isc +} // namespace isc::dhcp +} // namespace isc #endif // PACKET_QUEUE_H diff --git a/src/lib/dhcp/packet_queue_mgr4.h b/src/lib/dhcp/packet_queue_mgr4.h index 33fd4e400f1318b7afd46b17328353483a239bc5..60805df32b9db9f30d9492a95b47a2041b5d3295 100644 --- a/src/lib/dhcp/packet_queue_mgr4.h +++ b/src/lib/dhcp/packet_queue_mgr4.h @@ -25,17 +25,18 @@ public: /// @brief Logical name of the pre-registered, default queue implementation static const std::string DEFAULT_QUEUE_TYPE4; + /// @brief Constructor. + /// /// It registers a default factory for DHCPv4 queues. PacketQueueMgr4(); /// @brief virtual Destructor - virtual ~PacketQueueMgr4(){} + virtual ~PacketQueueMgr4() = default; }; /// @brief Defines a shared pointer to PacketQueueMgr4 typedef boost::shared_ptr PacketQueueMgr4Ptr; - } // end of namespace isc::dhcp } // end of namespace isc diff --git a/src/lib/dhcp/packet_queue_mgr6.h b/src/lib/dhcp/packet_queue_mgr6.h index 7711ac9e1ad03098f55f4978c00760337c90c486..66c90eba37b4353a6386baf1576a592aba779aa3 100644 --- a/src/lib/dhcp/packet_queue_mgr6.h +++ b/src/lib/dhcp/packet_queue_mgr6.h @@ -25,13 +25,13 @@ public: /// @brief Logical name of the pre-registered, default queue implementation static const std::string DEFAULT_QUEUE_TYPE6; - /// @brief constructor. + /// @brief Constructor. /// /// It registers a default factory for DHCPv6 queues. PacketQueueMgr6(); /// @brief virtual Destructor - virtual ~PacketQueueMgr6(){} + virtual ~PacketQueueMgr6() = default; }; /// @brief Defines a shared pointer to PacketQueueMgr6 diff --git a/src/lib/dhcp/packet_queue_ring.h b/src/lib/dhcp/packet_queue_ring.h index 8fce6ed85b99e24c49cdf4872b64a461e3fd5d52..823e54391bfeafc59617aaaf17bfae17d0db6f24 100644 --- a/src/lib/dhcp/packet_queue_ring.h +++ b/src/lib/dhcp/packet_queue_ring.h @@ -40,7 +40,7 @@ public: } /// @brief virtual Destructor - virtual ~PacketQueueRing(){}; + virtual ~PacketQueueRing() = default; /// @brief Adds a packet to the queue /// @@ -225,6 +225,7 @@ private: /// class PacketQueueRing4 : public PacketQueueRing { public: + /// @brief Constructor /// /// @param queue_type logical name of the queue implementation @@ -234,7 +235,7 @@ public: }; /// @brief virtual Destructor - virtual ~PacketQueueRing4(){} + virtual ~PacketQueueRing4() = default; }; /// @brief DHCPv6 packet queue buffer implementation @@ -245,6 +246,7 @@ public: /// class PacketQueueRing6 : public PacketQueueRing { public: + /// @brief Constructor /// /// @param queue_type logical name of the queue implementation @@ -254,10 +256,10 @@ public: }; /// @brief virtual Destructor - virtual ~PacketQueueRing6(){} + virtual ~PacketQueueRing6() = default; }; -}; // namespace isc::dhcp -}; // namespace isc +} // namespace isc::dhcp +} // namespace isc #endif // PACKET_QUEUE_RING_H diff --git a/src/lib/dhcp/pkt.h b/src/lib/dhcp/pkt.h index 54e61d73dac106b792dab5c44cb94395f3fa448d..e584aecf58b3f129421772747b3195ff3bb2317b 100644 --- a/src/lib/dhcp/pkt.h +++ b/src/lib/dhcp/pkt.h @@ -64,11 +64,14 @@ public: /// /// Disables options copying on a packets. ~ScopedEnableOptionsCopy() { - if (pkts_.first) { - pkts_.first->setCopyRetrievedOptions(false); - } - if (pkts_.second) { - pkts_.second->setCopyRetrievedOptions(false); + try { + if (pkts_.first) { + pkts_.first->setCopyRetrievedOptions(false); + } + if (pkts_.second) { + pkts_.second->setCopyRetrievedOptions(false); + } + } catch (...) { } } @@ -584,8 +587,7 @@ public: /// There is nothing to clean up here, but since there are virtual methods, /// we define virtual destructor to ensure that derived classes will have /// a virtual one, too. - virtual ~Pkt() { - } + virtual ~Pkt() = default; /// @brief Classes this packet belongs to. /// @@ -796,7 +798,7 @@ private: /// @brief A pointer to either Pkt4 or Pkt6 packet typedef boost::shared_ptr PktPtr; -}; // namespace isc::dhcp -}; // namespace isc +} // namespace isc::dhcp +} // namespace isc #endif diff --git a/src/lib/dhcp/pkt_filter.h b/src/lib/dhcp/pkt_filter.h index e175bef54354218dc8baaed04abf508f6f5ad1f3..8f67070e9f27848ee57ba622ae58dc79b8c4e04a 100644 --- a/src/lib/dhcp/pkt_filter.h +++ b/src/lib/dhcp/pkt_filter.h @@ -44,8 +44,11 @@ class Iface; class PktFilter { public: - /// @brief Virtual Destructor - virtual ~PktFilter() { } + /// @brief Constructor. + PktFilter() = default; + + /// @brief Virtual Destructor. + virtual ~PktFilter() = default; /// @brief Check if packet can be sent to the host without address directly. /// diff --git a/src/lib/dhcp/pkt_filter6.h b/src/lib/dhcp/pkt_filter6.h index c7eb9e3c32bcc3b4586a3ef2d8d8652ae27d258e..7e3ad469a23999406a8a26bf73440ce2f4157b8c 100644 --- a/src/lib/dhcp/pkt_filter6.h +++ b/src/lib/dhcp/pkt_filter6.h @@ -70,8 +70,11 @@ class Iface; class PktFilter6 { public: + /// @brief Constructor. + PktFilter6() = default; + /// @brief Virtual Destructor. - virtual ~PktFilter6() { } + virtual ~PktFilter6() = default; /// @brief Opens a socket. /// diff --git a/src/lib/dhcp/tests/duid_factory_unittest.cc b/src/lib/dhcp/tests/duid_factory_unittest.cc index 1669983d5d215219f1eb4ea466129070fba9e13f..0d6c075414853c03cb111f5aea87d322f9c48e02 100644 --- a/src/lib/dhcp/tests/duid_factory_unittest.cc +++ b/src/lib/dhcp/tests/duid_factory_unittest.cc @@ -163,7 +163,10 @@ DUIDFactoryTest::DUIDFactoryTest() } DUIDFactoryTest::~DUIDFactoryTest() { - removeDefaultFile(); + try { + removeDefaultFile(); + } catch (...) { + } } std::string @@ -526,4 +529,4 @@ TEST_F(DUIDFactoryTest, override) { testEN("000009BF", "12131415"); } -} // End anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/dhcp/tests/iface_mgr_test_config.cc b/src/lib/dhcp/tests/iface_mgr_test_config.cc index c0689c36eb2e47b46db63a985bcccfc7fa74c4e9..054e92d1ea17e445c7e9c23f4f3b117881c9ace6 100644 --- a/src/lib/dhcp/tests/iface_mgr_test_config.cc +++ b/src/lib/dhcp/tests/iface_mgr_test_config.cc @@ -39,15 +39,18 @@ IfaceMgrTestConfig::IfaceMgrTestConfig(const bool default_config) { } IfaceMgrTestConfig::~IfaceMgrTestConfig() { - IfaceMgr::instance().stopDHCPReceiver(); - IfaceMgr::instance().closeSockets(); - IfaceMgr::instance().getPacketQueueMgr4()->destroyPacketQueue(); - IfaceMgr::instance().getPacketQueueMgr6()->destroyPacketQueue(); - IfaceMgr::instance().clearIfaces(); - IfaceMgr::instance().setPacketFilter(PktFilterPtr(new PktFilterInet())); - IfaceMgr::instance().setPacketFilter(PktFilter6Ptr(new PktFilterInet6())); - IfaceMgr::instance().setTestMode(false); - IfaceMgr::instance().detectIfaces(); + try { + IfaceMgr::instance().stopDHCPReceiver(); + IfaceMgr::instance().closeSockets(); + IfaceMgr::instance().getPacketQueueMgr4()->destroyPacketQueue(); + IfaceMgr::instance().getPacketQueueMgr6()->destroyPacketQueue(); + IfaceMgr::instance().clearIfaces(); + IfaceMgr::instance().setPacketFilter(PktFilterPtr(new PktFilterInet())); + IfaceMgr::instance().setPacketFilter(PktFilter6Ptr(new PktFilterInet6())); + IfaceMgr::instance().setTestMode(false); + IfaceMgr::instance().detectIfaces(); + } catch (...) { + } } void diff --git a/src/lib/dhcp/tests/iface_mgr_test_config.h b/src/lib/dhcp/tests/iface_mgr_test_config.h index 26167e8f2d3de13a25d74282aaef6a6877809436..a6795a38ba9eda814f8f473ad4d96a6cefb90d90 100644 --- a/src/lib/dhcp/tests/iface_mgr_test_config.h +++ b/src/lib/dhcp/tests/iface_mgr_test_config.h @@ -267,8 +267,8 @@ private: PktFilter6Ptr packet_filter6_; }; -}; -}; -}; +} +} +} #endif // IFACE_MGR_TEST_CONFIG_H diff --git a/src/lib/dhcp/tests/iface_mgr_unittest.cc b/src/lib/dhcp/tests/iface_mgr_unittest.cc index 739aa0fd7a416e1accd21d2f9a9756e0c52543c4..70d450140d237c435169044336a93c896063e0a6 100644 --- a/src/lib/dhcp/tests/iface_mgr_unittest.cc +++ b/src/lib/dhcp/tests/iface_mgr_unittest.cc @@ -357,13 +357,14 @@ public: /// test failure path. class IfaceMgrTest : public ::testing::Test { public: + /// @brief Constructor. IfaceMgrTest() : errors_count_(0) { } - ~IfaceMgrTest() { - } + /// @brief Destructor. + ~IfaceMgrTest() = default; /// @brief Tests the number of IPv6 sockets on interface /// diff --git a/src/lib/dhcp/tests/libdhcp++_unittest.cc b/src/lib/dhcp/tests/libdhcp++_unittest.cc index b525533496db976c75c19509ab8e123e609ee0c9..7f0cb93f126a13f5db6a4adb9609b75464f599a2 100644 --- a/src/lib/dhcp/tests/libdhcp++_unittest.cc +++ b/src/lib/dhcp/tests/libdhcp++_unittest.cc @@ -55,6 +55,7 @@ const uint16_t OPTION_CM_MAC = 1026; class LibDhcpTest : public ::testing::Test { public: + /// @brief Constructor. /// /// Removes runtime option definitions. @@ -66,7 +67,10 @@ public: /// /// Removes runtime option definitions. virtual ~LibDhcpTest() { - LibDHCP::clearRuntimeOptionDefs(); + try { + LibDHCP::clearRuntimeOptionDefs(); + } catch (...) { + } } /// @brief Generic factory function to create any option. diff --git a/src/lib/dhcp/tests/packet_queue4_unittest.cc b/src/lib/dhcp/tests/packet_queue4_unittest.cc index 58164f27e2ed666e2e1b8937c66b2200c197f2a4..77c5bf4c5260ee4fd6ba0d3db9ad9551bd3231b4 100644 --- a/src/lib/dhcp/tests/packet_queue4_unittest.cc +++ b/src/lib/dhcp/tests/packet_queue4_unittest.cc @@ -28,15 +28,16 @@ namespace { /// mechanics. class TestQueue4 : public PacketQueueRing4 { public: + /// @brief Constructor /// /// @param queue_size maximum number of packets the queue can hold TestQueue4(size_t queue_size) : PacketQueueRing4("kea-ring4", queue_size), drop_enabled_(false), eat_count_(0) { - }; + } /// @brief virtual Destructor - virtual ~TestQueue4(){}; + virtual ~TestQueue4() = default; /// @brief Determines is a packet should be dropped. /// diff --git a/src/lib/dhcp/tests/packet_queue6_unittest.cc b/src/lib/dhcp/tests/packet_queue6_unittest.cc index 52fb0dc3d7433b2d5ec8855200b3a45d58e5eeb7..a1e69d14a1d488c45303b1ba2837fc5a5ce9f61d 100644 --- a/src/lib/dhcp/tests/packet_queue6_unittest.cc +++ b/src/lib/dhcp/tests/packet_queue6_unittest.cc @@ -29,15 +29,16 @@ namespace { /// mechanics. class TestQueue6 : public PacketQueueRing6 { public: + /// @brief Constructor /// /// @param queue_size maximum number of packets the queue can hold TestQueue6(size_t queue_size) : PacketQueueRing6("kea-ring6", queue_size), drop_enabled_(false), eat_count_(0) { - }; + } /// @brief virtual Destructor - virtual ~TestQueue6(){}; + virtual ~TestQueue6() = default; /// @brief Determines is a packet should be dropped. /// diff --git a/src/lib/dhcp/tests/packet_queue_mgr4_unittest.cc b/src/lib/dhcp/tests/packet_queue_mgr4_unittest.cc index 90aa61eebe3e5ed9396c038388ff49e538156285..d35acb1b347435df939d5fac543bb32d888f1f08 100644 --- a/src/lib/dhcp/tests/packet_queue_mgr4_unittest.cc +++ b/src/lib/dhcp/tests/packet_queue_mgr4_unittest.cc @@ -37,6 +37,7 @@ namespace { /// @brief Test fixture for exercising the DHCPv4 Packet Queue Manager (PQM) class PacketQueueMgr4Test : public ::testing::Test { public: + /// @brief Constructor /// /// Note that it instantiates the PQM singleton. @@ -46,7 +47,7 @@ public: } /// @brief Destructor - virtual ~PacketQueueMgr4Test(){} + virtual ~PacketQueueMgr4Test() = default; /// @brief Registers a queue type factory /// diff --git a/src/lib/dhcp/tests/packet_queue_mgr6_unittest.cc b/src/lib/dhcp/tests/packet_queue_mgr6_unittest.cc index b97f7e9fdeb70c63f50b57f2da332ae39a587aef..a07004adbed7776dcf1547146e9d19874c031590 100644 --- a/src/lib/dhcp/tests/packet_queue_mgr6_unittest.cc +++ b/src/lib/dhcp/tests/packet_queue_mgr6_unittest.cc @@ -23,19 +23,19 @@ namespace { /// @brief Test fixture for exercising the DHCPv6 Packet Queue Manager (PQM) class PacketQueueMgr6Test : public ::testing::Test { public: + /// @brief Constructor /// /// Note that it instantiates the PQM singleton. PacketQueueMgr6Test() : default_queue_type_(PacketQueueMgr6::DEFAULT_QUEUE_TYPE6) { packet_queue_mgr6_.reset(new PacketQueueMgr6()); - } /// @brief Destructor /// /// It destroys the PQM singleton. - virtual ~PacketQueueMgr6Test(){} + virtual ~PacketQueueMgr6Test() = default; /// @brief Registers a queue type factory /// diff --git a/src/lib/dhcp/tests/pkt_filter6_test_utils.cc b/src/lib/dhcp/tests/pkt_filter6_test_utils.cc index 83afc1c1e239bb8f0cdb09b7466946298f028390..8dfc1c76a24a802b1e8f3fce4fb87cbf340c2a64 100644 --- a/src/lib/dhcp/tests/pkt_filter6_test_utils.cc +++ b/src/lib/dhcp/tests/pkt_filter6_test_utils.cc @@ -33,16 +33,19 @@ PktFilter6Test::PktFilter6Test(const uint16_t port) } PktFilter6Test::~PktFilter6Test() { - // Cleanup after each test. This guarantees - // that the sockets do not hang after a test. - if (sock_info_.sockfd_ >= 0) { - close(sock_info_.sockfd_); - } - if (sock_info_.fallbackfd_ >=0) { - close(sock_info_.fallbackfd_); - } - if (send_msg_sock_ >= 0) { - close(send_msg_sock_); + try { + // Cleanup after each test. This guarantees + // that the sockets do not hang after a test. + if (sock_info_.sockfd_ >= 0) { + close(sock_info_.sockfd_); + } + if (sock_info_.fallbackfd_ >=0) { + close(sock_info_.fallbackfd_); + } + if (send_msg_sock_ >= 0) { + close(send_msg_sock_); + } + } catch (...) { } } @@ -200,7 +203,6 @@ PktFilter6Stub::send(const Iface&, uint16_t, const Pkt6Ptr&) { return (0); } - } // end of isc::dhcp::test namespace } // end of isc::dhcp namespace } // end of isc namespace diff --git a/src/lib/dhcp/tests/pkt_filter6_test_utils.h b/src/lib/dhcp/tests/pkt_filter6_test_utils.h index 398b3a1ac11048d4c8b19ff96e74334715d7e8d6..513eb0305fde5b8ef4b878bee505ce3e6a912302 100644 --- a/src/lib/dhcp/tests/pkt_filter6_test_utils.h +++ b/src/lib/dhcp/tests/pkt_filter6_test_utils.h @@ -145,8 +145,8 @@ public: }; -}; // end of isc::dhcp::test namespace -}; // end of isc::dhcp namespace -}; // end of isc namespace +} // end of isc::dhcp::test namespace +} // end of isc::dhcp namespace +} // end of isc namespace #endif // PKT_FILTER6_TEST_UTILS_H diff --git a/src/lib/dhcp/tests/pkt_filter_test_utils.cc b/src/lib/dhcp/tests/pkt_filter_test_utils.cc index 7b5a79ec561b483d231785e8ca5df896de58e2e7..d0823716721284955e9120e3bb24ff5b588a4e08 100644 --- a/src/lib/dhcp/tests/pkt_filter_test_utils.cc +++ b/src/lib/dhcp/tests/pkt_filter_test_utils.cc @@ -26,16 +26,19 @@ PktFilterTest::PktFilterTest(const uint16_t port) } PktFilterTest::~PktFilterTest() { - // Cleanup after each test. This guarantees - // that the sockets do not hang after a test. - if (sock_info_.sockfd_ >= 0) { - close(sock_info_.sockfd_); - } - if (sock_info_.fallbackfd_ >=0) { - close(sock_info_.fallbackfd_); - } - if (send_msg_sock_ >= 0) { - close(send_msg_sock_); + try { + // Cleanup after each test. This guarantees + // that the sockets do not hang after a test. + if (sock_info_.sockfd_ >= 0) { + close(sock_info_.sockfd_); + } + if (sock_info_.fallbackfd_ >=0) { + close(sock_info_.fallbackfd_); + } + if (send_msg_sock_ >= 0) { + close(send_msg_sock_); + } + } catch (...) { } } @@ -190,7 +193,6 @@ PktFilterStub::send(const Iface&, uint16_t, const Pkt4Ptr&) { return (0); } - } // end of isc::dhcp::test namespace } // end of isc::dhcp namespace } // end of isc namespace diff --git a/src/lib/dhcp/tests/pkt_filter_test_utils.h b/src/lib/dhcp/tests/pkt_filter_test_utils.h index 253df184d245181cdbc3aca5c396232b2e1f287e..d71fadf756ffa4a98985ae22d14814506fff1edd 100644 --- a/src/lib/dhcp/tests/pkt_filter_test_utils.h +++ b/src/lib/dhcp/tests/pkt_filter_test_utils.h @@ -163,8 +163,8 @@ public: }; -}; // end of isc::dhcp::test namespace -}; // end of isc::dhcp namespace -}; // end of isc namespace +} // end of isc::dhcp::test namespace +} // end of isc::dhcp namespace +} // end of isc namespace #endif // PKT_FILTER_TEST_UTILS_H diff --git a/src/lib/dhcp_ddns/ncr_io.h b/src/lib/dhcp_ddns/ncr_io.h index 664057d961914dc765557c6b5609779496235e75..6883394a2d1503632ab80e1872d3340677bdde34 100644 --- a/src/lib/dhcp_ddns/ncr_io.h +++ b/src/lib/dhcp_ddns/ncr_io.h @@ -183,6 +183,9 @@ public: class RequestReceiveHandler { public: + /// @brief Constructor + RequestReceiveHandler() = default; + /// @brief Function operator implementing a NCR receive callback. /// /// This method allows the application to receive the inbound @@ -198,8 +201,8 @@ public: virtual void operator ()(const Result result, NameChangeRequestPtr& ncr) = 0; - virtual ~RequestReceiveHandler() { - } + /// @brief Destructor + virtual ~RequestReceiveHandler() = default; }; /// @brief Constructor @@ -209,8 +212,7 @@ public: NameChangeListener(RequestReceiveHandler& recv_handler); /// @brief Destructor - virtual ~NameChangeListener() { - }; + virtual ~NameChangeListener() = default; /// @brief Prepares the IO for reception and initiates the first receive. /// @@ -488,6 +490,9 @@ public: class RequestSendHandler { public: + /// @brief Constructor + RequestSendHandler() = default; + /// @brief Function operator implementing a NCR send callback. /// /// This method allows the application to receive the outcome of @@ -502,8 +507,8 @@ public: virtual void operator ()(const Result result, NameChangeRequestPtr& ncr) = 0; - virtual ~RequestSendHandler() { - } + /// @brief Destructor + virtual ~RequestSendHandler() = default; }; /// @brief Constructor @@ -517,8 +522,7 @@ public: size_t send_queue_max = MAX_QUEUE_DEFAULT); /// @brief Destructor - virtual ~NameChangeSender() { - } + virtual ~NameChangeSender() = default; /// @brief Prepares the IO for transmission. /// diff --git a/src/lib/dhcp_ddns/ncr_udp.cc b/src/lib/dhcp_ddns/ncr_udp.cc index 9ba44ca71308aa1f3e11c8b564487e01e67f27ea..bc3a1ce24b75015573abfc854f777f28782fda17 100644 --- a/src/lib/dhcp_ddns/ncr_udp.cc +++ b/src/lib/dhcp_ddns/ncr_udp.cc @@ -80,8 +80,11 @@ NameChangeUDPListener(const isc::asiolink::IOAddress& ip_address, } NameChangeUDPListener::~NameChangeUDPListener() { - // Clean up. - stopListening(); + try { + // Clean up. + stopListening(); + } catch (...) { + } } void @@ -214,8 +217,11 @@ NameChangeUDPSender(const isc::asiolink::IOAddress& ip_address, } NameChangeUDPSender::~NameChangeUDPSender() { - // Clean up. - stopSending(); + try { + // Clean up. + stopSending(); + } catch (...) { + } } void @@ -376,5 +382,5 @@ NameChangeUDPSender::closeWatchSocket() { } } -}; // end of isc::dhcp_ddns namespace -}; // end of isc namespace +} // end of isc::dhcp_ddns namespace +} // end of isc namespace diff --git a/src/lib/dhcp_ddns/ncr_udp.h b/src/lib/dhcp_ddns/ncr_udp.h index 01284aff7e256bab3da96628081fc2f62c368bb1..318a6b986443f2b724ed318530dd8ea093160f24 100644 --- a/src/lib/dhcp_ddns/ncr_udp.h +++ b/src/lib/dhcp_ddns/ncr_udp.h @@ -469,7 +469,6 @@ public: /// @brief Destructor virtual ~NameChangeUDPSender(); - /// @brief Opens a UDP socket using the given IOService. /// /// Creates a NameChangeUDPSocket bound to the sender's IP address @@ -480,7 +479,6 @@ public: /// @throw NcrUDPError if the open fails. virtual void open(isc::asiolink::IOService& io_service); - /// @brief Closes the UDPSocket. /// /// It first invokes the socket's cancel method which should stop any diff --git a/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc b/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc index a6350fa4a08a1b43a18facb4fba30289fcf45741..c0d1b9567b6334cd1670b48c4d1e6e8cfa968f75 100644 --- a/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc +++ b/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc @@ -165,8 +165,8 @@ public: /// @brief Constructor // - // Instantiates the listener member and the test timer. The timer is used - // to ensure a test doesn't go awry and hang forever. + /// Instantiates the listener member and the test timer. The timer is used + /// to ensure a test doesn't go awry and hang forever. NameChangeUDPListenerTest() : io_service_(), result_(NameChangeListener::SUCCESS), test_timer_(io_service_) { @@ -180,9 +180,8 @@ public: TEST_TIMEOUT); } - virtual ~NameChangeUDPListenerTest(){ - } - + /// @brief Destructor + virtual ~NameChangeUDPListenerTest() = default; /// @brief Converts JSON string into an NCR and sends it to the listener. /// @@ -292,14 +291,20 @@ public: /// @brief Text fixture for testing NameChangeUDPListener class NameChangeUDPSenderBasicTest : public virtual ::testing::Test { public: + + /// @brief Constructor NameChangeUDPSenderBasicTest() { // Disable multi-threading MultiThreadingMgr::instance().setMode(false); } + /// @brief Destructor ~NameChangeUDPSenderBasicTest() { - // Disable multi-threading - MultiThreadingMgr::instance().setMode(false); + try { + // Disable multi-threading + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } }; @@ -965,6 +970,7 @@ public: std::vector sent_ncrs_; std::vector received_ncrs_; + /// @brief Constructor NameChangeUDPTest() : io_service_(), recv_result_(NameChangeListener::SUCCESS), send_result_(NameChangeSender::SUCCESS), test_timer_(io_service_) { @@ -987,9 +993,13 @@ public: MultiThreadingMgr::instance().setMode(false); } + /// @brief Destructor ~NameChangeUDPTest() { - // Disable multi-threading - MultiThreadingMgr::instance().setMode(false); + try { + // Disable multi-threading + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } void reset_results() { diff --git a/src/lib/dhcp_ddns/tests/ncr_unittests.cc b/src/lib/dhcp_ddns/tests/ncr_unittests.cc index ddbf0f631d6f0abcc36cb6512b1cd671aa3309ef..a774134fae6dcccc7c7a272a8f27e8c386fbbe52 100644 --- a/src/lib/dhcp_ddns/tests/ncr_unittests.cc +++ b/src/lib/dhcp_ddns/tests/ncr_unittests.cc @@ -337,6 +337,7 @@ TEST(NameChangeRequestTest, dhcidTest) { /// @brief Test fixture class for testing DHCID creation. class DhcidTest : public ::testing::Test { public: + /// @brief Constructor DhcidTest() { const uint8_t fqdn_data[] = { @@ -348,8 +349,7 @@ public: } /// @brief Destructor - virtual ~DhcidTest() { - } + virtual ~DhcidTest() = default; std::vector wire_fqdn_; }; diff --git a/src/lib/dhcpsrv/alloc_engine.h b/src/lib/dhcpsrv/alloc_engine.h index d0b7a06d93cbe0ce789dbe8124ea2365cad96cdd..25ca923a30b643f9bf8c836a1de1e2908cbb9c49 100644 --- a/src/lib/dhcpsrv/alloc_engine.h +++ b/src/lib/dhcpsrv/alloc_engine.h @@ -115,8 +115,7 @@ protected: } /// @brief Virtual destructor - virtual ~Allocator() { - } + virtual ~Allocator() = default; private: virtual isc::asiolink::IOAddress @@ -285,7 +284,7 @@ public: AllocEngine(AllocType engine_type, uint64_t attempts, bool ipv6 = true); /// @brief Destructor. - virtual ~AllocEngine() { } + virtual ~AllocEngine() = default; /// @brief Returns allocator for a given pool type /// diff --git a/src/lib/dhcpsrv/base_host_data_source.h b/src/lib/dhcpsrv/base_host_data_source.h index 522849739747c16df9459161e85efe368b2c7032..e409225a18e83b09f66bc9b6fb9cb9b7519bc5d3 100644 --- a/src/lib/dhcpsrv/base_host_data_source.h +++ b/src/lib/dhcpsrv/base_host_data_source.h @@ -94,8 +94,11 @@ public: ID_DUID = 1 ///< DUID/client-id }; - /// @brief Default destructor implementation. - virtual ~BaseHostDataSource() { } + /// @brief Constructor. + BaseHostDataSource() = default; + + /// @brief Default destructor. + virtual ~BaseHostDataSource() = default; /// @brief Return all hosts connected to any subnet for which reservations /// have been made using a specified identifier. diff --git a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc index 59eb75323f0c2036ca4dac2c72febaf822455752..d58510897ccd1c4c2adb03a5ea8e8f4fecf93aef 100644 --- a/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/generic_host_data_source_benchmark.cc @@ -45,8 +45,11 @@ GenericHostDataSourceBenchmark::GenericHostDataSourceBenchmark() : hdsptr_() { } GenericHostDataSourceBenchmark::~GenericHostDataSourceBenchmark() { - LibDHCP::clearRuntimeOptionDefs(); - hdsptr_.reset(); + try { + LibDHCP::clearRuntimeOptionDefs(); + hdsptr_.reset(); + } catch (...) { + } } void diff --git a/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.cc index 39b98f6a6eed832eae2118d1c75b8d9936b4120d..c89278259025089f0718df9a1524f5260f65173d 100644 --- a/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.cc @@ -37,9 +37,6 @@ namespace bench { GenericLeaseMgrBenchmark::GenericLeaseMgrBenchmark() : lmptr_(NULL) { } -GenericLeaseMgrBenchmark::~GenericLeaseMgrBenchmark() { -} - void GenericLeaseMgrBenchmark::setUp4(::benchmark::State& state, size_t const& lease_count) { state.PauseTiming(); diff --git a/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h b/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h index af90223df9492ef9b8ffc631d7b66daf09a78ea4..1b05656e1c9d558686c22b0bd9809fec0cadf2c8 100644 --- a/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h +++ b/src/lib/dhcpsrv/benchmarks/generic_lease_mgr_benchmark.h @@ -36,7 +36,7 @@ public: GenericLeaseMgrBenchmark(); /// Virtual destructor - virtual ~GenericLeaseMgrBenchmark(); + virtual ~GenericLeaseMgrBenchmark() = default; /// @brief set up code for initializing IPv4 version of a benchmark /// diff --git a/src/lib/dhcpsrv/cache_host_data_source.h b/src/lib/dhcpsrv/cache_host_data_source.h index a0a32cc2337dddc7f19f18f8d4e1fdfd136fae76..2dd32d8554367c15a1a4add3665010b376a4ee58 100644 --- a/src/lib/dhcpsrv/cache_host_data_source.h +++ b/src/lib/dhcpsrv/cache_host_data_source.h @@ -18,8 +18,11 @@ namespace dhcp { class CacheHostDataSource : public virtual BaseHostDataSource { public: - /// @brief Default destructor implementation. - virtual ~CacheHostDataSource() { } + /// @brief Constructor. + CacheHostDataSource() = default; + + /// @brief Default destructor. + virtual ~CacheHostDataSource() = default; /// @brief Insert a host into the cache. /// diff --git a/src/lib/dhcpsrv/cfg_hosts.h b/src/lib/dhcpsrv/cfg_hosts.h index 495cc81265ba22912c5fc014c499b51546acaccb..ca6add6bce5fc45c6269c4be26f1277ea39709b7 100644 --- a/src/lib/dhcpsrv/cfg_hosts.h +++ b/src/lib/dhcpsrv/cfg_hosts.h @@ -38,8 +38,11 @@ class CfgHosts : public BaseHostDataSource, public WritableHostDataSource, public isc::data::CfgToElement { public: + /// @brief Constructor. + CfgHosts() = default; + /// @brief Destructor. - virtual ~CfgHosts() { } + virtual ~CfgHosts() = default; /// @brief Return all hosts connected to any subnet for which reservations /// have been made using a specified identifier. diff --git a/src/lib/dhcpsrv/cfgmgr.cc b/src/lib/dhcpsrv/cfgmgr.cc index c5324046ac4d3b94833a152ad9b45b4bc792c26d..0bd9d56395782a1145e13afd3084759223fc41c2 100644 --- a/src/lib/dhcpsrv/cfgmgr.cc +++ b/src/lib/dhcpsrv/cfgmgr.cc @@ -226,8 +226,5 @@ CfgMgr::CfgMgr() // See AM_CPPFLAGS definition in Makefile.am } -CfgMgr::~CfgMgr() { -} - } // end of isc::dhcp namespace } // end of isc namespace diff --git a/src/lib/dhcpsrv/cfgmgr.h b/src/lib/dhcpsrv/cfgmgr.h index 0302cf54e19892b85fa2b53ce986484bb2b2e4f3..8ebb1357cd36bed95ad2917d637868ae9f8dc9f7 100644 --- a/src/lib/dhcpsrv/cfgmgr.h +++ b/src/lib/dhcpsrv/cfgmgr.h @@ -294,7 +294,7 @@ protected: CfgMgr(); /// @brief virtual destructor - virtual ~CfgMgr(); + virtual ~CfgMgr() = default; private: diff --git a/src/lib/dhcpsrv/client_class_def.cc b/src/lib/dhcpsrv/client_class_def.cc index 48738aa9d4e0da52be0532d4a4384092ebaa42b1..fc1ea0d8f59098b7db541e9ca82917f8d393ecba 100644 --- a/src/lib/dhcpsrv/client_class_def.cc +++ b/src/lib/dhcpsrv/client_class_def.cc @@ -64,9 +64,6 @@ ClientClassDef::ClientClassDef(const ClientClassDef& rhs) filename_ = rhs.filename_; } -ClientClassDef::~ClientClassDef() { -} - std::string ClientClassDef::getName() const { return (name_); @@ -232,9 +229,6 @@ ClientClassDictionary::ClientClassDictionary(const ClientClassDictionary& rhs) } } -ClientClassDictionary::~ClientClassDictionary() { -} - void ClientClassDictionary::addClass(const std::string& name, const ExpressionPtr& match_expr, diff --git a/src/lib/dhcpsrv/client_class_def.h b/src/lib/dhcpsrv/client_class_def.h index 47b4baee60f141912fb72b8313be84d8be4e14c4..788591136580aff38a322702dd48b7d3f303f64d 100644 --- a/src/lib/dhcpsrv/client_class_def.h +++ b/src/lib/dhcpsrv/client_class_def.h @@ -46,6 +46,7 @@ public: /// @brief Embodies a single client class definition class ClientClassDef : public data::UserContext, public isc::data::CfgToElement { public: + /// @brief Constructor /// /// @param name Name to assign to this class @@ -59,7 +60,7 @@ public: ClientClassDef(const ClientClassDef& rhs); /// @brief Destructor - virtual ~ClientClassDef(); + virtual ~ClientClassDef() = default; /// @brief Fetches the class's name std::string getName() const; @@ -287,10 +288,11 @@ public: /// @brief Constructor ClientClassDictionary(); + /// @brief Constructor ClientClassDictionary(const ClientClassDictionary& rhs); /// @brief Destructor - ~ClientClassDictionary(); + ~ClientClassDictionary() = default; /// @brief Adds a new class to the list /// diff --git a/src/lib/dhcpsrv/config_backend_dhcp4.h b/src/lib/dhcpsrv/config_backend_dhcp4.h index f7aaaf8c8ebfcb0a15f926bc1bf5edbe5121f475..435d5f659260ecb2c7b4eaf5b96e9189ef0967a1 100644 --- a/src/lib/dhcpsrv/config_backend_dhcp4.h +++ b/src/lib/dhcpsrv/config_backend_dhcp4.h @@ -85,8 +85,11 @@ namespace dhcp { class ConfigBackendDHCPv4 : public cb::BaseConfigBackend { public: + /// @brief Constructor + ConfigBackendDHCPv4() = default; + /// @brief Virtual destructor. - virtual ~ConfigBackendDHCPv4() { } + virtual ~ConfigBackendDHCPv4() = default; /// @brief Retrieves a single subnet by subnet_prefix. /// diff --git a/src/lib/dhcpsrv/config_backend_dhcp6.h b/src/lib/dhcpsrv/config_backend_dhcp6.h index dd200cb7609bca6e8ad60dfe08c32e50f2382861..4608ddbaa03a74c5bab7db2986c787e9bfbbfebf 100644 --- a/src/lib/dhcpsrv/config_backend_dhcp6.h +++ b/src/lib/dhcpsrv/config_backend_dhcp6.h @@ -86,8 +86,11 @@ namespace dhcp { class ConfigBackendDHCPv6 : public cb::BaseConfigBackend { public: + /// @brief Constructor + ConfigBackendDHCPv6() = default; + /// @brief Virtual destructor. - virtual ~ConfigBackendDHCPv6() { } + virtual ~ConfigBackendDHCPv6() = default; /// @brief Retrieves a single subnet by subnet_prefix. /// diff --git a/src/lib/dhcpsrv/cql_host_data_source.cc b/src/lib/dhcpsrv/cql_host_data_source.cc index 79ebecd7a4b1e5418a80bd8fa753b703457d72c3..ae0d59ae6506816d3e9927f0be663db6fc230599 100644 --- a/src/lib/dhcpsrv/cql_host_data_source.cc +++ b/src/lib/dhcpsrv/cql_host_data_source.cc @@ -125,13 +125,14 @@ namespace dhcp { /// hosts table. class CqlHostExchange : public virtual CqlExchange { public: + /// @brief Constructor /// /// Specifies table columns. CqlHostExchange(); /// @brief Virtual destructor. - virtual ~CqlHostExchange(); + virtual ~CqlHostExchange() = default; /// @brief Binds member variables to data array to receive @ref Host data. /// @@ -1450,9 +1451,6 @@ CqlHostExchange::CqlHostExchange() option_scope_id_(NULL_OPTION_SCOPE_ID) { } -CqlHostExchange::~CqlHostExchange() { -} - void CqlHostExchange::createBindForSelect(AnyArray& data, StatementTag /* not used */) { // Start with a fresh array. @@ -2047,6 +2045,7 @@ CqlHostExchange::retrieveOption() const { /// This class is encapsulate all the Cassandra communication details. class CqlHostDataSourceImpl { public: + /// @brief Constructor. /// /// This constructor opens database connection and initializes @@ -2055,7 +2054,10 @@ public: explicit CqlHostDataSourceImpl(const DatabaseConnection::ParameterMap& parameters); /// @brief Destructor. - virtual ~CqlHostDataSourceImpl(); + /// + /// There is no need to close the database in this destructor: it is + /// closed in the destructor of the dbconn_ member variable. + virtual ~CqlHostDataSourceImpl() = default; /// @brief Implementation of @ref CqlHostDataSource::add() and del() /// @@ -2529,11 +2531,6 @@ CqlHostDataSourceImpl::CqlHostDataSourceImpl(const DatabaseConnection::Parameter dbconn_.prepareStatements(CqlHostExchange::tagged_statements_); } -CqlHostDataSourceImpl::~CqlHostDataSourceImpl() { - // There is no need to close the database in this destructor: it is - // closed in the destructor of the dbconn_ member variable. -} - bool CqlHostDataSourceImpl::insertOrDelete(const HostPtr& host, bool insert) { // If there is no host, there is nothing to do. @@ -3451,10 +3448,6 @@ CqlHostDataSource::CqlHostDataSource(const DatabaseConnection::ParameterMap& par : impl_(new CqlHostDataSourceImpl(parameters)) { } -CqlHostDataSource::~CqlHostDataSource() { - delete impl_; -} - void CqlHostDataSource::add(const HostPtr& host) { LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_HOST_ADD); diff --git a/src/lib/dhcpsrv/cql_host_data_source.h b/src/lib/dhcpsrv/cql_host_data_source.h index fd17b762cb04918def086fa83e91bf820537708e..40d0a3cd45881b3bc7eaca576ab8ee7177387260 100644 --- a/src/lib/dhcpsrv/cql_host_data_source.h +++ b/src/lib/dhcpsrv/cql_host_data_source.h @@ -30,6 +30,9 @@ namespace dhcp { /// @brief Forward declaration to the implementation of @ref CqlHostDataSource. class CqlHostDataSourceImpl; +/// @brief CqlHostDataSourceImpl pointer +typedef boost::shared_ptr CqlHostDataSourceImplPtr; + /// @brief Cassandra host data source /// /// Implements @ref isc::dhcp::BaseHostDataSource interface customized to @@ -55,6 +58,7 @@ class CqlHostDataSourceImpl; /// cases. class CqlHostDataSource : public BaseHostDataSource { public: + /// @brief Constructor /// /// Uses the following keywords in the parameters passed to it to @@ -91,7 +95,7 @@ public: /// @brief Virtual destructor. /// /// Releases prepared CQL statements used by the backend. - virtual ~CqlHostDataSource(); + virtual ~CqlHostDataSource() = default; /// @brief Adds a new host to the collection. /// @@ -461,7 +465,7 @@ public: private: /// @brief Pointer to the implementation of the @ref CqlHostDataSource. - CqlHostDataSourceImpl* impl_; + CqlHostDataSourceImplPtr impl_; }; // class CqlHostDataSource } // namespace dhcp diff --git a/src/lib/dhcpsrv/cql_lease_mgr.cc b/src/lib/dhcpsrv/cql_lease_mgr.cc index 5d4ce28b30099ea09ff8072bd9165578e88eb556..91ea35b2613d6099598dfc524812d6240d821422 100644 --- a/src/lib/dhcpsrv/cql_lease_mgr.cc +++ b/src/lib/dhcpsrv/cql_lease_mgr.cc @@ -1748,7 +1748,7 @@ public: } /// @brief Destructor - virtual ~CqlLeaseStatsQuery() {}; + virtual ~CqlLeaseStatsQuery() = default; /// @brief Creates the lease statistical data result set /// @@ -2119,11 +2119,6 @@ CqlLeaseMgr::CqlLeaseMgr(const DatabaseConnection::ParameterMap ¶meters) dbconn_.prepareStatements(CqlLeaseStatsQuery::tagged_statements_); } -CqlLeaseMgr::~CqlLeaseMgr() { - // There is no need to close the database in this destructor: it is - // closed in the destructor of the dbconn_ member variable. -} - std::string CqlLeaseMgr::getDBVersion() { std::stringstream tmp; diff --git a/src/lib/dhcpsrv/cql_lease_mgr.h b/src/lib/dhcpsrv/cql_lease_mgr.h index c874cee410b7c87a9e9e45dfd88cac1cabc02155..49b0d6501e4ef309757b8cb1f8dc6f70dce7644c 100644 --- a/src/lib/dhcpsrv/cql_lease_mgr.h +++ b/src/lib/dhcpsrv/cql_lease_mgr.h @@ -73,7 +73,10 @@ public: explicit CqlLeaseMgr(const db::DatabaseConnection::ParameterMap& parameters); /// @brief Destructor (closes database) - virtual ~CqlLeaseMgr(); + /// + /// There is no need to close the database in this destructor: it is + /// closed in the destructor of the dbconn_ member variable. + virtual ~CqlLeaseMgr() = default; /// @brief Local version of getDBVersion() class method static std::string getDBVersion(); diff --git a/src/lib/dhcpsrv/d2_client_cfg.cc b/src/lib/dhcpsrv/d2_client_cfg.cc index 78d7ffd75c96290a31bec1c71aa51f54d0bc9c6d..8ffd81ccdd141e7b65edf2b53df124132c9b3065 100644 --- a/src/lib/dhcpsrv/d2_client_cfg.cc +++ b/src/lib/dhcpsrv/d2_client_cfg.cc @@ -112,8 +112,6 @@ D2ClientConfig::D2ClientConfig() validateContents(); } -D2ClientConfig::~D2ClientConfig(){}; - void D2ClientConfig::enableUpdates(bool enable) { enable_updates_ = enable; diff --git a/src/lib/dhcpsrv/d2_client_cfg.h b/src/lib/dhcpsrv/d2_client_cfg.h index 98c77a515e09e936737ca7251c71fbdfd5aa5219..c835bdc01863dee05401eb88249ba666e1eb3d2d 100644 --- a/src/lib/dhcpsrv/d2_client_cfg.h +++ b/src/lib/dhcpsrv/d2_client_cfg.h @@ -108,7 +108,7 @@ public: D2ClientConfig(); /// @brief Destructor - virtual ~D2ClientConfig(); + virtual ~D2ClientConfig() = default; /// @brief Return whether or not DHCP-DDNS updating is enabled. bool getEnableUpdates() const { diff --git a/src/lib/dhcpsrv/d2_client_mgr.cc b/src/lib/dhcpsrv/d2_client_mgr.cc index 667147130965e5f711ee473f3972c635b06386d3..34a10355703c831fcb975156d39e6ef782baaaeb 100644 --- a/src/lib/dhcpsrv/d2_client_mgr.cc +++ b/src/lib/dhcpsrv/d2_client_mgr.cc @@ -25,8 +25,11 @@ D2ClientMgr::D2ClientMgr() : d2_client_config_(new D2ClientConfig()), // Default constructor initializes with a disabled configuration. } -D2ClientMgr::~D2ClientMgr(){ - stopSender(); +D2ClientMgr::~D2ClientMgr() { + try { + stopSender(); + } catch (...) { + } } void @@ -386,6 +389,5 @@ D2ClientMgr::runReadyIO() { name_change_sender_->runReadyIO(); } -}; // namespace dhcp - -}; // namespace isc +} // namespace dhcp +} // namespace isc diff --git a/src/lib/dhcpsrv/d2_client_mgr.h b/src/lib/dhcpsrv/d2_client_mgr.h index bfa611d8adca73e7abc9f4481e0a0124040bfd46..df373b0d0ad19da6068eb0e713a459c18eb901ec 100644 --- a/src/lib/dhcpsrv/d2_client_mgr.h +++ b/src/lib/dhcpsrv/d2_client_mgr.h @@ -79,6 +79,7 @@ std::function(close(sockfd_)); + try { + static_cast(close(sockfd_)); + } catch (...) { + } } // Set up address structures. diff --git a/src/lib/dhcpsrv/host_data_source_factory.cc b/src/lib/dhcpsrv/host_data_source_factory.cc index cb66041e4b0c6b847932c9f811fc4f4137a1638a..897631abcc8efd599ee23f6f952d885916c4c2f8 100644 --- a/src/lib/dhcpsrv/host_data_source_factory.cc +++ b/src/lib/dhcpsrv/host_data_source_factory.cc @@ -193,6 +193,7 @@ namespace { #ifdef HAVE_MYSQL struct MySqlHostDataSourceInit { + // Constructor registers MySqlHostDataSourceInit() { HostDataSourceFactory::registerFactory("mysql", factory, true); @@ -200,7 +201,10 @@ struct MySqlHostDataSourceInit { // Destructor deregisters ~MySqlHostDataSourceInit() { - HostDataSourceFactory::deregisterFactory("mysql", true); + try { + HostDataSourceFactory::deregisterFactory("mysql", true); + } catch (...) { + } } // Factory class method @@ -218,6 +222,7 @@ MySqlHostDataSourceInit mysql_init_; #ifdef HAVE_PGSQL struct PgSqlHostDataSourceInit { + // Constructor registers PgSqlHostDataSourceInit() { HostDataSourceFactory::registerFactory("postgresql", factory, true); @@ -225,7 +230,10 @@ struct PgSqlHostDataSourceInit { // Destructor deregisters ~PgSqlHostDataSourceInit() { - HostDataSourceFactory::deregisterFactory("postgresql", true); + try { + HostDataSourceFactory::deregisterFactory("postgresql", true); + } catch (...) { + } } // Factory class method @@ -243,6 +251,7 @@ PgSqlHostDataSourceInit pgsql_init_; #ifdef HAVE_CQL struct CqlHostDataSourceInit { + // Constructor registers CqlHostDataSourceInit() { HostDataSourceFactory::registerFactory("cql", factory, true); @@ -250,7 +259,10 @@ struct CqlHostDataSourceInit { // Destructor deregisters ~CqlHostDataSourceInit() { - HostDataSourceFactory::deregisterFactory("cql", true); + try { + HostDataSourceFactory::deregisterFactory("cql", true); + } catch (...) { + } } // Factory class method diff --git a/src/lib/dhcpsrv/lease.h b/src/lib/dhcpsrv/lease.h index 448c954b07f01a146dbc876d41be06ae40ac8be3..2e7a3fcdf1ab9da92292c2df610077390c14d0cc 100644 --- a/src/lib/dhcpsrv/lease.h +++ b/src/lib/dhcpsrv/lease.h @@ -111,7 +111,7 @@ struct Lease : public isc::data::UserContext, public isc::data::CfgToElement { const HWAddrPtr& hwaddr); /// @brief Destructor - virtual ~Lease() {} + virtual ~Lease() = default; /// @brief IPv4 ot IPv6 address /// @@ -652,7 +652,7 @@ typedef boost::shared_ptr Lease6CollectionPtr; std::ostream& operator<<(std::ostream& os, const Lease& lease); -}; // end of isc::dhcp namespace -}; // end of isc namespace +} // end of isc::dhcp namespace +} // end of isc namespace #endif // LEASE_H diff --git a/src/lib/dhcpsrv/lease_file_stats.h b/src/lib/dhcpsrv/lease_file_stats.h index 6a46480fac2b63ee8c868a7c16b19f1d01543b85..9498147b2fb8d42b894253a86d545d44092004b9 100644 --- a/src/lib/dhcpsrv/lease_file_stats.h +++ b/src/lib/dhcpsrv/lease_file_stats.h @@ -17,6 +17,7 @@ namespace dhcp { /// but it may be expanded in the future. class LeaseFileStats { public: + /// @brief Constructor /// /// Initializes the stats variables to zeros @@ -25,8 +26,7 @@ public: } /// @brief Destructor - ~LeaseFileStats() { - } + ~LeaseFileStats() = default; /// @brief Gets the number of attempts to read a lease uint32_t getReads() const { diff --git a/src/lib/dhcpsrv/lease_mgr.h b/src/lib/dhcpsrv/lease_mgr.h index 261780d37558f00350e5369b5628498c12936b8d..d593c907241482aaa31c9a041f2201972e6b57cd 100644 --- a/src/lib/dhcpsrv/lease_mgr.h +++ b/src/lib/dhcpsrv/lease_mgr.h @@ -156,8 +156,8 @@ public: /// @throw BadValue if either value given is 0 or if last <= first. LeaseStatsQuery(const SubnetID& first_subnet_id, const SubnetID& last_subnet_id); - /// @brief virtual destructor - virtual ~LeaseStatsQuery() {}; + /// @brief Virtual destructor + virtual ~LeaseStatsQuery() = default; /// @brief Executes the query /// @@ -221,14 +221,12 @@ typedef boost::shared_ptr LeaseStatsRowPtr; /// of those classes for details. class LeaseMgr { public: + /// @brief Constructor - /// - LeaseMgr() - {} + LeaseMgr() = default; /// @brief Destructor - virtual ~LeaseMgr() - {} + virtual ~LeaseMgr() = default; /// @brief Class method to return extended version info /// This class method must be redeclared and redefined in derived classes diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc index da1b31c61b0d04ec923cfed0c5b9acd6fabf7214..44e8a68ca8ea3b0b4d61321e86ddf12bda505b8b 100644 --- a/src/lib/dhcpsrv/memfile_lease_mgr.cc +++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc @@ -145,6 +145,7 @@ LFCSetup::~LFCSetup() { // we don't want an error message output during shutdown. LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_LFC_UNREGISTER_TIMER_FAILED).arg(ex.what()); + } catch (...) { } } @@ -258,18 +259,19 @@ LFCSetup::getExitStatus() const { /// class MemfileLeaseStatsQuery : public LeaseStatsQuery { public: + /// @brief Constructor for all subnets query /// MemfileLeaseStatsQuery() : rows_(0), next_pos_(rows_.end()) { - }; + } /// @brief Constructor for single subnet query /// /// @param subnet_id ID of the desired subnet MemfileLeaseStatsQuery(const SubnetID& subnet_id) : LeaseStatsQuery(subnet_id), rows_(0), next_pos_(rows_.end()) { - }; + } /// @brief Constructor for subnet range query /// @@ -277,10 +279,10 @@ public: /// @param last_subnet_id ID of the last subnet in the desired range MemfileLeaseStatsQuery(const SubnetID& first_subnet_id, const SubnetID& last_subnet_id) : LeaseStatsQuery(first_subnet_id, last_subnet_id), rows_(0), next_pos_(rows_.end()) { - }; + } /// @brief Destructor - virtual ~MemfileLeaseStatsQuery() {}; + virtual ~MemfileLeaseStatsQuery() = default; /// @brief Fetches the next row in the result set /// @@ -326,12 +328,13 @@ protected: /// class MemfileLeaseStatsQuery4 : public MemfileLeaseStatsQuery { public: + /// @brief Constructor for an all subnets query /// /// @param storage4 A pointer to the v4 lease storage to be counted MemfileLeaseStatsQuery4(Lease4Storage& storage4) : MemfileLeaseStatsQuery(), storage4_(storage4) { - }; + } /// @brief Constructor for a single subnet query /// @@ -339,7 +342,7 @@ public: /// @param subnet_id ID of the desired subnet MemfileLeaseStatsQuery4(Lease4Storage& storage4, const SubnetID& subnet_id) : MemfileLeaseStatsQuery(subnet_id), storage4_(storage4) { - }; + } /// @brief Constructor for a subnet range query /// @@ -349,10 +352,10 @@ public: MemfileLeaseStatsQuery4(Lease4Storage& storage4, const SubnetID& first_subnet_id, const SubnetID& last_subnet_id) : MemfileLeaseStatsQuery(first_subnet_id, last_subnet_id), storage4_(storage4) { - }; + } /// @brief Destructor - virtual ~MemfileLeaseStatsQuery4() {}; + virtual ~MemfileLeaseStatsQuery4() = default; /// @brief Creates the IPv4 lease statistical data result set /// @@ -468,12 +471,13 @@ private: /// class MemfileLeaseStatsQuery6 : public MemfileLeaseStatsQuery { public: + /// @brief Constructor /// /// @param storage6 A pointer to the v6 lease storage to be counted MemfileLeaseStatsQuery6(Lease6Storage& storage6) : MemfileLeaseStatsQuery(), storage6_(storage6) { - }; + } /// @brief Constructor for a single subnet query /// @@ -481,7 +485,7 @@ public: /// @param subnet_id ID of the desired subnet MemfileLeaseStatsQuery6(Lease6Storage& storage6, const SubnetID& subnet_id) : MemfileLeaseStatsQuery(subnet_id), storage6_(storage6) { - }; + } /// @brief Constructor for a subnet range query /// @@ -491,10 +495,10 @@ public: MemfileLeaseStatsQuery6(Lease6Storage& storage6, const SubnetID& first_subnet_id, const SubnetID& last_subnet_id) : MemfileLeaseStatsQuery(first_subnet_id, last_subnet_id), storage6_(storage6) { - }; + } /// @brief Destructor - virtual ~MemfileLeaseStatsQuery6() {}; + virtual ~MemfileLeaseStatsQuery6() = default; /// @brief Creates the IPv6 lease statistical data result set /// @@ -668,13 +672,16 @@ Memfile_LeaseMgr::Memfile_LeaseMgr(const DatabaseConnection::ParameterMap& param } Memfile_LeaseMgr::~Memfile_LeaseMgr() { - if (lease_file4_) { - lease_file4_->close(); - lease_file4_.reset(); - } - if (lease_file6_) { - lease_file6_->close(); - lease_file6_.reset(); + try { + if (lease_file4_) { + lease_file4_->close(); + lease_file4_.reset(); + } + if (lease_file6_) { + lease_file6_->close(); + lease_file6_.reset(); + } + } catch (...) { } } diff --git a/src/lib/dhcpsrv/mysql_host_data_source.cc b/src/lib/dhcpsrv/mysql_host_data_source.cc index bbbba6c2cfc789ec5718a41dd606e805f2f7e9a7..b81fcceb7abd20c69b450ac762c9d61d25d153fa 100644 --- a/src/lib/dhcpsrv/mysql_host_data_source.cc +++ b/src/lib/dhcpsrv/mysql_host_data_source.cc @@ -148,11 +148,10 @@ public: columns_[13] = "auth_key"; BOOST_STATIC_ASSERT(13 < HOST_COLUMNS); - }; + } /// @brief Virtual destructor. - virtual ~MySqlHostExchange() { - } + virtual ~MySqlHostExchange() = default; /// @brief Returns index of the first uninitialized column name. /// @@ -179,7 +178,7 @@ public: /// This method is used by derived classes. uint64_t getHostId() const { return (host_id_); - }; + } /// @brief Set error indicators /// @@ -197,7 +196,7 @@ public: error[i] = MLM_FALSE; bind[i].error = reinterpret_cast(&error[i]); } - }; + } /// @brief Return columns in error /// @@ -231,7 +230,7 @@ public: } return (result); - }; + } /// @brief Create MYSQL_BIND objects for Host Pointer /// @@ -399,7 +398,7 @@ public: vec.push_back(bind_[3]); // subnet_id } return (vec); - }; + } /// @brief Create BIND array to receive Host data. /// @@ -531,7 +530,7 @@ public: // Add the data to the vector. Note the end element is one after the // end of the array. return (bind_); - }; + } /// @brief Copy received data into Host object /// @@ -651,7 +650,7 @@ public: } return (h); - }; + } /// @brief Processes one row of data fetched from a database. /// @@ -691,7 +690,7 @@ public: /// "(None)". std::string getErrorColumns() { return (getColumnsInError(error_, columns_)); - }; + } protected: @@ -1316,7 +1315,7 @@ public: setErrorIndicators(bind_, error_); return (bind_); - }; + } private: @@ -1401,7 +1400,7 @@ public: return (reservation_id_); } return (0); - }; + } /// @brief Creates IPv6 reservation from the data contained in the /// currently processed row. @@ -1433,7 +1432,7 @@ public: std::string address = ipv6_address_buffer_; IPv6Resrv r(type, IOAddress(address), prefix_len_); return (r); - }; + } /// @brief Processes one row of data fetched from a database. /// @@ -1529,7 +1528,7 @@ public: setErrorIndicators(bind_, error_); return (bind_); - }; + } private: @@ -2067,7 +2066,7 @@ public: MySqlHostDataSourceImpl(const DatabaseConnection::ParameterMap& parameters); /// @brief Destructor. - ~MySqlHostDataSourceImpl(); + ~MySqlHostDataSourceImpl() = default; /// @brief Attempts to reconnect the server to the host DB backend manager. /// @@ -2766,15 +2765,18 @@ MySqlHostDataSource::MySqlHostContextAlloc::MySqlHostContextAlloc( } MySqlHostDataSource::MySqlHostContextAlloc::~MySqlHostContextAlloc() { - if (MultiThreadingMgr::instance().getMode()) { - // multi-threaded - lock_guard lock(mgr_.pool_->mutex_); - mgr_.pool_->pool_.push_back(ctx_); - if (ctx_->conn_.isUnusable()) { + try { + if (MultiThreadingMgr::instance().getMode()) { + // multi-threaded + lock_guard lock(mgr_.pool_->mutex_); + mgr_.pool_->pool_.push_back(ctx_); + if (ctx_->conn_.isUnusable()) { + mgr_.unusable_ = true; + } + } else if (ctx_->conn_.isUnusable()) { mgr_.unusable_ = true; } - } else if (ctx_->conn_.isUnusable()) { - mgr_.unusable_ = true; + } catch (...) { } } @@ -2849,9 +2851,6 @@ MySqlHostDataSourceImpl::createContext() const { return (ctx); } -MySqlHostDataSourceImpl::~MySqlHostDataSourceImpl() { -} - bool MySqlHostDataSourceImpl::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) { MultiThreadingCriticalSection cs; @@ -3159,9 +3158,6 @@ MySqlHostDataSource::MySqlHostDataSource(const DatabaseConnection::ParameterMap& : impl_(new MySqlHostDataSourceImpl(parameters)) { } -MySqlHostDataSource::~MySqlHostDataSource() { -} - DatabaseConnection::ParameterMap MySqlHostDataSource::getParameters() const { return impl_->parameters_; diff --git a/src/lib/dhcpsrv/mysql_host_data_source.h b/src/lib/dhcpsrv/mysql_host_data_source.h index 879eb7e3b6b2a26e1d7f52aeb56b8de4d0cb2c48..3f677f11cd2f53c63b128964a96fa9075c1b35ac 100644 --- a/src/lib/dhcpsrv/mysql_host_data_source.h +++ b/src/lib/dhcpsrv/mysql_host_data_source.h @@ -68,7 +68,7 @@ public: /// @brief Virtual destructor. /// /// Releases prepared MySQL statements used by the backend. - virtual ~MySqlHostDataSource(); + virtual ~MySqlHostDataSource() = default; /// @brief Return backend parameters /// diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc index f7668540ea989b89d95447cd06201607a87e570f..d6aa1a0e1851d9d850ca2486f628b6b3b8907859 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.cc +++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc @@ -1570,7 +1570,10 @@ public: /// @brief Destructor virtual ~MySqlLeaseStatsQuery() { - (void) mysql_stmt_free_result(statement_); + try { + (void) mysql_stmt_free_result(statement_); + } catch (...) { + } } /// @brief Creates the IPv4 lease statistical data result set @@ -1770,12 +1773,15 @@ MySqlLeaseMgr::MySqlLeaseContextAlloc::MySqlLeaseContextAlloc( } MySqlLeaseMgr::MySqlLeaseContextAlloc::~MySqlLeaseContextAlloc() { - if (MultiThreadingMgr::instance().getMode()) { - // multi-threaded - lock_guard lock(mgr_.pool_->mutex_); - mgr_.pool_->pool_.push_back(ctx_); + try { + if (MultiThreadingMgr::instance().getMode()) { + // multi-threaded + lock_guard lock(mgr_.pool_->mutex_); + mgr_.pool_->pool_.push_back(ctx_); + } + // If running in single-threaded mode, there's nothing to do here. + } catch (...) { } - // If running in single-threaded mode, there's nothing to do here. } // MySqlLeaseMgr Constructor and Destructor @@ -1805,9 +1811,6 @@ MySqlLeaseMgr::MySqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters) pool_->pool_.push_back(createContext()); } -MySqlLeaseMgr::~MySqlLeaseMgr() { -} - bool MySqlLeaseMgr::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) { MultiThreadingCriticalSection cs; diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.h b/src/lib/dhcpsrv/mysql_lease_mgr.h index edad80c4a6da2f47d87a4904a3fdea9c479bebd8..5edb85981ac2949515e553c132e3fb51c785260f 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.h +++ b/src/lib/dhcpsrv/mysql_lease_mgr.h @@ -114,7 +114,7 @@ public: MySqlLeaseMgr(const db::DatabaseConnection::ParameterMap& parameters); /// @brief Destructor (closes database) - virtual ~MySqlLeaseMgr(); + virtual ~MySqlLeaseMgr() = default; /// @brief Create a new context. /// diff --git a/src/lib/dhcpsrv/network.h b/src/lib/dhcpsrv/network.h index 1ca386f7f5c94f73d50b8c018218286cc0bd3714..65d128e2d9cc109cd6c6a0e096cf66e7533dafca 100644 --- a/src/lib/dhcpsrv/network.h +++ b/src/lib/dhcpsrv/network.h @@ -195,7 +195,7 @@ public: /// @brief Virtual destructor. /// /// Does nothing at the moment. - virtual ~Network() { }; + virtual ~Network() = default; /// @brief Sets the optional callback function used to fetch globally /// configured parameters. diff --git a/src/lib/dhcpsrv/network_state.cc b/src/lib/dhcpsrv/network_state.cc index 14e4fe7efb2431561edda911494cb635752e57b3..632422c3b882aae33d2fdb78e5c3fcb1d06618ca 100644 --- a/src/lib/dhcpsrv/network_state.cc +++ b/src/lib/dhcpsrv/network_state.cc @@ -41,8 +41,11 @@ public: /// @brief Destructor. ~NetworkStateImpl() { - destroyTimer(NetworkState::Origin::USER_COMMAND); - destroyTimer(NetworkState::Origin::HA_COMMAND); + try { + destroyTimer(NetworkState::Origin::USER_COMMAND); + destroyTimer(NetworkState::Origin::HA_COMMAND); + } catch (...) { + } } /// @brief Sets appropriate disabled or enabled DHCP service state for the diff --git a/src/lib/dhcpsrv/parsers/dhcp_parsers.h b/src/lib/dhcpsrv/parsers/dhcp_parsers.h index ba040773a37fa3c17b4e88af0b00ba1b74a0253a..10c497dde836175e0222d46a1027fd016d7bf52e 100644 --- a/src/lib/dhcpsrv/parsers/dhcp_parsers.h +++ b/src/lib/dhcpsrv/parsers/dhcp_parsers.h @@ -289,9 +289,11 @@ typedef boost::shared_ptr PoolStoragePtr; class PoolParser : public isc::data::SimpleParser { public: - /// @brief destructor. - virtual ~PoolParser() { - } + /// @brief Constructor. + PoolParser() = default; + + /// @brief Destructor. + virtual ~PoolParser() = default; /// @brief parses the actual structure /// @@ -366,9 +368,11 @@ protected: class PoolsListParser : public isc::data::SimpleParser { public: - /// @brief destructor. - virtual ~PoolsListParser() { - } + /// @brief Constructor. + PoolsListParser() = default; + + /// @brief Destructor. + virtual ~PoolsListParser() = default; /// @brief parses the actual structure /// @@ -476,7 +480,7 @@ public: explicit SubnetConfigParser(uint16_t family, bool check_iface = true); /// @brief virtual destructor (does nothing) - virtual ~SubnetConfigParser() { } + virtual ~SubnetConfigParser() = default; protected: /// @brief parses a subnet description and returns Subnet{4,6} structure diff --git a/src/lib/dhcpsrv/parsers/expiration_config_parser.h b/src/lib/dhcpsrv/parsers/expiration_config_parser.h index 44ba77d6e038d8088af2546c3264494d9a965237..c2bf8265964f1591139124d6a6f2bce4fc8ac0ae 100644 --- a/src/lib/dhcpsrv/parsers/expiration_config_parser.h +++ b/src/lib/dhcpsrv/parsers/expiration_config_parser.h @@ -39,8 +39,11 @@ namespace dhcp { class ExpirationConfigParser : public isc::data::SimpleParser { public: + /// @brief Constructor. + ExpirationConfigParser() = default; + /// @brief Destructor. - virtual ~ExpirationConfigParser() { } + virtual ~ExpirationConfigParser() = default; /// @brief Parses parameters in the JSON map, pertaining to the processing /// of the expired leases. @@ -50,7 +53,6 @@ public: /// @throw DhcpConfigError if unknown parameter specified or the /// parameter contains invalid value.. void parse(isc::data::ConstElementPtr expiration_config); - }; } // end of namespace isc::dhcp diff --git a/src/lib/dhcpsrv/parsers/host_reservation_parser.cc b/src/lib/dhcpsrv/parsers/host_reservation_parser.cc index 38a8915b41dca44d238fcc0c70805211cf261465..b68c3de752f5f4518677097fcafa9384223a61dd 100644 --- a/src/lib/dhcpsrv/parsers/host_reservation_parser.cc +++ b/src/lib/dhcpsrv/parsers/host_reservation_parser.cc @@ -351,10 +351,6 @@ HostReservationParser6::getSupportedParameters(const bool identifiers_only) cons return (getSupportedParams6(identifiers_only)); } -HostReservationIdsParser::HostReservationIdsParser() - : staging_cfg_() { -} - void HostReservationIdsParser::parse(isc::data::ConstElementPtr ids_list) { parseInternal(ids_list); diff --git a/src/lib/dhcpsrv/parsers/host_reservation_parser.h b/src/lib/dhcpsrv/parsers/host_reservation_parser.h index b6542c4af7c7f13cad3291e235476202ff24ce2b..caf717e817b7f63b5c6aaf977a23e4c3619aec1f 100644 --- a/src/lib/dhcpsrv/parsers/host_reservation_parser.h +++ b/src/lib/dhcpsrv/parsers/host_reservation_parser.h @@ -18,8 +18,11 @@ namespace dhcp { class HostReservationParser : public isc::data::SimpleParser { public: + /// @brief Constructor. + HostReservationParser() = default; + /// @brief Destructor. - virtual ~HostReservationParser() { } + virtual ~HostReservationParser() = default; /// @brief Parses a single entry for host reservation. /// @@ -141,10 +144,10 @@ class HostReservationIdsParser : public isc::data::SimpleParser { public: /// @brief Constructor. - HostReservationIdsParser(); + HostReservationIdsParser() = default; /// @brief Destructor. - virtual ~HostReservationIdsParser() { } + virtual ~HostReservationIdsParser() = default; /// @brief Parses a list of host identifiers. /// @@ -224,7 +227,6 @@ protected: virtual bool isSupportedIdentifier(const std::string& id_name) const; }; - } } // end of namespace isc diff --git a/src/lib/dhcpsrv/pgsql_host_data_source.cc b/src/lib/dhcpsrv/pgsql_host_data_source.cc index 1f5164494dd6006a2288589abbdc899524e7bf57..45990ca76a179dee4242e3be19c8f94eb596b9c7 100644 --- a/src/lib/dhcpsrv/pgsql_host_data_source.cc +++ b/src/lib/dhcpsrv/pgsql_host_data_source.cc @@ -141,8 +141,7 @@ public: }; /// @brief Virtual destructor. - virtual ~PgSqlHostExchange() { - } + virtual ~PgSqlHostExchange() = default; /// @brief Reinitializes state information /// @@ -1428,7 +1427,7 @@ public: PgSqlHostDataSourceImpl(const DatabaseConnection::ParameterMap& parameters); /// @brief Destructor. - ~PgSqlHostDataSourceImpl(); + ~PgSqlHostDataSourceImpl() = default; /// @brief Attempts to reconnect the server to the host DB backend manager. /// @@ -2206,15 +2205,18 @@ PgSqlHostDataSource::PgSqlHostContextAlloc::PgSqlHostContextAlloc( } PgSqlHostDataSource::PgSqlHostContextAlloc::~PgSqlHostContextAlloc() { - if (MultiThreadingMgr::instance().getMode()) { - // multi-threaded - lock_guard lock(mgr_.pool_->mutex_); - mgr_.pool_->pool_.push_back(ctx_); - if (ctx_->conn_.isUnusable()) { + try { + if (MultiThreadingMgr::instance().getMode()) { + // multi-threaded + lock_guard lock(mgr_.pool_->mutex_); + mgr_.pool_->pool_.push_back(ctx_); + if (ctx_->conn_.isUnusable()) { + mgr_.unusable_ = true; + } + } else if (ctx_->conn_.isUnusable()) { mgr_.unusable_ = true; } - } else if (ctx_->conn_.isUnusable()) { - mgr_.unusable_ = true; + } catch (...) { } } @@ -2284,9 +2286,6 @@ PgSqlHostDataSourceImpl::createContext() const { return (ctx); } -PgSqlHostDataSourceImpl::~PgSqlHostDataSourceImpl() { -} - bool PgSqlHostDataSourceImpl::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) { MultiThreadingCriticalSection cs; @@ -2567,9 +2566,6 @@ PgSqlHostDataSource::PgSqlHostDataSource(const DatabaseConnection::ParameterMap& : impl_(new PgSqlHostDataSourceImpl(parameters)) { } -PgSqlHostDataSource::~PgSqlHostDataSource() { -} - DatabaseConnection::ParameterMap PgSqlHostDataSource::getParameters() const { return impl_->parameters_; diff --git a/src/lib/dhcpsrv/pgsql_host_data_source.h b/src/lib/dhcpsrv/pgsql_host_data_source.h index 7fb251054a18d21a65ff61704bde0934c8491ce9..0969987608b318aec4c5161c2050b6379d55bef9 100644 --- a/src/lib/dhcpsrv/pgsql_host_data_source.h +++ b/src/lib/dhcpsrv/pgsql_host_data_source.h @@ -67,12 +67,13 @@ public: /// @throw isc::db::DbOpenError Error opening the database /// @throw isc::db::DbOperationError An operation on the open database has /// failed. - PgSqlHostDataSource(const db::DatabaseConnection::ParameterMap& parameters); + PgSqlHostDataSource(const db::DatabaseConnection::ParameterMap& parameters); /// @brief Virtual destructor. + /// /// Frees database resources and closes the database connection through /// the destruction of member impl_. - virtual ~PgSqlHostDataSource(); + virtual ~PgSqlHostDataSource() = default; /// @brief Return backend parameters /// diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc index 8b009f7e27fc9f7a6a14e7d2f07331a1e024dca4..da52357e5ee2042ddbbd245d852afea7e42758e4 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc @@ -375,6 +375,7 @@ namespace dhcp { class PgSqlLeaseExchange : public PgSqlExchange { public: + /// @brief Constructor PgSqlLeaseExchange() : addr_str_(""), hwaddr_length_(0), hwaddr_(hwaddr_length_), valid_lifetime_(0), valid_lifetime_str_(""), expire_(0), @@ -383,7 +384,8 @@ public: user_context_("") { } - virtual ~PgSqlLeaseExchange(){} + /// @brief Destructor + virtual ~PgSqlLeaseExchange() = default; protected: @@ -1042,7 +1044,7 @@ public: } /// @brief Destructor - virtual ~PgSqlLeaseStatsQuery() {}; + virtual ~PgSqlLeaseStatsQuery() = default; /// @brief Creates the lease statistical data result set /// @@ -1204,12 +1206,15 @@ PgSqlLeaseMgr::PgSqlLeaseContextAlloc::PgSqlLeaseContextAlloc( } PgSqlLeaseMgr::PgSqlLeaseContextAlloc::~PgSqlLeaseContextAlloc() { - if (MultiThreadingMgr::instance().getMode()) { - // multi-threaded - lock_guard lock(mgr_.pool_->mutex_); - mgr_.pool_->pool_.push_back(ctx_); + try { + if (MultiThreadingMgr::instance().getMode()) { + // multi-threaded + lock_guard lock(mgr_.pool_->mutex_); + mgr_.pool_->pool_.push_back(ctx_); + } + // If running in single-threaded mode, there's nothing to do here. + } catch (...) { } - // If running in single-threaded mode, there's nothing to do here. } // PgSqlLeaseMgr Constructor and Destructor @@ -1239,9 +1244,6 @@ PgSqlLeaseMgr::PgSqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters) pool_->pool_.push_back(createContext()); } -PgSqlLeaseMgr::~PgSqlLeaseMgr() { -} - bool PgSqlLeaseMgr::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) { MultiThreadingCriticalSection cs; diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.h b/src/lib/dhcpsrv/pgsql_lease_mgr.h index 6ea58ca0c16a36f814cccf6bcd18a6880c56a6ac..769140421faf74593436918ceacdad0cc9d8146b 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.h +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.h @@ -113,7 +113,7 @@ public: PgSqlLeaseMgr(const db::DatabaseConnection::ParameterMap& parameters); /// @brief Destructor (closes database) - virtual ~PgSqlLeaseMgr(); + virtual ~PgSqlLeaseMgr() = default; /// @brief Create a new context. /// diff --git a/src/lib/dhcpsrv/pool.h b/src/lib/dhcpsrv/pool.h index 95f89cfbf5679181ba15d4e483daaabb57f344ea..1a7c9c4e96a1a2b450b2d787b7d7942639025210 100644 --- a/src/lib/dhcpsrv/pool.h +++ b/src/lib/dhcpsrv/pool.h @@ -28,8 +28,8 @@ namespace dhcp { /// Stores information about pool of IPv4 or IPv6 addresses. /// That is a basic component of a configuration. class Pool : public isc::data::UserContext, public isc::data::CfgToElement { - public: + /// @note: /// PoolType enum was removed. Please use Lease::Type instead @@ -75,8 +75,7 @@ public: /// We need Pool to be a polymorphic class, so we could dynamic cast /// from PoolPtr to Pool6Ptr if we need to. A class becomes polymorphic, /// when there is at least one virtual method. - virtual ~Pool() { - } + virtual ~Pool() = default; /// @brief Returns the number of all leases in this pool. /// diff --git a/src/lib/dhcpsrv/resource_handler.cc b/src/lib/dhcpsrv/resource_handler.cc index 9ae2ee55b747875ff3de27c67b0e16d315d6e200..fde8c01d8dbe0a3df65ad88a64c041ae8efd26f1 100644 --- a/src/lib/dhcpsrv/resource_handler.cc +++ b/src/lib/dhcpsrv/resource_handler.cc @@ -20,15 +20,15 @@ mutex ResourceHandler::mutex_; ResourceHandler::ResourceContainer ResourceHandler::resources_; -ResourceHandler::ResourceHandler() : owned_() { -} - ResourceHandler::~ResourceHandler() { - lock_guard lock_(mutex_); - for (auto res : owned_) { - unLockInternal(res->type_, res->addr_); + try { + lock_guard lock_(mutex_); + for (auto res : owned_) { + unLockInternal(res->type_, res->addr_); + } + owned_.clear(); + } catch (...) { } - owned_.clear(); } ResourceHandler::ResourcePtr diff --git a/src/lib/dhcpsrv/resource_handler.h b/src/lib/dhcpsrv/resource_handler.h index 6430d6101d8e90e640ee6383dc2329700e766f3f..14fbae4b5699997a9a137c4d7576c1b2cd30b442 100644 --- a/src/lib/dhcpsrv/resource_handler.h +++ b/src/lib/dhcpsrv/resource_handler.h @@ -28,7 +28,7 @@ class ResourceHandler : public boost::noncopyable { public: /// @brief Constructor. - ResourceHandler(); + ResourceHandler() = default; /// @brief Destructor. /// @@ -172,10 +172,13 @@ private: class ResourceHandler4 : public ResourceHandler { public: + /// @brief Constructor. + ResourceHandler4() = default; + /// @brief Destructor. /// /// Releases owned resources. - virtual ~ResourceHandler4() { } + virtual ~ResourceHandler4() = default; /// @brief Tries to acquires a resource. /// diff --git a/src/lib/dhcpsrv/srv_config.cc b/src/lib/dhcpsrv/srv_config.cc index 10bb2d6c587b6a5b380a41394b12d0a3d56903da..9efd1a638b6f50a75063f2955737c5bf507ceebb 100644 --- a/src/lib/dhcpsrv/srv_config.cc +++ b/src/lib/dhcpsrv/srv_config.cc @@ -64,7 +64,8 @@ SrvConfig::SrvConfig(const uint32_t sequence) decline_timer_(0), echo_v4_client_id_(true), dhcp4o6_port_(0), d2_client_config_(new D2ClientConfig()), configured_globals_(Element::createMap()), - cfg_consist_(new CfgConsistency()) { + cfg_consist_(new CfgConsistency()), + lenient_option_parsing_(false) { } std::string diff --git a/src/lib/dhcpsrv/subnet.h b/src/lib/dhcpsrv/subnet.h index 07458b25cf9120ec98b18425b16eef8fa7ab7713..2fa0449814c2aae48ca07c01346da47b365a1984 100644 --- a/src/lib/dhcpsrv/subnet.h +++ b/src/lib/dhcpsrv/subnet.h @@ -329,7 +329,7 @@ protected: /// /// A virtual destructor is needed because other classes /// derive from this class. - virtual ~Subnet() { }; + virtual ~Subnet() = default; /// @brief keeps the subnet-id value. /// diff --git a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc index 4582df84c08c89ab5b0dd744e610ad3cac84a87b..01718d25ed350e39653d580621a34a2999272421 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc @@ -3957,6 +3957,7 @@ TEST_F(AllocEngine6Test, bothHostReservedPrefix) { /// extended info tests. class AllocEngine6ExtendedInfoTest : public AllocEngine6Test { public: + /// @brief Constructor AllocEngine6ExtendedInfoTest() : engine_(AllocEngine::ALLOC_ITERATIVE, 100, true), duid1_(), duid2_(), @@ -3991,7 +3992,7 @@ public: } /// @brief Destructor - virtual ~AllocEngine6ExtendedInfoTest(){}; + virtual ~AllocEngine6ExtendedInfoTest() = default; /// Configuration elements. These are initialized in the constructor /// and are used throughout the tests. diff --git a/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc index c758e476c02c6bef64a3aa64fc3ba5cf2a3fbf71..aed0e8b6be440b88e1a177b9f962d1f38a0a64ae 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc @@ -161,6 +161,7 @@ public: /// @brief Type definition for the lease algorithm. typedef std::function LeaseAlgorithmFun; + /// @brief type definition for the lease index algorithm. typedef std::function IndexAlgorithmFun; @@ -196,32 +197,35 @@ public: /// Stops D2 client (if running), clears configuration and removes /// an instance of the lease manager. virtual ~ExpirationAllocEngineTest() { - // Stop D2 client if running and remove all queued name change - // requests. - D2ClientMgr& mgr = CfgMgr::instance().getD2ClientMgr(); - if (mgr.amSending()) { - mgr.stopSender(); - mgr.clearQueue(); - } + try { + // Stop D2 client if running and remove all queued name change + // requests. + D2ClientMgr& mgr = CfgMgr::instance().getD2ClientMgr(); + if (mgr.amSending()) { + mgr.stopSender(); + mgr.clearQueue(); + } - // Clear configuration. - CfgMgr::instance().clear(); - D2ClientConfigPtr cfg(new D2ClientConfig()); - CfgMgr::instance().setD2ClientConfig(cfg); + // Clear configuration. + CfgMgr::instance().clear(); + D2ClientConfigPtr cfg(new D2ClientConfig()); + CfgMgr::instance().setD2ClientConfig(cfg); - // Remove all statistics. - StatsMgr::instance().resetAll(); + // Remove all statistics. + StatsMgr::instance().resetAll(); - // Kill lease manager. - LeaseMgrFactory::destroy(); + // Kill lease manager. + LeaseMgrFactory::destroy(); - // Remove callouts executed. - callouts_.clear(); + // Remove callouts executed. + callouts_.clear(); - // Unload libraries. - bool status = HooksManager::unloadLibraries(); - if (!status) { - cerr << "(fixture dtor) unloadLibraries failed" << endl; + // Unload libraries. + bool status = HooksManager::unloadLibraries(); + if (!status) { + cerr << "(fixture dtor) unloadLibraries failed" << endl; + } + } catch (...) { } } @@ -1119,8 +1123,11 @@ public: /// /// Clears up static fields that may be modified by hooks. virtual ~ExpirationAllocEngine6Test() { - callout_lease_.reset(); - callout_name_ = string(""); + try { + callout_lease_.reset(); + callout_name_ = string(""); + } catch (...) { + } } /// @brief Creates collection of leases for a test. @@ -1665,8 +1672,11 @@ public: /// /// Clears up static fields that may be modified by hooks. virtual ~ExpirationAllocEngine4Test() { - callout_lease_.reset(); - callout_name_ = string(""); + try { + callout_lease_.reset(); + callout_name_ = string(""); + } catch (...) { + } } /// @brief Creates collection of leases for a test. @@ -2320,4 +2330,4 @@ TEST_F(ExpirationAllocEngine4Test, reclaimDeclinedHook2) { testReclaimDeclinedHook(true); // true = use skip callout } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/dhcpsrv/tests/alloc_engine_hooks_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine_hooks_unittest.cc index 935296dcbaa761be8f28972ffee1cc4df598dfdb..c819b66eef7e364bdbc59c5284b42333f8445ec4 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_hooks_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine_hooks_unittest.cc @@ -28,17 +28,23 @@ namespace test { /// the data that is accessible via callouts. class HookAllocEngine6Test : public AllocEngine6Test { public: + + /// @brief Constructor HookAllocEngine6Test() { resetCalloutBuffers(); } + /// @brief Destructor virtual ~HookAllocEngine6Test() { - resetCalloutBuffers(); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts( - "lease6_select"); - bool status = HooksManager::unloadLibraries(); - if (!status) { - cerr << "(fixture dtor) unloadLibraries failed" << endl; + try { + resetCalloutBuffers(); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts( + "lease6_select"); + bool status = HooksManager::unloadLibraries(); + if (!status) { + cerr << "(fixture dtor) unloadLibraries failed" << endl; + } + } catch (...) { } } @@ -344,19 +350,25 @@ TEST_F(HookAllocEngine6Test, skip_lease6_select) { /// src/bin/dhcp4/tests/dhcp4_srv_unittest.cc class HookAllocEngine4Test : public AllocEngine4Test { public: + + /// @brief Constructor HookAllocEngine4Test() { // The default context is not used in these tests. ctx_.callout_handle_.reset(); resetCalloutBuffers(); } + /// @brief Destructor virtual ~HookAllocEngine4Test() { - resetCalloutBuffers(); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts( - "lease4_select"); - bool status = HooksManager::unloadLibraries(); - if (!status) { - cerr << "(fixture dtor) unloadLibraries failed" << endl; + try { + resetCalloutBuffers(); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts( + "lease4_select"); + bool status = HooksManager::unloadLibraries(); + if (!status) { + cerr << "(fixture dtor) unloadLibraries failed" << endl; + } + } catch (...) { } } diff --git a/src/lib/dhcpsrv/tests/alloc_engine_utils.h b/src/lib/dhcpsrv/tests/alloc_engine_utils.h index e6e1accd00609bb225472f0de312d95c6c84684a..63b3e2f9e33b9aaaa03479dd0239435f84068858 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_utils.h +++ b/src/lib/dhcpsrv/tests/alloc_engine_utils.h @@ -500,8 +500,12 @@ public: ASSERT_EQ(lease->cltt_, from_mgr->cltt_); } + /// @brief Destructor virtual ~AllocEngine6Test() { - factory_.destroy(); + try { + factory_.destroy(); + } catch (...) { + } } DuidPtr duid_; ///< client-identifier (value used in tests) @@ -608,8 +612,12 @@ public: void initSubnet(const asiolink::IOAddress& pool_start, const asiolink::IOAddress& pool_end); + /// @brief Destructor. virtual ~AllocEngine4Test() { - factory_.destroy(); + try { + factory_.destroy(); + } catch (...) { + } } ClientIdPtr clientid_; ///< Client-identifier (value used in tests) diff --git a/src/lib/dhcpsrv/tests/cb_ctl_dhcp_unittest.cc b/src/lib/dhcpsrv/tests/cb_ctl_dhcp_unittest.cc index 29d039c30abd2ae0df8c4271bf4d2a7bd8869d10..e8ecb5eb8a29ff5a52039a7533f7a1a17d17e52c 100644 --- a/src/lib/dhcpsrv/tests/cb_ctl_dhcp_unittest.cc +++ b/src/lib/dhcpsrv/tests/cb_ctl_dhcp_unittest.cc @@ -41,8 +41,11 @@ namespace { class NonUniqueHostDataSource : public MemHostDataSource { public: + /// @brief Constructor + NonUniqueHostDataSource() = default; + /// @brief Virtual destructor. - virtual ~NonUniqueHostDataSource() {} + virtual ~NonUniqueHostDataSource() = default; /// @brief Configure unique/non-unique IP reservations. /// @@ -72,17 +75,20 @@ public: /// @brief Destructor. virtual ~CBControlDHCPTest() { - // Unregister the factory to be tidy. - ConfigBackendDHCPv4Mgr::instance().unregisterBackendFactory("memfile"); - CfgMgr::instance().clear(); - // Unregister hooks. - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("cb4_updated"); - HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("cb6_updated"); - bool status = HooksManager::unloadLibraries(); - if (!status) { - std::cerr << "(fixture dtor) unloadLibraries failed" << std::endl; + try { + // Unregister the factory to be tidy. + ConfigBackendDHCPv4Mgr::instance().unregisterBackendFactory("memfile"); + CfgMgr::instance().clear(); + // Unregister hooks. + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("cb4_updated"); + HooksManager::preCalloutsLibraryHandle().deregisterAllCallouts("cb6_updated"); + bool status = HooksManager::unloadLibraries(); + if (!status) { + std::cerr << "(fixture dtor) unloadLibraries failed" << std::endl; + } + HostDataSourceFactory::deregisterFactory("test"); + } catch (...) { } - HostDataSourceFactory::deregisterFactory("test"); } /// @brief Creates new CREATE audit entry. diff --git a/src/lib/dhcpsrv/tests/cfg_db_access_unittest.cc b/src/lib/dhcpsrv/tests/cfg_db_access_unittest.cc index 520ccb10604a4d70f79a0a189ebbb90b3d7654d0..c9e0dcf1180ea81e693ae559c755d37828a3d3d6 100644 --- a/src/lib/dhcpsrv/tests/cfg_db_access_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_db_access_unittest.cc @@ -163,9 +163,12 @@ public: /// @brief Destructor. virtual ~CfgMySQLDbAccessTest() { - // If data wipe enabled, delete transient data otherwise destroy the schema - db::test::destroyMySQLSchema(); - LeaseMgrFactory::destroy(); + try { + // If data wipe enabled, delete transient data otherwise destroy the schema + db::test::destroyMySQLSchema(); + LeaseMgrFactory::destroy(); + } catch (...) { + } } }; @@ -259,9 +262,12 @@ public: /// @brief Destructor. virtual ~CfgPgSQLDbAccessTest() { - // If data wipe enabled, delete transient data otherwise destroy the schema - db::test::destroyPgSQLSchema(); - LeaseMgrFactory::destroy(); + try { + // If data wipe enabled, delete transient data otherwise destroy the schema + db::test::destroyPgSQLSchema(); + LeaseMgrFactory::destroy(); + } catch (...) { + } } }; @@ -355,9 +361,12 @@ public: /// @brief Destructor. virtual ~CfgCQLDbAccessTest() { - // If data wipe enabled, delete transient data otherwise destroy the schema - db::test::destroyCqlSchema(); - LeaseMgrFactory::destroy(); + try { + // If data wipe enabled, delete transient data otherwise destroy the schema + db::test::destroyCqlSchema(); + LeaseMgrFactory::destroy(); + } catch (...) { + } } }; diff --git a/src/lib/dhcpsrv/tests/cfg_duid_unittest.cc b/src/lib/dhcpsrv/tests/cfg_duid_unittest.cc index 10da5b9b4fd88f61b442fca4774aea96d2190957..4edf83beb52abaa944d615a0d62203997ee86333 100644 --- a/src/lib/dhcpsrv/tests/cfg_duid_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_duid_unittest.cc @@ -44,7 +44,10 @@ public: /// /// Removes DUID file if present. virtual ~CfgDUIDTest() { - static_cast(remove(absolutePath(DUID_FILE_NAME).c_str())); + try { + static_cast(remove(absolutePath(DUID_FILE_NAME).c_str())); + } catch (...) { + } } /// @brief Returns absolute path to a file used by tests. diff --git a/src/lib/dhcpsrv/tests/cfg_expiration_unittest.cc b/src/lib/dhcpsrv/tests/cfg_expiration_unittest.cc index b7e74d8c528d4972b6dfd58e40cfe181b18b9fb5..c0cf18dc387f08259e1c1e96806141869027e6cd 100644 --- a/src/lib/dhcpsrv/tests/cfg_expiration_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_expiration_unittest.cc @@ -309,7 +309,10 @@ public: /// It stops the @c TimerMgr worker thread and removes any registered /// timers. virtual ~CfgExpirationTimersTest() { - cleanupTimerMgr(); + try { + cleanupTimerMgr(); + } catch (...) { + } } /// @brief Stop @c TimerMgr worker thread and remove the timers. diff --git a/src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc b/src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc index a4cb460892197a26b11186adb42b1a45a88aba6c..e7e43c62e9d2130f40894a1318f7da78d548e2e7 100644 --- a/src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc @@ -94,7 +94,10 @@ CfgHostsTest::CfgHostsTest() { } CfgHostsTest::~CfgHostsTest() { - CfgMgr::instance().setFamily(AF_INET); + try { + CfgMgr::instance().setFamily(AF_INET); + } catch (...) { + } } IOAddress @@ -1200,5 +1203,4 @@ TEST_F(CfgHostsTest, duplicatesSubnet6DUID) { "foo.example.com")))); } - } // end of anonymous namespace diff --git a/src/lib/dhcpsrv/tests/cfg_multi_threading_unittest.cc b/src/lib/dhcpsrv/tests/cfg_multi_threading_unittest.cc index 72eff79f226847304b1164ec0fc5bd78ccb1497b..9fd037e7dc26943b85f6e8ba4f90876bb74b95b7 100644 --- a/src/lib/dhcpsrv/tests/cfg_multi_threading_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_multi_threading_unittest.cc @@ -22,6 +22,12 @@ namespace { class CfgMultiThreadingTest : public ::testing::Test { protected: + /// @brief Constructor + CfgMultiThreadingTest() = default; + + /// @brief Destructor + virtual ~CfgMultiThreadingTest() = default; + /// @brief Setup for each test. /// /// Clears the configuration in the @c MultiThreadingMgr. diff --git a/src/lib/dhcpsrv/tests/cfgmgr_unittest.cc b/src/lib/dhcpsrv/tests/cfgmgr_unittest.cc index 3eeda34c169b71c08d53549ff76add3e13944bb4..26c969e85fb2cffdf27d8feda9b34af369727aa3 100644 --- a/src/lib/dhcpsrv/tests/cfgmgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfgmgr_unittest.cc @@ -261,6 +261,8 @@ TEST(ValueStorageTest, StringTesting) { class CfgMgrTest : public ::testing::Test { public: + + /// @brief Constructor. CfgMgrTest() { // make sure we start with a clean configuration original_datadir_ = CfgMgr::instance().getDataDir(); @@ -277,11 +279,16 @@ public: return OptionPtr(new Option(Option::V6, D6O_INTERFACE_ID, buffer)); } + /// @brief Destructor. ~CfgMgrTest() { - // clean up after the test - clear(); + try { + // clean up after the test + clear(); + } catch (...) { + } } + /// @brief Clean up function. void clear() { CfgMgr::instance().setFamily(AF_INET); CfgMgr::instance().setDataDir(original_datadir_); diff --git a/src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc b/src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc index 214f7dc17c15362a48e524bcd0c21f11fddfa2f0..f8cf618b05984e5d5badbd1aea1f676655e80c38 100644 --- a/src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc +++ b/src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc @@ -99,7 +99,10 @@ public: /// Rolls back all pending transactions. The deletion of hdsptr_ will close /// the database. Then reopen it and delete everything created by the test. virtual ~CqlHostDataSourceTest() { - destroyTest(); + try { + destroyTest(); + } catch (...) { + } } /// @brief Reopen the database @@ -773,6 +776,12 @@ TEST_F(CqlHostDataSourceTest, testMultipleHosts6) { class CQLHostMgrTest : public HostMgrTest { protected: + /// @brief Constructor + CQLHostMgrTest() = default; + + /// @brief Destructor + virtual ~CQLHostMgrTest() = default; + /// @brief Build CQL schema for a test. virtual void SetUp(); diff --git a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc index 3d9b7282aca00098346f0c481be2a7c2017306fd..3983eb63771992ef515131119a1050631ba7c5ba 100644 --- a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc @@ -97,7 +97,10 @@ public: /// Rolls back all pending transactions. The deletion of lmptr_ will close /// the database. Then reopen it and delete everything created by the test. virtual ~CqlLeaseMgrTest() { - destroyTest(); + try { + destroyTest(); + } catch (...) { + } } /// @brief Reopen the database diff --git a/src/lib/dhcpsrv/tests/d2_client_unittest.cc b/src/lib/dhcpsrv/tests/d2_client_unittest.cc index 66c30601193e6122f9c83b68d250bdb056e0e897..07a1131af4023872e3b641ce25d344f955fd093e 100644 --- a/src/lib/dhcpsrv/tests/d2_client_unittest.cc +++ b/src/lib/dhcpsrv/tests/d2_client_unittest.cc @@ -340,6 +340,14 @@ TEST(D2ClientMgr, ipv6Config) { /// @brief Test class for execerising manager functions that are /// influenced by DDNS parameters. class D2ClientMgrParamsTest : public ::testing::Test { +public: + + /// @brief Constructor + D2ClientMgrParamsTest() = default; + + /// @brief Destructor + virtual ~D2ClientMgrParamsTest() = default; + private: /// @brief Prepares the class for a test. virtual void SetUp() { diff --git a/src/lib/dhcpsrv/tests/d2_udp_unittest.cc b/src/lib/dhcpsrv/tests/d2_udp_unittest.cc index 2d83e97a51bb755795cdd8221b469bc12515b36c..74a6693e16d076724d26ec9c48b40b6294fdb855 100644 --- a/src/lib/dhcpsrv/tests/d2_udp_unittest.cc +++ b/src/lib/dhcpsrv/tests/d2_udp_unittest.cc @@ -36,10 +36,13 @@ class D2ClientMgrTest : public D2ClientMgr, public ::testing::Test { public: /// @brief If true simulates a send which completed with a failed status. bool simulate_send_failure_; + /// @brief If true causes an exception throw in the client error handler. bool error_handler_throw_; + /// @brief Tracks the number times the completion handler is called. int callback_count_; + /// @brief Tracks the number of times the client error handler was called. int error_handler_count_; @@ -50,8 +53,7 @@ public: } /// @brief virtual Destructor - virtual ~D2ClientMgrTest(){ - } + virtual ~D2ClientMgrTest() = default; /// @brief Updates the D2ClientMgr's configuration to DDNS enabled. /// diff --git a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc index c08742e2c896074c8e7520f979e0e626e9e5d0c2..0178ee86ae390305c5050e0b3328220a3581dd80 100644 --- a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc +++ b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc @@ -52,6 +52,7 @@ namespace { /// @brief DHCP Parser test fixture class class DhcpParserTest : public ::testing::Test { public: + /// @brief Constructor DhcpParserTest() { resetIfaceCfg(); @@ -59,7 +60,10 @@ public: /// @brief Destructor. virtual ~DhcpParserTest() { - resetIfaceCfg(); + try { + resetIfaceCfg(); + } catch (...) { + } } /// @brief Resets selection of the interfaces from previous tests. @@ -162,15 +166,20 @@ TEST_F(DhcpParserTest, MacSourcesDuplicate) { /// by dhcp servers. class ParseConfigTest : public ::testing::Test { public: + /// @brief Constructor ParseConfigTest() :family_(AF_INET6) { reset_context(); } + /// @brief Destructor ~ParseConfigTest() { - reset_context(); - CfgMgr::instance().clear(); + try { + reset_context(); + CfgMgr::instance().clear(); + } catch (...) { + } } /// @brief Parses a configuration. @@ -3073,4 +3082,4 @@ TEST_F(ParseConfigTest, defaultSharedNetwork6) { // (see CtrlDhcpv4SrvTest.commandSocketBasic in // src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc). -}; // Anonymous namespace +} // Anonymous namespace diff --git a/src/lib/dhcpsrv/tests/dhcp_queue_control_parser_unittest.cc b/src/lib/dhcpsrv/tests/dhcp_queue_control_parser_unittest.cc index 5d19ef3ebd5d27789759ebb3a937faaefd845d2f..80d9babecedead0f6316476436129190c3d53c16 100644 --- a/src/lib/dhcpsrv/tests/dhcp_queue_control_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/dhcp_queue_control_parser_unittest.cc @@ -25,6 +25,12 @@ namespace { class DHCPQueueControlParserTest : public ::testing::Test { protected: + /// @brief Constructor + DHCPQueueControlParserTest() = default; + + /// @brief Destructor + virtual ~DHCPQueueControlParserTest() = default; + /// @brief Setup for each test. /// /// Clears the configuration in the @c CfgMgr. @@ -34,7 +40,6 @@ protected: /// /// Clears the configuration in the @c CfgMgr. virtual void TearDown(); - }; void @@ -205,4 +210,4 @@ TEST_F(DHCPQueueControlParserTest, multiThreading) { EXPECT_EQ("false", queue_control->get("enable-queue")->str()); } -}; // anonymous namespace +} // anonymous namespace diff --git a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc index 64b3220ce18e7ef278f7b992ccad46c4dad41c85..633be5526150a40dfa822b11ad3465e4ea7e3eaf 100644 --- a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc @@ -75,11 +75,6 @@ GenericLeaseMgrTest::GenericLeaseMgrTest() } } -GenericLeaseMgrTest::~GenericLeaseMgrTest() { - // Does nothing. The derived classes are expected to clean up, i.e. - // remove the lmptr_ pointer. -} - Lease4Ptr GenericLeaseMgrTest::initializeLease4(std::string address) { Lease4Ptr lease(new Lease4()); diff --git a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h index 3b83ebd477b6fed01355f2cb80602d9576188566..7f739bcb6133c8e1f775677350f05f98ea1de28d 100644 --- a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h +++ b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h @@ -40,7 +40,10 @@ public: GenericLeaseMgrTest(); /// @brief Virtual destructor. - virtual ~GenericLeaseMgrTest(); + /// + /// Does nothing. The derived classes are expected to clean up, i.e. + /// remove the lmptr_ pointer. + virtual ~GenericLeaseMgrTest() = default; /// @brief Reopen the database /// @@ -523,6 +526,8 @@ public: class LeaseMgrDbLostCallbackTest : public ::testing::Test { public: + + /// @brief Constructor LeaseMgrDbLostCallbackTest() : db_lost_callback_called_(0), db_recovered_callback_called_(0), db_failed_callback_called_(0), @@ -534,12 +539,16 @@ public: TimerMgr::instance()->setIOService(io_service_); } + /// @brief Destructor virtual ~LeaseMgrDbLostCallbackTest() { - db::DatabaseConnection::db_lost_callback_ = 0; - db::DatabaseConnection::db_recovered_callback_ = 0; - db::DatabaseConnection::db_failed_callback_ = 0; - LeaseMgr::setIOService(isc::asiolink::IOServicePtr()); - TimerMgr::instance()->unregisterTimers(); + try { + db::DatabaseConnection::db_lost_callback_ = 0; + db::DatabaseConnection::db_recovered_callback_ = 0; + db::DatabaseConnection::db_failed_callback_ = 0; + LeaseMgr::setIOService(isc::asiolink::IOServicePtr()); + TimerMgr::instance()->unregisterTimers(); + } catch (...) { + } } /// @brief Prepares the class for a test. diff --git a/src/lib/dhcpsrv/tests/host_cache_unittest.cc b/src/lib/dhcpsrv/tests/host_cache_unittest.cc index c6ad92009845c7a3a9e7c12097a24e9ce09fdf7f..2b1f0644416c2eefca952a5baabda723aa27fa65 100644 --- a/src/lib/dhcpsrv/tests/host_cache_unittest.cc +++ b/src/lib/dhcpsrv/tests/host_cache_unittest.cc @@ -31,11 +31,12 @@ namespace { class TestHostCache : public MemHostDataSource, public CacheHostDataSource { public: - /// Constructor - TestHostCache() : adds_(0), inserts_(0) { } + /// @brief Constructor + TestHostCache() : adds_(0), inserts_(0) { + } - /// Destructor - virtual ~TestHostCache() { } + /// @brief Destructor + virtual ~TestHostCache() = default; /// Override add void add(const HostPtr& host) { @@ -100,10 +101,13 @@ typedef boost::shared_ptr TestHostCachePtr; class TestHostDataSource : public MemHostDataSource { public: - /// Destructor - virtual ~TestHostDataSource() { } + /// @brief Constructor + TestHostDataSource() = default; - /// Type + /// @brief Destructor + virtual ~TestHostDataSource() = default; + + /// @brief Type string getType() const { return ("test"); } @@ -139,8 +143,11 @@ public: /// @brief Destructor. virtual ~HostCacheTest() { - HostDataSourceFactory::deregisterFactory("test"); - HostDataSourceFactory::deregisterFactory("cache"); + try { + HostDataSourceFactory::deregisterFactory("test"); + HostDataSourceFactory::deregisterFactory("cache"); + } catch (...) { + } } /// @brief Test host cache. @@ -593,10 +600,10 @@ class TestOneBackend : public BaseHostDataSource { public: /// Constructor - TestOneBackend() : value_() { } + TestOneBackend() = default; /// Destructor - virtual ~TestOneBackend() { } + virtual ~TestOneBackend() = default; ConstHostCollection getAll(const Host::IdentifierType&, const uint8_t*, const size_t) const { @@ -739,8 +746,11 @@ typedef boost::shared_ptr TestOneBackendPtr; class TestNoCache : public MemHostDataSource, public CacheHostDataSource { public: + /// Constructor + TestNoCache() = default; + /// Destructor - virtual ~TestNoCache() { } + virtual ~TestNoCache() = default; /// Override add void add(const HostPtr& host) { @@ -812,8 +822,11 @@ public: /// @brief Destructor. virtual ~NegativeCacheTest() { - HostDataSourceFactory::deregisterFactory("one"); - HostDataSourceFactory::deregisterFactory("nocache"); + try { + HostDataSourceFactory::deregisterFactory("one"); + HostDataSourceFactory::deregisterFactory("nocache"); + } catch (...) { + } } /// @brief Test one backend. @@ -993,4 +1006,4 @@ TEST_F(NegativeCacheTest, get6withNegativeCaching) { testGet6(); } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/dhcpsrv/tests/host_data_source_factory_unittest.cc b/src/lib/dhcpsrv/tests/host_data_source_factory_unittest.cc index 5f5fa03e1192217535f03927aa16f56a870df1e5..dea212823fb431de17db263c9a9e7678f31a29f4 100644 --- a/src/lib/dhcpsrv/tests/host_data_source_factory_unittest.cc +++ b/src/lib/dhcpsrv/tests/host_data_source_factory_unittest.cc @@ -74,6 +74,14 @@ factory0(const DatabaseConnection::ParameterMap&) { // @brief Test fixture class class HostDataSourceFactoryTest : public ::testing::Test { +public: + + /// @brief Constructor + HostDataSourceFactoryTest() = default; + + /// @brief Destructor + virtual ~HostDataSourceFactoryTest() = default; + private: // @brief Prepares the class for a test. virtual void SetUp() { @@ -192,4 +200,4 @@ TEST_F(HostDataSourceFactoryTest, multiple) { EXPECT_FALSE(HostDataSourceFactory::del(sources_, "mem2")); } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc b/src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc index 4a82130fec3795882de06be1bb06803e93eae209..f4f4b94ef8af83efac1327259ef53792690d4ba7 100644 --- a/src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc @@ -44,6 +44,12 @@ namespace { class HostReservationParserTest : public ::testing::Test { protected: + /// @brief Constructor + HostReservationParserTest() = default; + + /// @brief Destructor + virtual ~HostReservationParserTest() = default; + /// @brief Setup for each test. /// /// Clears the configuration in the @c CfgMgr. @@ -1294,7 +1300,10 @@ public: /// /// Clears current configuration. virtual ~HostReservationIdsParserTest() { - CfgMgr::instance().clear(); + try { + CfgMgr::instance().clear(); + } catch (...) { + } } /// @brief Test verifies that invalid configuration causes an error. diff --git a/src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc b/src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc index 31c0c796b156a26410408c205fced0d1583174c1..d881e22be75217b65ce59ba039c370e8242f9737 100644 --- a/src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc @@ -34,6 +34,12 @@ namespace { class HostReservationsListParserTest : public ::testing::Test { protected: + /// @brief Constructor + HostReservationsListParserTest() = default; + + /// @brief Destructor + virtual ~HostReservationsListParserTest() = default; + /// @brief Setup for each test. /// /// Clears the configuration in the @c CfgMgr. It also initializes diff --git a/src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc b/src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc index 8e49695122dc22e5b35ebd76bca5796b301d99a5..0493a6f50e2fd18dc282db012fa486f8c6afe69d 100644 --- a/src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc +++ b/src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc @@ -39,7 +39,7 @@ public: /// @brief Destructor /// /// Removes any configuration that may have been added in CfgMgr. - ~LeaseFileLoaderTest(); + virtual ~LeaseFileLoaderTest(); /// @brief Prepends the absolute path to the file specified /// as an argument. @@ -317,7 +317,10 @@ LeaseFileLoaderTest::LeaseFileLoaderTest() } LeaseFileLoaderTest::~LeaseFileLoaderTest() { - CfgMgr::instance().clear(); + try { + CfgMgr::instance().clear(); + } catch (...) { + } } std::string diff --git a/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc index fc8dc31f9dbcb9ab3bf12e8127eec0d403702870..bd60159bfec8d5ac8d74c579f76636b683dce100 100644 --- a/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc @@ -36,13 +36,10 @@ public: /// dbconfig is a generic way of passing parameters. Parameters /// are passed in the "name=value" format, separated by spaces. /// Values may be enclosed in double quotes, if needed. - ConcreteLeaseMgr(const DatabaseConnection::ParameterMap&) - : LeaseMgr() - {} + ConcreteLeaseMgr() = default; /// @brief Destructor - virtual ~ConcreteLeaseMgr() - {} + virtual ~ConcreteLeaseMgr() = default; /// @brief Adds an IPv4 lease. /// @@ -427,9 +424,7 @@ namespace { // This test checks if getLease6() method is working properly for 0 (NULL), // 1 (return the lease) and more than 1 leases (throw). TEST_F(LeaseMgrTest, getLease6) { - - DatabaseConnection::ParameterMap pmap; - boost::scoped_ptr mgr(new ConcreteLeaseMgr(pmap)); + boost::scoped_ptr mgr(new ConcreteLeaseMgr()); vector leases = createLeases6(); diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc index 5137b5b0ab837218230f0500b082ec2201f90cad..0b04c2bcb5b8f922c17cc57e647726f559dc0d4e 100644 --- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc @@ -137,15 +137,18 @@ public: /// /// destroys lease manager backend. virtual ~MemfileLeaseMgrTest() { - // Stop TimerMgr worker thread if it is running. - // Make sure there are no timers registered. - timer_mgr_->unregisterTimers(); - LeaseMgrFactory::destroy(); - // Remove lease files and products of Lease File Cleanup. - removeFiles(getLeaseFilePath("leasefile4_0.csv")); - removeFiles(getLeaseFilePath("leasefile6_0.csv")); - // Disable multi-threading. - MultiThreadingMgr::instance().setMode(false); + try { + // Stop TimerMgr worker thread if it is running. + // Make sure there are no timers registered. + timer_mgr_->unregisterTimers(); + LeaseMgrFactory::destroy(); + // Remove lease files and products of Lease File Cleanup. + removeFiles(getLeaseFilePath("leasefile4_0.csv")); + removeFiles(getLeaseFilePath("leasefile6_0.csv")); + // Disable multi-threading. + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } /// @brief Remove files being products of Lease File Cleanup. diff --git a/src/lib/dhcpsrv/tests/multi_threading_config_parser_unittest.cc b/src/lib/dhcpsrv/tests/multi_threading_config_parser_unittest.cc index 1f3b994bbd59056a42cb2dca56668ef3811f5172..d99e375b9febc4d65dd453ddea35788e7be8100b 100644 --- a/src/lib/dhcpsrv/tests/multi_threading_config_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/multi_threading_config_parser_unittest.cc @@ -25,6 +25,12 @@ namespace { class MultiThreadingConfigParserTest : public ::testing::Test { protected: + /// @brief Constructor + MultiThreadingConfigParserTest() = default; + + /// @brief Destructor + virtual ~MultiThreadingConfigParserTest() = default; + /// @brief Setup for each test. virtual void SetUp(); diff --git a/src/lib/dhcpsrv/tests/mysql_host_data_source_unittest.cc b/src/lib/dhcpsrv/tests/mysql_host_data_source_unittest.cc index 2677ef0136882327d3e9529b7410f9bad8714ebf..e18a2f737b204b0526a5c5b4a67d8d76e9bc93f9 100644 --- a/src/lib/dhcpsrv/tests/mysql_host_data_source_unittest.cc +++ b/src/lib/dhcpsrv/tests/mysql_host_data_source_unittest.cc @@ -92,7 +92,10 @@ public: /// Rolls back all pending transactions. The deletion of hdsptr_ will close /// the database. Then reopen it and delete everything created by the test. virtual ~MySqlHostDataSourceTest() { - destroyTest(); + try { + destroyTest(); + } catch (...) { + } } /// @brief Reopen the database diff --git a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc index 31d52cf7b51533523fa78916e02a63da642737ce..2a6c6b620aef8098b7649027261d6be3c5fdb3ba 100644 --- a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc @@ -89,7 +89,10 @@ public: /// Rolls back all pending transactions. The deletion of lmptr_ will close /// the database. Then reopen it and delete everything created by the test. virtual ~MySqlLeaseMgrTest() { - destroyTest(); + try { + destroyTest(); + } catch (...) { + } } /// @brief Reopen the database diff --git a/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc b/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc index 905df55479b89561a6b10e4750ccc7b30ae4df6b..ca6881c015e3e771525cd59018999ecd93367b49 100644 --- a/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc +++ b/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc @@ -49,6 +49,9 @@ public: : d2_mgr_(CfgMgr::instance().getD2ClientMgr()), lease_() { } + /// @brief Destructor + virtual ~NCRGeneratorTest() = default; + /// @brief Initializes the lease pointer used by the tests and starts D2. /// /// This method initializes the pointer to the lease which will be used diff --git a/src/lib/dhcpsrv/tests/network_state_unittest.cc b/src/lib/dhcpsrv/tests/network_state_unittest.cc index 7edf4581ae9e1630d204032f9fc0ddf31cd8c261..3c75b1fba2be631be6666f918c5de75311d5fd8a 100644 --- a/src/lib/dhcpsrv/tests/network_state_unittest.cc +++ b/src/lib/dhcpsrv/tests/network_state_unittest.cc @@ -34,13 +34,16 @@ public: /// @brief Destructor. virtual ~NetworkStateTest() { - // Cancel timers. - TimerMgr::instance()->unregisterTimers(); - // Make sure IO service will stop when no timers are scheduled. - io_service_->stopWork(); - // Run outstanding tasks. - io_service_->run(); - MultiThreadingMgr::instance().setMode(false); + try { + // Cancel timers. + TimerMgr::instance()->unregisterTimers(); + // Make sure IO service will stop when no timers are scheduled. + io_service_->stopWork(); + // Run outstanding tasks. + io_service_->run(); + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } /// @brief This test verifies the default is enable state. diff --git a/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc b/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc index 607151ab2eb2b6a1d6b373629cf176a42f04c368..408aba3ae0a0e9495d504f9aadad042d855ed834 100644 --- a/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc +++ b/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc @@ -92,7 +92,10 @@ public: /// Rolls back all pending transactions. The deletion of hdsptr_ will close /// the database. Then reopen it and delete everything created by the test. virtual ~PgSqlHostDataSourceTest() { - destroyTest(); + try { + destroyTest(); + } catch (...) { + } } /// @brief Reopen the database @@ -1429,6 +1432,12 @@ TEST_F(PgSqlHostDataSourceTest, testMultipleHosts6MultiThreading) { class PgSQLHostMgrTest : public HostMgrTest { protected: + /// @brief Constructor + PgSQLHostMgrTest() = default; + + /// @brief Destructor + virtual ~PgSQLHostMgrTest() = default; + /// @brief Build PostgreSQL schema for a test. virtual void SetUp(); diff --git a/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc index fbe32275e69bfb543d44771d5a4948a0d5212cbb..38afe408f5162da39e641ebed470dc56dbb350b9 100644 --- a/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc @@ -89,7 +89,10 @@ public: /// Rolls back all pending transactions. The deletion of lmptr_ will close /// the database. Then reopen it and delete everything created by the test. virtual ~PgSqlLeaseMgrTest() { - destroyTest(); + try { + destroyTest(); + } catch (...) { + } } /// @brief Reopen the database diff --git a/src/lib/dhcpsrv/tests/sanity_checks_unittest.cc b/src/lib/dhcpsrv/tests/sanity_checks_unittest.cc index cb305d6b951f1cbfa2cacfa579cdb17668b35fe2..14f0f105f5b7419bad135d06c09ff909fae99222 100644 --- a/src/lib/dhcpsrv/tests/sanity_checks_unittest.cc +++ b/src/lib/dhcpsrv/tests/sanity_checks_unittest.cc @@ -27,6 +27,7 @@ using namespace isc::dhcp::test; class SanityChecksTest : public ::testing::Test { public: + /// @brief Constructor SanityChecksTest() { LeaseMgrFactory::destroy(); } @@ -42,9 +43,13 @@ public: CfgMgr::instance().getCurrentCfg()->getConsistency()->setLeaseSanityCheck(sanity); } + /// @brief Destructor ~SanityChecksTest() { - CfgMgr::instance().clear(); - LeaseMgrFactory::destroy(); + try { + CfgMgr::instance().clear(); + LeaseMgrFactory::destroy(); + } catch (...) { + } } /// @brief Generates a simple IPv4 lease. diff --git a/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc b/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc index b91ea2b34cea76cbe53b2cfb19c2a534f44ae76b..e6af5b0e3ecd062013df9f5650466bcf9f230e8d 100644 --- a/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc @@ -41,8 +41,11 @@ public: IOAddressList addresses_; }; + /// @brief constructor + SharedNetworkParserTest() = default; + /// @brief virtual destructor - virtual ~SharedNetworkParserTest(){}; + virtual ~SharedNetworkParserTest() = default; /// @brief Fetch valid shared network configuration JSON text virtual std::string getWorkingConfig() const = 0; diff --git a/src/lib/dhcpsrv/tests/srv_config_unittest.cc b/src/lib/dhcpsrv/tests/srv_config_unittest.cc index 915bb50540f5e7ef0505cdf929875f425b854d7d..f9993e781cc7f32b97fcac2882e8a00a4eb00a34 100644 --- a/src/lib/dhcpsrv/tests/srv_config_unittest.cc +++ b/src/lib/dhcpsrv/tests/srv_config_unittest.cc @@ -40,6 +40,7 @@ const int TEST_SUBNETS_NUM = 3; /// @brief Test fixture class for testing configuration data storage. class SrvConfigTest : public ::testing::Test { public: + /// @brief Constructor. /// /// Creates IPv4 and IPv6 subnets for unit test. The number of subnets @@ -85,10 +86,8 @@ public: "", false, false, CfgOptionPtr()); } - /// @brief Destructor. - virtual ~SrvConfigTest() { - } + virtual ~SrvConfigTest() = default; /// @brief Convenience function which adds IPv4 subnet to the configuration. /// diff --git a/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc b/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc index 00583740c796c00fcbbfb33a96a04cded3248305..d38cb05f37dca398071f8803161fbf0a17b7dfe6 100644 --- a/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc @@ -27,6 +27,14 @@ namespace { /// @brief Test fixture class for @c TimerMgr. class TimerMgrTest : public ::testing::Test { +public: + + /// @brief Constructor + TimerMgrTest() = default; + + /// @brief Destructor + virtual ~TimerMgrTest() = default; + private: /// @brief Prepares the class for a test. virtual void SetUp(); diff --git a/src/lib/dhcpsrv/testutils/generic_backend_unittest.cc b/src/lib/dhcpsrv/testutils/generic_backend_unittest.cc index da6dc67d0f75c8e2d5e1cee8df9482d89c5d095a..ec8dd24ae471b94ec82025586e760017ef32caef 100644 --- a/src/lib/dhcpsrv/testutils/generic_backend_unittest.cc +++ b/src/lib/dhcpsrv/testutils/generic_backend_unittest.cc @@ -23,7 +23,10 @@ GenericBackendTest::GenericBackendTest() { } GenericBackendTest::~GenericBackendTest() { - LibDHCP::clearRuntimeOptionDefs(); + try { + LibDHCP::clearRuntimeOptionDefs(); + } catch (...) { + } } OptionDescriptor @@ -123,7 +126,6 @@ GenericBackendTest::checkConfiguredGlobal(const SrvConfigPtr& srv_cfg, checkConfiguredGlobal(srv_cfg, exp_global->getName(), exp_global->getElementValue()); } - } // end of namespace isc::dhcp::test } // end of namespace isc::dhcp } // end of namespace isc diff --git a/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc b/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc index 26732a9f6aed6d86d1c95757e77d7da4838e6ca4..0162e87fc93db293aa08ea27e657bbf54252f21b 100644 --- a/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc +++ b/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc @@ -44,14 +44,6 @@ namespace isc { namespace dhcp { namespace test { -GenericHostDataSourceTest::GenericHostDataSourceTest() - : GenericBackendTest(), hdsptr_() { -} - -GenericHostDataSourceTest::~GenericHostDataSourceTest() { - hdsptr_.reset(); -} - bool GenericHostDataSourceTest::compareHostsForSort4(const ConstHostPtr& host1, const ConstHostPtr& host2) { diff --git a/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.h b/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.h index 8444f9370476c089c27c1980e494c01316059ed4..749ca428b671d706b519b83d10e3a270461b543b 100644 --- a/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.h +++ b/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.h @@ -50,10 +50,10 @@ public: }; /// @brief Default constructor. - GenericHostDataSourceTest(); + GenericHostDataSourceTest() = default; /// @brief Virtual destructor. - virtual ~GenericHostDataSourceTest(); + virtual ~GenericHostDataSourceTest() = default; /// @brief Used to sort a host collection by IPv4 subnet id. /// @param host1 first host to be compared @@ -537,6 +537,8 @@ public: class HostMgrDbLostCallbackTest : public ::testing::Test { public: + + /// @brief Constructor HostMgrDbLostCallbackTest() : db_lost_callback_called_(0), db_recovered_callback_called_(0), db_failed_callback_called_(0), @@ -549,13 +551,17 @@ public: isc::dhcp::CfgMgr::instance().clear(); } + /// @brief Destructor virtual ~HostMgrDbLostCallbackTest() { - isc::db::DatabaseConnection::db_lost_callback_ = 0; - isc::db::DatabaseConnection::db_recovered_callback_ = 0; - isc::db::DatabaseConnection::db_failed_callback_ = 0; - isc::dhcp::HostMgr::setIOService(isc::asiolink::IOServicePtr()); - isc::dhcp::TimerMgr::instance()->unregisterTimers(); - isc::dhcp::CfgMgr::instance().clear(); + try { + isc::db::DatabaseConnection::db_lost_callback_ = 0; + isc::db::DatabaseConnection::db_recovered_callback_ = 0; + isc::db::DatabaseConnection::db_failed_callback_ = 0; + isc::dhcp::HostMgr::setIOService(isc::asiolink::IOServicePtr()); + isc::dhcp::TimerMgr::instance()->unregisterTimers(); + isc::dhcp::CfgMgr::instance().clear(); + } catch (...) { + } } /// @brief Prepares the class for a test. @@ -684,6 +690,12 @@ public: class HostMgrTest : public ::testing::Test { protected: + /// @brief Constructor + HostMgrTest() = default; + + /// @brief Destructor + virtual ~HostMgrTest() = default; + /// @brief Prepares the class for a test. /// /// This method crates a handful of unique HW address and DUID objects diff --git a/src/lib/dhcpsrv/testutils/lease_file_io.cc b/src/lib/dhcpsrv/testutils/lease_file_io.cc index d641a695f024e6032490aed138c2f35eac1ba81f..97bbe029899a0775963f8ae6bacbf4f9c2ad08e8 100644 --- a/src/lib/dhcpsrv/testutils/lease_file_io.cc +++ b/src/lib/dhcpsrv/testutils/lease_file_io.cc @@ -21,8 +21,11 @@ LeaseFileIO::LeaseFileIO(const std::string& filename, const bool recreate) } LeaseFileIO::~LeaseFileIO() { - if (recreate_) { - removeFile(); + try { + if (recreate_) { + removeFile(); + } + } catch (...) { } } diff --git a/src/lib/dhcpsrv/testutils/lease_file_io.h b/src/lib/dhcpsrv/testutils/lease_file_io.h index 25efd96d1426f4a163e8e6b536b19e6e6c2eab24..67d3bea4f7440a982ba680b45973789af4e30f6a 100644 --- a/src/lib/dhcpsrv/testutils/lease_file_io.h +++ b/src/lib/dhcpsrv/testutils/lease_file_io.h @@ -21,6 +21,7 @@ namespace test { /// of the existing file and remove existing file (cleanup after unit test). class LeaseFileIO { public: + /// @brief Constructor /// /// @param filename Absolute path to the file. diff --git a/src/lib/dhcpsrv/testutils/memory_host_data_source.h b/src/lib/dhcpsrv/testutils/memory_host_data_source.h index b2d06f48f2ff7db1ef0f97121641637d6862738c..69e68233e66d0c76390da17506432d1bf87def65 100644 --- a/src/lib/dhcpsrv/testutils/memory_host_data_source.h +++ b/src/lib/dhcpsrv/testutils/memory_host_data_source.h @@ -24,8 +24,12 @@ namespace test { class MemHostDataSource : public virtual BaseHostDataSource { public: + /// @brief Constructor. + MemHostDataSource() : next_host_id_(0) { + } + /// @brief Destructor. - virtual ~MemHostDataSource() { } + virtual ~MemHostDataSource() = default; /// BaseHostDataSource methods. diff --git a/src/lib/dhcpsrv/testutils/test_config_backend.h b/src/lib/dhcpsrv/testutils/test_config_backend.h index d78f97f8fd57b9c288efa17d291ccf8eb46d3f31..5eb0dfe07913a7d4c3cdeb9e36561978d2fb1036 100644 --- a/src/lib/dhcpsrv/testutils/test_config_backend.h +++ b/src/lib/dhcpsrv/testutils/test_config_backend.h @@ -25,6 +25,7 @@ typedef boost::shared_ptr StampedElementPtr; template class TestConfigBackend : public ConfigBackendType { public: + /// @brief Constructor /// /// @param params database connection parameters @@ -51,7 +52,7 @@ public: } /// @brief virtual Destructor. - virtual ~TestConfigBackend(){}; + virtual ~TestConfigBackend() = default; /// @brief Returns backend type. /// diff --git a/src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.h b/src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.h index 1ce5158c6112d3d8999853638ffee3161de3f900..3fcf79dac822ac719db7a08fe8d6dbf42bdef44e 100644 --- a/src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.h +++ b/src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.h @@ -38,6 +38,7 @@ namespace test { /// This backend stores server configuration information in memory. class TestConfigBackendDHCPv4 : public TestConfigBackend { public: + /// @brief Constructor /// /// @param params Database connection parameters. @@ -46,7 +47,7 @@ public: } /// @brief virtual Destructor. - virtual ~TestConfigBackendDHCPv4(){}; + virtual ~TestConfigBackendDHCPv4() = default; /// @brief Registers the backend type with the given backend manager /// diff --git a/src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.h b/src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.h index c13b50522febdd84094fd4c4c1d49bc7186f33ed..3579da004f01cdb5ab3fa2f58ca5dd716990b754 100644 --- a/src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.h +++ b/src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.h @@ -38,6 +38,7 @@ namespace test { /// This backend stores server configuration information in memory. class TestConfigBackendDHCPv6 : public TestConfigBackend { public: + /// @brief Constructor /// /// @param params Database connection parameters. @@ -46,7 +47,7 @@ public: } /// @brief virtual Destructor. - virtual ~TestConfigBackendDHCPv6(){}; + virtual ~TestConfigBackendDHCPv6() = default; /// @brief Registers the backend type with the given backend manager /// diff --git a/src/lib/dhcpsrv/testutils/test_utils.cc b/src/lib/dhcpsrv/testutils/test_utils.cc index 4fe7d86d9316ef1d43ae8af1b03290dc5ec9f323..943a4e7d5928c62cc0bf8303a1456cb36757fb95 100644 --- a/src/lib/dhcpsrv/testutils/test_utils.cc +++ b/src/lib/dhcpsrv/testutils/test_utils.cc @@ -142,9 +142,12 @@ FillFdHoles::FillFdHoles(int limit) : fds_() { } FillFdHoles::~FillFdHoles() { - while (!fds_.empty()) { - static_cast(close(fds_.back())); - fds_.pop_back(); + try { + while (!fds_.empty()) { + static_cast(close(fds_.back())); + fds_.pop_back(); + } + } catch (...) { } } diff --git a/src/lib/dhcpsrv/testutils/test_utils.h b/src/lib/dhcpsrv/testutils/test_utils.h index 02af9ba467a7b9438741e91d04adfb716ae733a1..6613d99a5848e57657a1ad10bdcb805f419ad82e 100644 --- a/src/lib/dhcpsrv/testutils/test_utils.h +++ b/src/lib/dhcpsrv/testutils/test_utils.h @@ -59,6 +59,7 @@ int findLastSocketFd(); /// of scope closes all file descriptors which were opened by the constructor. class FillFdHoles { public: + /// @brief Constructor /// /// Holes between 0 and the specified limit will be filled by opening diff --git a/src/lib/dhcpsrv/timer_mgr.cc b/src/lib/dhcpsrv/timer_mgr.cc index f71b768ba0c44cce9880be905531c4f1cc3177e0..97db82a66f5b6f1643c7d043cddfeedefc5e39f1 100644 --- a/src/lib/dhcpsrv/timer_mgr.cc +++ b/src/lib/dhcpsrv/timer_mgr.cc @@ -448,7 +448,10 @@ TimerMgr::TimerMgr() } TimerMgr::~TimerMgr() { - impl_->unregisterTimers(); + try { + impl_->unregisterTimers(); + } catch (...) { + } } void diff --git a/src/lib/dhcpsrv/writable_host_data_source.h b/src/lib/dhcpsrv/writable_host_data_source.h index 6115d228e92f2993184b717a7c634f94d8ae4849..7632af7e0e519e8ddecbc5a9c6c100b343c63532 100644 --- a/src/lib/dhcpsrv/writable_host_data_source.h +++ b/src/lib/dhcpsrv/writable_host_data_source.h @@ -21,8 +21,11 @@ namespace dhcp { class WritableHostDataSource { public: + /// @brief Constructor + WritableHostDataSource() = default; + /// @brief Default destructor implementation. - virtual ~WritableHostDataSource() { } + virtual ~WritableHostDataSource() = default; /// @brief Non-const version of the @c getAll const method. /// diff --git a/src/lib/dns/gen-rdatacode.py.in b/src/lib/dns/gen-rdatacode.py.in index 362f5e077e6df45f0d87a3f165e7c55af9dff852..8f5dfb187e7076589a73500df94d41d8e48f3144 100644 --- a/src/lib/dns/gen-rdatacode.py.in +++ b/src/lib/dns/gen-rdatacode.py.in @@ -131,6 +131,7 @@ class OutputBuffer;\n''' class AbstractMessageRenderer;\n\n''' if re.match('\s+// BEGIN_COMMON_MEMBERS$', line): content += ''' + /// \\brief Constructor explicit ''' + type_utxt + '''(const std::string& type_str); ''' + type_utxt + '''(isc::util::InputBuffer& buffer, size_t rdata_len); ''' + type_utxt + '''(const ''' + type_utxt + '''& other); diff --git a/src/lib/dns/master_lexer.cc b/src/lib/dns/master_lexer.cc index 0d1292e0c30889ee76b2eb7c9bbaaea5500dbc32..abc2b6951bc4fe139ce0556823f29a3e279d890a 100644 --- a/src/lib/dns/master_lexer.cc +++ b/src/lib/dns/master_lexer.cc @@ -131,7 +131,10 @@ MasterLexer::MasterLexer() : impl_(new MasterLexerImpl) { } MasterLexer::~MasterLexer() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } bool @@ -361,8 +364,15 @@ State::getParenCount(const MasterLexer& lexer) const { namespace { class CRLF : public State { public: - CRLF() {} - virtual ~CRLF() {} // see the base class for the destructor + + /// @brief Constructor + CRLF() = default; + + /// @brief Destructor + /// + /// see the base class for the destructor + virtual ~CRLF() = default; + virtual void handle(MasterLexer& lexer) const { // We've just seen '\r'. If this is part of a sequence of '\r\n', // we combine them as a single END-OF-LINE. Otherwise we treat the @@ -385,22 +395,41 @@ public: class String : public State { public: - String() {} - virtual ~String() {} // see the base class for the destructor + + /// @brief Constructor + String() = default; + + /// @brief Destructor + /// + /// see the base class for the destructor + virtual ~String() = default; + virtual void handle(MasterLexer& lexer) const; }; class QString : public State { public: - QString() {} - virtual ~QString() {} // see the base class for the destructor + + /// @brief Constructor + QString() = default; + + /// @brief Destructor + /// + /// see the base class for the destructor + virtual ~QString() = default; + virtual void handle(MasterLexer& lexer) const; }; class Number : public State { public: - Number() {} - virtual ~Number() {} + + /// @brief Constructor + Number() = default; + + /// @brief Destructor + virtual ~Number() = default; + virtual void handle(MasterLexer& lexer) const; }; diff --git a/src/lib/dns/master_lexer_inputsource.cc b/src/lib/dns/master_lexer_inputsource.cc index 841fc6c1bb7d16cab2ef6135c2a126873c5a34a9..a196143e47a7e1c20ff58d780b7fecab744126ae 100644 --- a/src/lib/dns/master_lexer_inputsource.cc +++ b/src/lib/dns/master_lexer_inputsource.cc @@ -122,13 +122,15 @@ InputSource::InputSource(const char* filename) : total_pos_(0), name_(filename), input_(openFileStream(file_stream_, filename)), - input_size_(getStreamSize(input_)) -{} + input_size_(getStreamSize(input_)) { +} -InputSource::~InputSource() -{ - if (file_stream_.is_open()) { - file_stream_.close(); +InputSource::~InputSource() { + try { + if (file_stream_.is_open()) { + file_stream_.close(); + } + } catch (...) { } } diff --git a/src/lib/dns/master_lexer_state.h b/src/lib/dns/master_lexer_state.h index d328a70918a386d364f1e7ea3cdb74f8fc951b2c..5bba5c850b7a4283808025ec43edb328b0daf351 100644 --- a/src/lib/dns/master_lexer_state.h +++ b/src/lib/dns/master_lexer_state.h @@ -47,11 +47,15 @@ namespace master_lexer_internal { /// this library are expected to use this class. class State { public: + + /// \brief Constructor. + State() = default; + /// \brief Virtual destructor. /// /// In our usage this actually doesn't matter, but some compilers complain /// about it and we need to silence them. - virtual ~State() {} + virtual ~State() = default; /// \brief Begin state transitions to get the next token. /// diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc index 568fdea507bd77787d6742de5e75f186bb5a40ba..1a7c816a05e915a4229fbb2397579153946e86c9 100644 --- a/src/lib/dns/master_loader.cc +++ b/src/lib/dns/master_loader.cc @@ -1044,7 +1044,10 @@ MasterLoader::MasterLoader(std::istream& stream, } MasterLoader::~MasterLoader() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } bool diff --git a/src/lib/dns/message.cc b/src/lib/dns/message.cc index 1e7bb7b5944bb0a561932d4f30c196e7302ae36c..db1a4b2c45fa7fb1e110b5647102028342e1d29e 100644 --- a/src/lib/dns/message.cc +++ b/src/lib/dns/message.cc @@ -380,11 +380,14 @@ MessageImpl::toWire(AbstractMessageRenderer& renderer, TSIGContext* tsig_ctx) { } Message::Message(Mode mode) : - impl_(new MessageImpl(mode)) -{} + impl_(new MessageImpl(mode)) { +} Message::~Message() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } bool @@ -1042,7 +1045,10 @@ SectionIterator::SectionIterator(const SectionIteratorImpl& impl) { template SectionIterator::~SectionIterator() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } template diff --git a/src/lib/dns/message.h b/src/lib/dns/message.h index da8acfe64841a0f47e29bd7cacb6b3ff1f9903c0..96df207b70f40936c9677cc6a51687165296714f 100644 --- a/src/lib/dns/message.h +++ b/src/lib/dns/message.h @@ -90,10 +90,20 @@ struct SectionIteratorImpl; template class SectionIterator : public std::iterator { public: - SectionIterator() : impl_(NULL) {} + + /// @brief Constructor + SectionIterator() : impl_(NULL) { + } + + /// @brief Copy constructor SectionIterator(const SectionIteratorImpl& impl); - ~SectionIterator(); + + /// @brief Copy constructor SectionIterator(const SectionIterator& source); + + /// @brief Destructor + ~SectionIterator(); + void operator=(const SectionIterator& source); SectionIterator& operator++(); SectionIterator operator++(int); @@ -247,15 +257,19 @@ public: /// mode from \c PARSE to \c RENDER, and vice versa. //@{ public: + /// \brief The constructor. /// The mode of the message is specified by the \c mode parameter. Message(Mode mode); + /// \brief The destructor. ~Message(); + private: Message(const Message& source); Message& operator=(const Message& source); //@} + public: /// \brief Return whether the specified header flag bit is set in the /// header section. diff --git a/src/lib/dns/messagerenderer.cc b/src/lib/dns/messagerenderer.cc index 81b2c92dd234ccc280323f8fbed175b280bfc581..ffb550bc9af643c37a700092adbdf9e8186bc41a 100644 --- a/src/lib/dns/messagerenderer.cc +++ b/src/lib/dns/messagerenderer.cc @@ -220,11 +220,14 @@ struct MessageRenderer::MessageRendererImpl { MessageRenderer::MessageRenderer() : AbstractMessageRenderer(), - impl_(new MessageRendererImpl) -{} + impl_(new MessageRendererImpl) { +} MessageRenderer::~MessageRenderer() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } void diff --git a/src/lib/dns/messagerenderer.h b/src/lib/dns/messagerenderer.h index 1b8b9c0f96f880af64e96cb11068c9f62c11dc05..1a65dbe123d26f41fe367e508ba4887bc23c7ec7 100644 --- a/src/lib/dns/messagerenderer.h +++ b/src/lib/dns/messagerenderer.h @@ -94,8 +94,9 @@ public: CASE_INSENSITIVE, //!< Compress names case-insensitive manner (default) CASE_SENSITIVE //!< Compress names case-sensitive manner }; + protected: - /// + /// \name Constructors and Destructor //@{ /// \brief The default constructor. @@ -105,8 +106,9 @@ protected: AbstractMessageRenderer(); public: + /// \brief The destructor. - virtual ~AbstractMessageRenderer() {} + virtual ~AbstractMessageRenderer() = default; //@} protected: /// \brief Return the output buffer we render into. @@ -354,14 +356,17 @@ public: /// pre-existing portion of the buffer contains DNS names, these names won't /// be considered for name compression. class MessageRenderer : public AbstractMessageRenderer, - public boost::noncopyable { // Can crash if copied + public boost::noncopyable { // Can crash if copied public: using AbstractMessageRenderer::CASE_INSENSITIVE; using AbstractMessageRenderer::CASE_SENSITIVE; + /// @brief Constructor MessageRenderer(); + /// @brief Destructor virtual ~MessageRenderer(); + virtual bool isTruncated() const; virtual size_t getLengthLimit() const; virtual CompressMode getCompressMode() const; diff --git a/src/lib/dns/nsec3hash.cc b/src/lib/dns/nsec3hash.cc index 6513f2354e3794d17aad89c9232a7a099ec116e3..77f8ed97305fbdbffdf09ed75dc7c3a8c03272e0 100644 --- a/src/lib/dns/nsec3hash.cc +++ b/src/lib/dns/nsec3hash.cc @@ -54,16 +54,18 @@ class NSEC3HashRFC5155 : boost::noncopyable, public NSEC3Hash { private: // This is the algorithm number for SHA1/NSEC3 as defined in RFC5155. static const uint8_t NSEC3_HASH_SHA1 = 1; + // For digest_ allocation static const size_t DEFAULT_DIGEST_LENGTH = 32; public: + + /// @brief Constructor NSEC3HashRFC5155(uint8_t algorithm, uint16_t iterations, const uint8_t* salt_data, size_t salt_length) : algorithm_(algorithm), iterations_(iterations), salt_data_(NULL), salt_length_(salt_length), - digest_(DEFAULT_DIGEST_LENGTH), obuf_(Name::MAX_WIRE) - { + digest_(DEFAULT_DIGEST_LENGTH), obuf_(Name::MAX_WIRE) { if (algorithm_ != NSEC3_HASH_SHA1) { isc_throw(UnknownNSEC3HashAlgorithm, "Unknown NSEC3 algorithm: " << static_cast(algorithm_)); @@ -78,8 +80,12 @@ public: } } + /// @brief Destructor virtual ~NSEC3HashRFC5155() { - std::free(salt_data_); + try { + std::free(salt_data_); + } catch (...) { + } } virtual std::string calculate(const Name& name) const; diff --git a/src/lib/dns/nsec3hash.h b/src/lib/dns/nsec3hash.h index 26bb715db2121b74df1e968bfa8ddbb03ac1b4fa..1de944772a350fed794437c48f4db501851b1204 100644 --- a/src/lib/dns/nsec3hash.h +++ b/src/lib/dns/nsec3hash.h @@ -73,12 +73,13 @@ public: /// the internal resources for different sets of parameters. class NSEC3Hash { protected: + /// \brief The default constructor. /// /// This is defined as protected to prevent this class from being directly /// instantiated even if the class definition is modified (accidentally /// or intentionally) to have no pure virtual methods. - NSEC3Hash() {} + NSEC3Hash() = default; public: /// \brief Factory method of NSECHash from NSEC3PARAM RDATA. @@ -120,7 +121,7 @@ public: const uint8_t* salt_data, size_t salt_length); /// \brief The destructor. - virtual ~NSEC3Hash() {} + virtual ~NSEC3Hash() = default; /// \brief Calculate the NSEC3 hash (Name variant). /// @@ -202,18 +203,20 @@ public: /// this condition can be loosened. class NSEC3HashCreator { protected: + /// \brief The default constructor. /// /// Make very sure this isn't directly instantiated by making it protected /// even if this class is modified to lose all pure virtual methods. - NSEC3HashCreator() {} + NSEC3HashCreator() = default; public: + /// \brief The destructor. /// /// This does nothing; defined only for allowing derived classes to /// specialize its behavior. - virtual ~NSEC3HashCreator() {} + virtual ~NSEC3HashCreator() = default; /// \brief Factory method of NSECHash from NSEC3PARAM RDATA. /// diff --git a/src/lib/dns/rdata.cc b/src/lib/dns/rdata.cc index 357ccc7cdf0b4933c90a7cdcc962334576db3b8e..32f57082e3d4c094eef783dad55129d39ee7cb50 100644 --- a/src/lib/dns/rdata.cc +++ b/src/lib/dns/rdata.cc @@ -307,17 +307,19 @@ Generic::Generic(const std::string& rdata_string) : Generic::Generic(MasterLexer& lexer, const Name*, MasterLoader::Options, MasterLoaderCallbacks&) : - impl_(constructFromLexer(lexer)) -{ + impl_(constructFromLexer(lexer)) { } Generic::~Generic() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } Generic::Generic(const Generic& source) : - Rdata(), impl_(new GenericImpl(*source.impl_)) -{} + Rdata(), impl_(new GenericImpl(*source.impl_)) { +} Generic& // Our check is better than the usual if (this == &source), diff --git a/src/lib/dns/rdata.h b/src/lib/dns/rdata.h index a6515ef936dfa0a001f75ede835119f1343bca92..2bba41ad0883799350bc540df191753d4faefeb6 100644 --- a/src/lib/dns/rdata.h +++ b/src/lib/dns/rdata.h @@ -129,6 +129,7 @@ class Rdata { /// own versions of these methods. //@{ protected: + /// The default constructor. /// /// This is intentionally defined as \c protected as this base class should @@ -136,13 +137,15 @@ protected: /// cases, the derived class wouldn't define a public default constructor /// either, because an \c Rdata object without concrete data isn't /// meaningful. - Rdata() {} + Rdata() = default; + private: Rdata(const Rdata& source); void operator=(const Rdata& source); public: + /// The destructor. - virtual ~Rdata() {}; + virtual ~Rdata() = default; //@} /// @@ -248,6 +251,7 @@ struct GenericImpl; /// assuming any structure. class Generic : public Rdata { public: + /// /// \name Constructors, Assignment Operator and Destructor. /// @@ -290,6 +294,7 @@ public: /// \param rdata_len The length in buffer of the \c Rdata. In bytes. Generic(isc::util::InputBuffer& buffer, size_t rdata_len); + /// /// \brief Constructor from master lexer. /// Generic(MasterLexer& lexer, const Name* name, diff --git a/src/lib/dns/rdata/any_255/tsig_250.cc b/src/lib/dns/rdata/any_255/tsig_250.cc index a80d742d097cc9b95534eba9bd45c076cfd83345..765bd469409ffc3c03616903476dd9025f7ba4de 100644 --- a/src/lib/dns/rdata/any_255/tsig_250.cc +++ b/src/lib/dns/rdata/any_255/tsig_250.cc @@ -362,7 +362,10 @@ TSIG::operator=(const TSIG& source) { } TSIG::~TSIG() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } /// \brief Convert the \c TSIG to a string. diff --git a/src/lib/dns/rdata/generic/caa_257.cc b/src/lib/dns/rdata/generic/caa_257.cc index 7f8b455687570d9cf8e6069274da6bae57423fc0..4a5f0722b07ce131b8c9948f07e9de4cbba9cbf7 100644 --- a/src/lib/dns/rdata/generic/caa_257.cc +++ b/src/lib/dns/rdata/generic/caa_257.cc @@ -214,7 +214,10 @@ CAA::operator=(const CAA& source) { } CAA::~CAA() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } void diff --git a/src/lib/dns/rdata/generic/caa_257.h b/src/lib/dns/rdata/generic/caa_257.h index 0e81e71c54422eb5322018a4277c514bbf2467c8..5ad0334ded8eae08afb32f98524fef2922994230 100644 --- a/src/lib/dns/rdata/generic/caa_257.h +++ b/src/lib/dns/rdata/generic/caa_257.h @@ -28,8 +28,12 @@ public: // BEGIN_COMMON_MEMBERS // END_COMMON_MEMBERS + /// \brief Constructor CAA(uint8_t flags, const std::string& tag, const std::string& value); + CAA& operator=(const CAA& source); + + /// \brief Destructor ~CAA(); /// diff --git a/src/lib/dns/rdata/generic/dlv_32769.cc b/src/lib/dns/rdata/generic/dlv_32769.cc index 66303b7a57ecaf0fdb6dfd4f1830d8f0d64b9d0d..c6ba5d891236e501448b332eb963df7c0ef16530 100644 --- a/src/lib/dns/rdata/generic/dlv_32769.cc +++ b/src/lib/dns/rdata/generic/dlv_32769.cc @@ -71,7 +71,10 @@ DLV::operator=(const DLV& source) { /// /// Deallocates an internal resource. DLV::~DLV() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } /// \brief Convert the \c DLV to a string. diff --git a/src/lib/dns/rdata/generic/dlv_32769.h b/src/lib/dns/rdata/generic/dlv_32769.h index 26523de6fec47a9693c10466d7c6788651e84dda..8b26810d7480c7d18e3e9b0b2213c56320b7b7f7 100644 --- a/src/lib/dns/rdata/generic/dlv_32769.h +++ b/src/lib/dns/rdata/generic/dlv_32769.h @@ -48,7 +48,7 @@ public: /// intact. DLV& operator=(const DLV& source); - /// \brief The destructor. + /// \brief Destructor ~DLV(); /// \brief Return the value of the Tag field. diff --git a/src/lib/dns/rdata/generic/dnskey_48.cc b/src/lib/dns/rdata/generic/dnskey_48.cc index 7bea8474279c9f93d71a69828dfdb62584d20807..7fd3428a4617b17892aa002870d9b64c06c5330e 100644 --- a/src/lib/dns/rdata/generic/dnskey_48.cc +++ b/src/lib/dns/rdata/generic/dnskey_48.cc @@ -218,7 +218,10 @@ DNSKEY::operator=(const DNSKEY& source) { } DNSKEY::~DNSKEY() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } string diff --git a/src/lib/dns/rdata/generic/dnskey_48.h b/src/lib/dns/rdata/generic/dnskey_48.h index a5e9efa43ff905d94a3a089188c86968c4870062..29c006a47b94019b7066deeca9e7113e113abec5 100644 --- a/src/lib/dns/rdata/generic/dnskey_48.h +++ b/src/lib/dns/rdata/generic/dnskey_48.h @@ -30,6 +30,8 @@ public: // BEGIN_COMMON_MEMBERS // END_COMMON_MEMBERS DNSKEY& operator=(const DNSKEY& source); + + /// \brief Destructor ~DNSKEY(); /// diff --git a/src/lib/dns/rdata/generic/ds_43.cc b/src/lib/dns/rdata/generic/ds_43.cc index 48c421c4d86ea3da7599d401e6d8bd848f32838e..143263b2ce78d5ad77475cc82e33b521a1944a4c 100644 --- a/src/lib/dns/rdata/generic/ds_43.cc +++ b/src/lib/dns/rdata/generic/ds_43.cc @@ -56,7 +56,10 @@ DS::operator=(const DS& source) { } DS::~DS() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } string diff --git a/src/lib/dns/rdata/generic/ds_43.h b/src/lib/dns/rdata/generic/ds_43.h index a20e349ef64dd429082af87e089799b4370dab55..3fec5be1d96448f24d9af6738fa2a08b3c9ef304 100644 --- a/src/lib/dns/rdata/generic/ds_43.h +++ b/src/lib/dns/rdata/generic/ds_43.h @@ -48,7 +48,7 @@ public: /// intact. DS& operator=(const DS& source); - /// \brief The destructor. + /// \brief Destructor ~DS(); /// \brief Return the value of the Tag field. diff --git a/src/lib/dns/rdata/generic/hinfo_13.cc b/src/lib/dns/rdata/generic/hinfo_13.cc index 3bda21979c448ee871fa0c678f6a8afc2a038e25..b8342f40ef291bb6004ddd4491df61db2dcccf60 100644 --- a/src/lib/dns/rdata/generic/hinfo_13.cc +++ b/src/lib/dns/rdata/generic/hinfo_13.cc @@ -51,8 +51,7 @@ public: } } - HINFOImpl(MasterLexer& lexer) - { + HINFOImpl(MasterLexer& lexer) { parseHINFOData(lexer); } @@ -89,13 +88,23 @@ HINFO::HINFO(MasterLexer& lexer, const Name*, {} HINFO& -HINFO::operator=(const HINFO& source) -{ - impl_.reset(new HINFOImpl(*source.impl_)); +HINFO::operator=(const HINFO& source) { + if (this == &source) { + return (*this); + } + + HINFOImpl* newimpl = new HINFOImpl(*source.impl_); + delete impl_; + impl_ = newimpl; + return (*this); } HINFO::~HINFO() { + try { + delete impl_; + } catch (...) { + } } std::string diff --git a/src/lib/dns/rdata/generic/hinfo_13.h b/src/lib/dns/rdata/generic/hinfo_13.h index acceb14fdb0da49899ad3b611c6376b2b59a5b1a..d9ff6b8415542994ac33140e5293446b5270aa39 100644 --- a/src/lib/dns/rdata/generic/hinfo_13.h +++ b/src/lib/dns/rdata/generic/hinfo_13.h @@ -37,6 +37,8 @@ public: // END_COMMON_MEMBERS // HINFO specific methods + + /// \brief Destructor ~HINFO(); HINFO& operator=(const HINFO&); @@ -51,7 +53,7 @@ private: template void toWireHelper(T& outputer) const; - boost::scoped_ptr impl_; + HINFOImpl* impl_; }; diff --git a/src/lib/dns/rdata/generic/naptr_35.cc b/src/lib/dns/rdata/generic/naptr_35.cc index aa2d7f54c6b58a84b744e21cf776c836951c203d..8885fa28cedb20bd7e7f55d89ff37d8754e94695 100644 --- a/src/lib/dns/rdata/generic/naptr_35.cc +++ b/src/lib/dns/rdata/generic/naptr_35.cc @@ -136,11 +136,22 @@ NAPTR::NAPTR(const NAPTR& naptr) : Rdata(), NAPTR& NAPTR::operator=(const NAPTR& source) { - impl_.reset(new NAPTRImpl(*source.impl_)); + if (this == &source) { + return (*this); + } + + NAPTRImpl* newimpl = new NAPTRImpl(*source.impl_); + delete impl_; + impl_ = newimpl; + return (*this); } NAPTR::~NAPTR() { + try { + delete impl_; + } catch (...) { + } } void diff --git a/src/lib/dns/rdata/generic/naptr_35.h b/src/lib/dns/rdata/generic/naptr_35.h index c77b95d0a81ab07c6e57f1975cd6f9147255cec2..0839de17200c08bd845709a971ce216f83e0a4cc 100644 --- a/src/lib/dns/rdata/generic/naptr_35.h +++ b/src/lib/dns/rdata/generic/naptr_35.h @@ -35,6 +35,7 @@ public: // END_COMMON_MEMBERS // NAPTR specific methods + /// \brief Destructor ~NAPTR(); NAPTR& operator=(const NAPTR& source); @@ -52,7 +53,7 @@ private: template void toWireHelper(T& outputer) const; - boost::scoped_ptr impl_; + NAPTRImpl* impl_; }; // END_RDATA_NAMESPACE diff --git a/src/lib/dns/rdata/generic/nsec3_50.cc b/src/lib/dns/rdata/generic/nsec3_50.cc index e99c109807bff0528b638a45dad1dc3149ee4450..fb02d9508a8cdd1633e2f0708065100fa3cedfad 100644 --- a/src/lib/dns/rdata/generic/nsec3_50.cc +++ b/src/lib/dns/rdata/generic/nsec3_50.cc @@ -206,7 +206,10 @@ NSEC3::operator=(const NSEC3& source) { } NSEC3::~NSEC3() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } string diff --git a/src/lib/dns/rdata/generic/nsec3_50.h b/src/lib/dns/rdata/generic/nsec3_50.h index cf73624f58e49318502af02dd98bf5257e691e09..7d87e104aed54b26bf0aa33d3d35e10fcee57d09 100644 --- a/src/lib/dns/rdata/generic/nsec3_50.h +++ b/src/lib/dns/rdata/generic/nsec3_50.h @@ -31,6 +31,8 @@ public: // BEGIN_COMMON_MEMBERS // END_COMMON_MEMBERS NSEC3& operator=(const NSEC3& source); + + /// \brief Destructor ~NSEC3(); uint8_t getHashalg() const; diff --git a/src/lib/dns/rdata/generic/nsec3param_51.cc b/src/lib/dns/rdata/generic/nsec3param_51.cc index 2d28a6988581f945fd9a97e185b6222848928ba7..2c167291775ca97a3e2019c87f23d6433e327728 100644 --- a/src/lib/dns/rdata/generic/nsec3param_51.cc +++ b/src/lib/dns/rdata/generic/nsec3param_51.cc @@ -145,7 +145,10 @@ NSEC3PARAM::operator=(const NSEC3PARAM& source) { } NSEC3PARAM::~NSEC3PARAM() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } string diff --git a/src/lib/dns/rdata/generic/nsec3param_51.h b/src/lib/dns/rdata/generic/nsec3param_51.h index 1c7bf032514b8c3cba30eb1d7b24ea0a0950311e..3621cf20c809593b02c6a5d4d8361ca4b0047eb2 100644 --- a/src/lib/dns/rdata/generic/nsec3param_51.h +++ b/src/lib/dns/rdata/generic/nsec3param_51.h @@ -31,6 +31,8 @@ public: // BEGIN_COMMON_MEMBERS // END_COMMON_MEMBERS NSEC3PARAM& operator=(const NSEC3PARAM& source); + + /// \brief Destructor ~NSEC3PARAM(); /// diff --git a/src/lib/dns/rdata/generic/nsec_47.cc b/src/lib/dns/rdata/generic/nsec_47.cc index f8af0e0142b4909df79b6caaaf657dce3edce7a5..f5770247d792c793658765455849ece988093b99 100644 --- a/src/lib/dns/rdata/generic/nsec_47.cc +++ b/src/lib/dns/rdata/generic/nsec_47.cc @@ -161,7 +161,10 @@ NSEC::operator=(const NSEC& source) { } NSEC::~NSEC() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } string diff --git a/src/lib/dns/rdata/generic/nsec_47.h b/src/lib/dns/rdata/generic/nsec_47.h index 299d3815982fd832edb50c07d6d0e65f292d5ffd..46c3ea8cc0d83b77949df7b8d35edb4619a3567f 100644 --- a/src/lib/dns/rdata/generic/nsec_47.h +++ b/src/lib/dns/rdata/generic/nsec_47.h @@ -29,6 +29,8 @@ public: // BEGIN_COMMON_MEMBERS // END_COMMON_MEMBERS NSEC& operator=(const NSEC& source); + + /// \brief Destructor ~NSEC(); // specialized methods diff --git a/src/lib/dns/rdata/generic/opt_41.cc b/src/lib/dns/rdata/generic/opt_41.cc index 40cb1c73ae4214bac678c8a5e29a6e03c9eef24c..a78342e5632062af650d3528624bed44dfb4b6af 100644 --- a/src/lib/dns/rdata/generic/opt_41.cc +++ b/src/lib/dns/rdata/generic/opt_41.cc @@ -26,8 +26,7 @@ using namespace isc::util; OPT::PseudoRR::PseudoRR(uint16_t code, boost::shared_ptr >& data) : code_(code), - data_(data) -{ + data_(data) { } uint16_t @@ -56,8 +55,7 @@ struct OPTImpl { /// \brief Default constructor. OPT::OPT() : - impl_(new OPTImpl) -{ + impl_(new OPTImpl) { } /// \brief Constructor from string. @@ -66,8 +64,7 @@ OPT::OPT() : /// /// \throw InvalidRdataText OPT RR cannot be constructed from text. OPT::OPT(const std::string&) : - impl_(NULL) -{ + impl_(NULL) { isc_throw(InvalidRdataText, "OPT RR cannot be constructed from text"); } @@ -78,14 +75,12 @@ OPT::OPT(const std::string&) : /// \throw InvalidRdataText OPT RR cannot be constructed from text. OPT::OPT(MasterLexer&, const Name*, MasterLoader::Options, MasterLoaderCallbacks&) : - impl_(NULL) -{ + impl_(NULL) { isc_throw(InvalidRdataText, "OPT RR cannot be constructed from text"); } OPT::OPT(InputBuffer& buffer, size_t rdata_len) : - impl_(NULL) -{ + impl_(NULL) { std::unique_ptr impl_ptr(new OPTImpl); while (true) { @@ -128,8 +123,7 @@ OPT::OPT(InputBuffer& buffer, size_t rdata_len) : } OPT::OPT(const OPT& other) : - Rdata(), impl_(new OPTImpl(*other.impl_)) -{ + Rdata(), impl_(new OPTImpl(*other.impl_)) { } OPT& @@ -146,7 +140,10 @@ OPT::operator=(const OPT& source) { } OPT::~OPT() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } std::string diff --git a/src/lib/dns/rdata/generic/opt_41.h b/src/lib/dns/rdata/generic/opt_41.h index 0c00aed20cdabe20bc1a85816b54869e6db090a4..fabdc472d5c46c4c56821c6df0939bc4d6c4547f 100644 --- a/src/lib/dns/rdata/generic/opt_41.h +++ b/src/lib/dns/rdata/generic/opt_41.h @@ -28,9 +28,12 @@ public: // BEGIN_COMMON_MEMBERS // END_COMMON_MEMBERS - // The default constructor makes sense for OPT as it can be empty. + /// \brief The default constructor makes sense for OPT as it can be empty. OPT(); + OPT& operator=(const OPT& source); + + /// \brief Destructor ~OPT(); /// \brief A class representing a pseudo RR (or option) within an diff --git a/src/lib/dns/rdata/generic/rrsig_46.cc b/src/lib/dns/rdata/generic/rrsig_46.cc index de92c67c3469f348e51639c6508a0edcca022c14..131cc8d49cb40cf44bb604044d45b8d2b13820b9 100644 --- a/src/lib/dns/rdata/generic/rrsig_46.cc +++ b/src/lib/dns/rdata/generic/rrsig_46.cc @@ -236,7 +236,10 @@ RRSIG::operator=(const RRSIG& source) { } RRSIG::~RRSIG() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } string diff --git a/src/lib/dns/rdata/generic/rrsig_46.h b/src/lib/dns/rdata/generic/rrsig_46.h index aca26bacab4e053e8ac40f4568f74bb5c61b976c..7fb0bb294d1c28cc900e4a0ca6d7b0ef4faad49c 100644 --- a/src/lib/dns/rdata/generic/rrsig_46.h +++ b/src/lib/dns/rdata/generic/rrsig_46.h @@ -34,6 +34,8 @@ public: // BEGIN_COMMON_MEMBERS // END_COMMON_MEMBERS RRSIG& operator=(const RRSIG& source); + + /// \brief Destructor ~RRSIG(); // specialized methods diff --git a/src/lib/dns/rdata/generic/spf_99.cc b/src/lib/dns/rdata/generic/spf_99.cc index f25585ab531c4ead3453145240827ba86426157f..1f2929ffdd849875bd494ba7470dd6602138fc0b 100644 --- a/src/lib/dns/rdata/generic/spf_99.cc +++ b/src/lib/dns/rdata/generic/spf_99.cc @@ -49,7 +49,10 @@ SPF::operator=(const SPF& source) { /// \brief The destructor SPF::~SPF() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } /// \brief Constructor from wire-format data. diff --git a/src/lib/dns/rdata/generic/spf_99.h b/src/lib/dns/rdata/generic/spf_99.h index 3a84d9deb84bb668344f6e5084668a840db825cc..935488bd83549a52d6d2082d2107ad83926033ff 100644 --- a/src/lib/dns/rdata/generic/spf_99.h +++ b/src/lib/dns/rdata/generic/spf_99.h @@ -46,7 +46,7 @@ public: /// intact. SPF& operator=(const SPF& source); - /// \brief The destructor. + /// \brief Destructor ~SPF(); /// diff --git a/src/lib/dns/rdata/generic/sshfp_44.cc b/src/lib/dns/rdata/generic/sshfp_44.cc index a08a17fcb0c453f07324a9c4db15f61a2e6819b7..15e8dbb7b122e955cf8afff962ba21589e493191 100644 --- a/src/lib/dns/rdata/generic/sshfp_44.cc +++ b/src/lib/dns/rdata/generic/sshfp_44.cc @@ -202,7 +202,10 @@ SSHFP::operator=(const SSHFP& source) { } SSHFP::~SSHFP() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } void diff --git a/src/lib/dns/rdata/generic/sshfp_44.h b/src/lib/dns/rdata/generic/sshfp_44.h index 4eae696bdcbac980d290549c3e55d4a4a31d9c1b..489d46b0c6c3a4435ba75f7dc92432def1751024 100644 --- a/src/lib/dns/rdata/generic/sshfp_44.h +++ b/src/lib/dns/rdata/generic/sshfp_44.h @@ -28,9 +28,12 @@ public: // BEGIN_COMMON_MEMBERS // END_COMMON_MEMBERS + /// \brief Constructor SSHFP(uint8_t algorithm, uint8_t fingerprint_type, const std::string& fingerprint); SSHFP& operator=(const SSHFP& source); + + /// \brief Destructor ~SSHFP(); /// diff --git a/src/lib/dns/rdata/generic/tlsa_52.cc b/src/lib/dns/rdata/generic/tlsa_52.cc index 330b7a2c829886f94a6cb832e83ff19b5a1388ef..2d0e27a95ae93c05f65612566b634d3283c085b1 100644 --- a/src/lib/dns/rdata/generic/tlsa_52.cc +++ b/src/lib/dns/rdata/generic/tlsa_52.cc @@ -228,7 +228,10 @@ TLSA::operator=(const TLSA& source) { } TLSA::~TLSA() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } void diff --git a/src/lib/dns/rdata/generic/tlsa_52.h b/src/lib/dns/rdata/generic/tlsa_52.h index 007aa43ddccab51609c9153fe0ed263f3f24976a..82bef3da30615c9c44a3d029a901f2ed327ab987 100644 --- a/src/lib/dns/rdata/generic/tlsa_52.h +++ b/src/lib/dns/rdata/generic/tlsa_52.h @@ -28,9 +28,12 @@ public: // BEGIN_COMMON_MEMBERS // END_COMMON_MEMBERS + /// \brief Constructor TLSA(uint8_t certificate_usage, uint8_t selector, uint8_t matching_type, const std::string& certificate_assoc_data); TLSA& operator=(const TLSA& source); + + /// \brief Destructor ~TLSA(); /// diff --git a/src/lib/dns/rdata/generic/txt_16.cc b/src/lib/dns/rdata/generic/txt_16.cc index 52d6b6473c089ddcf2d63ab134c330b5eb19b9d4..35cdaa0de50b4a36a9c89b120494d3f713cf976f 100644 --- a/src/lib/dns/rdata/generic/txt_16.cc +++ b/src/lib/dns/rdata/generic/txt_16.cc @@ -39,7 +39,10 @@ TXT::operator=(const TXT& source) { } TXT::~TXT() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } TXT::TXT(InputBuffer& buffer, size_t rdata_len) : diff --git a/src/lib/dns/rdata/generic/txt_16.h b/src/lib/dns/rdata/generic/txt_16.h index 83979c47658c7ee9e5d03f18e37b3fffc99c16ec..039db82adf2d32a075dc16d168c289d83917bb4d 100644 --- a/src/lib/dns/rdata/generic/txt_16.h +++ b/src/lib/dns/rdata/generic/txt_16.h @@ -30,6 +30,8 @@ public: // END_COMMON_MEMBERS TXT& operator=(const TXT& source); + + /// \brief Destructor ~TXT(); private: diff --git a/src/lib/dns/rdata/in_1/a_1.h b/src/lib/dns/rdata/in_1/a_1.h index 9aaeea8e3faef892d6af363099ff8fbf38442764..da0308234f73653c74a28e2e27eb46f6a0bd3d43 100644 --- a/src/lib/dns/rdata/in_1/a_1.h +++ b/src/lib/dns/rdata/in_1/a_1.h @@ -22,10 +22,10 @@ public: // BEGIN_COMMON_MEMBERS // END_COMMON_MEMBERS - //We can use the default destructor. - //virtual ~A() {} + // We can use the default destructor. + // virtual ~A() = default // notyet: - //const struct in_addr& getAddress() const { return (addr_); } + // const struct in_addr& getAddress() const { return (addr_); } private: uint32_t addr_; // raw IPv4 address (network byte order) }; diff --git a/src/lib/dns/rdata/in_1/srv_33.cc b/src/lib/dns/rdata/in_1/srv_33.cc index a8a050ca278bd2dd2d6b991aa0fcb23dbcf8009a..6d509fde2cd31a979f1324b5a5711dada28fbc82 100644 --- a/src/lib/dns/rdata/in_1/srv_33.cc +++ b/src/lib/dns/rdata/in_1/srv_33.cc @@ -196,7 +196,10 @@ SRV::operator=(const SRV& source) { } SRV::~SRV() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } /// \brief Convert the \c SRV to a string. diff --git a/src/lib/dns/rdata/in_1/srv_33.h b/src/lib/dns/rdata/in_1/srv_33.h index aca210e038089e5571fe81a966d63448dca28e72..a224b08e0f10ab0fe0d8a1b8de8fd1646782ba30 100644 --- a/src/lib/dns/rdata/in_1/srv_33.h +++ b/src/lib/dns/rdata/in_1/srv_33.h @@ -42,7 +42,7 @@ public: /// intact. SRV& operator=(const SRV& source); - /// \brief The destructor. + /// \brief Destructor ~SRV(); /// diff --git a/src/lib/dns/rdata_pimpl_holder.h b/src/lib/dns/rdata_pimpl_holder.h index baa343a529a904369016f9853da0f1b44e9687a1..2f33538b2f36fe5b332bedf9ac71bb8a8396ed1d 100644 --- a/src/lib/dns/rdata_pimpl_holder.h +++ b/src/lib/dns/rdata_pimpl_holder.h @@ -18,12 +18,18 @@ namespace rdata { template class RdataPimplHolder : boost::noncopyable { public: + + /// @brief Constructor RdataPimplHolder(T* obj = NULL) : - obj_(obj) - {} + obj_(obj) { + } + /// @brief Destructor ~RdataPimplHolder() { - delete obj_; + try { + delete obj_; + } catch (...) { + } } void reset(T* obj = NULL) { diff --git a/src/lib/dns/rdataclass.cc b/src/lib/dns/rdataclass.cc index b5c6107b851217206b65731e43960e24545e6048..536d3c1553eb826354bb6b2af170a00d50f5c4ee 100644 --- a/src/lib/dns/rdataclass.cc +++ b/src/lib/dns/rdataclass.cc @@ -371,7 +371,10 @@ TSIG::operator=(const TSIG& source) { } TSIG::~TSIG() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } /// \brief Convert the \c TSIG to a string. @@ -582,6 +585,8 @@ TSIG::getOtherData() const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include @@ -648,6 +653,8 @@ A::compare(const Rdata&) const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include @@ -1063,7 +1070,10 @@ CAA::operator=(const CAA& source) { } CAA::~CAA() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } void @@ -1282,6 +1292,8 @@ CNAME::getCname() const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include @@ -1349,7 +1361,10 @@ DLV::operator=(const DLV& source) { /// /// Deallocates an internal resource. DLV::~DLV() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } /// \brief Convert the \c DLV to a string. @@ -1751,7 +1766,10 @@ DNSKEY::operator=(const DNSKEY& source) { } DNSKEY::~DNSKEY() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } string @@ -1855,6 +1873,8 @@ DNSKEY::getAlgorithm() const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include @@ -1907,7 +1927,10 @@ DS::operator=(const DS& source) { } DS::~DS() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } string @@ -1996,8 +2019,7 @@ public: } } - HINFOImpl(MasterLexer& lexer) - { + HINFOImpl(MasterLexer& lexer) { parseHINFOData(lexer); } @@ -2034,13 +2056,23 @@ HINFO::HINFO(MasterLexer& lexer, const Name*, {} HINFO& -HINFO::operator=(const HINFO& source) -{ - impl_.reset(new HINFOImpl(*source.impl_)); +HINFO::operator=(const HINFO& source) { + if (this == &source) { + return (*this); + } + + HINFOImpl* newimpl = new HINFOImpl(*source.impl_); + delete impl_; + impl_ = newimpl; + return (*this); } HINFO::~HINFO() { + try { + delete impl_; + } catch (...) { + } } std::string @@ -2102,6 +2134,8 @@ HINFO::toWireHelper(T& outputer) const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include @@ -2575,11 +2609,22 @@ NAPTR::NAPTR(const NAPTR& naptr) : Rdata(), NAPTR& NAPTR::operator=(const NAPTR& source) { - impl_.reset(new NAPTRImpl(*source.impl_)); + if (this == &source) { + return (*this); + } + + NAPTRImpl* newimpl = new NAPTRImpl(*source.impl_); + delete impl_; + impl_ = newimpl; + return (*this); } NAPTR::~NAPTR() { + try { + delete impl_; + } catch (...) { + } } void @@ -3030,7 +3075,10 @@ NSEC3::operator=(const NSEC3& source) { } NSEC3::~NSEC3() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } string @@ -3316,7 +3364,10 @@ NSEC3PARAM::operator=(const NSEC3PARAM& source) { } NSEC3PARAM::~NSEC3PARAM() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } string @@ -3409,6 +3460,8 @@ NSEC3PARAM::getSalt() const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include #include @@ -3566,7 +3619,10 @@ NSEC::operator=(const NSEC& source) { } NSEC::~NSEC() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } string @@ -3651,8 +3707,7 @@ namespace generic { OPT::PseudoRR::PseudoRR(uint16_t code, boost::shared_ptr >& data) : code_(code), - data_(data) -{ + data_(data) { } uint16_t @@ -3681,8 +3736,7 @@ struct OPTImpl { /// \brief Default constructor. OPT::OPT() : - impl_(new OPTImpl) -{ + impl_(new OPTImpl) { } /// \brief Constructor from string. @@ -3691,8 +3745,7 @@ OPT::OPT() : /// /// \throw InvalidRdataText OPT RR cannot be constructed from text. OPT::OPT(const std::string&) : - impl_(NULL) -{ + impl_(NULL) { isc_throw(InvalidRdataText, "OPT RR cannot be constructed from text"); } @@ -3703,14 +3756,12 @@ OPT::OPT(const std::string&) : /// \throw InvalidRdataText OPT RR cannot be constructed from text. OPT::OPT(MasterLexer&, const Name*, MasterLoader::Options, MasterLoaderCallbacks&) : - impl_(NULL) -{ + impl_(NULL) { isc_throw(InvalidRdataText, "OPT RR cannot be constructed from text"); } OPT::OPT(InputBuffer& buffer, size_t rdata_len) : - impl_(NULL) -{ + impl_(NULL) { std::unique_ptr impl_ptr(new OPTImpl); while (true) { @@ -3753,8 +3804,7 @@ OPT::OPT(InputBuffer& buffer, size_t rdata_len) : } OPT::OPT(const OPT& other) : - Rdata(), impl_(new OPTImpl(*other.impl_)) -{ + Rdata(), impl_(new OPTImpl(*other.impl_)) { } OPT& @@ -3771,7 +3821,10 @@ OPT::operator=(const OPT& source) { } OPT::~OPT() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } std::string @@ -3977,6 +4030,8 @@ PTR::getPTRName() const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include @@ -4373,7 +4428,10 @@ RRSIG::operator=(const RRSIG& source) { } RRSIG::~RRSIG() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } string @@ -4691,6 +4749,8 @@ SOA::compare(const Rdata& other) const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include @@ -4736,7 +4796,10 @@ SPF::operator=(const SPF& source) { /// \brief The destructor SPF::~SPF() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } /// \brief Constructor from wire-format data. @@ -5032,7 +5095,10 @@ SSHFP::operator=(const SSHFP& source) { } SSHFP::~SSHFP() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } void @@ -5360,7 +5426,10 @@ TLSA::operator=(const TLSA& source) { } TLSA::~TLSA() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } void @@ -5480,6 +5549,8 @@ TLSA::getDataLength() const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include @@ -5515,7 +5586,10 @@ TXT::operator=(const TXT& source) { } TXT::~TXT() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } TXT::TXT(InputBuffer& buffer, size_t rdata_len) : @@ -5577,6 +5651,8 @@ TXT::compare(const Rdata& other) const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include @@ -5643,6 +5719,8 @@ A::compare(const Rdata&) const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include @@ -5819,6 +5897,8 @@ A::compare(const Rdata& other) const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include #include @@ -5974,6 +6054,8 @@ AAAA::compare(const Rdata& other) const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include @@ -6137,6 +6219,8 @@ DHCID::getDigest() const { // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include + #include #include @@ -6329,7 +6413,10 @@ SRV::operator=(const SRV& source) { } SRV::~SRV() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } /// \brief Convert the \c SRV to a string. diff --git a/src/lib/dns/rdataclass.h b/src/lib/dns/rdataclass.h index e8d8d7a2b6f3145bc1038e9b4592dba735f5b8b9..a40a2263104fc1604d417b8efcb86c554e327db0 100644 --- a/src/lib/dns/rdataclass.h +++ b/src/lib/dns/rdataclass.h @@ -64,6 +64,7 @@ class TSIG : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit TSIG(const std::string& type_str); TSIG(isc::util::InputBuffer& buffer, size_t rdata_len); TSIG(const TSIG& other); @@ -224,6 +225,7 @@ class A : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit A(const std::string& type_str); A(isc::util::InputBuffer& buffer, size_t rdata_len); A(const A& other); @@ -288,6 +290,7 @@ class AFSDB : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit AFSDB(const std::string& type_str); AFSDB(isc::util::InputBuffer& buffer, size_t rdata_len); AFSDB(const AFSDB& other); @@ -376,7 +379,8 @@ class CAA : public Rdata { public: // BEGIN_COMMON_MEMBERS - explicit CAA(const std::string& caa_str); + /// \brief Constructor + explicit CAA(const std::string& type_str); CAA(isc::util::InputBuffer& buffer, size_t rdata_len); CAA(const CAA& other); CAA( @@ -389,8 +393,12 @@ public: // END_COMMON_MEMBERS + /// \brief Constructor CAA(uint8_t flags, const std::string& tag, const std::string& value); + CAA& operator=(const CAA& source); + + /// \brief Destructor ~CAA(); /// @@ -458,6 +466,7 @@ class CNAME : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit CNAME(const std::string& type_str); CNAME(isc::util::InputBuffer& buffer, size_t rdata_len); CNAME(const CNAME& other); @@ -534,6 +543,7 @@ class DLV : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit DLV(const std::string& type_str); DLV(isc::util::InputBuffer& buffer, size_t rdata_len); DLV(const DLV& other); @@ -558,7 +568,7 @@ public: /// intact. DLV& operator=(const DLV& source); - /// \brief The destructor. + /// \brief Destructor ~DLV(); /// \brief Return the value of the Tag field. @@ -612,6 +622,7 @@ class DNAME : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit DNAME(const std::string& type_str); DNAME(isc::util::InputBuffer& buffer, size_t rdata_len); DNAME(const DNAME& other); @@ -681,6 +692,7 @@ class DNSKEY : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit DNSKEY(const std::string& type_str); DNSKEY(isc::util::InputBuffer& buffer, size_t rdata_len); DNSKEY(const DNSKEY& other); @@ -694,6 +706,8 @@ public: // END_COMMON_MEMBERS DNSKEY& operator=(const DNSKEY& source); + + /// \brief Destructor ~DNSKEY(); /// @@ -771,6 +785,7 @@ class DS : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit DS(const std::string& type_str); DS(isc::util::InputBuffer& buffer, size_t rdata_len); DS(const DS& other); @@ -795,7 +810,7 @@ public: /// intact. DS& operator=(const DS& source); - /// \brief The destructor. + /// \brief Destructor ~DS(); /// \brief Return the value of the Tag field. @@ -862,6 +877,7 @@ class HINFO : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit HINFO(const std::string& type_str); HINFO(isc::util::InputBuffer& buffer, size_t rdata_len); HINFO(const HINFO& other); @@ -876,6 +892,8 @@ public: // END_COMMON_MEMBERS // HINFO specific methods + + /// \brief Destructor ~HINFO(); HINFO& operator=(const HINFO&); @@ -890,7 +908,7 @@ private: template void toWireHelper(T& outputer) const; - boost::scoped_ptr impl_; + HINFOImpl* impl_; }; @@ -942,6 +960,7 @@ class MINFO : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit MINFO(const std::string& type_str); MINFO(isc::util::InputBuffer& buffer, size_t rdata_len); MINFO(const MINFO& other); @@ -1035,6 +1054,7 @@ class MX : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit MX(const std::string& type_str); MX(isc::util::InputBuffer& buffer, size_t rdata_len); MX(const MX& other); @@ -1119,6 +1139,7 @@ class NAPTR : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit NAPTR(const std::string& type_str); NAPTR(isc::util::InputBuffer& buffer, size_t rdata_len); NAPTR(const NAPTR& other); @@ -1133,6 +1154,7 @@ public: // END_COMMON_MEMBERS // NAPTR specific methods + /// \brief Destructor ~NAPTR(); NAPTR& operator=(const NAPTR& source); @@ -1150,7 +1172,7 @@ private: template void toWireHelper(T& outputer) const; - boost::scoped_ptr impl_; + NAPTRImpl* impl_; }; } // end of namespace "generic" @@ -1195,6 +1217,7 @@ class NS : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit NS(const std::string& type_str); NS(isc::util::InputBuffer& buffer, size_t rdata_len); NS(const NS& other); @@ -1269,6 +1292,7 @@ class NSEC3 : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit NSEC3(const std::string& type_str); NSEC3(isc::util::InputBuffer& buffer, size_t rdata_len); NSEC3(const NSEC3& other); @@ -1282,6 +1306,8 @@ public: // END_COMMON_MEMBERS NSEC3& operator=(const NSEC3& source); + + /// \brief Destructor ~NSEC3(); uint8_t getHashalg() const; @@ -1346,6 +1372,7 @@ class NSEC3PARAM : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit NSEC3PARAM(const std::string& type_str); NSEC3PARAM(isc::util::InputBuffer& buffer, size_t rdata_len); NSEC3PARAM(const NSEC3PARAM& other); @@ -1359,6 +1386,8 @@ public: // END_COMMON_MEMBERS NSEC3PARAM& operator=(const NSEC3PARAM& source); + + /// \brief Destructor ~NSEC3PARAM(); /// @@ -1423,6 +1452,7 @@ class NSEC : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit NSEC(const std::string& type_str); NSEC(isc::util::InputBuffer& buffer, size_t rdata_len); NSEC(const NSEC& other); @@ -1436,6 +1466,8 @@ public: // END_COMMON_MEMBERS NSEC& operator=(const NSEC& source); + + /// \brief Destructor ~NSEC(); // specialized methods @@ -1498,6 +1530,7 @@ class OPT : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit OPT(const std::string& type_str); OPT(isc::util::InputBuffer& buffer, size_t rdata_len); OPT(const OPT& other); @@ -1511,9 +1544,12 @@ public: // END_COMMON_MEMBERS - // The default constructor makes sense for OPT as it can be empty. + /// \brief The default constructor makes sense for OPT as it can be empty. OPT(); + OPT& operator=(const OPT& source); + + /// \brief Destructor ~OPT(); /// \brief A class representing a pseudo RR (or option) within an @@ -1606,6 +1642,7 @@ class PTR : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit PTR(const std::string& type_str); PTR(isc::util::InputBuffer& buffer, size_t rdata_len); PTR(const PTR& other); @@ -1679,6 +1716,7 @@ class RP : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit RP(const std::string& type_str); RP(isc::util::InputBuffer& buffer, size_t rdata_len); RP(const RP& other); @@ -1785,6 +1823,7 @@ class RRSIG : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit RRSIG(const std::string& type_str); RRSIG(isc::util::InputBuffer& buffer, size_t rdata_len); RRSIG(const RRSIG& other); @@ -1798,6 +1837,8 @@ public: // END_COMMON_MEMBERS RRSIG& operator=(const RRSIG& source); + + /// \brief Destructor ~RRSIG(); // specialized methods @@ -1852,6 +1893,7 @@ class SOA : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit SOA(const std::string& type_str); SOA(isc::util::InputBuffer& buffer, size_t rdata_len); SOA(const SOA& other); @@ -1937,6 +1979,7 @@ class SPF : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit SPF(const std::string& type_str); SPF(isc::util::InputBuffer& buffer, size_t rdata_len); SPF(const SPF& other); @@ -1961,7 +2004,7 @@ public: /// intact. SPF& operator=(const SPF& source); - /// \brief The destructor. + /// \brief Destructor ~SPF(); /// @@ -2025,6 +2068,7 @@ class SSHFP : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit SSHFP(const std::string& type_str); SSHFP(isc::util::InputBuffer& buffer, size_t rdata_len); SSHFP(const SSHFP& other); @@ -2038,9 +2082,12 @@ public: // END_COMMON_MEMBERS + /// \brief Constructor SSHFP(uint8_t algorithm, uint8_t fingerprint_type, const std::string& fingerprint); SSHFP& operator=(const SSHFP& source); + + /// \brief Destructor ~SSHFP(); /// @@ -2104,7 +2151,8 @@ class TLSA : public Rdata { public: // BEGIN_COMMON_MEMBERS - explicit TLSA(const std::string& tlsa_str); + /// \brief Constructor + explicit TLSA(const std::string& type_str); TLSA(isc::util::InputBuffer& buffer, size_t rdata_len); TLSA(const TLSA& other); TLSA( @@ -2117,9 +2165,12 @@ public: // END_COMMON_MEMBERS + /// \brief Constructor TLSA(uint8_t certificate_usage, uint8_t selector, uint8_t matching_type, const std::string& certificate_assoc_data); TLSA& operator=(const TLSA& source); + + /// \brief Destructor ~TLSA(); /// @@ -2185,6 +2236,7 @@ class TXT : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit TXT(const std::string& type_str); TXT(isc::util::InputBuffer& buffer, size_t rdata_len); TXT(const TXT& other); @@ -2199,6 +2251,8 @@ public: // END_COMMON_MEMBERS TXT& operator=(const TXT& source); + + /// \brief Destructor ~TXT(); private: @@ -2247,6 +2301,7 @@ class A : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit A(const std::string& type_str); A(isc::util::InputBuffer& buffer, size_t rdata_len); A(const A& other); @@ -2302,6 +2357,7 @@ class A : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit A(const std::string& type_str); A(isc::util::InputBuffer& buffer, size_t rdata_len); A(const A& other); @@ -2315,10 +2371,10 @@ public: // END_COMMON_MEMBERS - //We can use the default destructor. - //virtual ~A() {} + // We can use the default destructor. + // virtual ~A() = default // notyet: - //const struct in_addr& getAddress() const { return (addr_); } + // const struct in_addr& getAddress() const { return (addr_); } private: uint32_t addr_; // raw IPv4 address (network byte order) }; @@ -2365,6 +2421,7 @@ class AAAA : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit AAAA(const std::string& type_str); AAAA(isc::util::InputBuffer& buffer, size_t rdata_len); AAAA(const AAAA& other); @@ -2431,6 +2488,7 @@ class DHCID : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit DHCID(const std::string& type_str); DHCID(isc::util::InputBuffer& buffer, size_t rdata_len); DHCID(const DHCID& other); @@ -2509,6 +2567,7 @@ class SRV : public Rdata { public: // BEGIN_COMMON_MEMBERS + /// \brief Constructor explicit SRV(const std::string& type_str); SRV(isc::util::InputBuffer& buffer, size_t rdata_len); SRV(const SRV& other); @@ -2533,7 +2592,7 @@ public: /// intact. SRV& operator=(const SRV& source); - /// \brief The destructor. + /// \brief Destructor ~SRV(); /// diff --git a/src/lib/dns/rdatafields.cc b/src/lib/dns/rdatafields.cc index e02ec8ff87c59bd70e94ae28378b1c68d68ec9a0..f3c8f38c39eae51b453cbd9cdf82add324cdcb1d 100644 --- a/src/lib/dns/rdatafields.cc +++ b/src/lib/dns/rdatafields.cc @@ -64,18 +64,36 @@ namespace { // it's hopefully an acceptable practice. class RdataFieldComposer : public AbstractMessageRenderer { public: + + /// @brief Constructor RdataFieldComposer() : truncated_(false), length_limit_(65535), - mode_(CASE_INSENSITIVE), last_data_pos_(0) - {} - virtual ~RdataFieldComposer() {} - virtual bool isTruncated() const { return (truncated_); } - virtual size_t getLengthLimit() const { return (length_limit_); } - virtual CompressMode getCompressMode() const { return (mode_); } - virtual void setTruncated() { truncated_ = true; } - virtual void setLengthLimit(size_t len) { length_limit_ = len; } - virtual void setCompressMode(CompressMode mode) { mode_ = mode; } - virtual void writeName(const LabelSequence&, bool) {} + mode_(CASE_INSENSITIVE), last_data_pos_(0) { + } + + /// @brief Destructor + virtual ~RdataFieldComposer() = default; + + virtual bool isTruncated() const { + return (truncated_); + } + virtual size_t getLengthLimit() const { + return (length_limit_); + } + virtual CompressMode getCompressMode() const { + return (mode_); + } + virtual void setTruncated() { + truncated_ = true; + } + virtual void setLengthLimit(size_t len) { + length_limit_ = len; + } + virtual void setCompressMode(CompressMode mode) { + mode_ = mode; + } + virtual void writeName(const LabelSequence&, bool) { + } virtual void writeName(const Name& name, bool compress) { extendData(); const RdataFields::Type field_type = @@ -148,8 +166,7 @@ RdataFields::RdataFields(const void* fields, const unsigned int fields_length, nfields_(fields_length / sizeof(*fields_)), data_(static_cast(data)), data_length_(data_length), - detail_(NULL) -{ + detail_(NULL) { if ((fields_ == NULL && nfields_ > 0) || (fields_ != NULL && nfields_ == 0)) { isc_throw(InvalidParameter, @@ -176,7 +193,10 @@ RdataFields::RdataFields(const void* fields, const unsigned int fields_length, } RdataFields::~RdataFields() { - delete detail_; + try { + delete detail_; + } catch (...) { + } } RdataFields::FieldSpec @@ -211,6 +231,7 @@ void RdataFields::toWire(OutputBuffer& buffer) const { buffer.writeData(data_, data_length_); } + } // end of namespace rdata } // end of namespace dns } // end of namespace isc diff --git a/src/lib/dns/rdatafields.h b/src/lib/dns/rdatafields.h index c4a64ad79860a0800bc05c1d283f81d9370c9a24..167a4ebc296b7acbc0587b534c6c76b55b0f2b09 100644 --- a/src/lib/dns/rdatafields.h +++ b/src/lib/dns/rdatafields.h @@ -223,6 +223,7 @@ private: RdataFields& operator=(const RdataFields& source); public: + /// Constructor from Rdata. /// /// This constructor converts the data of a given \c Rdata object into @@ -246,7 +247,7 @@ public: /// \param rdata The RDATA for which the \c RdataFields to be constructed. RdataFields(const Rdata& rdata); - /// Constructor from field parameters. + /// \brief Constructor from field parameters. /// /// The intended usage of this version of constructor is to form a /// structured representation of \c RDATA encoded by the other @@ -295,7 +296,7 @@ public: RdataFields(const void* fields, const unsigned int fields_length, const void* data, const size_t data_length); - /// The destructor. + /// \brief The destructor. ~RdataFields(); //@} diff --git a/src/lib/dns/rrcollator.cc b/src/lib/dns/rrcollator.cc index 83780216750123b597a998d139b054cdeef5759e..f58ef72610062bb5d22fabdc5a5836e7de1da1fb 100644 --- a/src/lib/dns/rrcollator.cc +++ b/src/lib/dns/rrcollator.cc @@ -80,11 +80,14 @@ RRCollator::Impl::addRR(const Name& name, const RRClass& rrclass, } RRCollator::RRCollator(const AddRRsetCallback& callback) : - impl_(new Impl(callback)) -{} + impl_(new Impl(callback)) { +} RRCollator::~RRCollator() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } AddRRCallback diff --git a/src/lib/dns/rrparamregistry-placeholder.cc b/src/lib/dns/rrparamregistry-placeholder.cc index 455c117d69922bbe477307208c23ca0596fff5b4..89951694ea2fd512da4423737a6877933b8d2609 100644 --- a/src/lib/dns/rrparamregistry-placeholder.cc +++ b/src/lib/dns/rrparamregistry-placeholder.cc @@ -214,7 +214,10 @@ RRParamRegistry::RRParamRegistry() { } RRParamRegistry::~RRParamRegistry() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } RRParamRegistry& diff --git a/src/lib/dns/rrparamregistry.cc b/src/lib/dns/rrparamregistry.cc index 48505934281413a2de9f2363870616766d229e48..995dff0251b4ca2b650df023f4722f03a2077f96 100644 --- a/src/lib/dns/rrparamregistry.cc +++ b/src/lib/dns/rrparamregistry.cc @@ -315,7 +315,10 @@ RRParamRegistry::RRParamRegistry() { } RRParamRegistry::~RRParamRegistry() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } RRParamRegistry& diff --git a/src/lib/dns/rrparamregistry.h b/src/lib/dns/rrparamregistry.h index 27e8a4fc2d7d06c798bfcefb52bea53c0fd7b3c0..a2c82adf8dd619f61ce830c36c06a87161f79265 100644 --- a/src/lib/dns/rrparamregistry.h +++ b/src/lib/dns/rrparamregistry.h @@ -60,14 +60,17 @@ class AbstractRdataFactory { /// //@{ protected: + /// The default constructor /// /// This is intentionally defined as \c protected as this base class should /// never be instantiated (except as part of a derived class). - AbstractRdataFactory() {} + AbstractRdataFactory() = default; + public: + /// The destructor. - virtual ~AbstractRdataFactory() {}; + virtual ~AbstractRdataFactory() = default; //@} /// @@ -175,10 +178,17 @@ class RRParamRegistry { /// These are intentionally hidden (see the class description). //@{ private: + + /// @brief Constructor RRParamRegistry(); + + /// @brief Copy constructor RRParamRegistry(const RRParamRegistry& orig); + + /// @brief Destructor ~RRParamRegistry(); //@} + public: /// /// \brief Return the singleton instance of \c RRParamRegistry. diff --git a/src/lib/dns/rrset.cc b/src/lib/dns/rrset.cc index b2170029d48f21fa4ddceb421e2c6765d5d953d5..ef273ca5538b2299bb666c107ffd08c9f6571e8f 100644 --- a/src/lib/dns/rrset.cc +++ b/src/lib/dns/rrset.cc @@ -229,13 +229,15 @@ BasicRRsetImpl::toWire(AbstractMessageRenderer& renderer, size_t limit) const { } BasicRRset::BasicRRset(const Name& name, const RRClass& rrclass, - const RRType& rrtype, const RRTTL& ttl) -{ + const RRType& rrtype, const RRTTL& ttl) { impl_ = new BasicRRsetImpl(name, rrclass, rrtype, ttl); } BasicRRset::~BasicRRset() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } void @@ -349,13 +351,10 @@ BasicRRset::toWire(AbstractMessageRenderer& renderer) const { RRset::RRset(const Name& name, const RRClass& rrclass, const RRType& rrtype, const RRTTL& ttl) : - BasicRRset(name, rrclass, rrtype, ttl) -{ + BasicRRset(name, rrclass, rrtype, ttl) { rrsig_ = RRsetPtr(); } -RRset::~RRset() {} - unsigned int RRset::getRRsigDataCount() const { if (rrsig_) { @@ -416,12 +415,14 @@ namespace { class BasicRdataIterator : public RdataIterator { public: + /// @brief Constructor. BasicRdataIterator(const std::vector& datavector) : - datavector_(&datavector), it_(datavector_->begin()) {} + datavector_(&datavector), it_(datavector_->begin()) { + } /// @brief Destructor. - ~BasicRdataIterator() {} + ~BasicRdataIterator() = default; /// @brief Set iterator at first position. virtual void first() { diff --git a/src/lib/dns/rrset.h b/src/lib/dns/rrset.h index d17846aa97b073a0002005c202d5f17ffb641def..2bbc082df50b283b46c59551a1d1b882a3e760bd 100644 --- a/src/lib/dns/rrset.h +++ b/src/lib/dns/rrset.h @@ -162,14 +162,17 @@ private: AbstractRRset(const AbstractRRset& source); AbstractRRset& operator=(const AbstractRRset& source); protected: + /// \brief The default constructor. /// /// This is intentionally defined as \c protected as this base class should /// never be instantiated (except as part of a derived class). - AbstractRRset() {} + AbstractRRset() = default; + public: + /// The destructor. - virtual ~AbstractRRset() {} + virtual ~AbstractRRset() = default; //@} /// @@ -563,14 +566,17 @@ class RdataIterator { /// defined as private to make it explicit that this is a pure base class. //@{ protected: + /// \brief The default constructor. /// /// This is intentionally defined as \c protected as this base class should /// never be instantiated (except as part of a derived class). - RdataIterator() {} + RdataIterator() = default; + public: + /// \brief Destructor - virtual ~RdataIterator() {} + virtual ~RdataIterator() = default; private: RdataIterator(const RdataIterator& source); RdataIterator& operator=(const RdataIterator& source); @@ -639,6 +645,7 @@ private: BasicRRset(const BasicRRset& source); BasicRRset& operator=(const BasicRRset& source); public: + /// \brief Constructor from (mostly) fixed parameters of the RRset. /// /// This constructor is normally expected to be exception free, but @@ -651,6 +658,7 @@ public: /// \param ttl The TTL of the RRset. BasicRRset(const Name& name, const RRClass& rrclass, const RRType& rrtype, const RRTTL& ttl); + /// \brief The destructor. virtual ~BasicRRset(); //@} @@ -846,10 +854,13 @@ private: /// QNAME/QTYPE/QCLASS as a single object. class RRset : public BasicRRset { public: + + /// \brief Constructor RRset(const Name& name, const RRClass& rrclass, const RRType& rrtype, const RRTTL& ttl); - virtual ~RRset(); + /// \brief Destructor + virtual ~RRset() = default; /// \brief Get the wire format length of the \c RRset. /// diff --git a/src/lib/dns/rrset_collection.h b/src/lib/dns/rrset_collection.h index 7fb1e9c78bef74b124104eb27f818fcde2f3ce55..ba0306df4f4d3a3c7ae15d57bb34b7a05e9d45c2 100644 --- a/src/lib/dns/rrset_collection.h +++ b/src/lib/dns/rrset_collection.h @@ -22,12 +22,13 @@ namespace dns { /// container. class RRsetCollection : public RRsetCollectionBase { public: + /// \brief Constructor. /// /// This constructor creates an empty collection without any data in /// it. RRsets can be added to the collection with the \c addRRset() /// method. - RRsetCollection() {} + RRsetCollection() = default; /// \brief Constructor. /// @@ -58,7 +59,7 @@ public: const isc::dns::RRClass& rrclass); /// \brief Destructor - virtual ~RRsetCollection() {} + virtual ~RRsetCollection() = default; /// \brief Add an RRset to the collection. /// diff --git a/src/lib/dns/rrset_collection_base.h b/src/lib/dns/rrset_collection_base.h index ac77756e417a7ecdc3af3443b7fe5ef7c91eaaf7..85ffa3d8d7381d30172789337a97f715cd3c3e04 100644 --- a/src/lib/dns/rrset_collection_base.h +++ b/src/lib/dns/rrset_collection_base.h @@ -93,8 +93,11 @@ public: const isc::dns::RRType& rrtype) const = 0; + /// \brief Constructor + RRsetCollectionBase() = default; + /// \brief Destructor - virtual ~RRsetCollectionBase() {} + virtual ~RRsetCollectionBase() = default; protected: class Iter; // forward declaration @@ -112,7 +115,12 @@ protected: /// iterator only. class Iter { public: - virtual ~Iter() {}; + + /// @brief Constructor + Iter() = default; + + /// @brief Destructor + virtual ~Iter() = default; /// \brief Returns the \c AbstractRRset currently pointed to by /// the iterator. diff --git a/src/lib/dns/tests/nsec3hash_unittest.cc b/src/lib/dns/tests/nsec3hash_unittest.cc index b47bb4969bebca7039e05b3833d22c2b2052bddd..2fff8c71c121f0eb15a12f78dd0eac2a06d43b1a 100644 --- a/src/lib/dns/tests/nsec3hash_unittest.cc +++ b/src/lib/dns/tests/nsec3hash_unittest.cc @@ -32,6 +32,8 @@ const char* const nsec3_common = "2T7B4G4VSA5SMI47K61MV5BV1A22BOJR A RRSIG"; class NSEC3HashTest : public ::testing::Test { protected: + + /// @brief Constructor NSEC3HashTest() : test_hash(NSEC3Hash::create(generic::NSEC3PARAM("1 0 12 aabbccdd"))), test_hash_nsec3(NSEC3Hash::create(generic::NSEC3 @@ -42,9 +44,13 @@ protected: test_hash_args.reset(NSEC3Hash::create(1, 12, salt, sizeof(salt))); } + /// @brief Destructor ~NSEC3HashTest() { - // Make sure we reset the hash creator to the default - setNSEC3HashCreator(NULL); + try { + // Make sure we reset the hash creator to the default + setNSEC3HashCreator(NULL); + } catch (...) { + } } // An NSEC3Hash object commonly used in tests. Parameters are borrowed diff --git a/src/lib/dns/tests/rdatafields_unittest.cc b/src/lib/dns/tests/rdatafields_unittest.cc index 0531439574edb30f7b46eeb2e8b9fc431d79ac2f..98b2ae356f68d45ecac75319e721a0ccb81ef38a 100644 --- a/src/lib/dns/tests/rdatafields_unittest.cc +++ b/src/lib/dns/tests/rdatafields_unittest.cc @@ -332,9 +332,18 @@ TEST_F(RdataFieldsTest, getFieldSpecWithBadFieldId) { class DummyRdata : public Rdata { public: enum Mode { CLEAR, SKIP, TRIM }; - explicit DummyRdata(Mode mode) : mode_(mode) {} - DummyRdata(const DummyRdata& source) : Rdata(), mode_(source.mode_) {} - virtual ~DummyRdata() {} + + /// @brief Constructor + explicit DummyRdata(Mode mode) : mode_(mode) { + } + + /// @brief Copy constructor + DummyRdata(const DummyRdata& source) : Rdata(), mode_(source.mode_) { + } + + /// @brief Destructor + virtual ~DummyRdata() = default; + virtual void toWire(AbstractMessageRenderer& renderer) const { // call the unexpected method corresponding to the test mode. // method parameters don't matter. diff --git a/src/lib/dns/tests/rrparamregistry_unittest.cc b/src/lib/dns/tests/rrparamregistry_unittest.cc index 90574d095d7d3c1fea0c3bac4138dcec5f042f5d..f160ca575cf6c9787d2c1c9ff1be96bc096842cc 100644 --- a/src/lib/dns/tests/rrparamregistry_unittest.cc +++ b/src/lib/dns/tests/rrparamregistry_unittest.cc @@ -30,8 +30,9 @@ using namespace isc::dns::rdata; namespace { class RRParamRegistryTest : public ::testing::Test { protected: - RRParamRegistryTest() - { + + /// @brief Constructor + RRParamRegistryTest() { ostringstream oss1; oss1 << test_class_code; // cppcheck-suppress useInitializationList @@ -41,16 +42,20 @@ protected: oss2 << test_type_code; test_type_unknown_str = "TYPE" + oss2.str(); } - ~RRParamRegistryTest() - { - // cleanup any non well-known parameters that possibly remain - // as a side effect. - RRParamRegistry::getRegistry().removeType(test_type_code); - RRParamRegistry::getRegistry().removeClass(test_class_code); - RRParamRegistry::getRegistry().removeRdataFactory( - RRType(test_type_code), RRClass(test_class_code)); - RRParamRegistry::getRegistry().removeRdataFactory( - RRType(test_type_code)); + + /// @brief Destructor + ~RRParamRegistryTest() { + try { + // cleanup any non well-known parameters that possibly remain + // as a side effect. + RRParamRegistry::getRegistry().removeType(test_type_code); + RRParamRegistry::getRegistry().removeClass(test_class_code); + RRParamRegistry::getRegistry().removeRdataFactory( + RRType(test_type_code), RRClass(test_class_code)); + RRParamRegistry::getRegistry().removeRdataFactory( + RRType(test_type_code)); + } catch (...) { + } } string test_class_unknown_str; diff --git a/src/lib/dns/tests/tsig_unittest.cc b/src/lib/dns/tests/tsig_unittest.cc index 85b75532c9b7bd40af3da33922ab504fed8c0689..aa0ec6cbfc5cda420a79fef9b8199c14a1dc86ae 100644 --- a/src/lib/dns/tests/tsig_unittest.cc +++ b/src/lib/dns/tests/tsig_unittest.cc @@ -83,6 +83,8 @@ public: class TSIGTest : public ::testing::Test { protected: + + /// @brief Constructor TSIGTest() : tsig_ctx(NULL), qid(0x2d65), test_name("www.example.com"), badkey_name("badkey.example.com"), test_class(RRClass::IN()), @@ -91,8 +93,7 @@ protected: dummy_record(badkey_name, any::TSIG(TSIGKey::HMACMD5_NAME(), 0x4da8877a, TSIGContext::DEFAULT_FUDGE, - 0, NULL, qid, 0, 0, NULL)) - { + 0, NULL, qid, 0, 0, NULL)) { // Make sure we use the system time by default so that we won't be // confused due to other tests that tweak the time. isc::util::detail::gettimeFunction = NULL; @@ -107,8 +108,13 @@ protected: &secret[0], secret.size()))); } + + /// @brief Destructor ~TSIGTest() { - isc::util::detail::gettimeFunction = NULL; + try { + isc::util::detail::gettimeFunction = NULL; + } catch (...) { + } } // Many of the tests below create some DNS message and sign it under diff --git a/src/lib/dns/tests/unittest_util.cc b/src/lib/dns/tests/unittest_util.cc index b234c1cf9ddaa4809f040c3d8c3d0736362c2100..c3d756a6905ff6e2fb5484d5801ee9c10630963d 100644 --- a/src/lib/dns/tests/unittest_util.cc +++ b/src/lib/dns/tests/unittest_util.cc @@ -28,10 +28,17 @@ using isc::UnitTestUtil; namespace { class UnitTestUtilConfig { private: + // This is a singleton object and cannot be constructed explicitly. - UnitTestUtilConfig() {} - UnitTestUtilConfig(const UnitTestUtilConfig& source); - ~UnitTestUtilConfig() {} + /// @brief Constructor + UnitTestUtilConfig() = default; + + /// @brief Copy constructor + UnitTestUtilConfig(const UnitTestUtilConfig& source) = default; + + /// @brief Destructor + ~UnitTestUtilConfig() = default; + public: /// Return a singleton unit test configuration object. On first invocation /// one will be constructed. diff --git a/src/lib/dns/tsig.cc b/src/lib/dns/tsig.cc index 10bc51abbcbb178e0d8d65a68ba2c0bc2b423de8..9cf59009e1a5b4b581dc1609e0067e87d6332e4e 100644 --- a/src/lib/dns/tsig.cc +++ b/src/lib/dns/tsig.cc @@ -243,8 +243,7 @@ const size_t MESSAGE_HEADER_LEN = 12; void TSIGContext::TSIGContextImpl::digestDNSMessage(HMACPtr hmac, uint16_t qid, const void* data, - size_t data_len) const -{ + size_t data_len) const { OutputBuffer buffer(MESSAGE_HEADER_LEN); const uint8_t* msgptr = static_cast(data); @@ -266,13 +265,11 @@ TSIGContext::TSIGContextImpl::digestDNSMessage(HMACPtr hmac, hmac->update(msgptr, data_len - MESSAGE_HEADER_LEN); } -TSIGContext::TSIGContext(const TSIGKey& key) : impl_(new TSIGContextImpl(key)) -{ +TSIGContext::TSIGContext(const TSIGKey& key) : impl_(new TSIGContextImpl(key)) { } TSIGContext::TSIGContext(const Name& key_name, const Name& algorithm_name, - const TSIGKeyRing& keyring) : impl_(NULL) -{ + const TSIGKeyRing& keyring) : impl_(NULL) { const TSIGKeyRing::FindResult result(keyring.find(key_name, algorithm_name)); if (result.code == TSIGKeyRing::NOTFOUND) { @@ -288,7 +285,10 @@ TSIGContext::TSIGContext(const Name& key_name, const Name& algorithm_name, } TSIGContext::~TSIGContext() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } size_t diff --git a/src/lib/dns/tsigkey.cc b/src/lib/dns/tsigkey.cc index ff355d4fa44897e679a07bc4b6f8fc0e6030e323..84c76dbbd4a72d2f2dbee347c977193d02e2e125 100644 --- a/src/lib/dns/tsigkey.cc +++ b/src/lib/dns/tsigkey.cc @@ -207,7 +207,10 @@ TSIGKey::operator=(const TSIGKey& source) { } TSIGKey::~TSIGKey() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } const Name& @@ -310,7 +313,10 @@ TSIGKeyRing::TSIGKeyRing() : impl_(new TSIGKeyRingImpl) { } TSIGKeyRing::~TSIGKeyRing() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } unsigned int diff --git a/src/lib/dns/tsigkey.h b/src/lib/dns/tsigkey.h index 2b8e3d6cf239fc0c20ab2243a8fbbfa9f8f90328..dcadddaae1fd4a314d6a21e34bd62443f3005059 100644 --- a/src/lib/dns/tsigkey.h +++ b/src/lib/dns/tsigkey.h @@ -55,6 +55,7 @@ class Name; /// and more intuitive representations (e.g. strings) for algorithms. class TSIGKey { public: + /// /// \name Constructors, Assignment Operator and Destructor. /// @@ -292,6 +293,7 @@ private: TSIGKeyRing(const TSIGKeyRing& source); TSIGKeyRing& operator=(const TSIGKeyRing& source); public: + /// \brief The default constructor. /// /// This constructor never throws an exception. diff --git a/src/lib/eval/eval_context.cc b/src/lib/eval/eval_context.cc index d91fbb0abc38812fbb023df5a3974863b2c6aeb0..40f9a015e7efa868f562cee88cbe4d2d382e288d 100644 --- a/src/lib/eval/eval_context.cc +++ b/src/lib/eval/eval_context.cc @@ -21,11 +21,7 @@ EvalContext::EvalContext(const Option::Universe& option_universe, CheckDefined check_defined) : trace_scanning_(false), trace_parsing_(false), - option_universe_(option_universe), check_defined_(check_defined) -{ -} - -EvalContext::~EvalContext() { + option_universe_(option_universe), check_defined_(check_defined) { } bool diff --git a/src/lib/eval/eval_context.h b/src/lib/eval/eval_context.h index 38f44a5304e74505fef2ba65c6d8e532bf4ad1d4..809ac8fee68c8ab8ee6a551af4d6ed3402dacc55 100644 --- a/src/lib/eval/eval_context.h +++ b/src/lib/eval/eval_context.h @@ -55,7 +55,7 @@ public: CheckDefined check_defined = acceptAll); /// @brief destructor - virtual ~EvalContext(); + virtual ~EvalContext() = default; /// @brief Accept all client class names /// diff --git a/src/lib/eval/tests/dependency_unittest.cc b/src/lib/eval/tests/dependency_unittest.cc index 1f99bfdc7cb602f26ba71decfb6edbc002de5346..5279b422f0e0f9b7d28012bb4aeb978f2b41bf5e 100644 --- a/src/lib/eval/tests/dependency_unittest.cc +++ b/src/lib/eval/tests/dependency_unittest.cc @@ -30,10 +30,19 @@ namespace { class DependencyTest : public ::testing::Test { public: - /// @brief Reset expression and result. + /// @brief Constructor + DependencyTest() : result_(true) { + } + + /// @brief Destructor + /// + /// Reset expression and result. ~DependencyTest() { - e_.reset(); - result_ = false; + try { + e_.reset(); + result_ = false; + } catch (...) { + } } ExpressionPtr e_; ///< An expression @@ -95,4 +104,4 @@ TEST_F(DependencyTest, matching) { EXPECT_TRUE(result_); } -}; +} diff --git a/src/lib/eval/token.h b/src/lib/eval/token.h index 3e4e3be474c0cb4115ccff187110d80b6ac722cb..249702873aa07036c069fe48f805ec74ec86de00 100644 --- a/src/lib/eval/token.h +++ b/src/lib/eval/token.h @@ -77,8 +77,11 @@ public: /// @param values - stack of values with previously evaluated tokens virtual void evaluate(Pkt& pkt, ValueStack& values) = 0; + /// @brief Constructor + Token() = default; + /// @brief Virtual destructor - virtual ~Token() {} + virtual ~Token() = default; /// @brief Coverts a (string) value to a boolean /// diff --git a/src/lib/exceptions/exceptions.h b/src/lib/exceptions/exceptions.h index f5368c84587c80add646e22bb66e8bccf4d22bc1..bc2b022323ca3c571d5b38ab7c29f55879142bdb 100644 --- a/src/lib/exceptions/exceptions.h +++ b/src/lib/exceptions/exceptions.h @@ -22,6 +22,7 @@ namespace isc { /// class Exception : public std::exception { public: + /// /// \name Constructors and Destructor /// @@ -42,8 +43,8 @@ public: /// @param what a description (type) of the exception. Exception(const char* file, size_t line, const std::string& what); - /// The destructor - virtual ~Exception() throw() {} + /// \brief Destructor + virtual ~Exception() throw() = default; //@} private: /// diff --git a/src/lib/hooks/callout_handle.cc b/src/lib/hooks/callout_handle.cc index e80760ac922aa9420aac4cc520897a7528e5601c..6d48be3750238aa140ca85743ae680ae7f039b3b 100644 --- a/src/lib/hooks/callout_handle.cc +++ b/src/lib/hooks/callout_handle.cc @@ -35,28 +35,31 @@ CalloutHandle::CalloutHandle(const boost::shared_ptr& manager, // Destructor CalloutHandle::~CalloutHandle() { - // Call the "context_destroy" hook. We should be OK doing this - although - // the destructor is being called, all the member variables are still in - // existence. - manager_->callCallouts(ServerHooks::CONTEXT_DESTROY, *this); - - // Explicitly clear the argument and context objects. This should free up - // all memory that could have been allocated by libraries that were loaded. - arguments_.clear(); - context_collection_.clear(); - - // Normal destruction of the remaining variables will include the - // destruction of lm_collection_, an action that decrements the reference - // count on the library manager collection (which holds the libraries that - // could have allocated memory in the argument and context members.) When - // that goes to zero, the libraries will be unloaded: at that point nothing - // in the hooks framework will be pointing to memory in the libraries' - // address space. - // - // It is possible that some other data structure in the server (the program - // using the hooks library) still references the address space and attempts - // to access it causing a segmentation fault. That issue is outside the - // scope of this framework and is not addressed by it. + try { + // Call the "context_destroy" hook. We should be OK doing this - although + // the destructor is being called, all the member variables are still in + // existence. + manager_->callCallouts(ServerHooks::CONTEXT_DESTROY, *this); + + // Explicitly clear the argument and context objects. This should free up + // all memory that could have been allocated by libraries that were loaded. + arguments_.clear(); + context_collection_.clear(); + + // Normal destruction of the remaining variables will include the + // destruction of lm_collection_, an action that decrements the reference + // count on the library manager collection (which holds the libraries that + // could have allocated memory in the argument and context members.) When + // that goes to zero, the libraries will be unloaded: at that point nothing + // in the hooks framework will be pointing to memory in the libraries' + // address space. + // + // It is possible that some other data structure in the server (the program + // using the hooks library) still references the address space and attempts + // to access it causing a segmentation fault. That issue is outside the + // scope of this framework and is not addressed by it. + } catch (...) { + } } // Return the name of all argument items. @@ -148,7 +151,10 @@ ScopedCalloutHandleState(const CalloutHandlePtr& callout_handle) } ScopedCalloutHandleState::~ScopedCalloutHandleState() { - resetState(); + try { + resetState(); + } catch (...) { + } } void diff --git a/src/lib/hooks/callout_handle.h b/src/lib/hooks/callout_handle.h index b9e018b7c026ed34c364d1d3b0789ac533bd93a5..26030c8c8bd1c98279b5009b97e9120869310f3a 100644 --- a/src/lib/hooks/callout_handle.h +++ b/src/lib/hooks/callout_handle.h @@ -89,7 +89,6 @@ public: NEXT_STEP_PARK = 3 ///< park the packet }; - /// Typedef to allow abbreviation of iterator specification in methods. /// The std::string is the argument name and the "boost::any" is the /// corresponding value associated with it. @@ -504,5 +503,4 @@ private: } // namespace hooks } // namespace isc - #endif // CALLOUT_HANDLE_H diff --git a/src/lib/hooks/library_manager.cc b/src/lib/hooks/library_manager.cc index 447c9ebb883975df7cce5d10d27220547a8730b4..0c9788cf0f0381bd7e35b6c6b18e3e87143c343a 100644 --- a/src/lib/hooks/library_manager.cc +++ b/src/lib/hooks/library_manager.cc @@ -50,20 +50,23 @@ LibraryManager::LibraryManager(const std::string& name, int index, // The only method to do so is "validateLibrary", which takes care not to call // methods requiring a non-NULL manager. LibraryManager::LibraryManager(const std::string& name) - : dl_handle_(NULL), index_(-1), manager_(), library_name_(name) -{} + : dl_handle_(NULL), index_(-1), manager_(), library_name_(name) { +} // Destructor. LibraryManager::~LibraryManager() { - if (index_ >= 0) { - // LibraryManager instantiated to load a library, so ensure that - // it is unloaded before exiting. - static_cast(prepareUnloadLibrary()); - } + try { + if (index_ >= 0) { + // LibraryManager instantiated to load a library, so ensure that + // it is unloaded before exiting. + static_cast(prepareUnloadLibrary()); + } - // LibraryManager instantiated to validate a library, so just ensure - // that it is closed before exiting. - static_cast(closeLibrary()); + // LibraryManager instantiated to validate a library, so just ensure + // that it is closed before exiting. + static_cast(closeLibrary()); + } catch (...) { + } } // Open the library diff --git a/src/lib/hooks/library_manager.h b/src/lib/hooks/library_manager.h index f3a376fa627bf154a55302b51b00a829caf548df..bdc10584bbfe0d4d55672dcbed356421d07ac96a 100644 --- a/src/lib/hooks/library_manager.h +++ b/src/lib/hooks/library_manager.h @@ -72,6 +72,7 @@ class LibraryManager; class LibraryManager { public: + /// @brief Constructor /// /// This constructor is used by external agencies (i.e. the diff --git a/src/lib/hooks/library_manager_collection.h b/src/lib/hooks/library_manager_collection.h index 53a9669a49fac2a413a029aa2805b5b6780bd6d0..433fad912cd752d3996093a0675245c78fc68089 100644 --- a/src/lib/hooks/library_manager_collection.h +++ b/src/lib/hooks/library_manager_collection.h @@ -69,6 +69,7 @@ class LibraryManager; class LibraryManagerCollection { public: + /// @brief Constructor /// /// @param libraries List of libraries that this collection will manage. @@ -80,7 +81,10 @@ public: /// /// Unloads all loaded libraries. ~LibraryManagerCollection() { - static_cast(unloadLibraries()); + try { + static_cast(unloadLibraries()); + } catch (...) { + } } /// @brief Load libraries diff --git a/src/lib/hooks/tests/hooks_manager_unittest.cc b/src/lib/hooks/tests/hooks_manager_unittest.cc index a36d42ce0da723e3a0031a92decc044854d00f1c..7009c16a429886c822e5bda01ed1f3f3abd60dac 100644 --- a/src/lib/hooks/tests/hooks_manager_unittest.cc +++ b/src/lib/hooks/tests/hooks_manager_unittest.cc @@ -36,6 +36,7 @@ namespace { class HooksManagerTest : public ::testing::Test, public HooksCommonTestClass { public: + /// @brief Constructor /// /// Reset the hooks manager. The hooks manager is a singleton, so needs @@ -55,12 +56,15 @@ public: /// /// Unload all libraries. ~HooksManagerTest() { - static_cast(remove(MARKER_FILE)); - HooksManager::setTestMode(false); - HooksManager::prepareUnloadLibraries(); - bool status = HooksManager::unloadLibraries(); - if (!status) { - cerr << "(fixture dtor) unloadLibraries failed" << endl; + try { + static_cast(remove(MARKER_FILE)); + HooksManager::setTestMode(false); + HooksManager::prepareUnloadLibraries(); + bool status = HooksManager::unloadLibraries(); + if (!status) { + cerr << "(fixture dtor) unloadLibraries failed" << endl; + } + } catch (...) { } } @@ -1077,5 +1081,4 @@ TEST_F(HooksManagerTest, UnloadBeforeUnpark) { EXPECT_FALSE(unparked); } - } // Anonymous namespace diff --git a/src/lib/hooks/tests/library_manager_unittest.cc b/src/lib/hooks/tests/library_manager_unittest.cc index c0174a41bf5f41100428e841346ca18627e93920..c0546d9eef8db75d049f0fc29232bf1b1152f1a5 100644 --- a/src/lib/hooks/tests/library_manager_unittest.cc +++ b/src/lib/hooks/tests/library_manager_unittest.cc @@ -42,6 +42,7 @@ namespace { class LibraryManagerTest : public ::testing::Test, public HooksCommonTestClass { public: + /// @brief Constructor /// /// Initializes the CalloutManager object used in the tests. It sets it @@ -61,10 +62,13 @@ public: /// /// Ensures a marker file is removed after each test. ~LibraryManagerTest() { - static_cast(remove(MARKER_FILE)); + try { + static_cast(remove(MARKER_FILE)); - // Disable multi-threading. - MultiThreadingMgr::instance().setMode(false); + // Disable multi-threading. + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } /// @brief Marker file present diff --git a/src/lib/http/auth_config.h b/src/lib/http/auth_config.h index 3f76033f0122292dbdf92dbc06179da64f689df5..1e315f9995bdf4e3356b5eddd3a711d315fd83d4 100644 --- a/src/lib/http/auth_config.h +++ b/src/lib/http/auth_config.h @@ -23,8 +23,11 @@ class HttpAuthConfig : public isc::data::UserContext, public isc::data::CfgToElement { public: + /// @brief Constructor. + HttpAuthConfig() = default; + /// @brief Destructor. - virtual ~HttpAuthConfig() { } + virtual ~HttpAuthConfig() = default; /// @brief Set the realm. /// diff --git a/src/lib/http/basic_auth_config.h b/src/lib/http/basic_auth_config.h index 80417d7dd70b75b895af9900361e69fa2401b40a..dd80af41706fd695f0e2e7ae293f693b595c07ca 100644 --- a/src/lib/http/basic_auth_config.h +++ b/src/lib/http/basic_auth_config.h @@ -67,8 +67,11 @@ typedef std::list BasicHttpAuthClientList; class BasicHttpAuthConfig : public HttpAuthConfig { public: + /// @brief Constructor + BasicHttpAuthConfig() = default; + /// @brief Destructor. - virtual ~BasicHttpAuthConfig() { } + virtual ~BasicHttpAuthConfig() = default; /// @brief Add a client configuration. /// diff --git a/src/lib/http/client.cc b/src/lib/http/client.cc index 6067898ad32351e9070356d69968ae31f4f37dff..050e806eef643e91485761c837d0226a1fab23ff 100644 --- a/src/lib/http/client.cc +++ b/src/lib/http/client.cc @@ -487,7 +487,10 @@ public: /// /// Closes all connections. ~ConnectionPool() { - closeAll(); + try { + closeAll(); + } catch (...) { + } } /// @brief Process next queued request for the given URL and TLS context. @@ -805,6 +808,7 @@ private: /// @brief Encapsulates connections and requests for a given URL class Destination { public: + /// @brief Constructor /// /// @param url server URL of this destination @@ -818,7 +822,10 @@ private: /// @brief Destructor ~Destination() { - closeAllConnections(); + try { + closeAllConnections(); + } catch (...) { + } } /// @brief Adds a new connection @@ -1103,7 +1110,10 @@ Connection::Connection(IOService& io_service, } Connection::~Connection() { - close(); + try { + close(); + } catch (...) { + } } void @@ -1724,6 +1734,7 @@ namespace http { /// @brief HttpClient implementation. class HttpClientImpl { public: + /// @brief Constructor. /// /// If single-threading: @@ -1775,7 +1786,10 @@ public: /// /// Calls stop(). ~HttpClientImpl() { - stop(); + try { + stop(); + } catch (...) { + } } /// @brief Starts running the client's thread pool, if multi-threaded. @@ -1914,9 +1928,6 @@ HttpClient::HttpClient(IOService& io_service, size_t thread_pool_size, defer_thread_start)); } -HttpClient::~HttpClient() { -} - void HttpClient::asyncSendRequest(const Url& url, const TlsContextPtr& tls_context, diff --git a/src/lib/http/client.h b/src/lib/http/client.h index 34a0a23accb2c3982955bde991c68a158a562272..bafca5efaf73c32353dd1e41fed0d9f8d2bcf86a 100644 --- a/src/lib/http/client.h +++ b/src/lib/http/client.h @@ -145,11 +145,12 @@ public: /// the thread pool threads will be created and started, with the /// operational state being RUNNING. Applicable only when thread-pool size /// is greater than zero. - explicit HttpClient(asiolink::IOService& io_service, size_t thread_pool_size = 0, + explicit HttpClient(asiolink::IOService& io_service, + size_t thread_pool_size = 0, bool defer_thread_start = false); /// @brief Destructor. - ~HttpClient(); + ~HttpClient() = default; /// @brief Queues new asynchronous HTTP request for a given URL. /// diff --git a/src/lib/http/connection.cc b/src/lib/http/connection.cc index ba238ac4310639df17b8310b482a7a3d4aa12cb3..52c4f49a0e23c38591f6fb20969d73b8ff53a435 100644 --- a/src/lib/http/connection.cc +++ b/src/lib/http/connection.cc @@ -89,7 +89,10 @@ HttpConnection::HttpConnection(asiolink::IOService& io_service, } HttpConnection::~HttpConnection() { - close(); + try { + close(); + } catch (...) { + } } void diff --git a/src/lib/http/http_message.cc b/src/lib/http/http_message.cc index ce012cafaea36287e1c9dc0c527fe43c77c3a4eb..6c34583838c88ff28964a58bb689b6eb929f7b57 100644 --- a/src/lib/http/http_message.cc +++ b/src/lib/http/http_message.cc @@ -17,9 +17,6 @@ HttpMessage::HttpMessage(const HttpMessage::Direction& direction) created_(false), finalized_(false), headers_() { } -HttpMessage::~HttpMessage() { -} - void HttpMessage::requireHttpVersion(const HttpVersion& version) { required_versions_.insert(version); diff --git a/src/lib/http/http_message.h b/src/lib/http/http_message.h index 3634c80fa75181e8df937bfd433df3060e7c998f..6d63e422b82bd64e50e70cde64dc383d106a04b5 100644 --- a/src/lib/http/http_message.h +++ b/src/lib/http/http_message.h @@ -74,7 +74,7 @@ public: explicit HttpMessage(const Direction& direction); /// @brief Destructor. - virtual ~HttpMessage(); + virtual ~HttpMessage() = default; /// @brief Returns HTTP message direction. Direction getDirection() const { diff --git a/src/lib/http/http_thread_pool.cc b/src/lib/http/http_thread_pool.cc index 7e649f5f39b56ed22a2ec396f4f22d98aa81436e..a08a0f078ab704ebe74f45cadc8234f4d15e22ed 100644 --- a/src/lib/http/http_thread_pool.cc +++ b/src/lib/http/http_thread_pool.cc @@ -51,7 +51,10 @@ HttpThreadPool::HttpThreadPool(IOServicePtr io_service, size_t pool_size, } HttpThreadPool::~HttpThreadPool() { - stop(); + try { + stop(); + } catch (...) { + } } void diff --git a/src/lib/http/listener.cc b/src/lib/http/listener.cc index 2e6d2e1c62b4c7d6e9eb3f8c306ef1c23e32c3ee..53346bf95d876b346064d81e9814cfdc3fb37429 100644 --- a/src/lib/http/listener.cc +++ b/src/lib/http/listener.cc @@ -29,7 +29,10 @@ HttpListener::HttpListener(IOService& io_service, } HttpListener::~HttpListener() { - stop(); + try { + stop(); + } catch (...) { + } } IOAddress diff --git a/src/lib/http/listener_impl.h b/src/lib/http/listener_impl.h index 4ad19608440ec576db135c8aab6dcf996889ac6f..b6b2a1c0dd6266e8217d102dd9067b6899c9bc7a 100644 --- a/src/lib/http/listener_impl.h +++ b/src/lib/http/listener_impl.h @@ -53,8 +53,7 @@ public: const long idle_timeout); /// @brief Virtual destructor. - virtual ~HttpListenerImpl() { - } + virtual ~HttpListenerImpl() = default; /// @brief Returns reference to the current listener endpoint. const asiolink::TCPEndpoint& getEndpoint() const; diff --git a/src/lib/http/response_creator.h b/src/lib/http/response_creator.h index ac212fe5de6cf119b691af373fdd2e51c628de90..6369244cc328a78b6ef418922349c97498a9a46c 100644 --- a/src/lib/http/response_creator.h +++ b/src/lib/http/response_creator.h @@ -38,10 +38,13 @@ typedef boost::shared_ptr HttpResponseCreatorPtr; class HttpResponseCreator { public: + /// @brief Constructor. + HttpResponseCreator() = default; + /// @brief Destructor. /// /// Classes with virtual functions need virtual destructors. - virtual ~HttpResponseCreator() { }; + virtual ~HttpResponseCreator() = default; /// @brief Create HTTP response from HTTP request received. /// @@ -104,7 +107,6 @@ protected: /// @return Pointer to an object representing HTTP response. virtual HttpResponsePtr createDynamicHttpResponse(HttpRequestPtr request) = 0; - }; } // namespace http diff --git a/src/lib/http/response_creator_factory.h b/src/lib/http/response_creator_factory.h index c2fc9178a53fd70ab5768a059026bfdbe99341ff..e7348894c3742a09ecc5b5e17b3afbd29db2a5fe 100644 --- a/src/lib/http/response_creator_factory.h +++ b/src/lib/http/response_creator_factory.h @@ -35,8 +35,11 @@ namespace http { class HttpResponseCreatorFactory { public: + /// @brief Constructor. + HttpResponseCreatorFactory() = default; + /// @brief Virtual destructor. - virtual ~HttpResponseCreatorFactory() { } + virtual ~HttpResponseCreatorFactory() = default; /// @brief Returns an instance of the @ref HttpResponseCreator. /// @@ -46,7 +49,6 @@ public: /// @return Pointer to the instance of the @ref HttpResponseCreator to /// be used to generate HTTP response. virtual HttpResponseCreatorPtr create() const = 0; - }; /// @brief Pointer to the @ref HttpResponseCreatorFactory. diff --git a/src/lib/http/tests/client_mt_unittests.cc b/src/lib/http/tests/client_mt_unittests.cc index df09d1ad3e4beb5b24942ec5e1ba6bd7164443cf..82e1b60cce5ffab69d3b3c51733d0fba2d9c5367 100644 --- a/src/lib/http/tests/client_mt_unittests.cc +++ b/src/lib/http/tests/client_mt_unittests.cc @@ -207,17 +207,20 @@ public: /// @brief Destructor. ~MtHttpClientTest() { - // Stop the client. - if (client_) { - client_->stop(); - } + try { + // Stop the client. + if (client_) { + client_->stop(); + } - // Stop all listeners. - for (const auto& listener : listeners_) { - listener->stop(); - } + // Stop all listeners. + for (const auto& listener : listeners_) { + listener->stop(); + } - MultiThreadingMgr::instance().setMode(false); + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } /// @brief Callback function to invoke upon test timeout. diff --git a/src/lib/http/tests/connection_pool_unittests.cc b/src/lib/http/tests/connection_pool_unittests.cc index b8337c3d36dad5a23eaa0ecb73ca1b5a7fba2f71..f25a6eb180167e22124d8767eb6f38d55b19c17c 100644 --- a/src/lib/http/tests/connection_pool_unittests.cc +++ b/src/lib/http/tests/connection_pool_unittests.cc @@ -114,7 +114,10 @@ public: /// @brief Destructor. ~HttpConnectionPoolTest() { - MultiThreadingMgr::instance().setMode(false); + try { + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } /// @brief Verifies that connections can be added to the pool and removed. diff --git a/src/lib/http/tests/http_thread_pool_unittests.cc b/src/lib/http/tests/http_thread_pool_unittests.cc index fcc088bd773997bca66d33f0d4ac536fb03b6461..cf623e7e9a3ff77a6c3e435fca6f306b6d227f9b 100644 --- a/src/lib/http/tests/http_thread_pool_unittests.cc +++ b/src/lib/http/tests/http_thread_pool_unittests.cc @@ -27,6 +27,7 @@ const long TEST_TIMEOUT = 10000; /// @brief Simple test fixture for testing HttpThreadPool. class HttpThreadPoolTest : public ::testing::Test { public: + /// @brief Constructor. HttpThreadPoolTest() : io_service_(new IOService()) { @@ -34,7 +35,10 @@ public: /// @brief Destructor. virtual ~HttpThreadPoolTest() { - io_service_->stop(); + try { + io_service_->stop(); + } catch (...) { + } } /// @brief IOService instance used by thread pools. diff --git a/src/lib/http/tests/request_test.h b/src/lib/http/tests/request_test.h index f73b31f7866bf2248dfe066b2686ec126f0387df..e3891ef126f78ee1c9d07db5ba496ac675e8cc49 100644 --- a/src/lib/http/tests/request_test.h +++ b/src/lib/http/tests/request_test.h @@ -37,8 +37,7 @@ public: /// @brief Destructor. /// /// Does nothing. - virtual ~HttpRequestTestBase() { - } + virtual ~HttpRequestTestBase() = default; /// @brief Initializes HTTP request context with basic information. /// diff --git a/src/lib/http/tests/server_client_unittests.cc b/src/lib/http/tests/server_client_unittests.cc index 4b466a0e3f719e2fb744f41038c6e0678307d18f..879274c527491dc3baa3b431e2753c981999a9c2 100644 --- a/src/lib/http/tests/server_client_unittests.cc +++ b/src/lib/http/tests/server_client_unittests.cc @@ -409,9 +409,12 @@ public: /// /// Removes active HTTP clients. virtual ~HttpListenerTest() { - for (auto client = clients_.begin(); client != clients_.end(); - ++client) { - (*client)->close(); + try { + for (auto client = clients_.begin(); client != clients_.end(); + ++client) { + (*client)->close(); + } + } catch (...) { } } @@ -1019,11 +1022,14 @@ public: /// @brief Destructor. ~HttpClientTest() { - listener_.stop(); - listener2_.stop(); - listener3_.stop(); - io_service_.poll(); - MultiThreadingMgr::instance().setMode(false); + try { + listener_.stop(); + listener2_.stop(); + listener3_.stop(); + io_service_.poll(); + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } /// @brief Creates HTTP request with JSON body. diff --git a/src/lib/http/tests/test_http_client.h b/src/lib/http/tests/test_http_client.h index f95b11189cf762c1fe82cc6e4413ebdc60439a07..9b2d8c2b1f3b67efc0fde3c0907eb7bdc63a56df 100644 --- a/src/lib/http/tests/test_http_client.h +++ b/src/lib/http/tests/test_http_client.h @@ -43,7 +43,10 @@ public: /// /// Closes the underlying socket if it is open. ~TestHttpClient() { - close(); + try { + close(); + } catch (...) { + } } /// @brief Send HTTP request specified in textual format. diff --git a/src/lib/http/tests/tls_client_unittests.cc b/src/lib/http/tests/tls_client_unittests.cc index 4a64898bfd5d6a863a24da5a33377ea9d78545ae..f8e667efd07ff149834ebcdca3546117334e118f 100644 --- a/src/lib/http/tests/tls_client_unittests.cc +++ b/src/lib/http/tests/tls_client_unittests.cc @@ -303,11 +303,14 @@ public: /// @brief Destructor. ~HttpsClientTest() { - listener_->stop(); - listener2_->stop(); - listener3_->stop(); - io_service_.poll(); - MultiThreadingMgr::instance().setMode(false); + try { + listener_->stop(); + listener2_->stop(); + listener3_->stop(); + io_service_.poll(); + MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } /// @brief Creates HTTP request with JSON body. diff --git a/src/lib/http/tests/tls_server_unittests.cc b/src/lib/http/tests/tls_server_unittests.cc index 87c89579eeac0df1f6cafb54a320666a8bfe89f1..579ed10dc8f809cb29b6a8ff30fbe276260cc5ff 100644 --- a/src/lib/http/tests/tls_server_unittests.cc +++ b/src/lib/http/tests/tls_server_unittests.cc @@ -416,7 +416,10 @@ public: /// /// Closes the underlying socket if it is open. ~TestHttpClient() { - close(); + try { + close(); + } catch (...) { + } } /// @brief Send HTTP request specified in textual format. @@ -657,9 +660,12 @@ public: /// /// Removes active HTTP clients. virtual ~HttpsListenerTest() { - for (auto client = clients_.begin(); client != clients_.end(); - ++client) { - (*client)->close(); + try { + for (auto client = clients_.begin(); client != clients_.end(); + ++client) { + (*client)->close(); + } + } catch (...) { } } diff --git a/src/lib/log/buffer_appender_impl.h b/src/lib/log/buffer_appender_impl.h index 10290b5bd6ecf0a843abf5a011f03c6bededc4bd..cbaa8ce5c596d6c991c46f5236919ec57743f7bd 100644 --- a/src/lib/log/buffer_appender_impl.h +++ b/src/lib/log/buffer_appender_impl.h @@ -64,10 +64,12 @@ typedef std::vector LogEventList; /// it will dump any event it has left to stdout. class BufferAppender : public log4cplus::Appender { public: + /// \brief Constructor /// /// Constructs a BufferAppender that buffers log evens - BufferAppender() : flushed_(false) {} + BufferAppender() : flushed_(false) { + } /// \brief Destructor /// diff --git a/src/lib/log/compiler/message.cc b/src/lib/log/compiler/message.cc index a62d129d36224f45206ee8ad88e92f7a7ae0e9dc..cfc11d029f45b543a0022edb07a4c08bf71d9f15 100644 --- a/src/lib/log/compiler/message.cc +++ b/src/lib/log/compiler/message.cc @@ -510,8 +510,7 @@ main(int argc, char* argv[]) { writeProgramFile(message_file, ns_components, dictionary, output_directory); - } - catch (const MessageException& e) { + } catch (const MessageException& e) { // Create an error message from the ID and the text const MessageDictionaryPtr& global = MessageDictionary::globalDictionary(); string text = e.id(); @@ -529,6 +528,8 @@ main(int argc, char* argv[]) { cerr << text << "\n"; + return (1); + } catch (...) { return (1); } diff --git a/src/lib/log/interprocess/interprocess_sync.h b/src/lib/log/interprocess/interprocess_sync.h index 0692ee15b746026e5548f339cba0c4841a1245a0..6f8f7965a39c98c079c1aa43a12b6e027ffb95c5 100644 --- a/src/lib/log/interprocess/interprocess_sync.h +++ b/src/lib/log/interprocess/interprocess_sync.h @@ -42,6 +42,7 @@ class InterprocessSync { friend class InterprocessSyncLocker; public: + /// \brief Constructor /// /// Creates an interprocess synchronization object @@ -50,11 +51,11 @@ public: /// identical among the various processes that need to be /// synchronized for the same task. InterprocessSync(const std::string& task_name) : - task_name_(task_name), is_locked_(false) - {} + task_name_(task_name), is_locked_(false) { + } /// \brief Destructor - virtual ~InterprocessSync() {} + virtual ~InterprocessSync() = default; protected: /// \brief Acquire the lock (blocks if something else has acquired a @@ -85,6 +86,7 @@ protected: /// the description of InterprocessSync. class InterprocessSyncLocker { public: + /// \brief Constructor /// /// Creates a lock manager around a interprocess synchronization object @@ -92,13 +94,17 @@ public: /// \param sync The sync object which has to be locked/unlocked by /// this locker object. InterprocessSyncLocker(InterprocessSync& sync) : - sync_(sync) - {} + sync_(sync) { + } /// \brief Destructor ~InterprocessSyncLocker() { - if (isLocked()) - unlock(); + try { + if (isLocked()) { + unlock(); + } + } catch (...) { + } } /// \brief Acquire the lock (blocks if something else has acquired a diff --git a/src/lib/log/interprocess/interprocess_sync_file.cc b/src/lib/log/interprocess/interprocess_sync_file.cc index ed6a5b7e2f8fd57b9e57d676273e77d872b78d86..49aa0c8a50d74f84b5e4dabeb428b29d833d3912 100644 --- a/src/lib/log/interprocess/interprocess_sync_file.cc +++ b/src/lib/log/interprocess/interprocess_sync_file.cc @@ -29,11 +29,14 @@ namespace log { namespace interprocess { InterprocessSyncFile::~InterprocessSyncFile() { - if (fd_ != -1) { - // This will also release any applied locks. - close(fd_); - // The lockfile will continue to exist, and we must not delete - // it. + try { + if (fd_ != -1) { + // This will also release any applied locks. + close(fd_); + // The lockfile will continue to exist, and we must not delete + // it. + } + } catch (...) { } } diff --git a/src/lib/log/interprocess/interprocess_sync_file.h b/src/lib/log/interprocess/interprocess_sync_file.h index 9613e7f18ed339fc01bfe93adf1d815d96b4cf5b..722d8c7c49a439f10848dfd9b608fa5976e94443 100644 --- a/src/lib/log/interprocess/interprocess_sync_file.h +++ b/src/lib/log/interprocess/interprocess_sync_file.h @@ -41,6 +41,7 @@ public: /// processes may have locks on them. class InterprocessSyncFile : public InterprocessSync { public: + /// \brief Constructor /// /// Creates a file-based interprocess synchronization object diff --git a/src/lib/log/interprocess/interprocess_sync_null.cc b/src/lib/log/interprocess/interprocess_sync_null.cc index ccd9e32a7ceb86cb2ca5b13efb05cf291c8f4963..9464d5ff698b24102b15715821ed9bc98274fccb 100644 --- a/src/lib/log/interprocess/interprocess_sync_null.cc +++ b/src/lib/log/interprocess/interprocess_sync_null.cc @@ -12,9 +12,6 @@ namespace isc { namespace log { namespace interprocess { -InterprocessSyncNull::~InterprocessSyncNull() { -} - bool InterprocessSyncNull::lock() { is_locked_ = true; diff --git a/src/lib/log/interprocess/interprocess_sync_null.h b/src/lib/log/interprocess/interprocess_sync_null.h index 8b0c57b3f92eb8a4f39611c4da3266a12934cfaf..fcc94f76815cb0259a0546f8c01e545049b3657e 100644 --- a/src/lib/log/interprocess/interprocess_sync_null.h +++ b/src/lib/log/interprocess/interprocess_sync_null.h @@ -20,6 +20,7 @@ namespace interprocess { /// InterprocessSync class documentation for usage. class InterprocessSyncNull : public InterprocessSync { public: + /// \brief Constructor /// /// Creates a null interprocess synchronization object @@ -32,7 +33,7 @@ public: {} /// \brief Destructor - virtual ~InterprocessSyncNull(); + virtual ~InterprocessSyncNull() = default; protected: /// \brief Acquire the lock (never blocks) diff --git a/src/lib/log/log_formatter.h b/src/lib/log/log_formatter.h index 7fc67f14dc508e096a11135105083daccdb7c100..d9bec1833b483223261935813bc6df88590394b9 100644 --- a/src/lib/log/log_formatter.h +++ b/src/lib/log/log_formatter.h @@ -118,8 +118,8 @@ private: /// \brief Which will be the next placeholder to replace unsigned nextPlaceholder_; - public: + /// \brief Constructor of "active" formatter /// /// This will create a formatter. If the arguments are set, it @@ -156,13 +156,16 @@ public: // /// This is the place where output happens if the formatter is active. ~Formatter() { - if (logger_) { - try { - checkExcessPlaceholders(*message_, ++nextPlaceholder_); - logger_->output(severity_, *message_); - } catch (...) { - // Catch and ignore all exceptions here. + try { + if (logger_) { + try { + checkExcessPlaceholders(*message_, ++nextPlaceholder_); + logger_->output(severity_, *message_); + } catch (...) { + // Catch and ignore all exceptions here. + } } + } catch (...) { } } diff --git a/src/lib/log/logger.cc b/src/lib/log/logger.cc index d0cd19609fb201459d9941ef1e89f603f7b6d4fc..ff0b5e4b4bf9ad76da5cf3001e0f92fec46572c4 100644 --- a/src/lib/log/logger.cc +++ b/src/lib/log/logger.cc @@ -49,12 +49,15 @@ Logger::initLoggerImpl() { // Destructor. Logger::~Logger() { - delete loggerptr_; - - // The next statement is required for the Kea hooks framework, where a - // statically-linked Kea loads and unloads multiple libraries. See the hooks - // documentation for more details. - loggerptr_ = 0; + try { + delete loggerptr_; + + // The next statement is required for the Kea hooks framework, where a + // statically-linked Kea loads and unloads multiple libraries. See the hooks + // documentation for more details. + loggerptr_ = 0; + } catch (...) { + } } // Get Version diff --git a/src/lib/log/logger.h b/src/lib/log/logger.h index 5983b2450b0a6dcdc1c736c0c258dc64408c6d59..77cb7a2ea3c686e9dd457cfe3ba7a4f0d0d31342 100644 --- a/src/lib/log/logger.h +++ b/src/lib/log/logger.h @@ -357,5 +357,4 @@ private: } // namespace log } // namespace isc - #endif // LOGGER_H diff --git a/src/lib/log/logger_impl.cc b/src/lib/log/logger_impl.cc index 853cba056de0811b4d170d12c8f47843f551b9af..57b0e9cf0b59b89cb536c02bfb413c6089e764c6 100644 --- a/src/lib/log/logger_impl.cc +++ b/src/lib/log/logger_impl.cc @@ -79,7 +79,10 @@ LoggerImpl::LoggerImpl(const string& name) : // Destructor. (Here because of virtual declaration.) LoggerImpl::~LoggerImpl() { - delete sync_; + try { + delete sync_; + } catch (...) { + } } /// \brief Version diff --git a/src/lib/log/logger_impl.h b/src/lib/log/logger_impl.h index b41bbcb16f524d77ef116a51363f44afcc5e2fee..4ccf515e47bcfe7b38b47b5ad5153cd29eaf84d3 100644 --- a/src/lib/log/logger_impl.h +++ b/src/lib/log/logger_impl.h @@ -65,7 +65,6 @@ public: /// \param name Name of the logger. LoggerImpl(const std::string& name); - /// \brief Destructor virtual ~LoggerImpl(); @@ -73,13 +72,11 @@ public: /// \brief Version static std::string getVersion(); - /// \brief Get the full name of the logger (including the root name) virtual std::string getName() { return (name_); } - /// \brief Set Severity Level for Logger /// /// Sets the level at which this logger will log messages. If none is set, @@ -196,5 +193,4 @@ private: } // namespace log } // namespace isc - #endif // LOGGER_IMPL_H diff --git a/src/lib/log/logger_manager.cc b/src/lib/log/logger_manager.cc index 1890706898027811443b6a0fe9ddad804ab47966..0aa7ee81662f2fd8a6c2b7abadacaba63c7d0bff 100644 --- a/src/lib/log/logger_manager.cc +++ b/src/lib/log/logger_manager.cc @@ -72,7 +72,10 @@ LoggerManager::LoggerManager() { // Destructor - get rid of the implementation class LoggerManager::~LoggerManager() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } // Initialize processing diff --git a/src/lib/log/logger_manager.h b/src/lib/log/logger_manager.h index 1ddea6dd015f9e8847fae82094967a11fff97aa6..6640a0a4c43a4753cb5dea061c349efcfdac05e8 100644 --- a/src/lib/log/logger_manager.h +++ b/src/lib/log/logger_manager.h @@ -38,6 +38,7 @@ class LoggerManagerImpl; class LoggerManager : public boost::noncopyable { public: + /// \brief Constructor LoggerManager(); @@ -169,5 +170,4 @@ private: } // namespace log } // namespace isc - #endif // LOGGER_MANAGER_H diff --git a/src/lib/log/message_dictionary.cc b/src/lib/log/message_dictionary.cc index 12511b0607afbd941c61475c4e8a79dd51ca7b70..fb2da76eb5d240e9c0f68b16d120c791a820f7ca 100644 --- a/src/lib/log/message_dictionary.cc +++ b/src/lib/log/message_dictionary.cc @@ -15,16 +15,6 @@ using namespace std; namespace isc { namespace log { -// Constructor - -MessageDictionary::MessageDictionary() : dictionary_(), empty_("") { -} - -// (Virtual) Destructor - -MessageDictionary::~MessageDictionary() { -} - // Add message and note if ID already exists bool diff --git a/src/lib/log/message_dictionary.h b/src/lib/log/message_dictionary.h index 6afc0f084d26add1334d6457137cbbdd6dda9081..4aca5ec8244556b9e181ada664bf413137773a80 100644 --- a/src/lib/log/message_dictionary.h +++ b/src/lib/log/message_dictionary.h @@ -51,10 +51,10 @@ public: typedef Dictionary::const_iterator const_iterator; /// \brief Constructor - MessageDictionary(); + MessageDictionary() = default; /// \brief Virtual Destructor - virtual ~MessageDictionary(); + virtual ~MessageDictionary() = default; /// \brief Add Message /// diff --git a/src/lib/log/message_exception.h b/src/lib/log/message_exception.h index f5c77cf4bb49f872acc058af5541b7dc6bf7832e..cf045f700a837d9a26c8ea58ecfe6114c8817277 100644 --- a/src/lib/log/message_exception.h +++ b/src/lib/log/message_exception.h @@ -84,7 +84,7 @@ public: } /// \brief Destructor - ~MessageException() {} + ~MessageException() = default; /// \brief Return Message ID /// diff --git a/src/lib/log/message_initializer.cc b/src/lib/log/message_initializer.cc index a7c85ed2e68bd0a71aa07ed3c0b5c229e485f9c9..82301efb79f8712259c7c4afbb651c0e1e9d3a3b 100644 --- a/src/lib/log/message_initializer.cc +++ b/src/lib/log/message_initializer.cc @@ -56,35 +56,38 @@ MessageInitializer::MessageInitializer(const char* values[]) } MessageInitializer::~MessageInitializer() { - // Search for the pointer to pending messages belonging to our instance. - LoggerValuesList::iterator my_messages = std::find(global_logger_values_->begin(), - global_logger_values_->end(), - values_); - bool pending = (my_messages != global_logger_values_->end()); - // Our messages are still pending, so let's remove them from the list - // of pending messages. - if (pending) { - global_logger_values_->erase(my_messages); - - } else { - // Our messages are not pending, so they might have been loaded to - // the dictionary and/or duplicates. - int i = 0; - while (values_[i]) { - // Check if the unloaded message is registered as duplicate. If it is, - // remove it from the duplicates list. - LoggerDuplicatesList::iterator dup = - std::find(global_logger_duplicates_->begin(), - global_logger_duplicates_->end(), - values_[i]); - if (dup != global_logger_duplicates_->end()) { - global_logger_duplicates_->erase(dup); - - } else { - global_dictionary_->erase(values_[i], values_[i + 1]); + try { + // Search for the pointer to pending messages belonging to our instance. + LoggerValuesList::iterator my_messages = std::find(global_logger_values_->begin(), + global_logger_values_->end(), + values_); + bool pending = (my_messages != global_logger_values_->end()); + // Our messages are still pending, so let's remove them from the list + // of pending messages. + if (pending) { + global_logger_values_->erase(my_messages); + + } else { + // Our messages are not pending, so they might have been loaded to + // the dictionary and/or duplicates. + int i = 0; + while (values_[i]) { + // Check if the unloaded message is registered as duplicate. If it is, + // remove it from the duplicates list. + LoggerDuplicatesList::iterator dup = + std::find(global_logger_duplicates_->begin(), + global_logger_duplicates_->end(), + values_[i]); + if (dup != global_logger_duplicates_->end()) { + global_logger_duplicates_->erase(dup); + + } else { + global_dictionary_->erase(values_[i], values_[i + 1]); + } + i += 2; } - i += 2; } + } catch (...) { } } diff --git a/src/lib/log/message_reader.h b/src/lib/log/message_reader.h index 65fdb2bf0efbc87ca5c9834d98b067fa42bf8ff9..9d813a85bafa128d2a6efaf1128effbccf4d2de1 100644 --- a/src/lib/log/message_reader.h +++ b/src/lib/log/message_reader.h @@ -53,12 +53,11 @@ public: /// The ownership of the dictionary object is not transferred - the caller /// is responsible for managing the lifetime of the dictionary. MessageReader(MessageDictionary* dictionary = NULL) : - dictionary_(dictionary), lineno_(0) - {} + dictionary_(dictionary), lineno_(0) { + } /// \brief Virtual Destructor - virtual ~MessageReader() - {} + virtual ~MessageReader() = default; /// \brief Get Dictionary /// @@ -191,8 +190,6 @@ private: /// \return true if the name is invalid, false if it is valid. bool invalidSymbol(const std::string& symbol); - - /// Attributes MessageDictionary* dictionary_; ///< Dictionary to add messages to MessageIDCollection not_added_; ///< List of IDs not added diff --git a/src/lib/log/tests/buffer_appender_unittest.cc b/src/lib/log/tests/buffer_appender_unittest.cc index f52d8339b0eb2f09a2e85c44c3d8c98e51047226..da2f626820e9b7e12c20695c5ef25a7645cdc859 100644 --- a/src/lib/log/tests/buffer_appender_unittest.cc +++ b/src/lib/log/tests/buffer_appender_unittest.cc @@ -36,28 +36,33 @@ public: class BufferAppenderTest : public ::testing::Test { protected: + + /// @brief Constructor BufferAppenderTest() : buffer_appender1(new TestBufferAppender()), appender1(buffer_appender1), buffer_appender2(new TestBufferAppender()), appender2(buffer_appender2), - logger(log4cplus::Logger::getInstance("buffer")) - { + logger(log4cplus::Logger::getInstance("buffer")) { logger.setLogLevel(log4cplus::TRACE_LOG_LEVEL); } + /// @brief Destructor ~BufferAppenderTest() { - // If any log messages are left, we don't care, get rid of them, - // by flushing them to a null appender - // Given the 'messages should not get lost' approach of the logging - // system, not flushing them to a null appender would cause them - // to be dumped to stdout as the test is destroyed, making - // unnecessarily messy test output. - log4cplus::SharedAppenderPtr null_appender( - new log4cplus::NullAppender()); - logger.removeAllAppenders(); - logger.addAppender(null_appender); - buffer_appender1->flush(); - buffer_appender2->flush(); + try { + // If any log messages are left, we don't care, get rid of them, + // by flushing them to a null appender + // Given the 'messages should not get lost' approach of the logging + // system, not flushing them to a null appender would cause them + // to be dumped to stdout as the test is destroyed, making + // unnecessarily messy test output. + log4cplus::SharedAppenderPtr null_appender( + new log4cplus::NullAppender()); + logger.removeAllAppenders(); + logger.addAppender(null_appender); + buffer_appender1->flush(); + buffer_appender2->flush(); + } catch (...) { + } } TestBufferAppender* buffer_appender1; diff --git a/src/lib/log/tests/logger_level_impl_unittest.cc b/src/lib/log/tests/logger_level_impl_unittest.cc index c82be69b17f9db251058847322931aaa8ad003d2..9e9c721e13a9125a96adfb54c437e32537b4332c 100644 --- a/src/lib/log/tests/logger_level_impl_unittest.cc +++ b/src/lib/log/tests/logger_level_impl_unittest.cc @@ -22,13 +22,15 @@ using namespace std; class LoggerLevelImplTest : public ::testing::Test { protected: + + /// @brief Constructor LoggerLevelImplTest() { // Ensure logging set to default for unit tests setDefaultLoggingOutput(); } - ~LoggerLevelImplTest() - {} + /// @brief Destructor + ~LoggerLevelImplTest() = default; }; diff --git a/src/lib/log/tests/logger_level_unittest.cc b/src/lib/log/tests/logger_level_unittest.cc index ccaecd901523f29796bea172e78ee2449feb0b65..d7cf415d66c47d8838d9c3452c2c600878527323 100644 --- a/src/lib/log/tests/logger_level_unittest.cc +++ b/src/lib/log/tests/logger_level_unittest.cc @@ -22,13 +22,20 @@ using namespace std; class LoggerLevelTest : public ::testing::Test { protected: + + /// @brief Constructor LoggerLevelTest() { // Logger initialization is done in main(). As logging tests may // alter the default logging output, it is reset here. setDefaultLoggingOutput(); } + + /// @brief Destructor ~LoggerLevelTest() { - LoggerManager::reset(); + try { + LoggerManager::reset(); + } catch (...) { + } } }; diff --git a/src/lib/log/tests/logger_lock_test.cc b/src/lib/log/tests/logger_lock_test.cc index 9908800eca166f5965b9260a551f9ec89bb532b7..82a18a16b7ba2cf7e043d0b260d642f4998ecc2a 100644 --- a/src/lib/log/tests/logger_lock_test.cc +++ b/src/lib/log/tests/logger_lock_test.cc @@ -44,10 +44,14 @@ public: /// /// Unlocks the mutex. ~CheckMutex() { - mutex_.unlock(); + try { + mutex_.unlock(); + } catch (...) { + } } private: + /// @brief The mutex used for testing mutex& mutex_; }; diff --git a/src/lib/log/tests/logger_manager_unittest.cc b/src/lib/log/tests/logger_manager_unittest.cc index dc6046820cbcf4d0b9b4a82c884e0ec0e12eadfe..674f81e508713d59135a20499a2ba8e40ea20522 100644 --- a/src/lib/log/tests/logger_manager_unittest.cc +++ b/src/lib/log/tests/logger_manager_unittest.cc @@ -41,12 +41,18 @@ using namespace std; /// \brief LoggerManager Test class LoggerManagerTest : public ::testing::Test { public: + + /// @brief Constructor LoggerManagerTest() { // Initialization of logging is done in main() } + /// @brief Destructor ~LoggerManagerTest() { - LoggerManager::reset(); + try { + LoggerManager::reset(); + } catch (...) { + } } }; @@ -73,12 +79,15 @@ public: // Destructor, remove the file. This is only a test, so ignore failures ~SpecificationForFileLogger() { - if (! name_.empty()) { - static_cast(remove(name_.c_str())); - - // Depending on the log4cplus version, a lock file may also be - // created. - static_cast(remove((name_ + ".lock").c_str())); + try { + if (!name_.empty()) { + static_cast(remove(name_.c_str())); + + // Depending on the log4cplus version, a lock file may also be + // created. + static_cast(remove((name_ + ".lock").c_str())); + } + } catch (...) { } } @@ -327,6 +336,8 @@ namespace { // begin unnamed namespace class RegexHolder { public: + + /// @brief Constructor RegexHolder(const char* expr, const int flags = REG_EXTENDED) { const int rc = regcomp(®ex_, expr, flags); if (rc) { @@ -335,8 +346,12 @@ public: } } + /// @brief Destructor ~RegexHolder() { - regfree(®ex_); + try { + regfree(®ex_); + } catch (...) { + } } regex_t* operator*() { diff --git a/src/lib/log/tests/logger_name_unittest.cc b/src/lib/log/tests/logger_name_unittest.cc index 9048bf26626c6beea2951cc804d84940eac980ed..1306c4e7d0d30445e8d3bf18d24af75135704188 100644 --- a/src/lib/log/tests/logger_name_unittest.cc +++ b/src/lib/log/tests/logger_name_unittest.cc @@ -25,11 +25,18 @@ using namespace isc::log; class LoggerNameTest : public ::testing::Test { public: + + /// @brief Constructor LoggerNameTest() : - name_(getRootLoggerName()) - {} + name_(getRootLoggerName()) { + } + + /// @brief Destructor ~LoggerNameTest() { - setRootLoggerName(name_); + try { + setRootLoggerName(name_); + } catch (...) { + } } private: diff --git a/src/lib/log/tests/logger_support_unittest.cc b/src/lib/log/tests/logger_support_unittest.cc index 3f2943c6a4eb3636a067a3157eff7bf1031862a8..4d072b5f13881fbaf19cf82bb66e9b503381d3ba 100644 --- a/src/lib/log/tests/logger_support_unittest.cc +++ b/src/lib/log/tests/logger_support_unittest.cc @@ -14,13 +14,16 @@ using namespace isc::log; class LoggerSupportTest : public ::testing::Test { protected: + + /// @brief Constructor LoggerSupportTest() { // Logger initialization is done in main(). As logging tests may // alter the default logging output, it is reset here. setDefaultLoggingOutput(); } - ~LoggerSupportTest() { - } + + /// @brief Destructor + ~LoggerSupportTest() = default; }; // Check that the initialized flag can be manipulated. This is a bit chicken- diff --git a/src/lib/log/tests/logger_unittest.cc b/src/lib/log/tests/logger_unittest.cc index 8f06a4203dc7503e6b90f17ceff30f95ee98f892..65cd35bf3600e0c6f7acd9cd3dd668e007169c8b 100644 --- a/src/lib/log/tests/logger_unittest.cc +++ b/src/lib/log/tests/logger_unittest.cc @@ -32,11 +32,18 @@ using namespace std; class LoggerTest : public ::testing::Test { public: + + /// @brief Constructor LoggerTest() { // Initialization of logging is done in main() } + + /// @brief Destructor ~LoggerTest() { - LoggerManager::reset(); + try { + LoggerManager::reset(); + } catch (...) { + } } }; diff --git a/src/lib/log/tests/message_reader_unittest.cc b/src/lib/log/tests/message_reader_unittest.cc index 4dd64353b980cb27405e79d15bdecc5ad00bb037..8800312b39966b1eb0700dc58023c2eb80139d7d 100644 --- a/src/lib/log/tests/message_reader_unittest.cc +++ b/src/lib/log/tests/message_reader_unittest.cc @@ -21,14 +21,19 @@ using namespace std; class MessageReaderTest : public ::testing::Test { protected: - MessageReaderTest() : dictionary_(), reader_() - { + + /// @brief Constructor + MessageReaderTest() : dictionary_(), reader_() { dictionary_ = new MessageDictionary(); reader_.setDictionary(dictionary_); } + /// @brief Destructor ~MessageReaderTest() { - delete dictionary_; + try { + delete dictionary_; + } catch (...) { + } } MessageDictionary* dictionary_; // Dictionary to add messages to diff --git a/src/lib/mysql/mysql_connection.cc b/src/lib/mysql/mysql_connection.cc index 02ca83da096766ff7d696acbbb3fb1da9337f934..e32c1951f00b8e1f8b2fd5997725ec81d7206214 100644 --- a/src/lib/mysql/mysql_connection.cc +++ b/src/lib/mysql/mysql_connection.cc @@ -34,10 +34,13 @@ MySqlTransaction::MySqlTransaction(MySqlConnection& conn) } MySqlTransaction::~MySqlTransaction() { - // Rollback if the MySqlTransaction::commit wasn't explicitly - // called. - if (!committed_) { - conn_.rollback(); + try { + // Rollback if the MySqlTransaction::commit wasn't explicitly + // called. + if (!committed_) { + conn_.rollback(); + } + } catch (...) { } } @@ -362,17 +365,20 @@ void MySqlConnection::clearStatements() { /// @brief Destructor MySqlConnection::~MySqlConnection() { - // Free up the prepared statements, ignoring errors. (What would we do - // about them? We're destroying this object and are not really concerned - // with errors on a database connection that is about to go away.) - for (int i = 0; i < statements_.size(); ++i) { - if (statements_[i] != NULL) { - (void) mysql_stmt_close(statements_[i]); - statements_[i] = NULL; + try { + // Free up the prepared statements, ignoring errors. (What would we do + // about them? We're destroying this object and are not really concerned + // with errors on a database connection that is about to go away.) + for (int i = 0; i < statements_.size(); ++i) { + if (statements_[i] != NULL) { + (void) mysql_stmt_close(statements_[i]); + statements_[i] = NULL; + } } + statements_.clear(); + text_statements_.clear(); + } catch (...) { } - statements_.clear(); - text_statements_.clear(); } // Time conversion methods. diff --git a/src/lib/mysql/mysql_connection.h b/src/lib/mysql/mysql_connection.h index 2bd49280c1f3bfd600eb231af78408d78ee9ae03..6f82d0eef3b504ec65de56a9ab24659f35eb270c 100644 --- a/src/lib/mysql/mysql_connection.h +++ b/src/lib/mysql/mysql_connection.h @@ -53,18 +53,22 @@ public: /// way, any error from mysql_stmt_free_result is ignored. (Generating /// an exception is not much help, as it will only confuse things if the /// method calling mysql_stmt_fetch is exiting via an exception.) - MySqlFreeResult(MYSQL_STMT* statement) : statement_(statement) - {} + MySqlFreeResult(MYSQL_STMT* statement) : statement_(statement) { + } /// @brief Destructor /// /// Frees up fetch context if a fetch has been successfully executed. ~MySqlFreeResult() { - (void) mysql_stmt_free_result(statement_); + try { + (void) mysql_stmt_free_result(statement_); + } catch (...) { + } } private: - MYSQL_STMT* statement_; ///< Statement for which results are freed + /// @brief Statement for which results are freed + MYSQL_STMT* statement_; }; /// @brief MySQL Selection Statements @@ -147,8 +151,11 @@ public: /// /// Frees up resources allocated by the initialization of MySql. ~MySqlHolder() { - if (mysql_ != NULL) { - mysql_close(mysql_); + try { + if (mysql_ != NULL) { + mysql_close(mysql_); + } + } catch (...) { } } diff --git a/src/lib/mysql/tests/mysql_connection_unittest.cc b/src/lib/mysql/tests/mysql_connection_unittest.cc index 06e610be4dfeae5157303ccff680eaa414b3c9e7..c21db726a57e02e5789b1ec60550e66989795e7a 100644 --- a/src/lib/mysql/tests/mysql_connection_unittest.cc +++ b/src/lib/mysql/tests/mysql_connection_unittest.cc @@ -20,11 +20,17 @@ namespace { /// @brief RAII wrapper over MYSQL_RES obtained from MySQL library functions like /// mysql_use_result(). struct MySqlResult { + + /// @brief Constructor MySqlResult(MYSQL_RES* result) : result_(result) { } + /// @brief Destructor ~MySqlResult() { - mysql_free_result(result_); + try { + mysql_free_result(result_); + } catch (...) { + } } MYSQL_RES* const result_; @@ -109,8 +115,11 @@ public: /// /// Removes test table from the database. virtual ~MySqlConnectionTest() { - conn_.rollback(); - dropTestTable(); + try { + conn_.rollback(); + dropTestTable(); + } catch (...) { + } } /// @brief Creates test table @c mysql_connection_test. @@ -569,6 +578,7 @@ TEST_F(MySqlConnectionWithPrimaryKeyTest, deleteByValue) { /// @brief Test fixture class for @c MySqlConnection class methods. class MySqlSchemaTest : public ::testing::Test { public: + /// @brief Constructor. MySqlSchemaTest() { // Ensure we have the proper schema. @@ -577,7 +587,10 @@ public: /// @brief Destructor. virtual ~MySqlSchemaTest() { - destroyMySQLSchema(); + try { + destroyMySQLSchema(); + } catch (...) { + } } }; diff --git a/src/lib/pgsql/pgsql_connection.cc b/src/lib/pgsql/pgsql_connection.cc index b3b48bdb2a6196ecae7e5dbb1ab5d2fae1241b9f..72fbc8073dd2991ff865d8eb5000c507ab6d88cb 100644 --- a/src/lib/pgsql/pgsql_connection.cc +++ b/src/lib/pgsql/pgsql_connection.cc @@ -64,8 +64,11 @@ PgSqlResult::rowCheck(int row) const { } PgSqlResult::~PgSqlResult() { - if (result_) { - PQclear(result_); + try { + if (result_) { + PQclear(result_); + } + } catch (...) { } } @@ -104,9 +107,12 @@ PgSqlTransaction::PgSqlTransaction(PgSqlConnection& conn) } PgSqlTransaction::~PgSqlTransaction() { - // If commit() wasn't explicitly called, rollback. - if (!committed_) { - conn_.rollback(); + try { + // If commit() wasn't explicitly called, rollback. + if (!committed_) { + conn_.rollback(); + } + } catch (...) { } } @@ -117,16 +123,19 @@ PgSqlTransaction::commit() { } PgSqlConnection::~PgSqlConnection() { - if (conn_) { - // Deallocate the prepared queries. - if (PQstatus(conn_) == CONNECTION_OK) { - PgSqlResult r(PQexec(conn_, "DEALLOCATE all")); - if (PQresultStatus(r) != PGRES_COMMAND_OK) { - // Highly unlikely but we'll log it and go on. - DB_LOG_ERROR(PGSQL_DEALLOC_ERROR) - .arg(PQerrorMessage(conn_)); + try { + if (conn_) { + // Deallocate the prepared queries. + if (PQstatus(conn_) == CONNECTION_OK) { + PgSqlResult r(PQexec(conn_, "DEALLOCATE all")); + if (PQresultStatus(r) != PGRES_COMMAND_OK) { + // Highly unlikely but we'll log it and go on. + DB_LOG_ERROR(PGSQL_DEALLOC_ERROR) + .arg(PQerrorMessage(conn_)); + } } } + } catch (...) { } } @@ -138,7 +147,7 @@ PgSqlConnection::getVersion(const ParameterMap& parameters) { // Open the database. conn.openDatabase(); - const char* version_sql = "SELECT version, minor FROM schema_version;"; + const char* version_sql = "SELECT version, minor FROM schema_version;"; PgSqlResult r(PQexec(conn.conn_, version_sql)); if (PQresultStatus(r) != PGRES_TUPLES_OK) { isc_throw(DbOperationError, "unable to execute PostgreSQL statement <" diff --git a/src/lib/pgsql/pgsql_connection.h b/src/lib/pgsql/pgsql_connection.h index 449fd4870a7ccf77d85e80a70fa1d545ecf37eef..99bbd6b31af3ddc02f478fda509ec03750f0fd35 100644 --- a/src/lib/pgsql/pgsql_connection.h +++ b/src/lib/pgsql/pgsql_connection.h @@ -85,6 +85,7 @@ const size_t OID_TIMESTAMP = 1114; class PgSqlResult : public boost::noncopyable { public: + /// @brief Constructor /// /// Store the pointer to the result set to being fetched. Set row @@ -161,9 +162,14 @@ public: } private: - PGresult* result_; ///< Result set to be freed - int rows_; ///< Number of rows in the result set - int cols_; ///< Number of columns in the result set + /// @brief Result set to be freed + PGresult* result_; + + /// @brief Number of rows in the result set + int rows_; + + /// @brief Number of columns in the result set + int cols_; }; @@ -192,8 +198,11 @@ public: /// /// Frees up resources allocated by the connection. ~PgSqlHolder() { - if (pgconn_ != NULL) { - PQfinish(pgconn_); + try { + if (pgconn_ != NULL) { + PQfinish(pgconn_); + } + } catch (...) { } } @@ -226,7 +235,8 @@ public: } private: - PGconn* pgconn_; ///< Postgresql connection + /// @brief Postgresql connection + PGconn* pgconn_; }; /// @brief Forward declaration to @ref PgSqlConnection. diff --git a/src/lib/pgsql/pgsql_exchange.cc b/src/lib/pgsql/pgsql_exchange.cc index d65aa6dee67e79119d4cc896b7fea531a96410db..a24269235cb4174757a7c72452d984adc4b73389 100644 --- a/src/lib/pgsql/pgsql_exchange.cc +++ b/src/lib/pgsql/pgsql_exchange.cc @@ -150,7 +150,7 @@ time_t PgSqlExchange::convertFromDatabaseTime(const std::string& db_time_val) { // Convert string time value to time_t time_t new_time; - try { + try { new_time = (boost::lexical_cast(db_time_val)); } catch (const std::exception& ex) { isc_throw(BadValue, "Database time value is invalid: " << db_time_val); @@ -297,5 +297,5 @@ PgSqlExchange::dumpRow(const PgSqlResult& r, int row) { return (stream.str()); } -}; // end of isc::db namespace -}; // end of isc namespace +} // end of isc::db namespace +} // end of isc namespace diff --git a/src/lib/pgsql/pgsql_exchange.h b/src/lib/pgsql/pgsql_exchange.h index 8d166e3af61544184b28daaca73c825087dde829..cca4db5175f877359b8d4ac1c3ff31c2170d0192 100644 --- a/src/lib/pgsql/pgsql_exchange.h +++ b/src/lib/pgsql/pgsql_exchange.h @@ -70,7 +70,6 @@ struct PsqlBindArray { /// @return Returns true if there are no entries in the array, false /// otherwise. bool empty() const { - return (values_.empty()); } @@ -186,7 +185,6 @@ struct PsqlBindArray { private: /// @brief vector of strings which supplied the values std::vector bound_strs_; - }; /// @brief Defines a smart pointer to PsqlBindArray @@ -199,11 +197,13 @@ typedef boost::shared_ptr PsqlBindArrayPtr; /// database, and for retrieving column values from rows of a result set. class PgSqlExchange { public: + /// @brief Constructor - PgSqlExchange(const size_t num_columns = 0) : columns_(num_columns) {} + PgSqlExchange(const size_t num_columns = 0) : columns_(num_columns) { + } /// @brief Destructor - virtual ~PgSqlExchange(){} + virtual ~PgSqlExchange() = default; /// @brief Converts time_t value to a text representation in local time. /// @@ -396,7 +396,7 @@ protected: std::vectorcolumns_; }; -}; // end of isc::db namespace -}; // end of isc namespace +} // end of isc::db namespace +} // end of isc namespace #endif // PGSQL_EXCHANGE_H diff --git a/src/lib/pgsql/tests/pgsql_exchange_unittest.cc b/src/lib/pgsql/tests/pgsql_exchange_unittest.cc index 9b93e696089afeba5433b05f6b840bda084564e2..945b36bb6bdc0b067e6f8614e8fc67bde6597b69 100644 --- a/src/lib/pgsql/tests/pgsql_exchange_unittest.cc +++ b/src/lib/pgsql/tests/pgsql_exchange_unittest.cc @@ -159,7 +159,10 @@ public: /// Destroys the table. The database resources are freed and the connection /// closed by the destruction of conn_. virtual ~PgSqlBasicsTest () { - destroySchema(); + try { + destroySchema(); + } catch (...) { + } } /// @brief Gets the expected name of the column for a given column index @@ -920,4 +923,4 @@ TEST_F(PgSqlBasicsTest, timeStampTest) { MAX_DB_TIME), BadValue); } -}; // namespace +} // namespace diff --git a/src/lib/process/cb_ctl_base.h b/src/lib/process/cb_ctl_base.h index 7baf8dd725ac3d1efaadd7ecb3e74f018a3ac3a0..7d51ae42a80adf897e1003285c56ea32e3251745 100644 --- a/src/lib/process/cb_ctl_base.h +++ b/src/lib/process/cb_ctl_base.h @@ -103,7 +103,10 @@ public: /// /// It is always needed when there are virtual methods. virtual ~CBControlBase() { - databaseConfigDisconnect(); + try { + databaseConfigDisconnect(); + } catch (...) { + } } /// @brief Resets the state of this object. diff --git a/src/lib/process/d_cfg_mgr.cc b/src/lib/process/d_cfg_mgr.cc index 4a67183128d279580cc0ae88d0df7402dd75386f..cc52aebf9b8e012ef42dc5717ee48e654b702880 100644 --- a/src/lib/process/d_cfg_mgr.cc +++ b/src/lib/process/d_cfg_mgr.cc @@ -39,9 +39,6 @@ DCfgMgrBase::DCfgMgrBase(ConfigPtr context) { setContext(context); } -DCfgMgrBase::~DCfgMgrBase() { -} - void DCfgMgrBase::resetContext() { ConfigPtr context = createNewContext(); diff --git a/src/lib/process/d_cfg_mgr.h b/src/lib/process/d_cfg_mgr.h index 204f7b29bc5223b98716afda54309dc35fef0ab9..71d3ff51e8f9a28b04609b445b87feb482166550 100644 --- a/src/lib/process/d_cfg_mgr.h +++ b/src/lib/process/d_cfg_mgr.h @@ -107,6 +107,7 @@ public: /// for example use of this approach. class DCfgMgrBase { public: + /// @brief Constructor /// /// @param context is a pointer to the configuration context the manager @@ -116,7 +117,7 @@ public: DCfgMgrBase(ConfigPtr context); /// @brief Destructor - virtual ~DCfgMgrBase(); + virtual ~DCfgMgrBase() = default; /// @brief Acts as the receiver of new configurations. /// diff --git a/src/lib/process/d_controller.cc b/src/lib/process/d_controller.cc index 72bf80e027f2d719d71f5d59f1a8f8d138153203..d3ac21a1c6bed09d605aee879896dc24abf1facf 100644 --- a/src/lib/process/d_controller.cc +++ b/src/lib/process/d_controller.cc @@ -804,9 +804,6 @@ DControllerBase::usage(const std::string & text) { std::cerr << getUsageText() << std::endl; } -DControllerBase::~DControllerBase() { -} - // Refer to config_report so it will be embedded in the binary const char* const* d_config_report = isc::detail::config_report; diff --git a/src/lib/process/d_controller.h b/src/lib/process/d_controller.h index 1a1c6a6acf12c4a36ed1a0d2df4582da2b1961ed..9c4f342a2c3d282136a418c60da068a698abe4c9 100644 --- a/src/lib/process/d_controller.h +++ b/src/lib/process/d_controller.h @@ -103,6 +103,7 @@ typedef boost::shared_ptr DControllerBasePtr; /// member in order for it to be available for static callback functions. class DControllerBase : public Daemon { public: + /// @brief Constructor /// /// @param app_name is display name of the application under control. This @@ -111,7 +112,7 @@ public: DControllerBase(const char* app_name, const char* bin_name); /// @brief Destructor - virtual ~DControllerBase(); + virtual ~DControllerBase() = default; /// @brief returns Kea version on stdout and exit. /// redeclaration/redefinition. @ref isc::process::Daemon::getVersion() diff --git a/src/lib/process/d_process.h b/src/lib/process/d_process.h index e7e65465468a7fc15b84287163b30f792ab88a3d..acd5853d61a9a982bbfe32259ebfc7ce2ade43a6 100644 --- a/src/lib/process/d_process.h +++ b/src/lib/process/d_process.h @@ -80,6 +80,7 @@ static const int COMMAND_INVALID = 2; /// application. class DProcessBase { public: + /// @brief Constructor /// /// @param app_name is a text label for the process. Generally used @@ -151,7 +152,7 @@ public: bool check_only = false) = 0; /// @brief Destructor - virtual ~DProcessBase(){}; + virtual ~DProcessBase() = default; /// @brief Checks if the process has been instructed to shut down. /// diff --git a/src/lib/process/daemon.cc b/src/lib/process/daemon.cc index c2589c92a17d7bd2ab16df8f7c84fbd6811919a5..bebfb585d9bad9575ac4a22f60e24993c559c484 100644 --- a/src/lib/process/daemon.cc +++ b/src/lib/process/daemon.cc @@ -52,8 +52,11 @@ Daemon::Daemon() } Daemon::~Daemon() { - if (pid_file_ && am_file_author_) { - pid_file_->deleteFile(); + try { + if (pid_file_ && am_file_author_) { + pid_file_->deleteFile(); + } + } catch (...) { } } diff --git a/src/lib/process/daemon.h b/src/lib/process/daemon.h index d64445a77c5a1a775e097fde2f136a30d1055276..ed0d9823a884b0c4df37d9118a94581b308e9206 100644 --- a/src/lib/process/daemon.h +++ b/src/lib/process/daemon.h @@ -46,8 +46,8 @@ public: /// the whole operation of the server. Nothing, however, enforces the /// singleton status of the object. class Daemon : public boost::noncopyable { - public: + /// @brief Default constructor /// /// Initializes the object installing custom signal handlers for the diff --git a/src/lib/process/tests/cb_ctl_base_unittests.cc b/src/lib/process/tests/cb_ctl_base_unittests.cc index 58d0aa065f9fc45cc6ba695126f1326d57b69aa1..5ede396a03c275ddb79ecc02e71a950b7f237338 100644 --- a/src/lib/process/tests/cb_ctl_base_unittests.cc +++ b/src/lib/process/tests/cb_ctl_base_unittests.cc @@ -369,7 +369,10 @@ public: /// /// Removes audit entries created in the test. ~CBControlBaseTest() { - CBControlBackend::clearAuditEntries(); + try { + CBControlBackend::clearAuditEntries(); + } catch (...) { + } } /// @brief Initialize posix time values used in tests. diff --git a/src/lib/process/tests/d_cfg_mgr_unittests.cc b/src/lib/process/tests/d_cfg_mgr_unittests.cc index faa3e928970dba282ccea15bba5269cd5c68e788..967d3f8b796f69abef6b7e2b8178e6715f8b06ec 100644 --- a/src/lib/process/tests/d_cfg_mgr_unittests.cc +++ b/src/lib/process/tests/d_cfg_mgr_unittests.cc @@ -31,14 +31,14 @@ namespace { /// during construction. class DCtorTestCfgMgr : public DCfgMgrBase { public: + /// @brief Constructor - Note that is passes in an empty configuration /// pointer to the base class constructor. DCtorTestCfgMgr() : DCfgMgrBase(ConfigPtr()) { } /// @brief Destructor - virtual ~DCtorTestCfgMgr() { - } + virtual ~DCtorTestCfgMgr() = default; /// @brief Dummy implementation as this method is abstract. virtual ConfigPtr createNewContext() { @@ -60,12 +60,11 @@ class DStubCfgMgrTest : public ConfigParseTest { public: /// @brief Constructor - DStubCfgMgrTest():cfg_mgr_(new DStubCfgMgr) { + DStubCfgMgrTest() : cfg_mgr_(new DStubCfgMgr) { } /// @brief Destructor - ~DStubCfgMgrTest() { - } + ~DStubCfgMgrTest() = default; /// @brief Convenience method which returns a DStubContextPtr to the /// configuration context. diff --git a/src/lib/process/tests/daemon_unittest.cc b/src/lib/process/tests/daemon_unittest.cc index bd80e25a656fad7a7eef0d3e2b6d3515c6bccfc6..a9b09fa7d5e2357397e3ff46aaaa1824a73d0a2d 100644 --- a/src/lib/process/tests/daemon_unittest.cc +++ b/src/lib/process/tests/daemon_unittest.cc @@ -48,6 +48,7 @@ namespace { /// @brief Daemon Test test fixture class class DaemonTest : public ::testing::Test { public: + /// @brief Constructor DaemonTest() : env_copy_() { // Take a copy of KEA_PIDFILE_DIR environment variable value @@ -63,12 +64,15 @@ public: /// settings (when configureLogger is called), the logging is reset to /// the default after each test completes. ~DaemonTest() { - isc::log::setDefaultLoggingOutput(); - // Restore KEA_PIDFILE_DIR environment variable value - if (env_copy_.empty()) { - static_cast(unsetenv("KEA_PIDFILE_DIR")); - } else { - static_cast(setenv("KEA_PIDFILE_DIR", env_copy_.c_str(), 1)); + try { + isc::log::setDefaultLoggingOutput(); + // Restore KEA_PIDFILE_DIR environment variable value + if (env_copy_.empty()) { + static_cast(unsetenv("KEA_PIDFILE_DIR")); + } else { + static_cast(setenv("KEA_PIDFILE_DIR", env_copy_.c_str(), 1)); + } + } catch (...) { } } @@ -321,4 +325,4 @@ TEST_F(DaemonTest, exitValue) { // More tests will appear here as we develop Daemon class. -}; +} diff --git a/src/lib/process/tests/log_parser_unittests.cc b/src/lib/process/tests/log_parser_unittests.cc index 14acdbd1a180d2760645e42bf69152d933d53d52..487f7c0d9830967b2b42f41fc64ce5db3330921d 100644 --- a/src/lib/process/tests/log_parser_unittests.cc +++ b/src/lib/process/tests/log_parser_unittests.cc @@ -28,17 +28,21 @@ namespace { /// has the name "kea") but as the only other logger mentioned here ("wombat") /// is not used elsewhere, that is sufficient. class LoggingTest : public ::testing::Test { - public: - /// @brief Constructor - LoggingTest() {} - - /// @brief Destructor - /// - /// Reset root logger back to defaults. - ~LoggingTest() { +public: + + /// @brief Constructor + LoggingTest() = default; + + /// @brief Destructor + /// + /// Reset root logger back to defaults. + ~LoggingTest() { + try { isc::log::initLogger(); wipeFiles(); + } catch (...) { } + } /// @brief Generates a log file name suffixed with a rotation number /// @param rotation number to the append to the end of the file @@ -461,4 +465,4 @@ TEST_F(LoggingTest, emptyPattern) { /// check if the file is indeed created or configure stdout destination, then /// swap console file descriptors and check that messages are really logged. -}; +} diff --git a/src/lib/process/tests/logging_info_unittests.cc b/src/lib/process/tests/logging_info_unittests.cc index 865d6426b36861cc930a6fcaff2a19db5f736b79..f2b7531d974974187b23802e65df832079f481c4 100644 --- a/src/lib/process/tests/logging_info_unittests.cc +++ b/src/lib/process/tests/logging_info_unittests.cc @@ -51,6 +51,12 @@ TEST(LoggingDestination, equals) { class LoggingInfoTest : public ::testing::Test { public: + /// @brief Constructor + LoggingInfoTest() = default; + + /// @brief Destructor + virtual ~LoggingInfoTest() = default; + /// @brief Setup the test. virtual void SetUp() { Daemon::setVerbose(false); diff --git a/src/lib/process/testutils/d_test_stubs.cc b/src/lib/process/testutils/d_test_stubs.cc index 1186729e06f0cf86a5ec29a8ebcbf58d46f067ac..9c9b700f1dda6f9a1458fae2d9b95bd411145f3d 100644 --- a/src/lib/process/testutils/d_test_stubs.cc +++ b/src/lib/process/testutils/d_test_stubs.cc @@ -76,7 +76,10 @@ DStubProcess::configure(isc::data::ConstElementPtr config_set, bool check_only) } DStubProcess::~DStubProcess() { - Daemon::setVerbose(false); + try { + Daemon::setVerbose(false); + } catch (...) { + } }; //************************** DStubController ************************* @@ -164,9 +167,6 @@ DStubController::parseFile(const std::string& /*file_name*/) { return (elements); } -DStubController::~DStubController() { -} - //************************** DControllerTest ************************* void @@ -294,20 +294,11 @@ const char* DControllerTest::CFG_TEST_FILE = "d2-test-config.json"; //************************** DStubContext ************************* -DStubContext::DStubContext() { -} - -DStubContext::~DStubContext() { -} - ConfigPtr DStubContext::clone() { return (ConfigPtr(new DStubContext(*this))); } -DStubContext::DStubContext(const DStubContext& rhs): ConfigBase(rhs) { -} - isc::data::ElementPtr DStubContext::toElement() const { return (isc::data::Element::createMap()); @@ -319,9 +310,6 @@ DStubCfgMgr::DStubCfgMgr() : DCfgMgrBase(ConfigPtr(new DStubContext())) { } -DStubCfgMgr::~DStubCfgMgr() { -} - ConfigPtr DStubCfgMgr::createNewContext() { return (ConfigPtr (new DStubContext())); diff --git a/src/lib/process/testutils/d_test_stubs.h b/src/lib/process/testutils/d_test_stubs.h index 9881ee4dca5657e0651344ebb5d7c98e4c8c5517..9873aebfa16212ff219787a88566885b6f78011a 100644 --- a/src/lib/process/testutils/d_test_stubs.h +++ b/src/lib/process/testutils/d_test_stubs.h @@ -290,6 +290,7 @@ public: } private: + /// @brief Constructor is private to protect singleton integrity. DStubController(); @@ -303,7 +304,9 @@ private: bool use_alternate_parser_; public: - virtual ~DStubController(); + + /// @brief Destructor + virtual ~DStubController() = default; }; /// @brief Defines a pointer to a DStubController. @@ -339,17 +342,20 @@ public: /// Note the controller singleton is destroyed. This is essential to ensure /// a clean start between tests. virtual ~DControllerTest() { - // Some unit tests update the logging configuration which has a side - // effect that all subsequent tests print the output to stdout. This - // is to ensure that the logging settings are back to default. - isc::log::setDefaultLoggingOutput(); - - if (write_timer_) { - write_timer_->cancel(); + try { + // Some unit tests update the logging configuration which has a side + // effect that all subsequent tests print the output to stdout. This + // is to ensure that the logging settings are back to default. + isc::log::setDefaultLoggingOutput(); + + if (write_timer_) { + write_timer_->cancel(); + } + + getController().reset(); + static_cast(remove(CFG_TEST_FILE)); + } catch (...) { } - - getController().reset(); - static_cast(remove(CFG_TEST_FILE)); } /// @brief Convenience method that destructs and then recreates the @@ -595,10 +601,10 @@ class DStubContext : public ConfigBase { public: /// @brief Constructor - DStubContext(); + DStubContext() = default; /// @brief Destructor - virtual ~DStubContext(); + virtual ~DStubContext() = default; /// @brief Creates a clone of a DStubContext. /// @@ -607,7 +613,7 @@ public: protected: /// @brief Copy constructor - DStubContext(const DStubContext& rhs); + DStubContext(const DStubContext& rhs) = default; private: /// @brief Private assignment operator, not implemented. @@ -641,11 +647,12 @@ typedef boost::shared_ptr DStubContextPtr; /// are parsed. This is used to test ordered and non-ordered parsing. class DStubCfgMgr : public DCfgMgrBase { public: + /// @brief Constructor DStubCfgMgr(); /// @brief Destructor - virtual ~DStubCfgMgr(); + virtual ~DStubCfgMgr() = default; /// @brief Pretends to parse the config /// @@ -681,12 +688,10 @@ class ConfigParseTest : public ::testing::Test { public: /// @brief Constructor - ConfigParseTest(){ - } + ConfigParseTest() = default; /// @brief Destructor - ~ConfigParseTest() { - } + ~ConfigParseTest() = default; /// @brief Converts a given JSON string into an Element set and stores the /// result the member variable, config_set_. diff --git a/src/lib/stats/tests/stats_mgr_unittest.cc b/src/lib/stats/tests/stats_mgr_unittest.cc index 734d134c8ddfa6039d9939f26005fcccdfdc8bbd..104e2dd6492c24b4d4deed1240f356e5a421ff14 100644 --- a/src/lib/stats/tests/stats_mgr_unittest.cc +++ b/src/lib/stats/tests/stats_mgr_unittest.cc @@ -37,7 +37,9 @@ static const StatsDuration& dur1245(hours(1) + minutes(2) + seconds(45)); /// before the test and any statistics are wiped out after it. class StatsMgrTest : public ::testing::Test { public: + /// @brief Constructor + /// /// Makes sure that the Statistics Manager is instantiated. StatsMgrTest() { StatsMgr::instance(); @@ -45,11 +47,15 @@ public: } /// @brief Destructor + /// /// Removes all statistics and restores class defaults. ~StatsMgrTest() { - StatsMgr::instance().removeAll(); - StatsMgr::instance().setMaxSampleAgeDefault(StatsDuration::zero()); - StatsMgr::instance().setMaxSampleCountDefault(20); + try { + StatsMgr::instance().removeAll(); + StatsMgr::instance().setMaxSampleAgeDefault(StatsDuration::zero()); + StatsMgr::instance().setMaxSampleCountDefault(20); + } catch (...) { + } } }; diff --git a/src/lib/testutils/log_utils.cc b/src/lib/testutils/log_utils.cc index 50523190384ef76aecbff0bb6a08654b1774b9d3..ac847ea14ae8ac17592fec13a579e245fc03566c 100644 --- a/src/lib/testutils/log_utils.cc +++ b/src/lib/testutils/log_utils.cc @@ -42,7 +42,10 @@ LogContentTest::LogContentTest() } LogContentTest:: ~LogContentTest() { - remFile(); + try { + remFile(); + } catch (...) { + } } bool LogContentTest::checkFile() { diff --git a/src/lib/testutils/log_utils.h b/src/lib/testutils/log_utils.h index 9735e5ae8dfcd7019c6f0a9b5cd9a95b63adee79..224c6189d08d9d393b3c6d0a1d2b2ec0d9bf28d8 100644 --- a/src/lib/testutils/log_utils.h +++ b/src/lib/testutils/log_utils.h @@ -40,7 +40,9 @@ namespace test { class LogContentTest : public ::testing::Test { public: - /// @brief Initializes the logger setup for using + /// @brief Constructor + /// + /// Initializes the logger setup for using /// in checking log statements /// /// @todo add support to adjust the severity and debug level @@ -48,6 +50,7 @@ public: /// get logged. LogContentTest(); + /// @brief Destructor virtual ~LogContentTest(); /// @brief check that the requested strings are in the diff --git a/src/lib/testutils/multi_threading_utils.h b/src/lib/testutils/multi_threading_utils.h index 8754208198879a2cb51e9c03424b5d5472519ffe..fd9cf24f8631a2377768a28371cfa6de2b78caf5 100644 --- a/src/lib/testutils/multi_threading_utils.h +++ b/src/lib/testutils/multi_threading_utils.h @@ -28,7 +28,10 @@ public: /// @brief Destructor (disable multi threading). ~MultiThreadingTest() { - isc::util::MultiThreadingMgr::instance().setMode(false); + try { + isc::util::MultiThreadingMgr::instance().setMode(false); + } catch (...) { + } } }; diff --git a/src/lib/testutils/sandbox.h b/src/lib/testutils/sandbox.h index 8dfb5720ff338789377e9e8dce3a4fe378cb5cda..056a71dfb76b157c5a02d3137b06d32b9b161cbe 100644 --- a/src/lib/testutils/sandbox.h +++ b/src/lib/testutils/sandbox.h @@ -38,6 +38,7 @@ private: } public: + /// @brief Sandbox constructor. Sandbox() { char tmpl[] = {P_tmpdir "/kea-XXXXXX"}; @@ -46,11 +47,14 @@ public: /// @brief Destructor, it deletes temporary folder with its content. ~Sandbox() { - // Delete content of path_ recursively. - if (nftw(path_.c_str(), Sandbox::rmFile, 10, FTW_DEPTH | FTW_MOUNT | FTW_PHYS) < 0) { - auto msg = "Some error occurred while deleting unit test sandbox " + path_; - std::perror(msg.c_str()); - exit(1); + try { + // Delete content of path_ recursively. + if (nftw(path_.c_str(), Sandbox::rmFile, 10, FTW_DEPTH | FTW_MOUNT | FTW_PHYS) < 0) { + auto msg = "Some error occurred while deleting unit test sandbox " + path_; + std::perror(msg.c_str()); + exit(1); + } + } catch (...) { } } @@ -62,8 +66,7 @@ public: } }; - -}; // end of isc::test namespace -}; // end of isc namespace +} // end of isc::test namespace +} // end of isc namespace #endif // SANDBOX_H diff --git a/src/lib/testutils/unix_control_client.cc b/src/lib/testutils/unix_control_client.cc index f0f8dfaaab3fd2a53629b8077617c8f7ac88e4b5..779071e85e5adba8f649bd19ba59554b89000d32 100644 --- a/src/lib/testutils/unix_control_client.cc +++ b/src/lib/testutils/unix_control_client.cc @@ -23,7 +23,10 @@ UnixControlClient::UnixControlClient() { } UnixControlClient::~UnixControlClient() { - disconnectFromServer(); + try { + disconnectFromServer(); + } catch (...) { + } } /// @brief Closes the Control Channel socket @@ -134,6 +137,6 @@ int UnixControlClient::selectCheck(const unsigned int timeout_sec) { return (select(maxfd + 1, &read_fds, NULL, NULL, &select_timeout)); } -}; -}; -}; +} +} +} diff --git a/src/lib/testutils/unix_control_client.h b/src/lib/testutils/unix_control_client.h index 225c9491bfd596b2266cf888d8981294dbaeb73c..28390b488b032fbcfab41ac97149bdfff51ab640 100644 --- a/src/lib/testutils/unix_control_client.h +++ b/src/lib/testutils/unix_control_client.h @@ -59,8 +59,8 @@ public: int socket_fd_; }; -}; // end of isc::dhcp::test namespace -}; // end of isc::dhcp namespace -}; // end of isc namespace +} // end of isc::dhcp::test namespace +} // end of isc::dhcp namespace +} // end of isc namespace #endif // UNIX_CONTROL_CLIENT_H diff --git a/src/lib/util/buffer.h b/src/lib/util/buffer.h index 128db9998097a5da34ea28641b8484cbad6afa2f..48c8d530de7f921ee29c0c4ed471f6d66577907a 100644 --- a/src/lib/util/buffer.h +++ b/src/lib/util/buffer.h @@ -293,6 +293,7 @@ protected: /// the \c InputBuffer and \c MessageRenderer classes. class OutputBuffer { public: + /// /// \name Constructors and Destructor /// @@ -303,8 +304,7 @@ public: OutputBuffer(size_t len) : buffer_(NULL), size_(0), - allocated_(len) - { + allocated_(len) { // We use malloc and free instead of C++ new[] and delete[]. // This way we can use realloc, which may in fact do it without a copy. if (allocated_ != 0) { @@ -325,8 +325,7 @@ public: OutputBuffer(const OutputBuffer& other) : buffer_(NULL), size_(other.size_), - allocated_(other.allocated_) - { + allocated_(other.allocated_) { if (allocated_ != 0) { buffer_ = static_cast(malloc(allocated_)); if (buffer_ == NULL) { @@ -337,8 +336,11 @@ public: } /// \brief Destructor - ~ OutputBuffer() { - free(buffer_); + ~OutputBuffer() { + try { + free(buffer_); + } catch (...) { + } } //@} diff --git a/src/lib/util/csv_file.cc b/src/lib/util/csv_file.cc index f402038d18d146b8ebc36915724ea31adb69f832..cf45932fc0614071bf90c80354099a87977d6c75 100644 --- a/src/lib/util/csv_file.cc +++ b/src/lib/util/csv_file.cc @@ -116,7 +116,10 @@ CSVFile::CSVFile(const std::string& filename) } CSVFile::~CSVFile() { - close(); + try { + close(); + } catch (...) { + } } void @@ -552,6 +555,5 @@ CSVRow::unescapeCharacters(const std::string& escaped_str) { return(ss.str()); } - } // end of isc::util namespace } // end of isc namespace diff --git a/src/lib/util/io/socketsession.cc b/src/lib/util/io/socketsession.cc index 573931a30e3315fb94fb300204fb72cc92017710..85a2ed36270f27538cf35938a143d13c79ff97a2 100644 --- a/src/lib/util/io/socketsession.cc +++ b/src/lib/util/io/socketsession.cc @@ -76,7 +76,9 @@ const size_t INITIAL_BUFSIZE = 512; const int SOCKSESSION_BUFSIZE = (DEFAULT_HEADER_BUFLEN + MAX_DATASIZE) * 2; struct SocketSessionForwarder::ForwarderImpl { - ForwarderImpl() : fd_(-1), buf_(DEFAULT_HEADER_BUFLEN) {} + ForwarderImpl() : sock_un_len_(0), fd_(-1), buf_(DEFAULT_HEADER_BUFLEN) { + memset(&sock_un_, 0, sizeof(sock_un_)); + } struct sockaddr_un sock_un_; socklen_t sock_un_len_; int fd_; @@ -118,10 +120,13 @@ SocketSessionForwarder::SocketSessionForwarder(const std::string& unix_file) : } SocketSessionForwarder::~SocketSessionForwarder() { - if (impl_->fd_ != -1) { - close(); + try { + if (impl_->fd_ != -1) { + close(); + } + delete impl_; + } catch (...) { } - delete impl_; } void @@ -303,12 +308,14 @@ struct SocketSessionReceiver::ReceiverImpl { }; SocketSessionReceiver::SocketSessionReceiver(int fd) : - impl_(new ReceiverImpl(fd)) -{ + impl_(new ReceiverImpl(fd)) { } SocketSessionReceiver::~SocketSessionReceiver() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } namespace { @@ -328,17 +335,27 @@ readFail(int actual_len, int expected_len) { // SocketSessionReceiver::pop that ensures the socket is closed unless it // can be safely passed to the caller via release(). struct ScopedSocket : boost::noncopyable { - ScopedSocket(int fd) : fd_(fd) {} + + /// @brief Constructor + ScopedSocket(int fd) : fd_(fd) { + } + + /// @brief Destructor ~ScopedSocket() { - if (fd_ >= 0) { - close(fd_); + try { + if (fd_ >= 0) { + close(fd_); + } + } catch (...) { } } + int release() { const int fd = fd_; fd_ = -1; return (fd); } + int fd_; }; } diff --git a/src/lib/util/io/socketsession.h b/src/lib/util/io/socketsession.h index 52e33de64d51e697eb22990c982c7e73542c2001..08dd85fa47e36a93f3add9d0f726665e41a38d19 100644 --- a/src/lib/util/io/socketsession.h +++ b/src/lib/util/io/socketsession.h @@ -171,10 +171,15 @@ public: /// See description of \c SocketSessionForwarder for the expected interface. class BaseSocketSessionForwarder { protected: - BaseSocketSessionForwarder() {} + + /// @brief Constructor + BaseSocketSessionForwarder() = default; public: - virtual ~BaseSocketSessionForwarder() {} + + /// @brief Destructor + virtual ~BaseSocketSessionForwarder() = default; + virtual void connectToReceiver() = 0; virtual void close() = 0; virtual void push(int sock, int family, int type, int protocol, @@ -192,9 +197,9 @@ public: /// See the description of \ref SocketSessionUtility for other details of how /// the session forwarding works. class SocketSessionForwarder : boost::noncopyable, - public BaseSocketSessionForwarder -{ + public BaseSocketSessionForwarder { public: + /// The constructor. /// /// It's constructed with path information of the intended receiver, @@ -421,6 +426,7 @@ private: /// the session forwarding works. class SocketSessionReceiver : boost::noncopyable { public: + /// The constructor. /// /// \exception SocketSessionError Any error on an operation that is diff --git a/src/lib/util/labeled_value.cc b/src/lib/util/labeled_value.cc index 9fa184ad9dd27a228a2c8eeb9f24ede7b1077764..54800bb0ed56abb78be13ee84e09c0e5b0e7e703 100644 --- a/src/lib/util/labeled_value.cc +++ b/src/lib/util/labeled_value.cc @@ -20,9 +20,6 @@ LabeledValue::LabeledValue(const int value, const std::string& label) } } -LabeledValue::~LabeledValue(){ -} - int LabeledValue::getValue() const { return (value_); @@ -57,12 +54,6 @@ std::ostream& operator<<(std::ostream& os, const LabeledValue& vlp) { const char* LabeledValueSet::UNDEFINED_LABEL = "UNDEFINED"; -LabeledValueSet::LabeledValueSet(){ -} - -LabeledValueSet::~LabeledValueSet() { -} - void LabeledValueSet::add(LabeledValuePtr entry) { if (!entry) { diff --git a/src/lib/util/labeled_value.h b/src/lib/util/labeled_value.h index e85b5379046c4b18f719b363f8b2f982667be044..48249ba2b41f4c62efa93d6b6db62383e24b5b7e 100644 --- a/src/lib/util/labeled_value.h +++ b/src/lib/util/labeled_value.h @@ -50,7 +50,7 @@ public: /// @brief Destructor. /// /// Destructor is virtual to permit derivations. - virtual ~LabeledValue(); + virtual ~LabeledValue() = default; /// @brief Gets the integer value of this instance. /// @@ -119,12 +119,12 @@ public: /// @brief Constructor /// /// Constructs an empty set. - LabeledValueSet(); + LabeledValueSet() = default; /// @brief Destructor /// /// Destructor is virtual to permit derivations. - virtual ~LabeledValueSet(); + virtual ~LabeledValueSet() = default; /// @brief Adds the given entry to the set /// diff --git a/src/lib/util/memory_segment.h b/src/lib/util/memory_segment.h index c9ae97f9dea05873a027ce89a6ee4f0c39dafc15..34acce6794f3857d96e60ebd4e76b9c395db907d 100644 --- a/src/lib/util/memory_segment.h +++ b/src/lib/util/memory_segment.h @@ -53,8 +53,12 @@ public: /// MemorySegmentLocal should be used in code. class MemorySegment { public: + + /// \brief Constructor + MemorySegment() = default; + /// \brief Destructor - virtual ~MemorySegment() {} + virtual ~MemorySegment() = default; /// \brief Allocate/acquire a fragment of memory. /// diff --git a/src/lib/util/memory_segment_local.h b/src/lib/util/memory_segment_local.h index 2c0ee53db65a2113f588eb6f2f05183ab3b42f2b..9b582a50a7aef85b7efacec8fab69d968889bac4 100644 --- a/src/lib/util/memory_segment_local.h +++ b/src/lib/util/memory_segment_local.h @@ -22,6 +22,7 @@ namespace util { /// documentation for usage. class MemorySegmentLocal : public MemorySegment { public: + /// \brief Constructor /// /// Creates a local memory segment object @@ -29,7 +30,7 @@ public: } /// \brief Destructor - virtual ~MemorySegmentLocal() {} + virtual ~MemorySegmentLocal() = default; /// \brief Allocate/acquire a segment of memory. The source of the /// memory is libc's malloc(). diff --git a/src/lib/util/multi_threading_mgr.cc b/src/lib/util/multi_threading_mgr.cc index 4b2c2d3df7ffa122e7a533c7a4d35ccda99cd827..cc6df6c3916e033d26f6f4de62a5d16ce6171f70 100644 --- a/src/lib/util/multi_threading_mgr.cc +++ b/src/lib/util/multi_threading_mgr.cc @@ -15,9 +15,6 @@ MultiThreadingMgr::MultiThreadingMgr() : enabled_(false), critical_section_count_(0), thread_pool_size_(0) { } -MultiThreadingMgr::~MultiThreadingMgr() { -} - MultiThreadingMgr& MultiThreadingMgr::instance() { static MultiThreadingMgr manager; @@ -178,7 +175,10 @@ MultiThreadingCriticalSection::MultiThreadingCriticalSection() { } MultiThreadingCriticalSection::~MultiThreadingCriticalSection() { - MultiThreadingMgr::instance().exitCriticalSection(); + try { + MultiThreadingMgr::instance().exitCriticalSection(); + } catch (...) { + } } void diff --git a/src/lib/util/multi_threading_mgr.h b/src/lib/util/multi_threading_mgr.h index 2fe8e50790b676cc9a1e010bc85f3d7b7a2775d7..859e4a51358b774e7a7d52994123a0f104fd5737 100644 --- a/src/lib/util/multi_threading_mgr.h +++ b/src/lib/util/multi_threading_mgr.h @@ -234,7 +234,7 @@ protected: MultiThreadingMgr(); /// @brief Destructor. - virtual ~MultiThreadingMgr(); + virtual ~MultiThreadingMgr() = default; private: diff --git a/src/lib/util/pid_file.cc b/src/lib/util/pid_file.cc index ef519b3d870fdfb42c4f5a01d9fde3a7cbcf3313..5e438bdc44ad7d7408c84053951ce0ba28ff6f80 100644 --- a/src/lib/util/pid_file.cc +++ b/src/lib/util/pid_file.cc @@ -19,9 +19,6 @@ PIDFile::PIDFile(const std::string& filename) : filename_(filename) { } -PIDFile::~PIDFile() { -} - int PIDFile::check() const { std::ifstream fs(filename_.c_str()); diff --git a/src/lib/util/pid_file.h b/src/lib/util/pid_file.h index a30640d5ff69c20d2b85a723103af0257bec77e8..d4df0b0949344928b8f7a69793d7f6ed69072146 100644 --- a/src/lib/util/pid_file.h +++ b/src/lib/util/pid_file.h @@ -39,13 +39,14 @@ public: /// process is still running. class PIDFile { public: + /// @brief Constructor /// /// @param filename PID filename. PIDFile(const std::string& filename); /// @brief Destructor - ~PIDFile(); + ~PIDFile() = default; /// @brief Read the PID in from the file and check it. /// diff --git a/src/lib/util/readwrite_mutex.h b/src/lib/util/readwrite_mutex.h index f8766d5af42f2cd9e52c3681b9ca8723ca7d8a99..8ec5589589d06582ffe808a24eed8eb889e94050 100644 --- a/src/lib/util/readwrite_mutex.h +++ b/src/lib/util/readwrite_mutex.h @@ -47,7 +47,10 @@ public: /// @note: do not check that state is 0 as there is nothing very /// useful to do in this case... virtual ~ReadWriteMutex() { - std::lock_guard lk(mutex_); + try { + std::lock_guard lk(mutex_); + } catch (...) { + } } /// @brief Lock write. @@ -149,7 +152,10 @@ public: /// @brief Destructor. virtual ~ReadLockGuard() { - rw_mutex_.readUnlock(); + try { + rw_mutex_.readUnlock(); + } catch (...) { + } } private: @@ -173,7 +179,10 @@ public: /// @brief Destructor. virtual ~WriteLockGuard() { - rw_mutex_.writeUnlock(); + try { + rw_mutex_.writeUnlock(); + } catch (...) { + } } private: diff --git a/src/lib/util/state_model.cc b/src/lib/util/state_model.cc index 6c9a13d8a24801e2e1b679afecf1c6912e673907..be23db4ee62d2e15c75fc6414febbda96b302ec1 100644 --- a/src/lib/util/state_model.cc +++ b/src/lib/util/state_model.cc @@ -19,9 +19,6 @@ State::State(const int value, const std::string& label, StateHandler handler, was_paused_(false) { } -State::~State() { -} - void State::run() { (handler_)(); @@ -39,12 +36,6 @@ State::shouldPause() { /********************************** StateSet *******************************/ -StateSet::StateSet() { -} - -StateSet::~StateSet() { -} - void StateSet::add(const int value, const std::string& label, StateHandler handler, const StatePausing& state_pausing) { @@ -93,9 +84,6 @@ StateModel::StateModel() : events_(), states_(), dictionaries_initted_(false), paused_(false), mutex_(new std::mutex) { } -StateModel::~StateModel(){ -} - void StateModel::startModel(const int start_state) { // Initialize dictionaries of events and states. diff --git a/src/lib/util/state_model.h b/src/lib/util/state_model.h index da297da95d9258b32156bd7c5c9e518b59d81c96..ad1329b667d7e80320796462b94efa8cdeccff74 100644 --- a/src/lib/util/state_model.h +++ b/src/lib/util/state_model.h @@ -60,6 +60,7 @@ enum StatePausing { /// the state model should be paused when entering this state. class State : public LabeledValue { public: + /// @brief Constructor /// /// @param value is the numeric value of the state @@ -81,7 +82,7 @@ public: const StatePausing& state_pausing = STATE_PAUSE_NEVER); /// @brief Destructor - virtual ~State(); + virtual ~State() = default; /// @brief Invokes the State's handler. void run(); @@ -117,11 +118,12 @@ typedef boost::shared_ptr StatePtr; /// text labels, and their handlers. class StateSet : public LabeledValueSet { public: + /// @brief Constructor - StateSet(); + StateSet() = default; /// @brief Destructor - virtual ~StateSet(); + virtual ~StateSet() = default; /// @brief Adds a state definition to the set of states. /// @@ -308,7 +310,7 @@ public: StateModel(); /// @brief Destructor - virtual ~StateModel(); + virtual ~StateModel() = default; /// @brief Begins execution of the model. /// diff --git a/src/lib/util/stopwatch.cc b/src/lib/util/stopwatch.cc index f75c6cdf4c60cae4d605d4cc670a5294b0bb72cf..cdee4b1aca7e065f57ab7cb0fd9c6e2ec810b0c4 100644 --- a/src/lib/util/stopwatch.cc +++ b/src/lib/util/stopwatch.cc @@ -23,7 +23,10 @@ Stopwatch::Stopwatch(const bool autostart) } Stopwatch::~Stopwatch() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } void diff --git a/src/lib/util/stopwatch_impl.cc b/src/lib/util/stopwatch_impl.cc index 8f6bc653dd63f18f941fa5cf90636c18f481aca5..d9d90e2bfc6db7198141aca4effa89e369f6eb81 100644 --- a/src/lib/util/stopwatch_impl.cc +++ b/src/lib/util/stopwatch_impl.cc @@ -22,9 +22,6 @@ StopwatchImpl::StopwatchImpl() cumulative_time_(microseconds(0)) { } -StopwatchImpl::~StopwatchImpl() { -} - void StopwatchImpl::start() { // If stopwatch is "stopped", start it. diff --git a/src/lib/util/stopwatch_impl.h b/src/lib/util/stopwatch_impl.h index 3c1ee9cfb4627247ecbfb2354f674fed3a207ef1..7e3a02cdbb75c50605e60a7a355cf462a6ebda73 100644 --- a/src/lib/util/stopwatch_impl.h +++ b/src/lib/util/stopwatch_impl.h @@ -38,7 +38,7 @@ public: /// /// This destructor is virtual because the @c StopwatchImpl::getCurrentTime /// is virtual. - virtual ~StopwatchImpl(); + virtual ~StopwatchImpl() = default; /// @brief Starts the stopwatch. /// diff --git a/src/lib/util/strutil.cc b/src/lib/util/strutil.cc index 7eaabdc4d53ee6485613758592432dc61bd2dffd..5396eef6a0fe2821e733244183211b6976854cb0 100644 --- a/src/lib/util/strutil.cc +++ b/src/lib/util/strutil.cc @@ -309,6 +309,8 @@ decodeFormattedHexString(const std::string& hex_string, class StringSanitizerImpl { public: + + /// @brief Constructor StringSanitizerImpl(const std::string& char_set, const std::string& char_replacement) : char_set_(char_set), char_replacement_(char_replacement) { if (char_set.size() > StringSanitizer::MAX_DATA_SIZE) { @@ -342,9 +344,12 @@ public: /// @brief Destructor. ~StringSanitizerImpl() { + try { #ifndef USE_REGEX - regfree(&scrub_exp_); + regfree(&scrub_exp_); #endif + } catch (...) { + } } std::string scrub(const std::string& original) { @@ -440,7 +445,10 @@ StringSanitizer::StringSanitizer(const std::string& char_set, } StringSanitizer::~StringSanitizer() { - delete impl_; + try { + delete impl_; + } catch (...) { + } } std::string diff --git a/src/lib/util/tests/csv_file_unittest.cc b/src/lib/util/tests/csv_file_unittest.cc index fbc75c961b2aeef54a68d4c801e21382a63ddd33..1565e60a503eacac4cc84e125091c1ab27a8df7b 100644 --- a/src/lib/util/tests/csv_file_unittest.cc +++ b/src/lib/util/tests/csv_file_unittest.cc @@ -243,7 +243,10 @@ CSVFileTest::CSVFileTest() } CSVFileTest::~CSVFileTest() { - static_cast(removeFile()); + try { + static_cast(removeFile()); + } catch (...) { + } } std::string diff --git a/src/lib/util/tests/fd_tests.cc b/src/lib/util/tests/fd_tests.cc index f2ffb98e9778c3bf12f0e173f4e9718ad476e4e9..44e773ce30a467496ea09594ad6a2e3d3b71e253 100644 --- a/src/lib/util/tests/fd_tests.cc +++ b/src/lib/util/tests/fd_tests.cc @@ -24,19 +24,25 @@ namespace { const size_t TEST_DATA_SIZE = 8 * 1024 * 1024; class FDTest : public ::testing::Test { - public: - unsigned char *data, *buffer; - FDTest() : - // We do not care what is inside, we just need it to be the same - data(new unsigned char[TEST_DATA_SIZE]), - buffer(NULL) - { - memset(data, 0, TEST_DATA_SIZE); - } - ~ FDTest() { +public: + unsigned char *data, *buffer; + + /// @brief Constructor + FDTest() : + // We do not care what is inside, we just need it to be the same + data(new unsigned char[TEST_DATA_SIZE]), + buffer(NULL) { + memset(data, 0, TEST_DATA_SIZE); + } + + /// @brief Destructor + ~FDTest() { + try { delete[] data; delete[] buffer; + } catch (...) { } + } }; // Test we read what was sent diff --git a/src/lib/util/tests/pid_file_unittest.cc b/src/lib/util/tests/pid_file_unittest.cc index 08b1881eb73a8244bbcf99a6a69a23412990e08b..f4c0d473675e9768d58b7c7b28dc831d5b0e8dde 100644 --- a/src/lib/util/tests/pid_file_unittest.cc +++ b/src/lib/util/tests/pid_file_unittest.cc @@ -20,6 +20,13 @@ const char* TESTNAME = "pid_file.test"; class PIDFileTest : public ::testing::Test { public: + + /// @brief Constructor + PIDFileTest() = default; + + /// @brief Destructor + virtual ~PIDFileTest() = default; + /// @brief Prepends the absolute path to the file specified /// as an argument. /// @@ -196,4 +203,5 @@ TEST_F(PIDFileTest, noDeleteFile) { // Delete a file we haven't created pid_file.deleteFile(); } + } // end of anonymous namespace diff --git a/src/lib/util/tests/random_number_generator_unittest.cc b/src/lib/util/tests/random_number_generator_unittest.cc index 5710c95f05b595d9fbff03c362bcd9f5834219fc..d1194ecde21e02a6bacdad7e836744c1202cde5a 100644 --- a/src/lib/util/tests/random_number_generator_unittest.cc +++ b/src/lib/util/tests/random_number_generator_unittest.cc @@ -27,11 +27,13 @@ using namespace std; /// Or maybe we can trust the boost implementation class UniformRandomIntegerGeneratorTest : public ::testing::Test { public: - UniformRandomIntegerGeneratorTest(): - gen_(min_, max_) - { + + /// @brief Constructor + UniformRandomIntegerGeneratorTest() : gen_(min_, max_) { } - virtual ~UniformRandomIntegerGeneratorTest(){} + + /// @brief Destructor + virtual ~UniformRandomIntegerGeneratorTest() = default; int gen() { return (gen_()); } int max() const { return (max_); } @@ -79,11 +81,12 @@ TEST_F(UniformRandomIntegerGeneratorTest, IntegerRange) { /// \brief Test Fixture Class for weighted random number generator class WeightedRandomIntegerGeneratorTest : public ::testing::Test { public: - WeightedRandomIntegerGeneratorTest() - { } - virtual ~WeightedRandomIntegerGeneratorTest() - { } + /// @brief Constructor + WeightedRandomIntegerGeneratorTest() = default; + + /// @brief Destructor + virtual ~WeightedRandomIntegerGeneratorTest() = default; }; // Test of the weighted random number generator constructor diff --git a/src/lib/util/tests/state_model_unittest.cc b/src/lib/util/tests/state_model_unittest.cc index eaaba738f40c74382cf785f872bfe5dfd691686d..dc6fd6c056a3b3e8c37e695e3ac562dca2a85d72 100644 --- a/src/lib/util/tests/state_model_unittest.cc +++ b/src/lib/util/tests/state_model_unittest.cc @@ -69,9 +69,9 @@ public: StateModelTest() : dummy_called_(false), work_completed_(false), failure_explanation_("") { } + /// @brief Destructor - virtual ~StateModelTest() { - } + virtual ~StateModelTest() = default; /// @brief Fetches the value of the dummy called flag. bool getDummyCalled() { diff --git a/src/lib/util/tests/time_utilities_unittest.cc b/src/lib/util/tests/time_utilities_unittest.cc index 1637a7a19ef419e721f191aa3701ff4806631f9a..14412f9aaa4d651117feecab68589f30ab7a15b9 100644 --- a/src/lib/util/tests/time_utilities_unittest.cc +++ b/src/lib/util/tests/time_utilities_unittest.cc @@ -30,8 +30,16 @@ namespace { class DNSSECTimeTest : public ::testing::Test { protected: + + /// @brief Constructor + DNSSECTimeTest() = default; + + /// @brief Destructor ~DNSSECTimeTest() { - detail::gettimeFunction = NULL; + try { + detail::gettimeFunction = NULL; + } catch (...) { + } } }; diff --git a/src/lib/util/tests/versioned_csv_file_unittest.cc b/src/lib/util/tests/versioned_csv_file_unittest.cc index 36a1f913e8d28b1bcd9fefa12c5cd4e2ec83cef2..4b6286f66d5b71bf8e35234e49ac575672f1b63c 100644 --- a/src/lib/util/tests/versioned_csv_file_unittest.cc +++ b/src/lib/util/tests/versioned_csv_file_unittest.cc @@ -77,7 +77,10 @@ VersionedCSVFileTest::VersionedCSVFileTest() } VersionedCSVFileTest::~VersionedCSVFileTest() { - static_cast(removeFile()); + try { + static_cast(removeFile()); + } catch (...) { + } } std::string diff --git a/src/lib/util/tests/watched_thread_unittest.cc b/src/lib/util/tests/watched_thread_unittest.cc index dd01550772bbb614a79969dff5459c3034bda3e6..a5565ee1fc041f07b312bd19343bbb2f29b9419f 100644 --- a/src/lib/util/tests/watched_thread_unittest.cc +++ b/src/lib/util/tests/watched_thread_unittest.cc @@ -28,11 +28,10 @@ public: static const int WORKER_MAX_PASSES; /// @brief Constructor. - WatchedThreadTest() {} + WatchedThreadTest() = default; /// @brief Destructor. - ~WatchedThreadTest() { - } + ~WatchedThreadTest() = default; /// @brief Sleeps for a given number of event periods sleep /// Each period is 50 ms. diff --git a/src/lib/util/thread_pool.h b/src/lib/util/thread_pool.h index 7313ea73f0e1ab6fc4f3ae2d692dc7f9a1d5d5bf..ae89f35c7ccddb2a97276cfa8231490c57dc79ef 100644 --- a/src/lib/util/thread_pool.h +++ b/src/lib/util/thread_pool.h @@ -45,12 +45,14 @@ struct ThreadPool { typedef typename boost::shared_ptr WorkItemPtr; /// @brief Constructor - ThreadPool() { - } + ThreadPool() = default; /// @brief Destructor ~ThreadPool() { - reset(); + try { + reset(); + } catch (...) { + } } /// @brief reset the thread pool stopping threads and clearing the internal @@ -237,6 +239,7 @@ private: /// @tparam QueueContainer a 'queue like' container template > struct ThreadPoolQueue { + /// @brief Constructor /// /// Creates the thread pool queue in 'disabled' state @@ -249,8 +252,11 @@ private: /// /// Destroys the thread pool queue ~ThreadPoolQueue() { - disable(); - clear(); + try { + disable(); + clear(); + } catch (...) { + } } /// @brief set maximum number of work items in the queue diff --git a/src/lib/util/unlock_guard.h b/src/lib/util/unlock_guard.h index 30be51486c8713d6815462d56b7bc1d16efa1712..86e6f008cc43978ef565153ef2fa74527a19791e 100644 --- a/src/lib/util/unlock_guard.h +++ b/src/lib/util/unlock_guard.h @@ -20,6 +20,7 @@ namespace util { template class UnlockGuard : public boost::noncopyable { public: + /// @brief Constructor. /// /// Unlock mutex object on constructor. @@ -33,7 +34,10 @@ public: /// /// Lock mutex object on destructor. ~UnlockGuard() { - lock_.lock(); + try { + lock_.lock(); + } catch (...) { + } } private: diff --git a/src/lib/util/versioned_csv_file.cc b/src/lib/util/versioned_csv_file.cc index 8c48f66e10d6aa633badaac8b9b8e6ea20e2ed42..4e5085a2706bad77ac538ccd5346fe9c009439e1 100644 --- a/src/lib/util/versioned_csv_file.cc +++ b/src/lib/util/versioned_csv_file.cc @@ -17,9 +17,6 @@ VersionedCSVFile::VersionedCSVFile(const std::string& filename) input_schema_state_(CURRENT) { } -VersionedCSVFile::~VersionedCSVFile() { -} - void VersionedCSVFile::addColumn(const std::string& name, const std::string& version, diff --git a/src/lib/util/versioned_csv_file.h b/src/lib/util/versioned_csv_file.h index cfd18d945c6914ae2ecdb01d77e78d0aec5da4c9..7bc6f4286c8c71ea014f510310afd3d2b6ca13e3 100644 --- a/src/lib/util/versioned_csv_file.h +++ b/src/lib/util/versioned_csv_file.h @@ -22,6 +22,7 @@ public: /// @brief Contains the metadata for a single column in a file. class VersionedColumn { public: + /// @brief Constructor /// /// @param name Name of the column. @@ -32,10 +33,10 @@ public: VersionedColumn(const std::string& name, const std::string& version, const std::string& default_value = "") : name_(name), version_(version), default_value_(default_value) { - }; + } /// @brief Destructor - virtual ~VersionedColumn(){}; + virtual ~VersionedColumn() = default; /// @brief Name of the column. std::string name_; @@ -135,7 +136,7 @@ public: VersionedCSVFile(const std::string& filename); /// @brief Destructor - virtual ~VersionedCSVFile(); + virtual ~VersionedCSVFile() = default; /// @brief Adds metadata for a single column to the schema. /// @@ -310,7 +311,6 @@ private: enum InputSchemaState input_schema_state_; }; - } // namespace isc::util } // namespace isc diff --git a/src/lib/util/watch_socket.cc b/src/lib/util/watch_socket.cc index 6ffb3960830c7a801e8ff2e22caa1dcc656981fd..2ea3566c4b827c62edda79ceff9f0f13e2b6c30f 100644 --- a/src/lib/util/watch_socket.cc +++ b/src/lib/util/watch_socket.cc @@ -57,7 +57,10 @@ WatchSocket::WatchSocket() } WatchSocket::~WatchSocket() { - closeSocket(); + try { + closeSocket(); + } catch (...) { + } } void diff --git a/src/lib/util/watched_thread.h b/src/lib/util/watched_thread.h index 47b72642f2a3a6bcfd94582b3d0fbdcac618973e..a2f479e011168c0f8b016afb7f73b2b402dc8e34 100644 --- a/src/lib/util/watched_thread.h +++ b/src/lib/util/watched_thread.h @@ -39,10 +39,10 @@ public: }; /// @brief Constructor - WatchedThread(){}; + WatchedThread() = default; /// @brief Virtual destructor - virtual ~WatchedThread(){} + virtual ~WatchedThread() = default; /// @brief Fetches the fd of a watch socket /// diff --git a/src/lib/yang/adaptor.cc b/src/lib/yang/adaptor.cc index 597f233055305e87afb50d52b1a7666706fc514c..60c0615396e6ce8ee3d0a3935526ef895b4a30b4 100644 --- a/src/lib/yang/adaptor.cc +++ b/src/lib/yang/adaptor.cc @@ -17,12 +17,6 @@ using namespace isc::data; namespace isc { namespace yang { -Adaptor::Adaptor() { -} - -Adaptor::~Adaptor() { -} - ConstElementPtr Adaptor::getContext(ConstElementPtr parent) { diff --git a/src/lib/yang/adaptor.h b/src/lib/yang/adaptor.h index fa1bbd68847183e64c290702dedbf2eaea9c99db..9ba7c7cee6658c0b131f1fc278644231a3f3f478 100644 --- a/src/lib/yang/adaptor.h +++ b/src/lib/yang/adaptor.h @@ -31,10 +31,10 @@ class Adaptor { public: /// @brief Constructor. - Adaptor(); + Adaptor() = default; /// @brief Destructor. - virtual ~Adaptor(); + virtual ~Adaptor() = default; /// @brief Get user context. /// @@ -127,7 +127,7 @@ public: }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_ADAPTOR_H diff --git a/src/lib/yang/adaptor_config.cc b/src/lib/yang/adaptor_config.cc index 0128792a6a7b533e1ed9f597a19e8c1edd818030..c9d3975ec003e99d8f12f0cc78ca2d4d50b1cfa6 100644 --- a/src/lib/yang/adaptor_config.cc +++ b/src/lib/yang/adaptor_config.cc @@ -20,12 +20,6 @@ const string DHCP6_SPACE = "dhcp6"; namespace isc { namespace yang { -AdaptorConfig::AdaptorConfig() { -} - -AdaptorConfig::~AdaptorConfig() { -} - bool AdaptorConfig::subnetsCollectID(ConstElementPtr subnets, SubnetIDSet& set) { bool have_ids = true; diff --git a/src/lib/yang/adaptor_config.h b/src/lib/yang/adaptor_config.h index d849a611ee981391be47c7b10b349b826b7e5f1c..4e713249b8275760f359e3e7f3f04f272f0dbedd 100644 --- a/src/lib/yang/adaptor_config.h +++ b/src/lib/yang/adaptor_config.h @@ -22,15 +22,14 @@ namespace yang { /// as preProcess4 and preProcess6 class methods, filling some required /// (by YANG) fields (e.g. subnet IDs, or option code and space), or /// transforming a hand-written JSON configuration into a canonical form. -class AdaptorConfig : public AdaptorHost, public AdaptorOption, - public AdaptorSubnet { +class AdaptorConfig : public AdaptorHost, public AdaptorOption, public AdaptorSubnet { public: /// @brief Constructor. - AdaptorConfig(); + AdaptorConfig() = default; /// @brief Destructor. - virtual ~AdaptorConfig(); + virtual ~AdaptorConfig() = default; /// @brief Pre process a DHCPv4 configuration. /// @@ -288,7 +287,7 @@ protected: const std::string& space); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_ADAPTOR_CONFIG_H diff --git a/src/lib/yang/adaptor_host.cc b/src/lib/yang/adaptor_host.cc index c02896af0e15cc10a0915879dc5c64f74ffbc7d9..6f6639301b929c8aa72ad0e0e1130735dda0b65b 100644 --- a/src/lib/yang/adaptor_host.cc +++ b/src/lib/yang/adaptor_host.cc @@ -23,12 +23,6 @@ const string AdaptorHost::STD_CHARACTERS = "0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-.@_"; -AdaptorHost::AdaptorHost() { -} - -AdaptorHost::~AdaptorHost() { -} - void AdaptorHost::quoteIdentifier(ElementPtr host) { ConstElementPtr flex_id = host->get("flex-id"); diff --git a/src/lib/yang/adaptor_host.h b/src/lib/yang/adaptor_host.h index 918b4bf7b2198e5685b95cf111e71445200b023f..721e7071d76eaacaa525c2856b3e30e8da3bb76f 100644 --- a/src/lib/yang/adaptor_host.h +++ b/src/lib/yang/adaptor_host.h @@ -26,10 +26,10 @@ public: static const std::string STD_CHARACTERS; /// @brief Constructor. - AdaptorHost(); + AdaptorHost() = default; /// @brief Destructor. - virtual ~AdaptorHost(); + virtual ~AdaptorHost() = default; /// @brief Quote when needed a host identifier. /// @@ -41,7 +41,7 @@ public: static void quoteIdentifier(isc::data::ElementPtr host); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_ADAPTOR_HOST_H diff --git a/src/lib/yang/adaptor_option.cc b/src/lib/yang/adaptor_option.cc index db61ac366fa1cf1d8c147e2f0229b918d253d873..b27c3333d8f80222bc1771083bfd09656692826c 100644 --- a/src/lib/yang/adaptor_option.cc +++ b/src/lib/yang/adaptor_option.cc @@ -17,12 +17,6 @@ using namespace isc::dhcp; namespace isc { namespace yang { -AdaptorOption::AdaptorOption() { -} - -AdaptorOption::~AdaptorOption() { -} - void AdaptorOption::setSpace(ElementPtr option, const string& space) { if (!option->contains("space")) { diff --git a/src/lib/yang/adaptor_option.h b/src/lib/yang/adaptor_option.h index e3c53f18e20957670a592219aed7d079a2bbb111..2e0ae004dce20076a303a8b03d02eb380a0306e5 100644 --- a/src/lib/yang/adaptor_option.h +++ b/src/lib/yang/adaptor_option.h @@ -46,10 +46,10 @@ class AdaptorOption { public: /// @brief Constructor. - AdaptorOption(); + AdaptorOption() = default; /// @brief Destructor. - virtual ~AdaptorOption(); + virtual ~AdaptorOption() = default; /// @brief Set space. /// @@ -105,7 +105,7 @@ protected: size_t params_size); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_ADAPTOR_OPTION_H diff --git a/src/lib/yang/adaptor_pool.cc b/src/lib/yang/adaptor_pool.cc index a6586332dc09c029d3431eb84967eee1b771c001..d6b67bf61b35c5b7c09593c8c0e87d9d0499a46c 100644 --- a/src/lib/yang/adaptor_pool.cc +++ b/src/lib/yang/adaptor_pool.cc @@ -15,12 +15,6 @@ using namespace isc::data; namespace isc { namespace yang { -AdaptorPool::AdaptorPool() { -} - -AdaptorPool::~AdaptorPool() { -} - void AdaptorPool::canonizePool(ElementPtr pool) { const string& orig = pool->get("pool")->stringValue(); diff --git a/src/lib/yang/adaptor_pool.h b/src/lib/yang/adaptor_pool.h index f8e72bf2c48085e8b9da734378035d9d3f544e09..df2163e9af62d2fd9cb0f025f6427a654914763e 100644 --- a/src/lib/yang/adaptor_pool.h +++ b/src/lib/yang/adaptor_pool.h @@ -29,10 +29,10 @@ class AdaptorPool { public: /// @brief Constructor. - AdaptorPool(); + AdaptorPool() = default; /// @brief Destructor. - virtual ~AdaptorPool(); + virtual ~AdaptorPool() = default; /// @brief Canonize pool. /// @@ -92,7 +92,7 @@ protected: isc::data::ConstElementPtr pools); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_ADAPTOR_POOL_H diff --git a/src/lib/yang/adaptor_subnet.cc b/src/lib/yang/adaptor_subnet.cc index bb352b979f1b788c1225e99a303d4f75368a61a2..303706a465cf3f82a73880db7d3631ea328a81f2 100644 --- a/src/lib/yang/adaptor_subnet.cc +++ b/src/lib/yang/adaptor_subnet.cc @@ -15,12 +15,6 @@ using namespace isc::dhcp; namespace isc { namespace yang { -AdaptorSubnet::AdaptorSubnet() { -} - -AdaptorSubnet::~AdaptorSubnet() { -} - bool AdaptorSubnet::collectID(ConstElementPtr subnet, SubnetIDSet& set) { ConstElementPtr id = subnet->get("id"); diff --git a/src/lib/yang/adaptor_subnet.h b/src/lib/yang/adaptor_subnet.h index 0bfcae00efb3c188853663aa43c0d677af7c512e..a84786a0cf413fd5b59929da5da4e4eca0dab324 100644 --- a/src/lib/yang/adaptor_subnet.h +++ b/src/lib/yang/adaptor_subnet.h @@ -31,10 +31,10 @@ class AdaptorSubnet { public: /// @brief Constructor. - AdaptorSubnet(); + AdaptorSubnet() = default; /// @brief Destructor. - virtual ~AdaptorSubnet(); + virtual ~AdaptorSubnet() = default; /// @brief Collect a subnet ID. /// @@ -60,7 +60,7 @@ public: static void updateRelay(isc::data::ElementPtr subnet); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_ADAPTOR_SUBNET_H diff --git a/src/lib/yang/tests/config_unittests.cc b/src/lib/yang/tests/config_unittests.cc index f749a3060a4b59ba62809df15fd7e9394f087a86..0f11d12539f23ffb1e0101ac01a9a13de711424a 100644 --- a/src/lib/yang/tests/config_unittests.cc +++ b/src/lib/yang/tests/config_unittests.cc @@ -62,9 +62,12 @@ public: /// @brief Virtual destructor. virtual ~ConfigTest() { - session_.reset(); - connection_.reset(); - model_.clear(); + try { + session_.reset(); + connection_.reset(); + model_.clear(); + } catch (...) { + } } /// @brief Set model. @@ -427,4 +430,4 @@ TEST_F(ConfigTest, designExample) { EXPECT_TRUE(verify(designExampleTree)); } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/yang/tests/sysrepo_setup.h b/src/lib/yang/tests/sysrepo_setup.h index 855431f4118a024aa1ab38135240f7496b6d4f8d..81b5064e8feacb13a0a7b2990d81fd9657b25e24 100644 --- a/src/lib/yang/tests/sysrepo_setup.h +++ b/src/lib/yang/tests/sysrepo_setup.h @@ -50,9 +50,12 @@ public: /// /// Destroy all objects. virtual ~GenericTranslatorTest() { - t_obj_.reset(); - sess_.reset(); - conn_.reset(); + try { + t_obj_.reset(); + sess_.reset(); + conn_.reset(); + } catch (...) { + } } /// @brief Sysrepo connection. diff --git a/src/lib/yang/tests/translator_class_unittests.cc b/src/lib/yang/tests/translator_class_unittests.cc index 30191b259c0c54366b17d6f791a2d78ef389684d..60672eb87e83792d1f9d561cb46438e39830f867 100644 --- a/src/lib/yang/tests/translator_class_unittests.cc +++ b/src/lib/yang/tests/translator_class_unittests.cc @@ -33,10 +33,10 @@ class TranslatorClassesTest : public: /// Constructor. - TranslatorClassesTest() { } + TranslatorClassesTest() = default; /// Destructor (does nothing). - virtual ~TranslatorClassesTest() { } + virtual ~TranslatorClassesTest() = default; }; // This test verifies that an empty client class list can be properly @@ -145,4 +145,4 @@ TEST_F(TranslatorClassesTest, set) { EXPECT_NO_THROW(sess_->validate()); } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/yang/tests/translator_control_socket_unittests.cc b/src/lib/yang/tests/translator_control_socket_unittests.cc index 5ceef861b4dcb6a93765cd29d890b6b85e26e545..de05e933bfe95be8dc9b21e82f54a6374c18b076 100644 --- a/src/lib/yang/tests/translator_control_socket_unittests.cc +++ b/src/lib/yang/tests/translator_control_socket_unittests.cc @@ -32,10 +32,10 @@ class TranslatorControlSocketTest : public: /// Constructor. - TranslatorControlSocketTest() { } + TranslatorControlSocketTest() = default; /// Destructor (does nothing). - virtual ~TranslatorControlSocketTest() { } + virtual ~TranslatorControlSocketTest() = default; }; // This test verifies that an empty control socket can be properly @@ -153,4 +153,4 @@ TEST_F(TranslatorControlSocketTest, setEmpty) { EXPECT_FALSE(sock); } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/yang/tests/translator_database_unittests.cc b/src/lib/yang/tests/translator_database_unittests.cc index bf71051a038057e38a7c6fe3fe7f87a3fc75fbfb..a00090cee52c9faad6c7fd4339b108801a3b10c4 100644 --- a/src/lib/yang/tests/translator_database_unittests.cc +++ b/src/lib/yang/tests/translator_database_unittests.cc @@ -32,10 +32,10 @@ class TranslatorDatabaseTest : public: /// Constructor. - TranslatorDatabaseTest() { } + TranslatorDatabaseTest() = default; /// Destructor (does nothing). - virtual ~TranslatorDatabaseTest() { } + virtual ~TranslatorDatabaseTest() = default; }; // This test verifies that an empty database can be properly @@ -149,10 +149,10 @@ class TranslatorDatabasesTest : public: /// Constructor. - TranslatorDatabasesTest() { } + TranslatorDatabasesTest() = default; /// Destructor (does nothing). - virtual ~TranslatorDatabasesTest() { } + virtual ~TranslatorDatabasesTest() = default; }; // This test verifies that an empty database list can be properly @@ -343,4 +343,4 @@ TEST_F(TranslatorDatabasesTest, setEmpties) { EXPECT_FALSE(databases); } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/yang/tests/translator_host_unittests.cc b/src/lib/yang/tests/translator_host_unittests.cc index 375d775832ab9a9bf9f07b4f4bff97de5198e69f..b7677344ab041f505f1f801addfdd698afe9c935 100644 --- a/src/lib/yang/tests/translator_host_unittests.cc +++ b/src/lib/yang/tests/translator_host_unittests.cc @@ -33,10 +33,10 @@ class TranslatorHostsTest : public: /// Constructor. - TranslatorHostsTest() { } + TranslatorHostsTest() = default; /// Destructor (does nothing). - virtual ~TranslatorHostsTest() { } + virtual ~TranslatorHostsTest() = default; }; // This test verifies that an empty host reservation list can be properly @@ -216,4 +216,4 @@ TEST_F(TranslatorHostsTest, getMany) { "\"ip-addresses\": [ \"2001:db8::2\" ] } ]"); } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/yang/tests/translator_logger_unittests.cc b/src/lib/yang/tests/translator_logger_unittests.cc index cc8100a8e0c7e34725e35223196515a84d622637..2667109833fc7659533fd9c436d6a9de3d08c2de 100644 --- a/src/lib/yang/tests/translator_logger_unittests.cc +++ b/src/lib/yang/tests/translator_logger_unittests.cc @@ -32,10 +32,10 @@ class TranslatorLoggersTest : public: /// Constructor. - TranslatorLoggersTest() { } + TranslatorLoggersTest() = default; /// Destructor (does nothing). - virtual ~TranslatorLoggersTest() { } + virtual ~TranslatorLoggersTest() = default; }; // This test verifies that an empty logger list can be properly @@ -181,4 +181,4 @@ TEST_F(TranslatorLoggersTest, set) { /// @todo: Implement a test that will cover multiple loggers. -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/yang/tests/translator_option_data_unittests.cc b/src/lib/yang/tests/translator_option_data_unittests.cc index e95030a7634d02563691f17f96122d49116b25e7..afb2453e7eddbcf75ed6ddda567c251cb43712d0 100644 --- a/src/lib/yang/tests/translator_option_data_unittests.cc +++ b/src/lib/yang/tests/translator_option_data_unittests.cc @@ -33,10 +33,10 @@ class TranslatorOptionDataListTest : public: /// Constructor. - TranslatorOptionDataListTest() { } + TranslatorOptionDataListTest() = default; /// Destructor (does nothing). - virtual ~TranslatorOptionDataListTest() { } + virtual ~TranslatorOptionDataListTest() = default; }; // This test verifies that an empty option data list can be properly @@ -162,4 +162,4 @@ TEST_F(TranslatorOptionDataListTest, set) { EXPECT_NO_THROW(sess_->validate()); } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/yang/tests/translator_option_def_unittests.cc b/src/lib/yang/tests/translator_option_def_unittests.cc index 515d9ec303f3c35606a515ded62d1f7fef7c2f3d..0441458130f35f08a13ab4e1acf422cbf87fc1c4 100644 --- a/src/lib/yang/tests/translator_option_def_unittests.cc +++ b/src/lib/yang/tests/translator_option_def_unittests.cc @@ -33,10 +33,10 @@ class TranslatorOptionDefListTest : public: /// Constructor. - TranslatorOptionDefListTest() { } + TranslatorOptionDefListTest() = default; /// Destructor (does nothing). - virtual ~TranslatorOptionDefListTest() { } + virtual ~TranslatorOptionDefListTest() = default; }; // This test verifies that an empty option definition list can be properly @@ -162,4 +162,4 @@ TEST_F(TranslatorOptionDefListTest, set) { EXPECT_NO_THROW(sess_->validate()); } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/yang/tests/translator_pd_pool_unittests.cc b/src/lib/yang/tests/translator_pd_pool_unittests.cc index 1be28b16c8e18986f4b899fc33d6d05b49476056..b8ee604317908d49b98335a79b945a3b5ccb0577 100644 --- a/src/lib/yang/tests/translator_pd_pool_unittests.cc +++ b/src/lib/yang/tests/translator_pd_pool_unittests.cc @@ -33,10 +33,10 @@ class TranslatorPdPoolsTest : public: /// Constructor. - TranslatorPdPoolsTest() { } + TranslatorPdPoolsTest() = default; /// Destructor (does nothing). - virtual ~TranslatorPdPoolsTest() { } + virtual ~TranslatorPdPoolsTest() = default; }; // This test verifies that an empty pd pool list can be properly @@ -373,4 +373,4 @@ TEST_F(TranslatorPdPoolsTest, getListKea) { "\"2001:db8:0:2000::\", \"prefix-len\": 56 } ]"); } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/yang/tests/translator_pool_unittests.cc b/src/lib/yang/tests/translator_pool_unittests.cc index e18f2e11743439ac88911fc4baedd15f6885f5d6..7c16021507ef0160dbb9a97dd025fb905b28d382 100644 --- a/src/lib/yang/tests/translator_pool_unittests.cc +++ b/src/lib/yang/tests/translator_pool_unittests.cc @@ -33,10 +33,10 @@ class TranslatorPoolsTest : public: /// Constructor. - TranslatorPoolsTest() { } + TranslatorPoolsTest() = default; /// Destructor (does nothing). - virtual ~TranslatorPoolsTest() { } + virtual ~TranslatorPoolsTest() = default; }; // This test verifies that an empty pool list can be properly @@ -307,4 +307,4 @@ TEST_F(TranslatorPoolsTest, setKea) { EXPECT_NO_THROW(sess_->validate()); } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/yang/tests/translator_shared_network_unittests.cc b/src/lib/yang/tests/translator_shared_network_unittests.cc index ad255e75ba80855ba5c445479d88856541cc9a45..0b7b08f67ee98a667771b48b48d0d6dc1e78c02c 100644 --- a/src/lib/yang/tests/translator_shared_network_unittests.cc +++ b/src/lib/yang/tests/translator_shared_network_unittests.cc @@ -32,10 +32,10 @@ class TranslatorSharedNetworksTest : public: /// Constructor. - TranslatorSharedNetworksTest() { } + TranslatorSharedNetworksTest() = default; /// Destructor (does nothing). - virtual ~TranslatorSharedNetworksTest() { } + virtual ~TranslatorSharedNetworksTest() = default; }; // This test verifies that an empty shared network list can be properly @@ -237,4 +237,4 @@ TEST_F(TranslatorSharedNetworksTest, getList) { EXPECT_EQ(exp_both, networks->str()); } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/yang/tests/translator_subnet_unittests.cc b/src/lib/yang/tests/translator_subnet_unittests.cc index f2d31fd1b4803a93819d290255454189cade0635..e1b6c08d8ec7bb89e7dfae66091a7dc4dd09609f 100644 --- a/src/lib/yang/tests/translator_subnet_unittests.cc +++ b/src/lib/yang/tests/translator_subnet_unittests.cc @@ -32,10 +32,10 @@ class TranslatorSubnetsTest : public: /// Constructor. - TranslatorSubnetsTest() { } + TranslatorSubnetsTest() = default; /// Destructor (does nothing). - virtual ~TranslatorSubnetsTest() { } + virtual ~TranslatorSubnetsTest() = default; }; // This test verifies that an empty subnet list can be properly @@ -483,4 +483,4 @@ TEST_F(TranslatorSubnetsTest, setTwoKea) { EXPECT_NO_THROW(sess_->validate()); } -}; // end of anonymous namespace +} // end of anonymous namespace diff --git a/src/lib/yang/translator.cc b/src/lib/yang/translator.cc index 531be3569eb7e89b5becac195ce2999c7e588b55..1eb9e3bb554080e127716f806e3490ad0f332e11 100644 --- a/src/lib/yang/translator.cc +++ b/src/lib/yang/translator.cc @@ -44,9 +44,6 @@ TranslatorBasic::TranslatorBasic(S_Session session, const string& model) : session_(session), model_(model) { } -TranslatorBasic::~TranslatorBasic() { -} - ElementPtr #ifndef HAVE_PRE_0_7_6_SYSREPO TranslatorBasic::value(sysrepo::S_Val s_val) { diff --git a/src/lib/yang/translator.h b/src/lib/yang/translator.h index 5c3313e42453efad37547139623e5cc0df99a194..8933a52774e96603aad7e346fa3a8fcd9d79d02d 100644 --- a/src/lib/yang/translator.h +++ b/src/lib/yang/translator.h @@ -38,7 +38,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorBasic(); + virtual ~TranslatorBasic() = default; /// @brief Translate basic value from YANG to JSON. /// @@ -132,7 +132,7 @@ protected: std::string model_; }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_TRANSLATOR_H diff --git a/src/lib/yang/translator_class.cc b/src/lib/yang/translator_class.cc index 88f97cd46103698e47fe2a9fcf6eb95855f09291..3a44e29e1e781ca415178720258027cfc6ce10b3 100644 --- a/src/lib/yang/translator_class.cc +++ b/src/lib/yang/translator_class.cc @@ -28,9 +28,6 @@ TranslatorClass::TranslatorClass(S_Session session, const string& model) TranslatorOptionDefList(session, model) { } -TranslatorClass::~TranslatorClass() { -} - ElementPtr TranslatorClass::getClass(const string& xpath) { try { @@ -173,9 +170,6 @@ TranslatorClasses::TranslatorClasses(S_Session session, const string& model) TranslatorClass(session, model) { } -TranslatorClasses::~TranslatorClasses() { -} - ConstElementPtr TranslatorClasses::getClasses(const string& xpath) { try { diff --git a/src/lib/yang/translator_class.h b/src/lib/yang/translator_class.h index 3e641c4100059c77642bf41935816264651442c6..71f53b61dc02cb8a51932127e2e131188012caa7 100644 --- a/src/lib/yang/translator_class.h +++ b/src/lib/yang/translator_class.h @@ -84,7 +84,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorClass(); + virtual ~TranslatorClass() = default; /// @brief Get and translate a client class from YANG to JSON. /// @@ -134,7 +134,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorClasses(); + virtual ~TranslatorClasses() = default; /// @brief Get and translate client classes from YANG to JSON. /// @@ -167,7 +167,7 @@ protected: isc::data::ConstElementPtr elem); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_TRANSLATOR_CLASS_H diff --git a/src/lib/yang/translator_config.cc b/src/lib/yang/translator_config.cc index 898d662e814c00c181bdbff7bbd67ea607140603..e3249562a04d57844c5b2052e5a8dd592e935de0 100644 --- a/src/lib/yang/translator_config.cc +++ b/src/lib/yang/translator_config.cc @@ -45,9 +45,6 @@ TranslatorConfig::TranslatorConfig(S_Session session, const string& model) TranslatorLoggers(session, model) { } -TranslatorConfig::~TranslatorConfig() { -} - ElementPtr TranslatorConfig::getConfig() { try { diff --git a/src/lib/yang/translator_config.h b/src/lib/yang/translator_config.h index bb3290649f097017fe0c3db0a578977d970acb11..85e15c8db6a5f92468435b63bd2ffad1ab28cbe1 100644 --- a/src/lib/yang/translator_config.h +++ b/src/lib/yang/translator_config.h @@ -395,7 +395,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorConfig(); + virtual ~TranslatorConfig() = default; /// @brief Get and translate the whole DHCP server configuration /// from YANG to JSON. @@ -530,7 +530,7 @@ protected: const std::string& name); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_TRANSLATOR_CONFIG_H diff --git a/src/lib/yang/translator_control_socket.cc b/src/lib/yang/translator_control_socket.cc index 65757e583e6d09d8df7dacf550e3d1f79bccda46..a32c6a59e551b04ae7cfec502de3d42748d4be77 100644 --- a/src/lib/yang/translator_control_socket.cc +++ b/src/lib/yang/translator_control_socket.cc @@ -25,9 +25,6 @@ TranslatorControlSocket::TranslatorControlSocket(S_Session session, : TranslatorBasic(session, model) { } -TranslatorControlSocket::~TranslatorControlSocket() { -} - ConstElementPtr TranslatorControlSocket::getControlSocket(const string& xpath) { try { diff --git a/src/lib/yang/translator_control_socket.h b/src/lib/yang/translator_control_socket.h index 236d17bdd6f5b86844b0334a165b15a61d10e255..2008c36c7a23145a1958b8f3088ed45d8ce44e07 100644 --- a/src/lib/yang/translator_control_socket.h +++ b/src/lib/yang/translator_control_socket.h @@ -82,7 +82,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorControlSocket(); + virtual ~TranslatorControlSocket() = default; /// @brief Get and translate a control socket from YANG to JSON. /// @@ -119,7 +119,7 @@ protected: isc::data::ConstElementPtr elem); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_TRANSLATOR_CONTROL_SOCKET_H diff --git a/src/lib/yang/translator_database.cc b/src/lib/yang/translator_database.cc index 3527a79fbac805de2b35089a278fbe6379d6fc89..0c7829158230190d4306e2af5de57d4dee2bede9 100644 --- a/src/lib/yang/translator_database.cc +++ b/src/lib/yang/translator_database.cc @@ -24,9 +24,6 @@ TranslatorDatabase::TranslatorDatabase(S_Session session, const string& model) : TranslatorBasic(session, model) { } -TranslatorDatabase::~TranslatorDatabase() { -} - ElementPtr TranslatorDatabase::getDatabase(const string& xpath) { try { @@ -258,9 +255,6 @@ TranslatorDatabases::TranslatorDatabases(S_Session session, TranslatorDatabase(session, model) { } -TranslatorDatabases::~TranslatorDatabases() { -} - ConstElementPtr TranslatorDatabases::getDatabases(const string& xpath) { try { diff --git a/src/lib/yang/translator_database.h b/src/lib/yang/translator_database.h index 0f86bd91e0ed8d52c34aed1d6b7ff6685b89d466..3e252c26fca875c029e025b769c887da09bba87d 100644 --- a/src/lib/yang/translator_database.h +++ b/src/lib/yang/translator_database.h @@ -121,7 +121,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorDatabase(); + virtual ~TranslatorDatabase() = default; /// @brief Get and translate a database access from YANG to JSON. /// @@ -178,7 +178,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorDatabases(); + virtual ~TranslatorDatabases() = default; /// @brief Get and translate database accesses from YANG to JSON. /// @@ -213,7 +213,7 @@ protected: isc::data::ConstElementPtr elem); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_TRANSLATOR_DATABASE_H diff --git a/src/lib/yang/translator_host.cc b/src/lib/yang/translator_host.cc index 9b164c8ecbf071d02eac76ba9fe073f1299da4b8..639a150d00fb7ab019d2288734a743582d1cac73 100644 --- a/src/lib/yang/translator_host.cc +++ b/src/lib/yang/translator_host.cc @@ -26,9 +26,6 @@ TranslatorHost::TranslatorHost(S_Session session, const string& model) TranslatorOptionDataList(session, model) { } -TranslatorHost::~TranslatorHost() { -} - ElementPtr TranslatorHost::getHost(const string& xpath) { try { @@ -188,9 +185,6 @@ TranslatorHosts::TranslatorHosts(S_Session session, const string& model) TranslatorHost(session, model) { } -TranslatorHosts::~TranslatorHosts() { -} - ElementPtr TranslatorHosts::getHosts(const string& xpath) { try { diff --git a/src/lib/yang/translator_host.h b/src/lib/yang/translator_host.h index 3677f7094b1f073e9b133710ab357c39c78c0612..561656a6e0fa8c84eab8810ec6cc19eefd058d57 100644 --- a/src/lib/yang/translator_host.h +++ b/src/lib/yang/translator_host.h @@ -123,7 +123,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorHost(); + virtual ~TranslatorHost() = default; /// @brief Get and translate a host reservation from YANG to JSON. /// @@ -174,7 +174,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorHosts(); + virtual ~TranslatorHosts() = default; /// @brief Get and translate host reservations from YANG to JSON. /// @@ -198,7 +198,7 @@ protected: isc::data::ConstElementPtr elem); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_TRANSLATOR_HOST_H diff --git a/src/lib/yang/translator_logger.cc b/src/lib/yang/translator_logger.cc index e4a21d244e6ae70f64246d6cd1df3628c2a20e63..aace30047686d3e320a4bbbf8419943ade9005d1 100644 --- a/src/lib/yang/translator_logger.cc +++ b/src/lib/yang/translator_logger.cc @@ -24,9 +24,6 @@ TranslatorLogger::TranslatorLogger(S_Session session, const string& model) : TranslatorBasic(session, model) { } -TranslatorLogger::~TranslatorLogger() { -} - ElementPtr TranslatorLogger::getLogger(const string& xpath) { try { @@ -212,9 +209,6 @@ TranslatorLoggers::TranslatorLoggers(S_Session session, const string& model) TranslatorLogger(session, model) { } -TranslatorLoggers::~TranslatorLoggers() { -} - ConstElementPtr TranslatorLoggers::getLoggers(const string& xpath) { try { diff --git a/src/lib/yang/translator_logger.h b/src/lib/yang/translator_logger.h index 5aca5315ef60ee3f9b4aee1521cdb5e24abb397e..d36d315dbf7b5d58ce0789ed619e56718b7bef23 100644 --- a/src/lib/yang/translator_logger.h +++ b/src/lib/yang/translator_logger.h @@ -106,7 +106,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorLogger(); + virtual ~TranslatorLogger() = default; /// @brief Get and translate a logger from YANG to JSON. /// @@ -184,7 +184,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorLoggers(); + virtual ~TranslatorLoggers() = default; /// @brief Get and translate loggeres from YANG to JSON. /// @@ -217,7 +217,7 @@ protected: isc::data::ConstElementPtr elem); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_TRANSLATOR_LOGGER_H diff --git a/src/lib/yang/translator_option_data.cc b/src/lib/yang/translator_option_data.cc index 644cf794693096090c0147fdc651d6275bb9036b..3ebe3dafce039e3df38b78da82e8d7b44f727973 100644 --- a/src/lib/yang/translator_option_data.cc +++ b/src/lib/yang/translator_option_data.cc @@ -25,9 +25,6 @@ TranslatorOptionData::TranslatorOptionData(S_Session session, : TranslatorBasic(session, model) { } -TranslatorOptionData::~TranslatorOptionData() { -} - ElementPtr TranslatorOptionData::getOptionData(const string& xpath) { try { @@ -131,9 +128,6 @@ TranslatorOptionDataList::TranslatorOptionDataList(S_Session session, TranslatorOptionData(session, model) { } -TranslatorOptionDataList::~TranslatorOptionDataList() { -} - ConstElementPtr TranslatorOptionDataList::getOptionDataList(const string& xpath) { try { diff --git a/src/lib/yang/translator_option_data.h b/src/lib/yang/translator_option_data.h index 69c444e6ac76735647a46a54a3211911b0cc14f8..6459f28c278b310ce203d4b34ec68a7c913d0801 100644 --- a/src/lib/yang/translator_option_data.h +++ b/src/lib/yang/translator_option_data.h @@ -86,7 +86,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorOptionData(); + virtual ~TranslatorOptionData() = default; /// @brief Get and translate an option data from YANG to JSON. /// @@ -138,7 +138,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorOptionDataList(); + virtual ~TranslatorOptionDataList() = default; /// @brief Get and translate option data list from YANG to JSON. /// @@ -169,7 +169,7 @@ protected: isc::data::ConstElementPtr elem); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_TRANSLATOR_OPTION_DATA_H diff --git a/src/lib/yang/translator_option_def.cc b/src/lib/yang/translator_option_def.cc index 8153859c26b36b0cfa1685729292723ea9d152af..9ca3c5945bf7d0ca2dd425e2680ea6bac1d032b1 100644 --- a/src/lib/yang/translator_option_def.cc +++ b/src/lib/yang/translator_option_def.cc @@ -25,9 +25,6 @@ TranslatorOptionDef::TranslatorOptionDef(S_Session session, : TranslatorBasic(session, model) { } -TranslatorOptionDef::~TranslatorOptionDef() { -} - ElementPtr TranslatorOptionDef::getOptionDef(const string& xpath) { try { @@ -140,9 +137,6 @@ TranslatorOptionDefList::TranslatorOptionDefList(S_Session session, TranslatorOptionDef(session, model) { } -TranslatorOptionDefList::~TranslatorOptionDefList() { -} - ConstElementPtr TranslatorOptionDefList::getOptionDefList(const string& xpath) { try { diff --git a/src/lib/yang/translator_option_def.h b/src/lib/yang/translator_option_def.h index b3332edd25d6a82560a65cf229665f0d6a93b3ff..1048b9765a3771965a5b0edaee41592364d29173 100644 --- a/src/lib/yang/translator_option_def.h +++ b/src/lib/yang/translator_option_def.h @@ -89,7 +89,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorOptionDef(); + virtual ~TranslatorOptionDef() = default; /// @brief Get and translate an option definition from YANG to JSON. /// @@ -143,7 +143,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorOptionDefList(); + virtual ~TranslatorOptionDefList() = default; /// @brief Get and translate option definition list from YANG to JSON. /// @@ -176,7 +176,7 @@ protected: isc::data::ConstElementPtr elem); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_TRANSLATOR_OPTION_DEF_H diff --git a/src/lib/yang/translator_pd_pool.cc b/src/lib/yang/translator_pd_pool.cc index 081558be1f4b305462ef6d41abaa238a648e2bc6..c7f19ccca7849b2ec53b2bb0536ccfc3b2b5b3f5 100644 --- a/src/lib/yang/translator_pd_pool.cc +++ b/src/lib/yang/translator_pd_pool.cc @@ -27,9 +27,6 @@ TranslatorPdPool::TranslatorPdPool(S_Session session, const string& model) TranslatorOptionDataList(session, model) { } -TranslatorPdPool::~TranslatorPdPool() { -} - ElementPtr TranslatorPdPool::getPdPool(const string& xpath) { try { @@ -293,9 +290,6 @@ TranslatorPdPools::TranslatorPdPools(S_Session session, const string& model) TranslatorPdPool(session, model) { } -TranslatorPdPools::~TranslatorPdPools() { -} - ElementPtr TranslatorPdPools::getPdPools(const string& xpath) { try { diff --git a/src/lib/yang/translator_pd_pool.h b/src/lib/yang/translator_pd_pool.h index fae6bbeda673b0e1eaf900ad42e7e5cac518a9be..834e26eefbc45c711a55562d910757923b7bddab 100644 --- a/src/lib/yang/translator_pd_pool.h +++ b/src/lib/yang/translator_pd_pool.h @@ -127,7 +127,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorPdPool(); + virtual ~TranslatorPdPool() = default; /// @brief Get and translate a pd-pool from YANG to JSON. /// @@ -194,7 +194,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorPdPools(); + virtual ~TranslatorPdPools() = default; /// @brief Get and translate pd-pools from YANG to JSON. /// @@ -231,7 +231,7 @@ protected: isc::data::ConstElementPtr elem); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_TRANSLATOR_PD_POOL_H diff --git a/src/lib/yang/translator_pool.cc b/src/lib/yang/translator_pool.cc index 905e2b6b1817c4d94403c0f419eab1a5dc625e19..639ffa337ab6c820b44d3dce3bbc501cbb527d9c 100644 --- a/src/lib/yang/translator_pool.cc +++ b/src/lib/yang/translator_pool.cc @@ -30,9 +30,6 @@ TranslatorPool::TranslatorPool(S_Session session, const string& model) TranslatorOptionDataList(session, model) { } -TranslatorPool::~TranslatorPool() { -} - ElementPtr TranslatorPool::getPool(const string& xpath) { try { @@ -272,9 +269,6 @@ TranslatorPools::TranslatorPools(S_Session session, const string& model) TranslatorPool(session, model) { } -TranslatorPools::~TranslatorPools() { -} - ElementPtr TranslatorPools::getPools(const string& xpath) { try { diff --git a/src/lib/yang/translator_pool.h b/src/lib/yang/translator_pool.h index 0f2fa7530eb36510b9a2a4fe24703119e2b2cf2d..079e9d6a156935b5ebed33945e43a62d7697758c 100644 --- a/src/lib/yang/translator_pool.h +++ b/src/lib/yang/translator_pool.h @@ -135,7 +135,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorPool(); + virtual ~TranslatorPool() = default; /// @brief Get and translate a pool from YANG to JSON. /// @@ -209,7 +209,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorPools(); + virtual ~TranslatorPools() = default; /// @brief Get and translate pools from YANG to JSON. /// @@ -250,7 +250,7 @@ protected: isc::data::ConstElementPtr elem); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_TRANSLATOR_POOL_H diff --git a/src/lib/yang/translator_shared_network.cc b/src/lib/yang/translator_shared_network.cc index 9ba195f7619ffdc2e2bb75da831ea03e29ba195a..0fecad01b724c29aaf07723114ef53ebe989f8b9 100644 --- a/src/lib/yang/translator_shared_network.cc +++ b/src/lib/yang/translator_shared_network.cc @@ -35,9 +35,6 @@ TranslatorSharedNetwork::TranslatorSharedNetwork(S_Session session, TranslatorSubnets(session, model) { } -TranslatorSharedNetwork::~TranslatorSharedNetwork() { -} - ElementPtr TranslatorSharedNetwork::getSharedNetwork(const string& xpath) { try { @@ -344,9 +341,6 @@ TranslatorSharedNetworks::TranslatorSharedNetworks(S_Session session, TranslatorSharedNetwork(session, model) { } -TranslatorSharedNetworks::~TranslatorSharedNetworks() { -} - ElementPtr TranslatorSharedNetworks::getSharedNetworks(const string& xpath) { try { diff --git a/src/lib/yang/translator_shared_network.h b/src/lib/yang/translator_shared_network.h index 316e9b8bb118b56146f247f2185b6c7db114d1ad..82d815742806cff5cb1598bc7b8c77fa2d950776 100644 --- a/src/lib/yang/translator_shared_network.h +++ b/src/lib/yang/translator_shared_network.h @@ -156,7 +156,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorSharedNetwork(); + virtual ~TranslatorSharedNetwork() = default; /// @brief Get and translate a shared network from YANG to JSON. /// @@ -214,7 +214,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorSharedNetworks(); + virtual ~TranslatorSharedNetworks() = default; /// @brief Get and translate shared networks from YANG to JSON. /// @@ -240,7 +240,7 @@ protected: isc::data::ConstElementPtr elem); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_TRANSLATOR_SHARED_NETWORK_H diff --git a/src/lib/yang/translator_subnet.cc b/src/lib/yang/translator_subnet.cc index 1d8ac030b745726afd9f7d1be8c01e9a3bf4cb36..43aead8fba826f79b4037a33abd2e7148ee090ee 100644 --- a/src/lib/yang/translator_subnet.cc +++ b/src/lib/yang/translator_subnet.cc @@ -32,9 +32,6 @@ TranslatorSubnet::TranslatorSubnet(S_Session session, const string& model) TranslatorHosts(session, model) { } -TranslatorSubnet::~TranslatorSubnet() { -} - ElementPtr TranslatorSubnet::getSubnet(const string& xpath) { try { @@ -459,9 +456,6 @@ TranslatorSubnets::TranslatorSubnets(S_Session session, const string& model) TranslatorSubnet(session, model) { } -TranslatorSubnets::~TranslatorSubnets() { -} - ElementPtr TranslatorSubnets::getSubnets(const string& xpath) { try { diff --git a/src/lib/yang/translator_subnet.h b/src/lib/yang/translator_subnet.h index 1d493d6f8004a8623987cbdaefb7192edafab883..9e8ec2afaa4c6c1f1b46c3eb8f8744a10842ef50 100644 --- a/src/lib/yang/translator_subnet.h +++ b/src/lib/yang/translator_subnet.h @@ -266,7 +266,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorSubnet(); + virtual ~TranslatorSubnet() = default; /// @brief Get and translate a subnet from YANG to JSON. /// @@ -329,7 +329,7 @@ public: #endif /// @brief Destructor. - virtual ~TranslatorSubnets(); + virtual ~TranslatorSubnets() = default; /// @brief Get and translate subnets from YANG to JSON. /// @@ -369,7 +369,7 @@ protected: const std::string& subsel); }; -}; // end of namespace isc::yang -}; // end of namespace isc +} // end of namespace isc::yang +} // end of namespace isc #endif // ISC_TRANSLATOR_SUBNET_H