diff options
author | Razvan Becheriu <razvan@isc.org> | 2023-12-20 20:06:42 +0100 |
---|---|---|
committer | Razvan Becheriu <razvan@isc.org> | 2024-01-22 16:33:26 +0100 |
commit | 54dd674d0da13aac0cf2ca484842740477276e26 (patch) | |
tree | 884e70409a29a318cf9b038855204a8edbd042b0 /src | |
parent | [#3119] Fixed some coverity reported defects (diff) | |
download | kea-54dd674d0da13aac0cf2ca484842740477276e26.tar.xz kea-54dd674d0da13aac0cf2ca484842740477276e26.zip |
[#3119] use auto const& whenever possible
Diffstat (limited to 'src')
143 files changed, 535 insertions, 541 deletions
diff --git a/src/bin/agent/simple_parser.cc b/src/bin/agent/simple_parser.cc index 218ee21c56..9c863656d6 100644 --- a/src/bin/agent/simple_parser.cc +++ b/src/bin/agent/simple_parser.cc @@ -146,7 +146,7 @@ AgentSimpleParser::parse(const CtrlAgentCfgContextPtr& ctx, // Control sockets are third. ConstElementPtr ctrl_sockets = config->get("control-sockets"); if (ctrl_sockets) { - auto sockets_map = ctrl_sockets->mapValue(); + auto const& sockets_map = ctrl_sockets->mapValue(); for (auto cs = sockets_map.cbegin(); cs != sockets_map.cend(); ++cs) { ctx->setControlSocketInfo(cs->second, cs->first); } diff --git a/src/bin/agent/tests/parser_unittests.cc b/src/bin/agent/tests/parser_unittests.cc index 166d6f99aa..6d86b1152d 100644 --- a/src/bin/agent/tests/parser_unittests.cc +++ b/src/bin/agent/tests/parser_unittests.cc @@ -785,12 +785,12 @@ TEST(ParserTest, mapEntries) { [] (ConstElementPtr json, KeywordSet& set) { if (json->getType() == Element::list) { // Handle lists. - for (auto elem : json->listValue()) { + for (auto const& elem : json->listValue()) { extract(elem, set); } } else if (json->getType() == Element::map) { // Handle maps. - for (auto elem : json->mapValue()) { + for (auto const& elem : json->mapValue()) { static_cast<void>(set.insert(elem.first)); // Skip entries with free content. if ((elem.first != "user-context") && @@ -841,12 +841,12 @@ TEST(ParserTest, duplicateMapEntries) { [] (ElementPtr config, ElementPtr json, size_t& cnt) { if (json->getType() == Element::list) { // Handle lists. - for (auto elem : json->listValue()) { + for (auto const& elem : json->listValue()) { test(config, elem, cnt); } } else if (json->getType() == Element::map) { // Handle maps. - for (auto elem : json->mapValue()) { + for (auto const& elem : json->mapValue()) { // Skip entries with free content. if ((elem.first == "user-context") || (elem.first == "parameters")) { diff --git a/src/bin/d2/tests/parser_unittest.cc b/src/bin/d2/tests/parser_unittest.cc index 7190fbdd1b..71bbba5457 100644 --- a/src/bin/d2/tests/parser_unittest.cc +++ b/src/bin/d2/tests/parser_unittest.cc @@ -739,12 +739,12 @@ TEST(ParserTest, mapEntries) { [] (ConstElementPtr json, KeywordSet& set) { if (json->getType() == Element::list) { // Handle lists. - for (auto elem : json->listValue()) { + for (auto const& elem : json->listValue()) { extract(elem, set); } } else if (json->getType() == Element::map) { // Handle maps. - for (auto elem : json->mapValue()) { + for (auto const& elem : json->mapValue()) { static_cast<void>(set.insert(elem.first)); // Skip entries with free content. if ((elem.first != "user-context") && @@ -795,12 +795,12 @@ TEST(ParserTest, duplicateMapEntries) { [] (ElementPtr config, ElementPtr json, size_t& cnt) { if (json->getType() == Element::list) { // Handle lists. - for (auto elem : json->listValue()) { + for (auto const& elem : json->listValue()) { test(config, elem, cnt); } } else if (json->getType() == Element::map) { // Handle maps. - for (auto elem : json->mapValue()) { + for (auto const& elem : json->mapValue()) { // Skip entries with free content. if ((elem.first == "user-context") || (elem.first == "parameters")) { diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 5e2a448f46..d2914b46f6 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -380,7 +380,7 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&, // Check unsupported objects. if (message.empty()) { - for (auto obj : args->mapValue()) { + for (auto const& obj : args->mapValue()) { const string& obj_name = obj.first; if (obj_name != "Dhcp4") { LOG_ERROR(dhcp4_logger, DHCP4_CONFIG_UNSUPPORTED_OBJECT) @@ -475,7 +475,7 @@ ControlledDhcpv4Srv::commandConfigTestHandler(const string&, // Check unsupported objects. if (message.empty()) { - for (auto obj : args->mapValue()) { + for (auto const& obj : args->mapValue()) { const string& obj_name = obj.first; if (obj_name != "Dhcp4") { LOG_ERROR(dhcp4_logger, DHCP4_CONFIG_UNSUPPORTED_OBJECT) diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 612e8aa58b..4761c91ba1 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -501,7 +501,7 @@ Dhcpv4Exchange::removeDependentEvaluatedClasses(const Pkt4Ptr& query) { const ClientClassDictionaryPtr& dict = CfgMgr::instance().getCurrentCfg()->getClientClassDictionary(); const ClientClassDefListPtr& defs_ptr = dict->getClasses(); - for (auto def : *defs_ptr) { + for (auto const& def : *defs_ptr) { // Only remove evaluated classes. Other classes can be // assigned via hooks libraries and we should not remove // them because there is no way they can be added back. @@ -1975,7 +1975,7 @@ Dhcpv4Srv::appendRequestedOptions(Dhcpv4Exchange& ex) { // VIVCO options at most once per vendor. set<uint32_t> vendor_ids; // Get what already exists in the response. - for (auto opt : resp->getOptions(DHO_VIVCO_SUBOPTIONS)) { + for (auto const& opt : resp->getOptions(DHO_VIVCO_SUBOPTIONS)) { OptionVendorClassPtr vendor_opts; vendor_opts = boost::dynamic_pointer_cast<OptionVendorClass>(opt.second); if (vendor_opts) { @@ -1985,7 +1985,7 @@ Dhcpv4Srv::appendRequestedOptions(Dhcpv4Exchange& ex) { } // Iterate on the configured option list. for (auto const& copts : co_list) { - for (OptionDescriptor desc : copts->getList(DHCP4_OPTION_SPACE, + for (auto const& desc : copts->getList(DHCP4_OPTION_SPACE, DHO_VIVCO_SUBOPTIONS)) { if (!desc.option_) { continue; @@ -2013,7 +2013,7 @@ Dhcpv4Srv::appendRequestedOptions(Dhcpv4Exchange& ex) { // VIVSO options at most once per vendor. set<uint32_t> vendor_ids; // Get what already exists in the response. - for (auto opt : resp->getOptions(DHO_VIVSO_SUBOPTIONS)) { + for (auto const& opt : resp->getOptions(DHO_VIVSO_SUBOPTIONS)) { OptionVendorPtr vendor_opts; vendor_opts = boost::dynamic_pointer_cast<OptionVendor>(opt.second); if (vendor_opts) { @@ -2023,7 +2023,7 @@ Dhcpv4Srv::appendRequestedOptions(Dhcpv4Exchange& ex) { } // Iterate on the configured option list for (auto const& copts : co_list) { - for (OptionDescriptor desc : copts->getList(DHCP4_OPTION_SPACE, + for (auto const& desc : copts->getList(DHCP4_OPTION_SPACE, DHO_VIVSO_SUBOPTIONS)) { if (!desc.option_) { continue; @@ -2073,7 +2073,7 @@ Dhcpv4Srv::appendRequestedVendorOptions(Dhcpv4Exchange& ex) { // The server could have provided the option using client classification or // hooks. If there're vendor info options in the response already, use them. map<uint32_t, OptionVendorPtr> vendor_rsps; - for (auto opt : resp->getOptions(DHO_VIVSO_SUBOPTIONS)) { + for (auto const& opt : resp->getOptions(DHO_VIVSO_SUBOPTIONS)) { OptionVendorPtr vendor_rsp; vendor_rsp = boost::dynamic_pointer_cast<OptionVendor>(opt.second); if (vendor_rsp) { @@ -2086,7 +2086,7 @@ Dhcpv4Srv::appendRequestedVendorOptions(Dhcpv4Exchange& ex) { // Next, try to get the vendor-id from the client packet's // vendor-specific information option (125). map<uint32_t, OptionVendorPtr> vendor_reqs; - for (auto opt : query->getOptions(DHO_VIVSO_SUBOPTIONS)) { + for (auto const& opt : query->getOptions(DHO_VIVSO_SUBOPTIONS)) { OptionVendorPtr vendor_req; vendor_req = boost::dynamic_pointer_cast<OptionVendor>(opt.second); if (vendor_req) { @@ -2098,7 +2098,7 @@ Dhcpv4Srv::appendRequestedVendorOptions(Dhcpv4Exchange& ex) { // Finally, try to get the vendor-id from the client packet's // vendor-specific class option (124). - for (auto opt : query->getOptions(DHO_VIVCO_SUBOPTIONS)) { + for (auto const& opt : query->getOptions(DHO_VIVCO_SUBOPTIONS)) { OptionVendorClassPtr vendor_class; vendor_class = boost::dynamic_pointer_cast<OptionVendorClass>(opt.second); if (vendor_class) { diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index 811192c41f..b26cfc4e05 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -523,7 +523,7 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) { if (hosts_databases) { parameter_name = "hosts-databases"; CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess(); - for (auto it : hosts_databases->listValue()) { + for (auto const& it : hosts_databases->listValue()) { db::DbAccessParser parser; std::string access_string; parser.parse(access_string, it); @@ -578,7 +578,7 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) { ConstElementPtr compatibility = mutable_cfg->get("compatibility"); if (compatibility) { - for (auto kv : compatibility->mapValue()) { + for (auto const& kv : compatibility->mapValue()) { if (!kv.second || (kv.second->getType() != Element::boolean)) { isc_throw(DhcpConfigError, "compatibility parameter values must be " diff --git a/src/bin/dhcp4/tests/config_parser_unittest.cc b/src/bin/dhcp4/tests/config_parser_unittest.cc index a0dde7828d..bc19bbc20d 100644 --- a/src/bin/dhcp4/tests/config_parser_unittest.cc +++ b/src/bin/dhcp4/tests/config_parser_unittest.cc @@ -3784,7 +3784,7 @@ TEST_F(Dhcp4ParserTest, optionDataValidHexLiterals) { "0xA0B0C0D" // 0x prefix }; - for (auto valid_hex : valid_hexes) { + for (auto const& valid_hex : valid_hexes) { ConstElementPtr x; std::string config = createConfigWithOption(valid_hex, "data"); ConstElementPtr json; @@ -7421,7 +7421,7 @@ TEST_F(Dhcp4ParserTest, dhcpQueueControl) { // Iterate over the valid scenarios and verify they succeed. data::ElementPtr exp_control; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { // Clear the config @@ -7522,7 +7522,7 @@ TEST_F(Dhcp4ParserTest, dhcpQueueControlInvalid) { // Iterate over the incorrect scenarios and verify they // fail as expected. Note, we use parseDHCP4() directly // as all of the errors above are enforced by the grammar. - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { // Construct the config JSON diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc index 3be1090ad3..fc3e6ca5ef 100644 --- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc @@ -1302,7 +1302,7 @@ TEST_F(Dhcpv4SrvTest, DiscoverValidLifetime) { }; // Iterate over the test scenarios. - for (auto test : tests) { + for (auto const& test : tests) { SCOPED_TRACE(test.description_); // Create a discover packet to use @@ -1468,12 +1468,12 @@ TEST_F(Dhcpv4SrvTest, DiscoverTimers) { dis->setIndex(ETH1_INDEX); // Iterate over the test scenarios. - for (auto test = tests.begin(); test != tests.end(); ++test) { + for (auto const& test : tests) { { - SCOPED_TRACE((*test).description_); + SCOPED_TRACE(test.description_); // Configure subnet's timer values - subnet_->setT1((*test).cfg_t1_); - subnet_->setT2((*test).cfg_t2_); + subnet_->setT1(test.cfg_t1_); + subnet_->setT2(test.cfg_t2_); // Discover/Offer exchange with the server Pkt4Ptr offer = srv->processDiscover(dis); @@ -1483,7 +1483,7 @@ TEST_F(Dhcpv4SrvTest, DiscoverTimers) { // Verify the timers are as expected. checkAddressParams(offer, subnet_, - (*test).exp_t1_, (*test).exp_t2_); + test.exp_t1_, test.exp_t2_); } } } @@ -1585,15 +1585,15 @@ TEST_F(Dhcpv4SrvTest, calculateTeeTimers) { dis->setIndex(ETH1_INDEX); // Iterate over the test scenarios. - for (auto test = tests.begin(); test != tests.end(); ++test) { + for (auto const& test : tests) { { - SCOPED_TRACE((*test).description_); + SCOPED_TRACE(test.description_); // Configure subnet's timer values - subnet_->setT1((*test).cfg_t1_); - subnet_->setT2((*test).cfg_t2_); + subnet_->setT1(test.cfg_t1_); + subnet_->setT2(test.cfg_t2_); - subnet_->setT1Percent((*test).t1_percent_); - subnet_->setT2Percent((*test).t2_percent_); + subnet_->setT1Percent(test.t1_percent_); + subnet_->setT2Percent(test.t2_percent_); // Discover/Offer exchange with the server Pkt4Ptr offer = srv->processDiscover(dis); @@ -1605,24 +1605,24 @@ TEST_F(Dhcpv4SrvTest, calculateTeeTimers) { OptionUint32Ptr opt = boost::dynamic_pointer_cast <OptionUint32> (offer->getOption(DHO_DHCP_RENEWAL_TIME)); - if ((*test).t1_exp_value_ == not_expected) { + if (test.t1_exp_value_ == not_expected) { EXPECT_FALSE(opt) << "T1 present and shouldn't be"; } else { ASSERT_TRUE(opt) << "Required T1 option missing or it has" " an unexpected type"; - EXPECT_EQ(opt->getValue(), (*test).t1_exp_value_); + EXPECT_EQ(opt->getValue(), test.t1_exp_value_); } // Check T2 timer opt = boost::dynamic_pointer_cast <OptionUint32>(offer->getOption(DHO_DHCP_REBINDING_TIME)); - if ((*test).t2_exp_value_ == not_expected) { + if (test.t2_exp_value_ == not_expected) { EXPECT_FALSE(opt) << "T2 present and shouldn't be"; } else { ASSERT_TRUE(opt) << "Required T2 option missing or it has" " an unexpected type"; - EXPECT_EQ(opt->getValue(), (*test).t2_exp_value_); + EXPECT_EQ(opt->getValue(), test.t2_exp_value_); } } } @@ -2991,11 +2991,11 @@ Dhcpv4SrvTest::checkConfigFiles() { "with-ddns.json", }; vector<string> files; - for (string example : examples) { + for (const string& example : examples) { string file = path + "/" + example; files.push_back(file); } - for (const auto& file: files) { + for (const auto& file : files) { string label("Checking configuration from file: "); label += file; SCOPED_TRACE(label); @@ -5174,7 +5174,7 @@ TEST_F(Dhcpv4SrvTest, fixedFieldsInClassOrder) { } }; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.hw_str_); { // Build a DISCOVER Pkt4Ptr query(new Pkt4(DHCPDISCOVER, 1234)); diff --git a/src/bin/dhcp4/tests/fqdn_unittest.cc b/src/bin/dhcp4/tests/fqdn_unittest.cc index d7e92bcb6b..24ad943f4b 100644 --- a/src/bin/dhcp4/tests/fqdn_unittest.cc +++ b/src/bin/dhcp4/tests/fqdn_unittest.cc @@ -1227,7 +1227,7 @@ TEST_F(NameDhcpv4SrvTest, createNameChangeRequestsUpdateOnRenew) { }; // Iterate over test scenarios. - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { // Set and verify DDNS params flags subnet_->setDdnsSendUpdates(scenario.send_updates_); @@ -2164,7 +2164,7 @@ TEST_F(NameDhcpv4SrvTest, sanitizeHostDefault) { Pkt4Ptr resp; OptionStringPtr hostname; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE((scenario).description_); { // Set the hostname option. @@ -2233,7 +2233,7 @@ TEST_F(NameDhcpv4SrvTest, sanitizeHost) { Pkt4Ptr resp; OptionStringPtr hostname; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE((scenario).description_); { // Set the hostname option. @@ -2295,7 +2295,7 @@ TEST_F(NameDhcpv4SrvTest, sanitizeHostGlobal) { Pkt4Ptr resp; OptionStringPtr hostname; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE((scenario).description_); { // Set the hostname option. @@ -2363,12 +2363,12 @@ TEST_F(NameDhcpv4SrvTest, sanitizeFqdn) { Pkt4Ptr resp; Option4ClientFqdnPtr fqdn; - for (auto scenario = scenarios.begin(); scenario != scenarios.end(); ++scenario) { - SCOPED_TRACE((*scenario).description_); + for (auto const& scenario : scenarios) { + SCOPED_TRACE(scenario.description_); { // Set the hostname option. - ASSERT_NO_THROW(client.includeHostname((*scenario).original_)); - ASSERT_NO_THROW(client.includeFQDN(0, (*scenario).original_, (*scenario).name_type_)); + ASSERT_NO_THROW(client.includeHostname(scenario.original_)); + ASSERT_NO_THROW(client.includeFQDN(0, scenario.original_, scenario.name_type_)); // Send the DHCPDISCOVER and make sure that the server responded. ASSERT_NO_THROW(client.doDiscover()); @@ -2379,7 +2379,7 @@ TEST_F(NameDhcpv4SrvTest, sanitizeFqdn) { // Make sure the response fqdn is what we expect. fqdn = boost::dynamic_pointer_cast<Option4ClientFqdn>(resp->getOption(DHO_FQDN)); ASSERT_TRUE(fqdn); - EXPECT_EQ((*scenario).sanitized_, fqdn->getDomainName()); + EXPECT_EQ(scenario.sanitized_, fqdn->getDomainName()); } } } @@ -2437,12 +2437,12 @@ TEST_F(NameDhcpv4SrvTest, sanitizeFqdnGlobal) { Pkt4Ptr resp; Option4ClientFqdnPtr fqdn; - for (auto scenario = scenarios.begin(); scenario != scenarios.end(); ++scenario) { - SCOPED_TRACE((*scenario).description_); + for (auto const& scenario : scenarios) { + SCOPED_TRACE(scenario.description_); { // Set the hostname option. - ASSERT_NO_THROW(client.includeHostname((*scenario).original_)); - ASSERT_NO_THROW(client.includeFQDN(0, (*scenario).original_, (*scenario).name_type_)); + ASSERT_NO_THROW(client.includeHostname(scenario.original_)); + ASSERT_NO_THROW(client.includeFQDN(0, scenario.original_, scenario.name_type_)); // Send the DHCPDISCOVER and make sure that the server responded. ASSERT_NO_THROW(client.doDiscover()); @@ -2453,7 +2453,7 @@ TEST_F(NameDhcpv4SrvTest, sanitizeFqdnGlobal) { // Make sure the response fqdn is what we expect. fqdn = boost::dynamic_pointer_cast<Option4ClientFqdn>(resp->getOption(DHO_FQDN)); ASSERT_TRUE(fqdn); - EXPECT_EQ((*scenario).sanitized_, fqdn->getDomainName()); + EXPECT_EQ(scenario.sanitized_, fqdn->getDomainName()); } } } @@ -2588,7 +2588,7 @@ TEST_F(NameDhcpv4SrvTest, processReuseExpired) { } }; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.label_); { // Create the original leasing client. diff --git a/src/bin/dhcp4/tests/hooks_unittest.cc b/src/bin/dhcp4/tests/hooks_unittest.cc index 5ab9a9a295..0973a74d5c 100644 --- a/src/bin/dhcp4/tests/hooks_unittest.cc +++ b/src/bin/dhcp4/tests/hooks_unittest.cc @@ -3371,7 +3371,7 @@ TEST_F(LoadUnloadDhcpv4SrvTest, failLoadIncompatibleLibraries) { // Checks if callouts installed on the dhcp4_srv_configured ared indeed called // and all the necessary parameters are passed. TEST_F(LoadUnloadDhcpv4SrvTest, Dhcpv4SrvConfigured) { - for (string parameters : { + for (const string& parameters : vector<string>{ "", R"(, "parameters": { "mode": "fail-without-error" } )", R"(, "parameters": { "mode": "fail-with-error" } )"}) { diff --git a/src/bin/dhcp4/tests/parser_unittest.cc b/src/bin/dhcp4/tests/parser_unittest.cc index 48c92783cd..c3a88cb53e 100644 --- a/src/bin/dhcp4/tests/parser_unittest.cc +++ b/src/bin/dhcp4/tests/parser_unittest.cc @@ -804,12 +804,12 @@ TEST(ParserTest, mapEntries) { [] (ConstElementPtr json, KeywordSet& set) { if (json->getType() == Element::list) { // Handle lists. - for (auto elem : json->listValue()) { + for (auto const& elem : json->listValue()) { extract(elem, set); } } else if (json->getType() == Element::map) { // Handle maps. - for (auto elem : json->mapValue()) { + for (auto const& elem : json->mapValue()) { static_cast<void>(set.insert(elem.first)); // Skip entries with free content. if ((elem.first != "user-context") && @@ -825,7 +825,7 @@ TEST(ParserTest, mapEntries) { auto print_keys = [](const KeywordSet& keys) { string s = "{"; bool first = true; - for (auto key : keys) { + for (auto const& key : keys) { if (first) { first = false; s += " "; @@ -876,12 +876,12 @@ TEST(ParserTest, duplicateMapEntries) { [] (ElementPtr config, ElementPtr json, size_t& cnt) { if (json->getType() == Element::list) { // Handle lists. - for (auto elem : json->listValue()) { + for (auto const& elem : json->listValue()) { test(config, elem, cnt); } } else if (json->getType() == Element::map) { // Handle maps. - for (auto elem : json->mapValue()) { + for (auto const& elem : json->mapValue()) { // Skip entries with free content. if ((elem.first == "user-context") || (elem.first == "parameters")) { diff --git a/src/bin/dhcp4/tests/shared_network_unittest.cc b/src/bin/dhcp4/tests/shared_network_unittest.cc index 67bac00040..bf5964dc1e 100644 --- a/src/bin/dhcp4/tests/shared_network_unittest.cc +++ b/src/bin/dhcp4/tests/shared_network_unittest.cc @@ -2975,7 +2975,7 @@ TEST_F(Dhcpv4SharedNetworkTest, authoritative) { // Let's test them one by one int cnt = 0; - for ( auto s : scenarios) { + for (auto const& s : scenarios) { cnt++; string cfg = generateAuthConfig(s.global, s.subnet1, s.subnet2); diff --git a/src/bin/dhcp4/tests/vendor_opts_unittest.cc b/src/bin/dhcp4/tests/vendor_opts_unittest.cc index 44553b5a93..46e9789d25 100644 --- a/src/bin/dhcp4/tests/vendor_opts_unittest.cc +++ b/src/bin/dhcp4/tests/vendor_opts_unittest.cc @@ -2770,7 +2770,7 @@ TEST_F(VendorOptsTest, twoVivcos) { ASSERT_EQ(2, classes.size()); OptionVendorClassPtr opt_class1234; OptionVendorClassPtr opt_class5678; - for (auto opt : classes) { + for (auto const& opt : classes) { ASSERT_EQ(DHO_VIVCO_SUBOPTIONS, opt.first); OptionVendorClassPtr opt_class = boost::dynamic_pointer_cast<OptionVendorClass>(opt.second); diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index feb4b02f84..035f3a9314 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -382,7 +382,7 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&, // Check unsupported objects. if (message.empty()) { - for (auto obj : args->mapValue()) { + for (auto const& obj : args->mapValue()) { const string& obj_name = obj.first; if (obj_name != "Dhcp6") { LOG_ERROR(dhcp6_logger, DHCP6_CONFIG_UNSUPPORTED_OBJECT) @@ -477,7 +477,7 @@ ControlledDhcpv6Srv::commandConfigTestHandler(const string&, // Check unsupported objects. if (message.empty()) { - for (auto obj : args->mapValue()) { + for (auto const& obj : args->mapValue()) { const string& obj_name = obj.first; if (obj_name != "Dhcp6") { LOG_ERROR(dhcp6_logger, DHCP6_CONFIG_UNSUPPORTED_OBJECT) diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 6024cdd2df..ad4f94a940 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -1109,7 +1109,7 @@ Dhcpv6Srv::processDhcp6Query(Pkt6Ptr& query, Pkt6Ptr& rsp) { Lease6CollectionPtr new_leases(new Lease6Collection()); if (!ctx.new_leases_.empty()) { // Filter out reused leases as they were not committed. - for (auto new_lease : ctx.new_leases_) { + for (auto const& new_lease : ctx.new_leases_) { if (new_lease->reuseable_valid_lft_ == 0) { new_leases->push_back(new_lease); } @@ -1122,7 +1122,7 @@ Dhcpv6Srv::processDhcp6Query(Pkt6Ptr& query, Pkt6Ptr& rsp) { // Do per IA lists for (auto const& iac : ctx.ias_) { if (!iac.old_leases_.empty()) { - for (auto old_lease : iac.old_leases_) { + for (auto const& old_lease : iac.old_leases_) { if (ctx.new_leases_.empty()) { deleted_leases->push_back(old_lease); continue; @@ -1570,7 +1570,7 @@ Dhcpv6Srv::appendRequestedOptions(const Pkt6Ptr& question, Pkt6Ptr& answer, // D6O_VENDOR_CLASS options at most once per vendor. set<uint32_t> vendor_ids; // Get what already exists in the response. - for (auto opt : answer->getOptions(D6O_VENDOR_CLASS)) { + for (auto const& opt : answer->getOptions(D6O_VENDOR_CLASS)) { OptionVendorClassPtr vendor_class; vendor_class = boost::dynamic_pointer_cast<OptionVendorClass>(opt.second); if (vendor_class) { @@ -1580,8 +1580,7 @@ Dhcpv6Srv::appendRequestedOptions(const Pkt6Ptr& question, Pkt6Ptr& answer, } // Iterate on the configured option list. for (auto const& copts : co_list) { - for (OptionDescriptor desc : copts->getList(DHCP6_OPTION_SPACE, - D6O_VENDOR_CLASS)) { + for (auto const& desc : copts->getList(DHCP6_OPTION_SPACE, D6O_VENDOR_CLASS)) { if (!desc.option_) { continue; } @@ -1608,7 +1607,7 @@ Dhcpv6Srv::appendRequestedOptions(const Pkt6Ptr& question, Pkt6Ptr& answer, // D6O_VENDOR_OPTS options at most once per vendor. set<uint32_t> vendor_ids; // Get what already exists in the response. - for (auto opt : answer->getOptions(D6O_VENDOR_OPTS)) { + for (auto const& opt : answer->getOptions(D6O_VENDOR_OPTS)) { OptionVendorPtr vendor_opts; vendor_opts = boost::dynamic_pointer_cast<OptionVendor>(opt.second); if (vendor_opts) { @@ -1618,8 +1617,7 @@ Dhcpv6Srv::appendRequestedOptions(const Pkt6Ptr& question, Pkt6Ptr& answer, } // Iterate on the configured option list for (auto const& copts : co_list) { - for (OptionDescriptor desc : copts->getList(DHCP6_OPTION_SPACE, - D6O_VENDOR_OPTS)) { + for (auto const& desc : copts->getList(DHCP6_OPTION_SPACE, D6O_VENDOR_OPTS)) { if (!desc.option_) { continue; } @@ -1665,7 +1663,7 @@ Dhcpv6Srv::appendRequestedVendorOptions(const Pkt6Ptr& question, // The server could have provided the option using client classification or // hooks. If there're vendor info options in the response already, use them. map<uint32_t, OptionVendorPtr> vendor_rsps; - for (auto opt : answer->getOptions(D6O_VENDOR_OPTS)) { + for (auto const& opt : answer->getOptions(D6O_VENDOR_OPTS)) { OptionVendorPtr vendor_rsp; vendor_rsp = boost::dynamic_pointer_cast<OptionVendor>(opt.second); if (vendor_rsp) { @@ -1678,7 +1676,7 @@ Dhcpv6Srv::appendRequestedVendorOptions(const Pkt6Ptr& question, // Next, try to get the vendor-id from the client packet's // vendor-specific information option (17). map<uint32_t, OptionVendorPtr> vendor_reqs; - for (auto opt : question->getOptions(D6O_VENDOR_OPTS)) { + for (auto const& opt : question->getOptions(D6O_VENDOR_OPTS)) { OptionVendorPtr vendor_req; vendor_req = boost::dynamic_pointer_cast<OptionVendor>(opt.second); if (vendor_req) { @@ -1690,7 +1688,7 @@ Dhcpv6Srv::appendRequestedVendorOptions(const Pkt6Ptr& question, // Finally, try to get the vendor-id from the client packet's vendor-class // option (16). - for (auto opt : question->getOptions(D6O_VENDOR_CLASS)) { + for (auto const& opt : question->getOptions(D6O_VENDOR_CLASS)) { OptionVendorClassPtr vendor_class; vendor_class = boost::dynamic_pointer_cast<OptionVendorClass>(opt.second); if (vendor_class) { @@ -2240,7 +2238,7 @@ Dhcpv6Srv::createNameChangeRequests(const Pkt6Ptr& answer, // Get all IAs from the answer. For each IA, holding an address we will // create a corresponding NameChangeRequest. - for (auto answer_ia : answer->getOptions(D6O_IA_NA)) { + for (auto const& answer_ia : answer->getOptions(D6O_IA_NA)) { /// @todo IA_NA may contain multiple addresses. We should process /// each address individually. Currently we get only one. Option6IAAddrPtr iaaddr = boost::static_pointer_cast< @@ -4270,7 +4268,7 @@ Dhcpv6Srv::removeDependentEvaluatedClasses(const Pkt6Ptr& pkt) { const ClientClassDictionaryPtr& dict = CfgMgr::instance().getCurrentCfg()->getClientClassDictionary(); const ClientClassDefListPtr& defs_ptr = dict->getClasses(); - for (auto def : *defs_ptr) { + for (auto const& def : *defs_ptr) { // Only remove evaluated classes. Other classes can be // assigned via hooks libraries and we should not remove // them because there is no way they can be added back. @@ -4484,7 +4482,7 @@ Dhcpv6Srv::generateFqdn(const Pkt6Ptr& answer, // our notion of client's FQDN in the Client FQDN option. if (answer->getType() != DHCPV6_ADVERTISE) { Lease6Ptr lease; - for (auto l : ctx.new_leases_) { + for (auto const& l : ctx.new_leases_) { if ((l->type_ == Lease::TYPE_NA) && (l->addr_ == addr)) { lease = l; break; diff --git a/src/bin/dhcp6/json_config_parser.cc b/src/bin/dhcp6/json_config_parser.cc index dbd4291e85..47a8f3f100 100644 --- a/src/bin/dhcp6/json_config_parser.cc +++ b/src/bin/dhcp6/json_config_parser.cc @@ -649,7 +649,7 @@ processDhcp6Config(isc::data::ConstElementPtr config_set) { if (hosts_databases) { parameter_name = "hosts-databases"; CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess(); - for (auto it : hosts_databases->listValue()) { + for (auto const& it : hosts_databases->listValue()) { db::DbAccessParser parser; std::string access_string; parser.parse(access_string, it); @@ -711,7 +711,7 @@ processDhcp6Config(isc::data::ConstElementPtr config_set) { ConstElementPtr compatibility = mutable_cfg->get("compatibility"); if (compatibility) { - for (auto kv : compatibility->mapValue()) { + for (auto const& kv : compatibility->mapValue()) { if (!kv.second || (kv.second->getType() != Element::boolean)) { isc_throw(DhcpConfigError, "compatibility parameter values must be " diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc index 8ef97b887b..a3fd0cd15d 100644 --- a/src/bin/dhcp6/tests/config_parser_unittest.cc +++ b/src/bin/dhcp6/tests/config_parser_unittest.cc @@ -2091,16 +2091,16 @@ TEST_F(Dhcp6ParserTest, badSubnetValues) { // Iterate over the list of scenarios. Each should fail to parse with // a specific error message. - for (auto scenario = scenarios.begin(); scenario != scenarios.end(); ++scenario) { + for (auto const& scenario : scenarios) { { - SCOPED_TRACE((*scenario).description_); + SCOPED_TRACE(scenario.description_); ConstElementPtr config; - ASSERT_NO_THROW(config = parseDHCP6((*scenario).config_json_)) + ASSERT_NO_THROW(config = parseDHCP6(scenario.config_json_)) << "invalid json, broken test"; ConstElementPtr status; EXPECT_NO_THROW(status = Dhcpv6SrvTest::configure(srv_, config)); checkResult(status, 1); - EXPECT_EQ(comment_->stringValue(), (*scenario).exp_error_msg_); + EXPECT_EQ(comment_->stringValue(), scenario.exp_error_msg_); } } } @@ -4098,7 +4098,7 @@ TEST_F(Dhcp6ParserTest, optionDataValidHexLiterals) { "0xA0B0C0D" // 0x prefix }; - for (auto valid_hex : valid_hexes) { + for (auto const& valid_hex : valid_hexes) { ConstElementPtr x; std::string config = createConfigWithOption(valid_hex, "data"); ConstElementPtr json; @@ -7995,7 +7995,7 @@ TEST_F(Dhcp6ParserTest, dhcpQueueControl) { // Iterate over the valid scenarios and verify they succeed. data::ElementPtr exp_control; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { // Clear the config @@ -8096,7 +8096,7 @@ TEST_F(Dhcp6ParserTest, dhcpQueueControlInvalid) { // Iterate over the incorrect scenarios and verify they // fail as expected. Note, we use parseDHCP6() directly // as all of the errors above are enforced by the grammar. - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { // Construct the config JSON diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc index 4a70d6b525..9b595874e3 100644 --- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc @@ -362,11 +362,11 @@ Dhcpv6SrvTest::checkConfigFiles() { "with-ddns.json", }; vector<string> files; - for (string example : examples) { + for (const string& example : examples) { string file = path + "/" + example; files.push_back(file); } - for (const auto& file: files) { + for (const auto& file : files) { string label("Checking configuration from file: "); label += file; SCOPED_TRACE(label); @@ -3859,15 +3859,15 @@ TEST_F(Dhcpv6SrvTest, calculateTeeTimers) { sol->setIndex(ETH0_INDEX); // Iterate over the test scenarios. - for (auto test = tests.begin(); test != tests.end(); ++test) { + for (auto const& test : tests) { { - SCOPED_TRACE((*test).description_); + SCOPED_TRACE(test.description_); // Configure subnet for the scenario - subnet_->setT1((*test).cfg_t1_); - subnet_->setT2((*test).cfg_t2_); - subnet_->setCalculateTeeTimes((*test).calculate_tee_times); - subnet_->setT1Percent((*test).t1_percent_); - subnet_->setT2Percent((*test).t2_percent_); + subnet_->setT1(test.cfg_t1_); + subnet_->setT2(test.cfg_t2_); + subnet_->setCalculateTeeTimes(test.calculate_tee_times); + subnet_->setT1Percent(test.t1_percent_); + subnet_->setT2Percent(test.t2_percent_); AllocEngine::ClientContext6 ctx; bool drop = !srv.earlyGHRLookup(sol, ctx); ASSERT_FALSE(drop); @@ -3879,7 +3879,7 @@ TEST_F(Dhcpv6SrvTest, calculateTeeTimers) { checkResponse(reply, DHCPV6_ADVERTISE, 1234); // check that IA_NA was returned and T1 and T2 are correct. - checkIA_NA(reply, 234, (*test).t1_exp_value_, (*test).t2_exp_value_); + checkIA_NA(reply, 234, test.t1_exp_value_, test.t2_exp_value_); } } } diff --git a/src/bin/dhcp6/tests/fqdn_unittest.cc b/src/bin/dhcp6/tests/fqdn_unittest.cc index f3b93930d3..c29f5d1c72 100644 --- a/src/bin/dhcp6/tests/fqdn_unittest.cc +++ b/src/bin/dhcp6/tests/fqdn_unittest.cc @@ -2074,7 +2074,7 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRenew) { subnet_->setDdnsReplaceClientNameMode(D2ClientConfig::RCM_NEVER); // Iterate over test scenarios. - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { // Make sure the lease does not exist. ASSERT_FALSE(LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, diff --git a/src/bin/dhcp6/tests/hooks_unittest.cc b/src/bin/dhcp6/tests/hooks_unittest.cc index bdf876d0f2..d72464de6d 100644 --- a/src/bin/dhcp6/tests/hooks_unittest.cc +++ b/src/bin/dhcp6/tests/hooks_unittest.cc @@ -5589,7 +5589,7 @@ TEST_F(LoadUnloadDhcpv6SrvTest, failLoadIncompatibleLibraries) { // Checks if callouts installed on the dhcp6_srv_configured ared indeed called // and all the necessary parameters are passed. TEST_F(LoadUnloadDhcpv6SrvTest, Dhcpv6SrvConfigured) { - for (string parameters : { + for (const string& parameters : vector<string>{ "", R"(, "parameters": { "mode": "fail-without-error" } )", R"(, "parameters": { "mode": "fail-with-error" } )"}) { diff --git a/src/bin/dhcp6/tests/parser_unittest.cc b/src/bin/dhcp6/tests/parser_unittest.cc index d7f45f5219..b0218233af 100644 --- a/src/bin/dhcp6/tests/parser_unittest.cc +++ b/src/bin/dhcp6/tests/parser_unittest.cc @@ -795,12 +795,12 @@ TEST(ParserTest, mapEntries) { [] (ConstElementPtr json, KeywordSet& set) { if (json->getType() == Element::list) { // Handle lists. - for (auto elem : json->listValue()) { + for (auto const& elem : json->listValue()) { extract(elem, set); } } else if (json->getType() == Element::map) { // Handle maps. - for (auto elem : json->mapValue()) { + for (auto const& elem : json->mapValue()) { static_cast<void>(set.insert(elem.first)); // Skip entries with free content. if ((elem.first != "user-context") && @@ -816,7 +816,7 @@ TEST(ParserTest, mapEntries) { auto print_keys = [](const KeywordSet& keys) { string s = "{"; bool first = true; - for (auto key : keys) { + for (auto const& key : keys) { if (first) { first = false; s += " "; @@ -867,12 +867,12 @@ TEST(ParserTest, duplicateMapEntries) { [] (ElementPtr config, ElementPtr json, size_t& cnt) { if (json->getType() == Element::list) { // Handle lists. - for (auto elem : json->listValue()) { + for (auto const& elem : json->listValue()) { test(config, elem, cnt); } } else if (json->getType() == Element::map) { // Handle maps. - for (auto elem : json->mapValue()) { + for (auto const& elem : json->mapValue()) { // Skip entries with free content. if ((elem.first == "user-context") || (elem.first == "parameters")) { diff --git a/src/bin/dhcp6/tests/vendor_opts_unittest.cc b/src/bin/dhcp6/tests/vendor_opts_unittest.cc index 0cbc224752..593bf7b000 100644 --- a/src/bin/dhcp6/tests/vendor_opts_unittest.cc +++ b/src/bin/dhcp6/tests/vendor_opts_unittest.cc @@ -1692,7 +1692,7 @@ TEST_F(VendorOptsTest, twoVendors) { ASSERT_EQ(2, classes.size()); OptionVendorClassPtr opt_class1234; OptionVendorClassPtr opt_class5678; - for (auto opt : classes) { + for (auto const& opt : classes) { ASSERT_EQ(D6O_VENDOR_CLASS, opt.first); OptionVendorClassPtr opt_class = boost::dynamic_pointer_cast<OptionVendorClass>(opt.second); @@ -1724,7 +1724,7 @@ TEST_F(VendorOptsTest, twoVendors) { ASSERT_EQ(2, options.size()); OptionVendorPtr opt_opts1234; OptionVendorPtr opt_opts5678; - for (auto opt : options) { + for (auto const& opt : options) { ASSERT_EQ(D6O_VENDOR_OPTS, opt.first); OptionVendorPtr opt_opts = boost::dynamic_pointer_cast<OptionVendor>(opt.second); @@ -1861,7 +1861,7 @@ TEST_F(VendorOptsTest, threeVendors) { OptionVendorPtr opt_opts1234; OptionVendorPtr opt_docsis; OptionVendorPtr opt_opts5678; - for (auto opt : options) { + for (auto const& opt : options) { ASSERT_EQ(D6O_VENDOR_OPTS, opt.first); OptionVendorPtr opt_opts = boost::dynamic_pointer_cast<OptionVendor>(opt.second); diff --git a/src/bin/netconf/netconf.cc b/src/bin/netconf/netconf.cc index c515dec4ea..a9091bf02b 100644 --- a/src/bin/netconf/netconf.cc +++ b/src/bin/netconf/netconf.cc @@ -306,7 +306,7 @@ void NetconfAgent::checkModules(CfgServersMapPtr const& servers /* = {} */) const { bool faulty_model(false); if (servers) { - for (auto pair : *servers) { + for (auto const& pair : *servers) { if (!checkModule(pair.second->getModel())) { faulty_model = true; } @@ -318,7 +318,7 @@ NetconfAgent::checkModules(CfgServersMapPtr const& servers /* = {} */) const { "supported. Check logs for details."); } - for (auto modrev : YANG_REVISIONS) { + for (auto const& modrev : YANG_REVISIONS) { auto module = modules_.find(modrev.first); if (module == modules_.end()) { LOG_WARN(netconf_logger, NETCONF_MODULE_MISSING_WARN) diff --git a/src/bin/netconf/netconf_cfg_mgr.cc b/src/bin/netconf/netconf_cfg_mgr.cc index 019bfaf554..55c6adaeb0 100644 --- a/src/bin/netconf/netconf_cfg_mgr.cc +++ b/src/bin/netconf/netconf_cfg_mgr.cc @@ -65,7 +65,7 @@ NetconfCfgMgr::getConfigSummary(const uint32_t /*selection*/) { ostringstream s; // Then print managed servers. - for (auto serv : *ctx->getCfgServersMap()) { + for (auto const& serv : *ctx->getCfgServersMap()) { if (s.tellp() != 0) { s << " "; } @@ -156,7 +156,7 @@ NetconfConfig::toElement() const { netconf->set("hooks-libraries", hooks_config_.toElement()); // Set managed-servers ElementPtr servers = Element::createMap(); - for (auto serv : *servers_map_) { + for (auto const& serv : *servers_map_) { ElementPtr server = serv.second->toElement(); servers->set(serv.first, server); } diff --git a/src/bin/netconf/simple_parser.cc b/src/bin/netconf/simple_parser.cc index 0e7b8f808a..fefa996c40 100644 --- a/src/bin/netconf/simple_parser.cc +++ b/src/bin/netconf/simple_parser.cc @@ -95,7 +95,7 @@ size_t NetconfSimpleParser::setAllDefaults(const ElementPtr& global) { ConstElementPtr servers = global->get("managed-servers"); if (servers) { ElementPtr mutable_servers(copy(servers, 0)); - for (auto it : mutable_servers->mapValue()) { + for (auto const& it : mutable_servers->mapValue()) { ElementPtr server(copy(it.second, 0)); cnt += setServerDefaults(it.first, server); mutable_servers->set(it.first, server); @@ -113,7 +113,7 @@ size_t NetconfSimpleParser::deriveParameters(ElementPtr global) { ConstElementPtr servers = global->get("managed-servers"); if (servers) { ElementPtr mutable_servers(copy(servers, 0)); - for (auto it : mutable_servers->mapValue()) { + for (auto const& it : mutable_servers->mapValue()) { ElementPtr mutable_server = copy(it.second, 0); cnt += SimpleParser::deriveParams(global, mutable_server, @@ -166,7 +166,7 @@ NetconfSimpleParser::parse(const NetconfConfigPtr& ctx, // get managed servers. ConstElementPtr servers = config->get("managed-servers"); if (servers) { - for (auto it : servers->mapValue()) { + for (auto const& it : servers->mapValue()) { ServerConfigParser server_parser; CfgServerPtr server = server_parser.parse(it.second); ctx->getCfgServersMap()->insert(make_pair(it.first, server)); diff --git a/src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc b/src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc index 897e2921de..05e7ebb50f 100644 --- a/src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc +++ b/src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc @@ -177,7 +177,7 @@ TEST(NetconfCfgMgr, contextGlobals) { EXPECT_NE(0, globals->mapValue().size()); // Maps and lists should be excluded. - for (auto it : globals->mapValue()) { + for (auto const& it : globals->mapValue()) { if (it.first == "astring") { ASSERT_EQ(Element::string, it.second->getType()); EXPECT_EQ("okay", it.second->stringValue()); diff --git a/src/bin/netconf/tests/parser_unittests.cc b/src/bin/netconf/tests/parser_unittests.cc index d4ef6c1d35..852b5acbfa 100644 --- a/src/bin/netconf/tests/parser_unittests.cc +++ b/src/bin/netconf/tests/parser_unittests.cc @@ -835,12 +835,12 @@ TEST(ParserTest, mapEntries) { [] (ConstElementPtr json, KeywordSet& set) { if (json->getType() == Element::list) { // Handle lists. - for (auto elem : json->listValue()) { + for (auto const& elem : json->listValue()) { extract(elem, set); } } else if (json->getType() == Element::map) { // Handle maps. - for (auto elem : json->mapValue()) { + for (auto const& elem : json->mapValue()) { static_cast<void>(set.insert(elem.first)); // Skip entries with free content. if ((elem.first != "user-context") && @@ -891,12 +891,12 @@ TEST(ParserTest, duplicateMapEntries) { [] (ElementPtr config, ElementPtr json, size_t& cnt) { if (json->getType() == Element::list) { // Handle lists. - for (auto elem : json->listValue()) { + for (auto const& elem : json->listValue()) { test(config, elem, cnt); } } else if (json->getType() == Element::map) { // Handle maps. - for (auto elem : json->mapValue()) { + for (auto const& elem : json->mapValue()) { // Skip entries with free content. if ((elem.first == "user-context") || (elem.first == "parameters")) { diff --git a/src/bin/perfdhcp/perf_socket.cc b/src/bin/perfdhcp/perf_socket.cc index aa67796a1d..ba69e82ef6 100644 --- a/src/bin/perfdhcp/perf_socket.cc +++ b/src/bin/perfdhcp/perf_socket.cc @@ -134,8 +134,8 @@ PerfSocket::~PerfSocket() { void PerfSocket::initSocketData() { - for (IfacePtr iface : IfaceMgr::instance().getIfaces()) { - for (SocketInfo s : iface->getSockets()) { + for (auto const& iface : IfaceMgr::instance().getIfaces()) { + for (auto const& s : iface->getSockets()) { if (s.sockfd_ == sockfd_) { ifindex_ = iface->getIndex(); addr_ = s.addr_; diff --git a/src/bin/perfdhcp/test_control.cc b/src/bin/perfdhcp/test_control.cc index c15153b6e3..47165552b7 100644 --- a/src/bin/perfdhcp/test_control.cc +++ b/src/bin/perfdhcp/test_control.cc @@ -1924,7 +1924,7 @@ void TestControl::addExtraOpts(const Pkt4Ptr& pkt) { // Add all extra options that the user may have specified. const dhcp::OptionCollection& extra_opts = options_.getExtraOpts(); - for (auto entry : extra_opts) { + for (auto const& entry : extra_opts) { mergeOptionIntoPacket(pkt, entry.second); } } @@ -1933,7 +1933,7 @@ void TestControl::addExtraOpts(const Pkt6Ptr& pkt) { // Add all extra options that the user may have specified. const dhcp::OptionCollection& extra_opts = options_.getExtraOpts(); - for (auto entry : extra_opts) { + for (auto const& entry : extra_opts) { pkt->addOption(entry.second); } } diff --git a/src/hooks/dhcp/flex_option/flex_option.cc b/src/hooks/dhcp/flex_option/flex_option.cc index aa6edd9211..b27f937489 100644 --- a/src/hooks/dhcp/flex_option/flex_option.cc +++ b/src/hooks/dhcp/flex_option/flex_option.cc @@ -141,7 +141,7 @@ FlexOptionImpl::configure(ConstElementPtr options) { if (options->empty()) { return; } - for (auto option : options->listValue()) { + for (auto const& option : options->listValue()) { parseOptionConfig(option); } } @@ -156,7 +156,7 @@ FlexOptionImpl::parseOptionConfig(ConstElementPtr option) { isc_throw(BadValue, "option element is not a map"); } // See SimpleParser::checkKeywords - for (auto entry : option->mapValue()) { + for (auto const& entry : option->mapValue()) { if (OPTION_PARAMETERS.count(entry.first) == 0) { isc_throw(BadValue, "unknown parameter '" << entry.first << "'"); } @@ -316,7 +316,7 @@ void FlexOptionImpl::parseSubOptions(ConstElementPtr sub_options, OptionConfigPtr opt_cfg, Option::Universe universe) { - for (ConstElementPtr sub_option : sub_options->listValue()) { + for (auto const& sub_option : sub_options->listValue()) { parseSubOption(sub_option, opt_cfg, universe); } } @@ -332,7 +332,7 @@ FlexOptionImpl::parseSubOption(ConstElementPtr sub_option, isc_throw(BadValue, "sub-option element is not a map"); } // See SimpleParser::checkKeywords - for (auto entry : sub_option->mapValue()) { + for (auto const& entry : sub_option->mapValue()) { if (SUB_OPTION_PARAMETERS.count(entry.first) == 0) { isc_throw(BadValue, "unknown parameter '" << entry.first << "'"); } diff --git a/src/hooks/dhcp/flex_option/flex_option.h b/src/hooks/dhcp/flex_option/flex_option.h index e26b437ed9..55fc4a71a2 100644 --- a/src/hooks/dhcp/flex_option/flex_option.h +++ b/src/hooks/dhcp/flex_option/flex_option.h @@ -286,7 +286,7 @@ public: template <typename PktType> void process(isc::dhcp::Option::Universe universe, PktType query, PktType response) { - for (auto pair : getOptionConfigMap()) { + for (auto const& pair : getOptionConfigMap()) { for (const OptionConfigPtr& opt_cfg : pair.second) { const isc::dhcp::ClientClass& client_class = opt_cfg->getClass(); @@ -374,7 +374,7 @@ public: } } } - for (auto pair : getSubOptionConfigMap()) { + for (auto const& pair : getSubOptionConfigMap()) { for (const auto& sub_pair : pair.second) { const SubOptionConfigPtr& sub_cfg = sub_pair.second; uint16_t sub_code = sub_cfg->getCode(); diff --git a/src/hooks/dhcp/high_availability/communication_state.cc b/src/hooks/dhcp/high_availability/communication_state.cc index 1c72ee287b..abde103f97 100644 --- a/src/hooks/dhcp/high_availability/communication_state.cc +++ b/src/hooks/dhcp/high_availability/communication_state.cc @@ -548,7 +548,7 @@ CommunicationState::getReport() const { } auto list = Element::createList(); - for (auto scope : getPartnerScopes()) { + for (auto const& scope : getPartnerScopes()) { list->add(Element::create(scope)); } report->set("last-scopes", list); diff --git a/src/hooks/dhcp/high_availability/ha_config_parser.cc b/src/hooks/dhcp/high_availability/ha_config_parser.cc index 7b8106e394..6e4662786a 100644 --- a/src/hooks/dhcp/high_availability/ha_config_parser.cc +++ b/src/hooks/dhcp/high_availability/ha_config_parser.cc @@ -104,7 +104,7 @@ HAConfigParser::parseAll(const HAConfigMapperPtr& config_storage, if (config_vec.empty()) { isc_throw(ConfigError, "a list of HA configurations must not be empty"); } - for (auto config : config_vec) { + for (auto const& config : config_vec) { parseOne(config_storage, config); } } @@ -374,7 +374,7 @@ HAConfigParser::parseOne(const HAConfigMapperPtr& config_storage, rel_config->validate(); auto peer_configs = rel_config->getAllServersConfig(); - for (auto peer_config : peer_configs) { + for (auto const& peer_config : peer_configs) { try { config_storage->map(peer_config.first, rel_config); @@ -404,7 +404,7 @@ void HAConfigParser::logConfigStatus(const HAConfigMapperPtr& config_storage) { LOG_INFO(ha_logger, HA_CONFIGURATION_SUCCESSFUL); - for (auto config : config_storage->getAll()) { + for (auto const& config : config_storage->getAll()) { // If lease updates are disabled, we want to make sure that the user // realizes that and that he has configured some other mechanism to // populate leases. @@ -449,7 +449,7 @@ HAConfigParser::validateRelationships(const HAConfigMapperPtr& config_storage) { return; } std::unordered_set<std::string> server_names; - for (auto config : configs) { + for (auto const& config : configs) { // Only the hot-standby mode is supported for multiple relationships. if (config->getHAMode() != HAConfig::HOT_STANDBY) { isc_throw(HAConfigValidationError, "multiple HA relationships are only supported for 'hot-standby' mode"); diff --git a/src/hooks/dhcp/high_availability/ha_impl.cc b/src/hooks/dhcp/high_availability/ha_impl.cc index c6f546156a..ac3fea0e68 100644 --- a/src/hooks/dhcp/high_availability/ha_impl.cc +++ b/src/hooks/dhcp/high_availability/ha_impl.cc @@ -47,21 +47,21 @@ HAImpl::startServices(const IOServicePtr& io_service, // Create the HA service and crank up the state machine. auto service = boost::make_shared<HAService>(id, io_service, network_state, configs[id], server_type); - for (auto peer_config : configs[id]->getAllServersConfig()) { + for (auto const& peer_config : configs[id]->getAllServersConfig()) { services_->map(peer_config.first, service); } } // Schedule a start of the services. This ensures we begin after // the dust has settled and Kea MT mode has been firmly established. io_service->post([&]() { - for (auto service : services_->getAll()) { + for (auto const& service : services_->getAll()) { service->startClientAndListener(); } }); } HAImpl::~HAImpl() { - for (auto service : services_->getAll()) { + for (auto const& service : services_->getAll()) { // Shut down the services explicitly, we need finer control // than relying on destruction order. service->stopClientAndListener(); @@ -574,7 +574,7 @@ HAImpl::commandProcessed(hooks::CalloutHandle& callout_handle) { // Process the status get command for each HA service. auto ha_relationships = Element::createList(); - for (auto service : services_->getAll()) { + for (auto const& service : services_->getAll()) { auto ha_relationship = Element::createMap(); ConstElementPtr ha_servers = service->processStatusGet(); ha_relationship->set("ha-servers", ha_servers); @@ -798,7 +798,7 @@ HAImpl::maintenanceNotifyHandler(hooks::CalloutHandle& callout_handle) { void HAImpl::maintenanceStartHandler(hooks::CalloutHandle& callout_handle) { ConstElementPtr response; - for (auto service : services_->getAll()) { + for (auto const& service : services_->getAll()) { response = service->processMaintenanceStart(); int rcode = CONTROL_RESULT_SUCCESS; static_cast<void>(parseAnswer(rcode, response)); @@ -812,7 +812,7 @@ HAImpl::maintenanceStartHandler(hooks::CalloutHandle& callout_handle) { void HAImpl::maintenanceCancelHandler(hooks::CalloutHandle& callout_handle) { ConstElementPtr response; - for (auto service : services_->getAll()) { + for (auto const& service : services_->getAll()) { response = service->processMaintenanceCancel(); } callout_handle.setArgument("response", response); diff --git a/src/hooks/dhcp/high_availability/ha_relationship_mapper.h b/src/hooks/dhcp/high_availability/ha_relationship_mapper.h index 9990258ef2..a902f2c105 100644 --- a/src/hooks/dhcp/high_availability/ha_relationship_mapper.h +++ b/src/hooks/dhcp/high_availability/ha_relationship_mapper.h @@ -47,7 +47,7 @@ public: mapping_[key] = obj; auto found = false; - for (auto o : vector_) { + for (auto const& o : vector_) { if (o == obj) { found = true; break; diff --git a/src/hooks/dhcp/high_availability/ha_service.cc b/src/hooks/dhcp/high_availability/ha_service.cc index 55c0bed647..09f72ca265 100644 --- a/src/hooks/dhcp/high_availability/ha_service.cc +++ b/src/hooks/dhcp/high_availability/ha_service.cc @@ -1658,7 +1658,7 @@ HAService::processStatusGet() const { } std::set<std::string> scopes = query_filter_.getServedScopes(); ElementPtr list = Element::createList(); - for (std::string scope : scopes) { + for (const std::string& scope : scopes) { list->add(Element::create(scope)); } local->set("scopes", list); @@ -1700,7 +1700,7 @@ HAService::processHeartbeat() { auto scopes = query_filter_.getServedScopes(); ElementPtr scopes_list = Element::createList(); - for (auto scope : scopes) { + for (auto const& scope : scopes) { scopes_list->add(Element::create(scope)); } arguments->set("scopes", scopes_list); diff --git a/src/hooks/dhcp/high_availability/libloadtests/close_unittests.cc b/src/hooks/dhcp/high_availability/libloadtests/close_unittests.cc index 36df83e94d..2fb05645f8 100644 --- a/src/hooks/dhcp/high_availability/libloadtests/close_unittests.cc +++ b/src/hooks/dhcp/high_availability/libloadtests/close_unittests.cc @@ -243,7 +243,7 @@ CloseHATest::runPartners(bool const backup /* = true */) { if (accept_partner2 > nfd) { nfd = accept_partner2; } - for (auto reader : readers) { + for (auto const& reader : readers) { if (!reader.second) { continue; } @@ -285,7 +285,7 @@ CloseHATest::runPartners(bool const backup /* = true */) { readers[fd] = true; } } - for (auto reader : readers) { + for (auto const& reader : readers) { if (!reader.second) { continue; } @@ -314,7 +314,7 @@ CloseHATest::runPartners(bool const backup /* = true */) { if (accept_partner2 >= 0) { close(accept_partner2); } - for (auto reader : readers) { + for (auto const& reader : readers) { if (!reader.second) { continue; } diff --git a/src/hooks/dhcp/high_availability/query_filter.cc b/src/hooks/dhcp/high_availability/query_filter.cc index 5e5b7b3a44..b2538ebdb5 100644 --- a/src/hooks/dhcp/high_availability/query_filter.cc +++ b/src/hooks/dhcp/high_availability/query_filter.cc @@ -338,7 +338,7 @@ QueryFilter::getServedScopes() const { std::set<std::string> QueryFilter::getServedScopesInternal() const { std::set<std::string> scope_set; - for (auto scope : scopes_) { + for (auto const& scope : scopes_) { if (scope.second) { scope_set.insert(scope.first); } @@ -474,7 +474,7 @@ uint8_t QueryFilter::loadBalanceHash(const uint8_t* key, const size_t key_len) const { uint8_t hash = static_cast<uint8_t>(key_len); - for (auto i = key_len; i > 0;) { + for (size_t i = key_len; i > 0;) { hash = loadb_mx_tbl[hash ^ key[--i]]; } 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 8c33c094ed..52d1780b3f 100644 --- a/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc @@ -964,7 +964,7 @@ CommunicationStateTest::getRejectedLeaseUpdatesCountFromContainerTest() { EXPECT_EQ(500, entries.size()); // Validate that we removed expired entries, not the valid ones. - for (auto entry : entries) { + for (auto const& entry : entries) { EXPECT_EQ(1, entry.ordinal_ % 2); } } 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 4c4639d4fa..800d31a2cd 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc @@ -1226,7 +1226,7 @@ public: // to add several more leases to the backlog to exceed the limit. if (overflow) { ASSERT_NO_THROW(generateTestLeases4()); - for (auto lease : leases4_) { + for (auto const& lease : leases4_) { service_->lease_update_backlog_.push(LeaseUpdateBacklog::ADD, lease); } } @@ -1641,7 +1641,7 @@ public: // to add several more leases to the backlog to exceed the limit. if (overflow) { ASSERT_NO_THROW(generateTestLeases6()); - for (auto lease : leases6_) { + for (auto const& lease : leases6_) { service_->lease_update_backlog_.push(LeaseUpdateBacklog::ADD, lease); } } @@ -4794,7 +4794,7 @@ TEST_F(HAServiceTest, processMaintenanceNotify) { TestHAService service(1, io_service_, network_state_, config_storage); // Test transition from the states for which it is allowed. - for (auto state : valid_states) { + for (auto const& state : valid_states) { EXPECT_NO_THROW(service.transition(state, HAService::NOP_EVT)); // Process ha-maintenance-notify command that should transition the @@ -4828,7 +4828,7 @@ TEST_F(HAServiceTest, processMaintenanceNotify) { }; // Make sure that the transition from the other states is not allowed. - for (auto state : invalid_states) { + for (auto const& state : invalid_states) { EXPECT_NO_THROW(service.transition(state, HAService::NOP_EVT)); EXPECT_NO_THROW(service.runModel(HAService::NOP_EVT)); @@ -5507,7 +5507,7 @@ public: } if (!static_scopes_.empty()) { auto json_scopes = Element::createList(); - for (auto scope : static_scopes_) { + for (auto const& scope : static_scopes_) { json_scopes->add(Element::create(scope)); } response_arguments->set("scopes", json_scopes); @@ -5890,7 +5890,7 @@ public: << "'"; // Now, verify that each specified scope is handled. - for(auto scope : scopes) { + for(auto const& scope : scopes) { EXPECT_TRUE(service_->query_filter_.amServingScope(scope)) << "test failed for state '" << service_->getStateLabel(my_state.state_) << "'"; diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds4_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds4_unittest.cc index 444b4be024..c01874563d 100644 --- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds4_unittest.cc +++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds4_unittest.cc @@ -1541,7 +1541,7 @@ void Lease4CmdsTest::testLease4GetPaged() { EXPECT_EQ(2, page_count->intValue()); // Go over each lease and verify its correctness. - for (ConstElementPtr lease : leases->listValue()) { + for (auto const& lease : leases->listValue()) { ASSERT_EQ(Element::map, lease->getType()); ASSERT_TRUE(lease->contains("ip-address")); ConstElementPtr ip_address = lease->get("ip-address"); @@ -3128,7 +3128,7 @@ void Lease4CmdsTest::testLease4ResendDdnsEnabled() { // Expected response string. string exp_rsp = "NCR generated for: 192.0.2.1, hostname: myhost.example.com."; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); // Fetch the lease so we can update the DDNS direction flags. @@ -3220,7 +3220,7 @@ void Lease4CmdsTest::testLease4DnsRemoveD2Enabled() { }, }; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); // Let's create a lease with scenario attributes. diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds6_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds6_unittest.cc index 181042b8c4..bc5e953fa5 100644 --- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds6_unittest.cc +++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds6_unittest.cc @@ -1712,7 +1712,7 @@ void Lease6CmdsTest::testLease6GetPaged() { EXPECT_EQ(2, page_count->intValue()); // Go over each lease and verify its correctness. - for (ConstElementPtr lease : leases->listValue()) { + for (auto const& lease : leases->listValue()) { ASSERT_EQ(Element::map, lease->getType()); ASSERT_TRUE(lease->contains("ip-address")); ConstElementPtr ip_address = lease->get("ip-address"); @@ -3795,7 +3795,7 @@ void Lease6CmdsTest::testLease6ResendDdnsEnabled() { // Expected response string. string exp_rsp = "NCR generated for: 2001:db8:1::1, hostname: myhost.example.com."; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); // Fetch the lease so we can update the DDNS direction flags. @@ -3887,7 +3887,7 @@ void Lease6CmdsTest::testLease6DnsRemoveD2Enabled() { }, }; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); // Let's create a lease with scenario attributes. diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc index c89c1316cd..992ee5740f 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc @@ -2550,7 +2550,7 @@ public: tossNonMatchingElements(server_selector, class_list); - for (auto c : class_list) { + for (auto const& c : class_list) { client_classes.addClass(c); } } diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc index 2f290faad7..c32babe9f9 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc @@ -2978,7 +2978,7 @@ public: tossNonMatchingElements(server_selector, class_list); - for (auto c : class_list) { + for (auto const& c : class_list) { client_classes.addClass(c); } } diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc index cf080f8914..13284b2548 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc @@ -520,7 +520,7 @@ MySqlConfigBackendImpl::createUpdateOptionDef(const db::ServerSelector& server_s auto tag = getServerTag(server_selector, "creating or updating option definition"); ElementPtr record_types = Element::createList(); - for (auto field : option_def->getRecordFields()) { + for (auto const& field : option_def->getRecordFields()) { record_types->add(Element::create(static_cast<int>(field))); } MySqlBindingPtr record_types_binding = record_types->empty() ? diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h index 78eb87bd64..8592ecf955 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.h @@ -730,7 +730,7 @@ public: void multipleUpdateDeleteQueries(T first_index, R... other_indexes) { std::vector<T> indexes({ first_index, other_indexes... }); db::MySqlBindingCollection empty_bindings; - for (auto index : indexes) { + for (auto const& index : indexes) { conn_.updateDeleteQuery(index, empty_bindings); } } diff --git a/src/hooks/dhcp/pgsql_cb/pgsql_cb_dhcp4.cc b/src/hooks/dhcp/pgsql_cb/pgsql_cb_dhcp4.cc index 4e7b77056f..71eb9fa91f 100644 --- a/src/hooks/dhcp/pgsql_cb/pgsql_cb_dhcp4.cc +++ b/src/hooks/dhcp/pgsql_cb/pgsql_cb_dhcp4.cc @@ -2340,7 +2340,7 @@ public: tossNonMatchingElements(server_selector, class_list); - for (auto c : class_list) { + for (auto const& c : class_list) { client_classes.addClass(c); } } diff --git a/src/hooks/dhcp/pgsql_cb/pgsql_cb_dhcp6.cc b/src/hooks/dhcp/pgsql_cb/pgsql_cb_dhcp6.cc index 06dff3f3e1..899f912613 100644 --- a/src/hooks/dhcp/pgsql_cb/pgsql_cb_dhcp6.cc +++ b/src/hooks/dhcp/pgsql_cb/pgsql_cb_dhcp6.cc @@ -2663,7 +2663,7 @@ public: tossNonMatchingElements(server_selector, class_list); - for (auto c : class_list) { + for (auto const& c : class_list) { client_classes.addClass(c); } } diff --git a/src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.cc b/src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.cc index 2732f7a62c..a3e1534b41 100644 --- a/src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.cc +++ b/src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.cc @@ -523,7 +523,7 @@ PgSqlConfigBackendImpl::createUpdateOptionDef(const db::ServerSelector& server_s in_bindings.addTempString(option_def->getEncapsulatedSpace()); ElementPtr record_types = Element::createList(); - for (auto field : option_def->getRecordFields()) { + for (auto const& field : option_def->getRecordFields()) { record_types->add(Element::create(static_cast<int>(field))); } diff --git a/src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.h b/src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.h index aaa76b6056..e449cb763c 100644 --- a/src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.h +++ b/src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.h @@ -694,7 +694,7 @@ public: void multipleUpdateDeleteQueries(T first_index, R... other_indexes) { std::vector<T> indexes({ first_index, other_indexes... }); db::PsqlBindArray in_bindings; - for (auto index : indexes) { + for (auto const& index : indexes) { updateDeleteQuery(index, in_bindings); } } 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 5dc284157e..33255f0f80 100644 --- a/src/hooks/dhcp/run_script/tests/run_script_unittests.cc +++ b/src/hooks/dhcp/run_script/tests/run_script_unittests.cc @@ -67,7 +67,7 @@ namespace { string join(const ProcessEnvVars& vars) { string result; - for (auto var : vars) { + for (auto const& var : vars) { result += var + "\n"; } return (result); diff --git a/src/lib/asiolink/io_service_thread_pool.cc b/src/lib/asiolink/io_service_thread_pool.cc index 8919385cff..8a4488074e 100644 --- a/src/lib/asiolink/io_service_thread_pool.cc +++ b/src/lib/asiolink/io_service_thread_pool.cc @@ -114,7 +114,7 @@ IoServiceThreadPool::checkPermissions(State state) { bool IoServiceThreadPool::checkThreadId(std::thread::id id) { - for (auto thread : threads_) { + for (const auto& thread : threads_) { if (id == thread->get_id()) { return (true); } diff --git a/src/lib/cc/command_interpreter.cc b/src/lib/cc/command_interpreter.cc index 0ea03bcd48..50b390621d 100644 --- a/src/lib/cc/command_interpreter.cc +++ b/src/lib/cc/command_interpreter.cc @@ -212,8 +212,8 @@ parseCommand(ConstElementPtr& arg, ConstElementPtr command) { } // Make sure that all specified parameters are supported. - auto command_params = command->mapValue(); - for (auto param : command_params) { + auto const& command_params = command->mapValue(); + for (const auto& param : command_params) { if ((param.first != CONTROL_COMMAND) && (param.first != CONTROL_ARGUMENTS) && (param.first != CONTROL_SERVICE) && diff --git a/src/lib/cc/data.cc b/src/lib/cc/data.cc index 9b13bcea5c..8350462844 100644 --- a/src/lib/cc/data.cc +++ b/src/lib/cc/data.cc @@ -1122,7 +1122,7 @@ MapElement::equals(const Element& other) const { if (size() != other.size()) { return (false); } - for (auto kv : mapValue()) { + for (const auto& kv : mapValue()) { auto key = kv.first; if (other.contains(key)) { if (!get(key)->equals(*other.get(key))) { @@ -1156,7 +1156,7 @@ removeIdentical(ElementPtr a, ConstElementPtr b) { // over a checking for identical entries in b or vice-versa. As elements // are removed from a if a match is found, we choose to iterate over b to // avoid problems with element removal affecting the iterator. - for (auto kv : b->mapValue()) { + for (const auto& kv : b->mapValue()) { auto key = kv.first; if (a->contains(key)) { if (a->get(key)->equals(*b->get(key))) { @@ -1249,7 +1249,7 @@ mergeDiffAdd(ElementPtr& element, ElementPtr& other, } if (element->getType() == Element::map) { - for (auto kv : other->mapValue()) { + for (const auto& kv : other->mapValue()) { auto current_key = kv.first; auto value = boost::const_pointer_cast<Element>(kv.second); if (value && value->getType() != Element::null) { @@ -1318,7 +1318,7 @@ mergeDiffDel(ElementPtr& element, ElementPtr& other, // If the resulting element still contains data, we need to restore the // key parameters, so we store them here. ElementPtr new_elements = Element::createMap(); - for (auto kv : other->mapValue()) { + for (const auto& kv : other->mapValue()) { auto current_key = kv.first; auto value = boost::const_pointer_cast<Element>(kv.second); if (value && value->getType() != Element::null) { @@ -1349,7 +1349,7 @@ mergeDiffDel(ElementPtr& element, ElementPtr& other, } // If the element still contains data, restore the key elements. if (element->size()) { - for (auto kv : new_elements->mapValue()) { + for (const auto& kv : new_elements->mapValue()) { element->set(kv.first, kv.second); } } @@ -1389,7 +1389,7 @@ extend(const std::string& container, const std::string& extension, } if (element->getType() == Element::map) { - for (auto kv : other->mapValue()) { + for (const auto& kv : other->mapValue()) { auto current_key = kv.first; auto value = boost::const_pointer_cast<Element>(kv.second); if (value && value->getType() != Element::null) { @@ -1428,7 +1428,7 @@ copy(ConstElementPtr from, int level) { return (ElementPtr(new StringElement(from->stringValue()))); } else if (from_type == Element::list) { ElementPtr result = ElementPtr(new ListElement()); - for (auto elem : from->listValue()) { + for (const auto& elem : from->listValue()) { if (level == 0) { result->add(elem); } else { @@ -1438,7 +1438,7 @@ copy(ConstElementPtr from, int level) { return (result); } else if (from_type == Element::map) { ElementPtr result = ElementPtr(new MapElement()); - for (auto kv : from->mapValue()) { + for (const auto& kv : from->mapValue()) { auto key = kv.first; auto value = kv.second; if (level == 0) { diff --git a/src/lib/cc/simple_parser.cc b/src/lib/cc/simple_parser.cc index 8140d13379..e0baa31fd1 100644 --- a/src/lib/cc/simple_parser.cc +++ b/src/lib/cc/simple_parser.cc @@ -24,7 +24,7 @@ namespace data { void SimpleParser::checkRequired(const SimpleRequiredKeywords& required, ConstElementPtr scope) { - for (auto name : required) { + for (const auto& name : required) { if (scope->contains(name)) { continue; } @@ -36,7 +36,7 @@ void SimpleParser::checkKeywords(const SimpleKeywords& keywords, ConstElementPtr scope) { string spurious; - for (auto entry : scope->mapValue()) { + for (const auto& entry : scope->mapValue()) { if (keywords.count(entry.first) == 0) { if (spurious.empty()) { spurious = entry.first; diff --git a/src/lib/cc/stamped_element.cc b/src/lib/cc/stamped_element.cc index 3c53b3826f..93915d63ca 100644 --- a/src/lib/cc/stamped_element.cc +++ b/src/lib/cc/stamped_element.cc @@ -38,7 +38,7 @@ StampedElement::getMetadata() const { ElementPtr metadata = Element::createMap(); ElementPtr tags = Element::createList(); - for (auto server_tag : server_tags_) { + for (const auto& server_tag : server_tags_) { tags->add(Element::create(server_tag.get())); } diff --git a/src/lib/config_backend/base_config_backend_pool.h b/src/lib/config_backend/base_config_backend_pool.h index 1c836771a0..55ed91d01e 100644 --- a/src/lib/config_backend/base_config_backend_pool.h +++ b/src/lib/config_backend/base_config_backend_pool.h @@ -171,7 +171,7 @@ protected: // If no particular backend is selected, call each backend and return // the first non-null (non zero) value. if (backend_selector.amUnspecified()) { - for (auto backend : backends_) { + for (const auto& backend : backends_) { property = ((*backend).*MethodPointer)(server_selector, input...); if (property) { break; @@ -182,7 +182,7 @@ protected: // Backend selected, find the one that matches selection. auto backends = selectBackends(backend_selector); if (!backends.empty()) { - for (auto backend : backends) { + for (const auto& backend : backends) { property = ((*backend).*MethodPointer)(server_selector, input...); if (property) { break; @@ -312,7 +312,7 @@ protected: PropertyCollectionType& properties, Args... input) const { if (backend_selector.amUnspecified()) { - for (auto backend : backends_) { + for (const auto& backend : backends_) { properties = ((*backend).*MethodPointer)(server_selector, input...); if (!properties.empty()) { break; @@ -322,7 +322,7 @@ protected: } else { auto backends = selectBackends(backend_selector); if (!backends.empty()) { - for (auto backend : backends) { + for (const auto& backend : backends) { properties = ((*backend).*MethodPointer)(server_selector, input...); if (!properties.empty()) { break; @@ -382,7 +382,7 @@ protected: const db::ServerSelector& server_selector, PropertyCollectionType& properties) const { if (backend_selector.amUnspecified()) { - for (auto backend : backends_) { + for (const auto& backend : backends_) { properties = ((*backend).*MethodPointer)(server_selector); if (!properties.empty()) { break; @@ -392,7 +392,7 @@ protected: } else { auto backends = selectBackends(backend_selector); if (!backends.empty()) { - for (auto backend : backends) { + for (const auto& backend : backends) { properties = ((*backend).*MethodPointer)(server_selector); if (!properties.empty()) { break; @@ -609,7 +609,7 @@ protected: } // Go over all backends. - for (auto backend : backends_) { + for (const auto& backend : backends_) { // If backend type is specified and it is not matching, // do not select this backend. if ((backend_selector.getBackendType() != db::BackendSelector::Type::UNSPEC) && 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 09645e3e5c..7a4fad632c 100644 --- a/src/lib/config_backend/tests/config_backend_mgr_unittest.cc +++ b/src/lib/config_backend/tests/config_backend_mgr_unittest.cc @@ -56,7 +56,7 @@ public: /// @return Value of the property or 0 if property doesn't exist. virtual int getProperty(const ServerSelector&, const std::string& property_name) const { - for (auto property : properties_) { + for (const auto& property : properties_) { if (property.first == property_name) { return (property.second); } @@ -72,7 +72,7 @@ public: virtual int getProperty(const ServerSelector&, const std::string& property_name, const int property_value) const { - for (auto property : properties_) { + for (const auto& property : properties_) { if ((property.first == property_name) && (property.second == property_value)) { return (property.second); @@ -89,7 +89,7 @@ public: virtual PropertiesList getProperties(const ServerSelector&, const std::string& property_name) const { PropertiesList properties; - for (auto property : properties_) { + for (const auto& property : properties_) { if (property.first == property_name) { properties.push_back(property); } diff --git a/src/lib/database/database_connection.cc b/src/lib/database/database_connection.cc index d0bf207277..43bdfaaae6 100644 --- a/src/lib/database/database_connection.cc +++ b/src/lib/database/database_connection.cc @@ -220,7 +220,7 @@ isc::data::ElementPtr DatabaseConnection::toElement(const ParameterMap& params) { isc::data::ElementPtr result = isc::data::Element::createMap(); - for (auto param: params) { + for (const auto& param : params) { std::string keyword = param.first; std::string value = param.second; diff --git a/src/lib/database/dbaccess_parser.cc b/src/lib/database/dbaccess_parser.cc index e31ae7a1a1..f6e70eacaf 100644 --- a/src/lib/database/dbaccess_parser.cc +++ b/src/lib/database/dbaccess_parser.cc @@ -58,7 +58,7 @@ DbAccessParser::parse(std::string& access_string, int64_t max_row_errors = 0; // 2. Update the copy with the passed keywords. - for (std::pair<std::string, ConstElementPtr> param : database_config->mapValue()) { + for (auto const& param : database_config->mapValue()) { try { if ((param.first == "persist") || (param.first == "readonly") || @@ -270,7 +270,7 @@ DbAccessParser::getDbAccessString() const { // Construct the database access string from all keywords and values in the // parameter map where the value is not null. string dbaccess; - for (auto keyval : values_) { + for (const auto& keyval : values_) { if (!keyval.second.empty()) { // Separate keyword/value pair from predecessor (if there is one). diff --git a/src/lib/database/server_selector.cc b/src/lib/database/server_selector.cc index 18fbdbd0fe..09e39a6e85 100644 --- a/src/lib/database/server_selector.cc +++ b/src/lib/database/server_selector.cc @@ -24,7 +24,7 @@ ServerSelector::MULTIPLE(const std::set<std::string>& server_tags) { std::set<ServerTag> tags; // Create a set of tags from strings. - for (auto tag : server_tags) { + for (const auto& tag : server_tags) { tags.insert(ServerTag(tag)); } diff --git a/src/lib/database/tests/database_connection_unittest.cc b/src/lib/database/tests/database_connection_unittest.cc index b34f2e8fa6..ff37ef95ff 100644 --- a/src/lib/database/tests/database_connection_unittest.cc +++ b/src/lib/database/tests/database_connection_unittest.cc @@ -626,7 +626,7 @@ TEST(DatabaseConnection, DISABLED_toElementDbAccessStringInvalid) { "readonly=not-boolean" }; - for (auto access_str : access_strs) { + for (auto const& access_str : access_strs) { /// @todo: verify that an ERROR is logged. ASSERT_NO_THROW(DatabaseConnection::toElementDbAccessString(access_str)); } diff --git a/src/lib/dhcp/classify.cc b/src/lib/dhcp/classify.cc index 7b0be454f1..9f1461604e 100644 --- a/src/lib/dhcp/classify.cc +++ b/src/lib/dhcp/classify.cc @@ -66,7 +66,7 @@ ClientClasses::toText(const std::string& separator) const { ElementPtr ClientClasses::toElement() const { ElementPtr result(Element::createList()); - for (ClientClass c : container_) { + for (const ClientClass& c : container_) { result->add(Element::create(c)); } return (result); diff --git a/src/lib/dhcp/duid_factory.cc b/src/lib/dhcp/duid_factory.cc index 1a023445bd..6303e9ea1f 100644 --- a/src/lib/dhcp/duid_factory.cc +++ b/src/lib/dhcp/duid_factory.cc @@ -244,7 +244,7 @@ void DUIDFactory::createLinkLayerId(std::vector<uint8_t>& identifier, uint16_t& htype) const { // Let's find suitable interface. - for (IfacePtr iface : IfaceMgr::instance().getIfaces()) { + for (const IfacePtr& iface : IfaceMgr::instance().getIfaces()) { // All the following checks could be merged into one multi-condition // statement, but let's keep them separated as perhaps one day // we will grow knobs to selectively turn them on or off. Also, diff --git a/src/lib/dhcp/libdhcp++.cc b/src/lib/dhcp/libdhcp++.cc index 5512a96b10..a9bdb69d7a 100644 --- a/src/lib/dhcp/libdhcp++.cc +++ b/src/lib/dhcp/libdhcp++.cc @@ -1126,7 +1126,7 @@ LibDHCP::splitOptions4(OptionCollection& options, // parent option will be created for each suboption. // This will guarantee that none of the options plus // suboptions will have more than 255 bytes. - for (auto sub_option : candidate->getMutableOptions()) { + for (auto const& sub_option : candidate->getMutableOptions()) { OptionPtr data_sub_option(new Option(candidate->getUniverse(), candidate->getType(), OptionBuffer(0))); diff --git a/src/lib/dhcp/option6_auth.cc b/src/lib/dhcp/option6_auth.cc index b859886d3d..c87402136c 100644 --- a/src/lib/dhcp/option6_auth.cc +++ b/src/lib/dhcp/option6_auth.cc @@ -58,7 +58,7 @@ Option6Auth::pack(isc::util::OutputBuffer& buf, bool) const { // authentication information for reconfig msg // should have zero - for (auto i : auth_info_) { + for (auto const& i : auth_info_) { buf.writeUint8(i); } } diff --git a/src/lib/dhcp/option_space_container.h b/src/lib/dhcp/option_space_container.h index d1c2952cb6..017eeec695 100644 --- a/src/lib/dhcp/option_space_container.h +++ b/src/lib/dhcp/option_space_container.h @@ -111,7 +111,7 @@ public: /// @return Number of deleted options or option definitions. uint64_t deleteItems(const uint64_t id) { uint64_t num_deleted = 0; - for (auto space : option_space_map_) { + for (auto const& space : option_space_map_) { auto container = space.second; auto& index = container->template get<OptionIdIndexTag>(); num_deleted += index.erase(id); diff --git a/src/lib/dhcp/pkt6.cc b/src/lib/dhcp/pkt6.cc index 6ab5894250..eb800f90ae 100644 --- a/src/lib/dhcp/pkt6.cc +++ b/src/lib/dhcp/pkt6.cc @@ -948,7 +948,7 @@ HWAddrPtr Pkt6::getMACFromDocsisModem() { HWAddrPtr mac; OptionVendorPtr vendor; - for (auto opt : getNonCopiedOptions(D6O_VENDOR_OPTS)) { + for (auto const& opt : getNonCopiedOptions(D6O_VENDOR_OPTS)) { if (opt.first != D6O_VENDOR_OPTS) { continue; } @@ -982,8 +982,8 @@ Pkt6::getMACFromDocsisCMTS() { // CMTS-specific options in it. HWAddrPtr mac; OptionVendorPtr vendor; - for (auto opt : getAllRelayOptions(D6O_VENDOR_OPTS, - RELAY_SEARCH_FROM_CLIENT)) { + for (auto const& opt : getAllRelayOptions(D6O_VENDOR_OPTS, + RELAY_SEARCH_FROM_CLIENT)) { if (opt.first != D6O_VENDOR_OPTS) { continue; } diff --git a/src/lib/dhcp/tests/iface_mgr_unittest.cc b/src/lib/dhcp/tests/iface_mgr_unittest.cc index 82b877aca2..a0a7a28f01 100644 --- a/src/lib/dhcp/tests/iface_mgr_unittest.cc +++ b/src/lib/dhcp/tests/iface_mgr_unittest.cc @@ -336,7 +336,7 @@ public: const bool up, const bool running, const bool inactive4, const bool inactive6) { - for (IfacePtr iface : ifaces_) { + for (const IfacePtr& iface : ifaces_) { if (iface->getName() == name) { iface->flag_loopback_ = loopback; iface->flag_up_ = up; @@ -1121,7 +1121,7 @@ TEST_F(IfaceMgrTest, getIface) { cout << "There are " << ifacemgr->getIfacesLst().size() << " interfaces." << endl; - for (IfacePtr iface : ifacemgr->getIfacesLst()) { + for (const IfacePtr& iface : ifacemgr->getIfacesLst()) { cout << " " << iface->getFullName() << endl; } diff --git a/src/lib/dhcp/tests/option6_auth_unittest.cc b/src/lib/dhcp/tests/option6_auth_unittest.cc index 41b7799d57..bcbc87aa4e 100644 --- a/src/lib/dhcp/tests/option6_auth_unittest.cc +++ b/src/lib/dhcp/tests/option6_auth_unittest.cc @@ -74,7 +74,7 @@ TEST_F(Option6AuthTest, parseFields) { buff_[8] = 0xa9; //rdm value buff_[9] = 0xaa; //rdm value buff_[10] = 0xab; //rdm value - for ( uint8_t i = 11; i < 27; i++ ) { + for (uint8_t i = 11; i < 27; i++) { buff_[i] = 0xa8; //auth info 16 bytes } diff --git a/src/lib/dhcp/tests/pkt6_unittest.cc b/src/lib/dhcp/tests/pkt6_unittest.cc index 953a67a0bb..caee2d2fdb 100644 --- a/src/lib/dhcp/tests/pkt6_unittest.cc +++ b/src/lib/dhcp/tests/pkt6_unittest.cc @@ -1029,7 +1029,7 @@ TEST_F(Pkt6Test, getAnyRelayOption) { msg->getNonCopiedAllRelayOptions(200, Pkt6::RELAY_SEARCH_FROM_CLIENT); EXPECT_EQ(3, opts0.size()); vector<OptionPtr> lopts0; - for (auto it : opts0) { + for (auto const& it : opts0) { lopts0.push_back(it.second); } ASSERT_EQ(3, lopts0.size()); @@ -1052,7 +1052,7 @@ TEST_F(Pkt6Test, getAnyRelayOption) { opts = msg->getNonCopiedAllRelayOptions(200, Pkt6::RELAY_SEARCH_FROM_SERVER); EXPECT_EQ(3, opts.size()); vector<OptionPtr> lopts; - for (auto it : opts) { + for (auto const& it : opts) { lopts.push_back(it.second); } ASSERT_EQ(3, lopts.size()); @@ -1113,7 +1113,7 @@ TEST_F(Pkt6Test, getAnyRelayOption) { // Check collections. opts = msg->getNonCopiedAllRelayOptions(200, Pkt6::RELAY_SEARCH_FROM_CLIENT); lopts0.clear(); - for (auto it : opts) { + for (auto const& it : opts) { lopts0.push_back(it.second); } ASSERT_EQ(3, lopts0.size()); @@ -1123,7 +1123,7 @@ TEST_F(Pkt6Test, getAnyRelayOption) { EXPECT_TRUE(lopts0[2] == relay1_opt1); opts = msg->getAllRelayOptions(200, Pkt6::RELAY_SEARCH_FROM_CLIENT); lopts.clear(); - for (auto it : opts) { + for (auto const& it : opts) { lopts.push_back(it.second); } ASSERT_EQ(3, lopts.size()); @@ -1150,7 +1150,7 @@ TEST_F(Pkt6Test, getAnyRelayOption) { // Check collections. opts = msg->getNonCopiedAllRelayOptions(200, Pkt6::RELAY_SEARCH_FROM_SERVER); lopts0.clear(); - for (auto it : opts) { + for (auto const& it : opts) { lopts0.push_back(it.second); } ASSERT_EQ(3, lopts0.size()); @@ -1160,7 +1160,7 @@ TEST_F(Pkt6Test, getAnyRelayOption) { EXPECT_TRUE(lopts0[2] == relay3_opt1); opts = msg->getAllRelayOptions(200, Pkt6::RELAY_SEARCH_FROM_SERVER); lopts.clear(); - for (auto it : opts) { + for (auto const& it : opts) { lopts.push_back(it.second); } ASSERT_EQ(3, lopts.size()); diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index 8097e5ffc4..4819e3be6a 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -435,7 +435,7 @@ AllocEngine::findReservation(ClientContext6& ctx) { // The hosts can be used by the server to return reserved options to // the DHCP client. Such options must be encapsulated (i.e., they must // include suboptions). - for (auto host : ctx.hosts_) { + for (auto const& host : ctx.hosts_) { host.second->encapsulateOptions(); } } @@ -480,7 +480,7 @@ AllocEngine::allocateLeases6(ClientContext6& ctx) { // our shared network. Lease6Collection leases; while (subnet) { - for (auto l : all_leases) { + for (auto const& l : all_leases) { if ((l)->subnet_id_ == subnet->getID()) { leases.push_back(l); } @@ -3369,7 +3369,7 @@ addressReserved(const IOAddress& address, const AllocEngine::ClientContext4& ctx hosts = HostMgr::instance().getAll4(ctx.subnet_->getID(), address); } - for (auto host : hosts) { + for (auto const& host : hosts) { for (const AllocEngine::IdentifierPair& id_pair : ctx.host_identifiers_) { // If we find the matching host we know that this address is reserved // for us and we can return immediately. @@ -3806,7 +3806,7 @@ AllocEngine::findReservation(ClientContext4& ctx) { // The hosts can be used by the server to return reserved options to // the DHCP client. Such options must be encapsulated (i.e., they must // include suboptions). - for (auto host : ctx.hosts_) { + for (auto const& host : ctx.hosts_) { host.second->encapsulateOptions(); } } @@ -5054,7 +5054,7 @@ AllocEngine::updateLease6ExtendedInfo(const Lease6Ptr& lease, // },..] // ElementPtr extended_info = Element::createList(); - for (auto relay : ctx.query_->relay_info_) { + for (auto const& relay : ctx.query_->relay_info_) { ElementPtr relay_elem = Element::createMap(); relay_elem->set("hop", ElementPtr(new IntElement(relay.hop_count_))); relay_elem->set("link", ElementPtr(new StringElement(relay.linkaddr_.toText()))); diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc index 1b263f30b5..febf988285 100644 --- a/src/lib/dhcpsrv/cfg_hosts.cc +++ b/src/lib/dhcpsrv/cfg_hosts.cc @@ -709,7 +709,7 @@ CfgHosts::getAll4(const SubnetID& subnet_id, .arg(subnet_id).arg(address.toText()); ConstHostCollection hosts; - for (auto host : getAll4(address)) { + for (auto const& host : getAll4(address)) { if (host->getIPv4SubnetID() == subnet_id) { LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE_DETAIL_DATA, HOSTS_CFG_GET_ALL_SUBNET_ID_ADDRESS4_HOST) @@ -1092,7 +1092,7 @@ CfgHosts::del(const SubnetID& subnet_id, const asiolink::IOAddress& addr) { if (addr.isV4()) { HostContainerIndex4& idx = hosts_.get<4>(); // Delete IPv4 reservation and host. - for (auto host : getAll4(subnet_id, addr)) { + for (auto const& host : getAll4(subnet_id, addr)) { erased_hosts += idx.erase(host->getHostId()); } erased_addresses = erased_hosts; diff --git a/src/lib/dhcpsrv/cfg_iface.cc b/src/lib/dhcpsrv/cfg_iface.cc index e129a4f482..16f523cada 100644 --- a/src/lib/dhcpsrv/cfg_iface.cc +++ b/src/lib/dhcpsrv/cfg_iface.cc @@ -49,7 +49,7 @@ CfgIface::equals(const CfgIface& other) const { bool CfgIface::multipleAddressesPerInterfaceActive() { - for (IfacePtr iface : IfaceMgr::instance().getIfaces()) { + for (const IfacePtr& iface : IfaceMgr::instance().getIfaces()) { if (iface->countActive4() > 1) { return (true); } @@ -284,7 +284,7 @@ CfgIface::reset() { void CfgIface::setState(const uint16_t family, const bool inactive, const bool loopback_inactive) const { - for (IfacePtr iface : IfaceMgr::instance().getIfaces()) { + for (const IfacePtr& iface : IfaceMgr::instance().getIfaces()) { bool iface_inactive = iface->flag_loopback_ ? loopback_inactive : inactive; if (family == AF_INET) { iface->inactive4_ = iface_inactive; @@ -301,7 +301,7 @@ void CfgIface::setIfaceAddrsState(const uint16_t family, const bool active, Iface& iface) const { // Activate/deactivate all addresses. - for (Iface::Address addr : iface.getAddresses()) { + for (const Iface::Address& addr : iface.getAddresses()) { if (addr.get().getFamily() == family) { iface.setActive(addr.get(), active); } diff --git a/src/lib/dhcpsrv/cfg_option.cc b/src/lib/dhcpsrv/cfg_option.cc index 9a241dfa9f..4c1cddc069 100644 --- a/src/lib/dhcpsrv/cfg_option.cc +++ b/src/lib/dhcpsrv/cfg_option.cc @@ -411,7 +411,7 @@ CfgOption::del(const uint64_t id) { // Hierarchical nature of the options configuration requires that // we go over all options and decapsulate them before removing // any of them. Let's walk over the existing option spaces. - for (auto space_name : getOptionSpaceNames()) { + for (auto const& space_name : getOptionSpaceNames()) { // Get all options for the option space. auto options = getAll(space_name); for (auto option_it = options->begin(); option_it != options->end(); diff --git a/src/lib/dhcpsrv/cfg_option_def.cc b/src/lib/dhcpsrv/cfg_option_def.cc index 02de922ee1..e154d19441 100644 --- a/src/lib/dhcpsrv/cfg_option_def.cc +++ b/src/lib/dhcpsrv/cfg_option_def.cc @@ -240,16 +240,16 @@ CfgOptionDef::merge(CfgOptionDef& other) { // Iterate over this config's definitions in each space. // If either a definition's name or code already exist in // that space in "other", skip it. Otherwise, add it to "other". - for (auto space : option_definitions_.getOptionSpaceNames()) { - for (auto my_def : *(getAll(space))) { - if ((other.get(space, my_def->getName())) || - (other.get(space, my_def->getCode()))) { + for (auto const& space : option_definitions_.getOptionSpaceNames()) { + for (auto const& tmp_def : *(getAll(space))) { + if ((other.get(space, tmp_def->getName())) || + (other.get(space, tmp_def->getCode()))) { // Already in "other" so skip it. continue; } // Not in "other" so add it. - other.add(my_def); + other.add(tmp_def); } } diff --git a/src/lib/dhcpsrv/cfg_subnets4.cc b/src/lib/dhcpsrv/cfg_subnets4.cc index 5241269cfa..3e7c58bed5 100644 --- a/src/lib/dhcpsrv/cfg_subnets4.cc +++ b/src/lib/dhcpsrv/cfg_subnets4.cc @@ -619,7 +619,7 @@ CfgSubnets4::updateStatistics() { void CfgSubnets4::initAllocatorsAfterConfigure() { - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { subnet->initAllocatorsAfterConfigure(); } } diff --git a/src/lib/dhcpsrv/cfg_subnets6.cc b/src/lib/dhcpsrv/cfg_subnets6.cc index f1725ae16c..bf2b6be519 100644 --- a/src/lib/dhcpsrv/cfg_subnets6.cc +++ b/src/lib/dhcpsrv/cfg_subnets6.cc @@ -565,7 +565,7 @@ CfgSubnets6::updateStatistics() { void CfgSubnets6::initAllocatorsAfterConfigure() { - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { subnet->initAllocatorsAfterConfigure(); } } diff --git a/src/lib/dhcpsrv/client_class_def.cc b/src/lib/dhcpsrv/client_class_def.cc index a5c92aaade..168288343c 100644 --- a/src/lib/dhcpsrv/client_class_def.cc +++ b/src/lib/dhcpsrv/client_class_def.cc @@ -376,7 +376,7 @@ ClientClassDictionary::addClass(const std::string& name, } void -ClientClassDictionary::addClass(ClientClassDefPtr& class_def) { +ClientClassDictionary::addClass(const ClientClassDefPtr& class_def) { if (!class_def) { isc_throw(BadValue, "ClientClassDictionary::addClass " " - class definition cannot be null"); @@ -485,7 +485,7 @@ ClientClassDictionary::equals(const ClientClassDictionary& other) const { void ClientClassDictionary::initMatchExpr(uint16_t family) { std::queue<ExpressionPtr> expressions; - for (auto c : *list_) { + for (auto const& c : *list_) { if (!c->getTest().empty()) { ExpressionPtr match_expr = boost::make_shared<Expression>(); ExpressionParser parser; @@ -500,7 +500,7 @@ ClientClassDictionary::initMatchExpr(uint16_t family) { } // All expressions successfully initialized. Let's set them for the // client classes in the dictionary. - for (auto c : *list_) { + for (auto const& c : *list_) { if (!c->getTest().empty()) { c->setMatchExpr(expressions.front()); expressions.pop(); @@ -510,7 +510,7 @@ ClientClassDictionary::initMatchExpr(uint16_t family) { void ClientClassDictionary::createOptions(const CfgOptionDefPtr& external_defs) { - for (auto c : *list_) { + for (auto const& c : *list_) { // If the class has no options, skip it. CfgOptionPtr class_options = c->getCfgOption(); if (!class_options || class_options->empty()) { @@ -564,7 +564,7 @@ ClientClassDictionary::operator=(const ClientClassDictionary& rhs) { if (this != &rhs) { list_->clear(); map_->clear(); - for (auto cclass : *(rhs.list_)) { + for (auto const& cclass : *(rhs.list_)) { ClientClassDefPtr copy(new ClientClassDef(*cclass)); addClass(copy); } diff --git a/src/lib/dhcpsrv/client_class_def.h b/src/lib/dhcpsrv/client_class_def.h index 0cede454c8..d645b5274a 100644 --- a/src/lib/dhcpsrv/client_class_def.h +++ b/src/lib/dhcpsrv/client_class_def.h @@ -406,7 +406,7 @@ public: /// /// @throw DuplicateClientClassDef if class already exists within the /// dictionary, BadValue if the pointer is empty. - void addClass(ClientClassDefPtr& class_def); + void addClass(const ClientClassDefPtr& class_def); /// @brief Fetches the class definition for a given class name /// diff --git a/src/lib/dhcpsrv/flq_allocator.cc b/src/lib/dhcpsrv/flq_allocator.cc index 8da982f6c1..088283eac3 100644 --- a/src/lib/dhcpsrv/flq_allocator.cc +++ b/src/lib/dhcpsrv/flq_allocator.cc @@ -189,14 +189,14 @@ FreeLeaseQueueAllocator::populateFreeAddressLeases(const LeaseCollectionType& le // unordered_set. Also, elminate the expired leases and those // in the expired-reclaimed state. unordered_set<IOAddress, IOAddress::Hash> leased_addresses; - for (auto lease : leases) { + for (auto const& lease : leases) { if ((lease->getType() == pool_type_) && (!lease->expired()) && (!lease->stateExpiredReclaimed())) { leased_addresses.insert(lease->addr_); } } // For each pool, check if the address is in the leases list. size_t free_lease_count = 0; - for (auto pool : pools) { + for (auto const& pool : pools) { // Create the pool permutation so the resulting lease queue is no // particular order. IPRangePermutation perm(AddressRange(pool->getFirstAddress(), pool->getLastAddress())); @@ -236,14 +236,14 @@ FreeLeaseQueueAllocator::populateFreePrefixDelegationLeases(const Lease6Collecti // unordered_set. Also, elminate the expired leases and those // in the expired-reclaimed state. unordered_set<IOAddress, IOAddress::Hash> leased_prefixes; - for (auto lease : leases) { + for (auto const& lease : leases) { if ((lease->getType() == Lease::TYPE_PD) && (!lease->expired()) && (!lease->stateExpiredReclaimed())) { leased_prefixes.insert(lease->addr_); } } // For each pool, check if the prefix is in the leases list. size_t free_lease_count = 0; - for (auto pool : pools) { + for (auto const& pool : pools) { auto pool6 = boost::dynamic_pointer_cast<Pool6>(pool); if (!pool6) { continue; diff --git a/src/lib/dhcpsrv/host_data_source_factory.cc b/src/lib/dhcpsrv/host_data_source_factory.cc index fa27d08f8f..374df12c3b 100644 --- a/src/lib/dhcpsrv/host_data_source_factory.cc +++ b/src/lib/dhcpsrv/host_data_source_factory.cc @@ -167,7 +167,7 @@ void HostDataSourceFactory::printRegistered() { std::stringstream txt; - for (auto x : map_) { + for (auto const& x : map_) { txt << x.first << " "; } diff --git a/src/lib/dhcpsrv/host_mgr.cc b/src/lib/dhcpsrv/host_mgr.cc index b81181af6b..47997a968d 100644 --- a/src/lib/dhcpsrv/host_mgr.cc +++ b/src/lib/dhcpsrv/host_mgr.cc @@ -130,7 +130,7 @@ HostMgr::getAll(const Host::IdentifierType& identifier_type, identifier_len); } if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) { - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { ConstHostCollection hosts_plus = source->getAll(identifier_type, identifier_begin, identifier_len); hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end()); @@ -154,7 +154,7 @@ HostMgr::getAll4(const SubnetID& subnet_id, const HostMgrOperationTarget target) hosts = getCfgHosts()->getAll4(subnet_id); } if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) { - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { ConstHostCollection hosts_plus = source->getAll4(subnet_id); hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end()); } @@ -174,7 +174,7 @@ HostMgr::getAll6(const SubnetID& subnet_id, const HostMgrOperationTarget target) hosts = getCfgHosts()->getAll6(subnet_id); } if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) { - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { ConstHostCollection hosts_plus = source->getAll6(subnet_id); hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end()); } @@ -194,7 +194,7 @@ HostMgr::getAllbyHostname(const std::string& hostname, const HostMgrOperationTar hosts = getCfgHosts()->getAllbyHostname(hostname); } if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) { - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { ConstHostCollection hosts_plus = source->getAllbyHostname(hostname); hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end()); } @@ -216,7 +216,7 @@ HostMgr::getAllbyHostname4(const std::string& hostname, hosts = getCfgHosts()->getAllbyHostname4(hostname, subnet_id); } if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) { - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { ConstHostCollection hosts_plus = source->getAllbyHostname4(hostname, subnet_id); hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end()); @@ -240,7 +240,7 @@ HostMgr::getAllbyHostname6(const std::string& hostname, hosts = getCfgHosts()->getAllbyHostname6(hostname, subnet_id); } if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) { - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { ConstHostCollection hosts_plus = source->getAllbyHostname6(hostname, subnet_id); hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end()); @@ -384,7 +384,7 @@ HostMgr::getAll4(const IOAddress& address, const HostMgrOperationTarget target) hosts = getCfgHosts()->getAll4(address); } if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) { - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { ConstHostCollection hosts_plus = source->getAll4(address); hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end()); } @@ -424,7 +424,7 @@ HostMgr::get4Any(const SubnetID& subnet_id, // Try to find a host in each configured backend. We return as soon // as we find first hit. - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { host = source->get4(subnet_id, identifier_type, identifier_begin, identifier_len); @@ -503,7 +503,7 @@ HostMgr::get4(const SubnetID& subnet_id, HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_ADDRESS4) .arg(subnet_id) .arg(address.toText()); - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { host = source->get4(subnet_id, address); if (host && host->getNegative()) { return (ConstHostPtr()); @@ -539,7 +539,7 @@ HostMgr::getAll4(const SubnetID& subnet_id, .arg(subnet_id) .arg(address.toText()); - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { auto hosts_plus = source->getAll4(subnet_id, address); hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end()); } @@ -566,7 +566,7 @@ HostMgr::get6(const IOAddress& prefix, const uint8_t prefix_len, LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE, HOSTS_MGR_ALTERNATE_GET6_PREFIX) .arg(prefix.toText()) .arg(static_cast<int>(prefix_len)); - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { host = source->get6(prefix, prefix_len); if (host && host->getNegative()) { return (ConstHostPtr()); @@ -607,7 +607,7 @@ HostMgr::get6Any(const SubnetID& subnet_id, .arg(Host::getIdentifierAsText(identifier_type, identifier_begin, identifier_len)); - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { host = source->get6(subnet_id, identifier_type, identifier_begin, identifier_len); @@ -687,7 +687,7 @@ HostMgr::get6(const SubnetID& subnet_id, HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_ADDRESS6) .arg(subnet_id) .arg(addr.toText()); - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { host = source->get6(subnet_id, addr); if (host && host->getNegative()) { return (ConstHostPtr()); @@ -724,7 +724,7 @@ HostMgr::getAll6(const SubnetID& subnet_id, .arg(subnet_id) .arg(address.toText()); - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { auto hosts_plus = source->getAll6(subnet_id, address); hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end()); } @@ -751,7 +751,7 @@ HostMgr::getAll6(const IOAddress& address, const HostMgrOperationTarget target) } if (target & HostMgrOperationTarget::ALTERNATE_SOURCES) { - for (auto source : alternate_sources_) { + for (auto const&source : alternate_sources_) { ConstHostCollection hosts_plus = source->getAll6(address); hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end()); } @@ -774,7 +774,7 @@ HostMgr::add(const HostPtr& host, const HostMgrOperationTarget target) { } - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { source->add(host); } } @@ -806,7 +806,7 @@ HostMgr::del(const SubnetID& subnet_id, const asiolink::IOAddress& addr, "no hosts-database configured."); } - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { bool alternate_erased = source->del(subnet_id, addr); erased = alternate_erased || erased; } @@ -840,7 +840,7 @@ HostMgr::del4(const SubnetID& subnet_id, const Host::IdentifierType& identifier_ "no hosts-database configured."); } - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { if (source->del4(subnet_id, identifier_type, identifier_begin, identifier_len)) { success = true; @@ -877,7 +877,7 @@ HostMgr::del6(const SubnetID& subnet_id, const Host::IdentifierType& identifier_ "no hosts-database configured."); } - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { if (source->del6(subnet_id, identifier_type, identifier_begin, identifier_len)) { success = true; @@ -958,7 +958,7 @@ bool HostMgr::setIPReservationsUnique(const bool unique) { // Iterate over the alternate sources first, because they may include those // for which the new setting is not supported. - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { if (!source->setIPReservationsUnique(unique)) { // One of the sources does not support this new mode of operation. // Let's log a warning and back off the changes to the default @@ -966,7 +966,7 @@ HostMgr::setIPReservationsUnique(const bool unique) { ip_reservations_unique_ = true; LOG_WARN(hosts_logger, HOSTS_MGR_NON_UNIQUE_IP_UNSUPPORTED) .arg(source->getType()); - for (auto source : alternate_sources_) { + for (auto const& source : alternate_sources_) { source->setIPReservationsUnique(true); } return (false); diff --git a/src/lib/dhcpsrv/lease_mgr.cc b/src/lib/dhcpsrv/lease_mgr.cc index 9287f1d28f..00a3200341 100644 --- a/src/lib/dhcpsrv/lease_mgr.cc +++ b/src/lib/dhcpsrv/lease_mgr.cc @@ -722,7 +722,7 @@ LeaseMgr::upgradeLease4ExtendedInfo(const Lease4Ptr& lease, } verifying = "relay-agent-info"; - for (auto elem : extended_info->mapValue()) { + for (auto const& elem : extended_info->mapValue()) { if ((elem.first != "sub-options") && (elem.first != "remote-id") && (elem.first != "relay-id") && @@ -1060,7 +1060,7 @@ LeaseMgr::upgradeLease6ExtendedInfo(const Lease6Ptr& lease, } verifying = (upgraded ? "relays" : "relay-info"); - for (auto elem : relay->mapValue()) { + for (auto const& elem : relay->mapValue()) { if ((elem.first != "hop") && (elem.first != "link") && (elem.first != "peer") && diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc index 577f6943d3..42d754c757 100644 --- a/src/lib/dhcpsrv/memfile_lease_mgr.cc +++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc @@ -3076,7 +3076,7 @@ Memfile_LeaseMgr::getLeases4ByRemoteIdInternal(const OptionBuffer& remote_id, } // Return all leases being within the page size. - for (auto it : sorted) { + for (auto const& it : sorted) { collection.push_back(Lease4Ptr(new Lease4(*it.second))); if (collection.size() >= page_size.page_size_) { break; diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc index c33482b460..9a7092e7e5 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.cc +++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc @@ -4363,7 +4363,7 @@ MySqlLeaseMgr::upgradeExtendedInfo4(const LeasePageSize& page_size) { ++pages; start_addr = leases.back()->addr_; - for (auto lease : leases) { + for (auto const& lease : leases) { ConstElementPtr previous_user_context = lease->getContext(); vector<uint8_t> previous_relay_id = lease->relay_id_; vector<uint8_t> previous_remote_id = lease->remote_id_; diff --git a/src/lib/dhcpsrv/network_state.cc b/src/lib/dhcpsrv/network_state.cc index 521d9ed82b..98f99673bd 100644 --- a/src/lib/dhcpsrv/network_state.cc +++ b/src/lib/dhcpsrv/network_state.cc @@ -35,7 +35,7 @@ public: /// @brief Destructor. ~NetworkStateImpl() { - for (auto origin : disabled_by_origin_) { + for (auto const& origin : disabled_by_origin_) { destroyTimer(origin); } } @@ -206,7 +206,7 @@ NetworkState::isServiceEnabled() const { bool NetworkState::isDelayedEnableService() const { - for (auto origin : impl_->disabled_by_origin_) { + for (auto const& origin : impl_->disabled_by_origin_) { if (TimerMgr::instance()->isTimerRegistered(impl_->getTimerName(origin))) { return (true); } diff --git a/src/lib/dhcpsrv/parsers/client_class_def_parser.cc b/src/lib/dhcpsrv/parsers/client_class_def_parser.cc index a62af4d9f7..d84ca12a10 100644 --- a/src/lib/dhcpsrv/parsers/client_class_def_parser.cc +++ b/src/lib/dhcpsrv/parsers/client_class_def_parser.cc @@ -321,7 +321,7 @@ ClientClassDefParser::checkParametersSupported(const ConstElementPtr& class_def_ "max-preferred-lifetime" }; // Iterate over the specified parameters and check if they are all supported. - for (auto name_value_pair : class_def_cfg->mapValue()) { + for (auto const& name_value_pair : class_def_cfg->mapValue()) { if ((supported_params.count(name_value_pair.first) > 0) || ((family == AF_INET) && (supported_params_v4.count(name_value_pair.first) > 0)) || ((family != AF_INET) && (supported_params_v6.count(name_value_pair.first) > 0))) { diff --git a/src/lib/dhcpsrv/parsers/host_reservation_parser.cc b/src/lib/dhcpsrv/parsers/host_reservation_parser.cc index 751ca094d2..ed89b3b5f2 100644 --- a/src/lib/dhcpsrv/parsers/host_reservation_parser.cc +++ b/src/lib/dhcpsrv/parsers/host_reservation_parser.cc @@ -119,7 +119,7 @@ HostReservationParser::parseInternal(const SubnetID&, try { // Gather those parameters that are common for both IPv4 and IPv6 // reservations. - BOOST_FOREACH(auto element, reservation_data->mapValue()) { + BOOST_FOREACH(auto const& element, reservation_data->mapValue()) { // Check if we support this parameter. if (!isSupportedParameter(element.first)) { isc_throw(DhcpConfigError, "unsupported configuration" @@ -196,7 +196,7 @@ HostReservationParser4::parseInternal(const SubnetID& subnet_id, host->setIPv4SubnetID(subnet_id); - BOOST_FOREACH(auto element, reservation_data->mapValue()) { + BOOST_FOREACH(auto const& element, reservation_data->mapValue()) { // For 'option-data' element we will use another parser which // already returns errors with position appended, so don't // surround it with try-catch. @@ -257,7 +257,7 @@ HostReservationParser6::parseInternal(const SubnetID& subnet_id, host->setIPv6SubnetID(subnet_id); - BOOST_FOREACH(auto element, reservation_data->mapValue()) { + BOOST_FOREACH(auto const& element, reservation_data->mapValue()) { // Parse option values. Note that the configuration option parser // returns errors with position information appended, so there is no // need to surround it with try-clause (and rethrow with position diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc index b4e7ff35a2..a2d3fa4701 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc @@ -3441,7 +3441,7 @@ PgSqlLeaseMgr::upgradeExtendedInfo4(const LeasePageSize& page_size) { ++pages; start_addr = leases.back()->addr_; - for (auto lease : leases) { + for (auto const& lease : leases) { ConstElementPtr previous_user_context = lease->getContext(); vector<uint8_t> previous_relay_id = lease->relay_id_; vector<uint8_t> previous_remote_id = lease->remote_id_; diff --git a/src/lib/dhcpsrv/random_allocator.cc b/src/lib/dhcpsrv/random_allocator.cc index 4d4643b94d..5298078f6c 100644 --- a/src/lib/dhcpsrv/random_allocator.cc +++ b/src/lib/dhcpsrv/random_allocator.cc @@ -65,7 +65,7 @@ RandomAllocator::pickAddressInternal(const ClientClasses& client_classes, // All pools have been exhausted. We will start offering the same // addresses from these pools. We need to reset the permutations // of the exhausted pools. - for (auto e : exhausted) { + for (auto const& e : exhausted) { getPoolState(pools[e])->getPermutation()->reset(); } // Get random pool from those we just reset. @@ -132,7 +132,7 @@ RandomAllocator::pickPrefixInternal(const ClientClasses& client_classes, // All pools have been exhausted. We will start offering the same // prefixes from these pools. We need to reset the permutations // of the exhausted pools. - for (auto e : exhausted) { + for (auto const& e : exhausted) { getPoolState(pools[e])->getPermutation()->reset(); } // Get random pool from those we just reset. diff --git a/src/lib/dhcpsrv/resource_handler.cc b/src/lib/dhcpsrv/resource_handler.cc index 9ae2ee55b7..4ba4dae7c7 100644 --- a/src/lib/dhcpsrv/resource_handler.cc +++ b/src/lib/dhcpsrv/resource_handler.cc @@ -25,7 +25,7 @@ ResourceHandler::ResourceHandler() : owned_() { ResourceHandler::~ResourceHandler() { lock_guard<mutex> lock_(mutex_); - for (auto res : owned_) { + for (auto const& res : owned_) { unLockInternal(res->type_, res->addr_); } owned_.clear(); diff --git a/src/lib/dhcpsrv/srv_config.cc b/src/lib/dhcpsrv/srv_config.cc index 750b0797c9..5783eac252 100644 --- a/src/lib/dhcpsrv/srv_config.cc +++ b/src/lib/dhcpsrv/srv_config.cc @@ -243,7 +243,7 @@ SrvConfig::mergeGlobals(SrvConfig& other) { } // Iterate over the "other" globals, adding/overwriting them into // this config's list of globals. - for (auto other_global : other.getConfiguredGlobals()->valuesMap()) { + for (auto const& other_global : other.getConfiguredGlobals()->valuesMap()) { addConfiguredGlobal(other_global.first, other_global.second); } @@ -252,7 +252,7 @@ SrvConfig::mergeGlobals(SrvConfig& other) { // A handful of values are stored as members in SrvConfig. So we'll // iterate over the merged globals, setting appropriate members. - for (auto merged_global : getConfiguredGlobals()->valuesMap()) { + for (auto const& merged_global : getConfiguredGlobals()->valuesMap()) { std::string name = merged_global.first; ConstElementPtr element = merged_global.second; try { @@ -890,7 +890,7 @@ SrvConfig::moveDdnsParams(isc::data::ElementPtr srv_elem) { { "hostname-char-replacement", "hostname-char-replacement" } }; - for (auto param : params) { + for (auto const& param : params) { if (d2_elem->contains(param.from_name)) { if (!srv_elem->contains(param.to_name)) { // No global value for it already, so let's add it. diff --git a/src/lib/dhcpsrv/subnet.cc b/src/lib/dhcpsrv/subnet.cc index d0a380d7a2..0477fc17b1 100644 --- a/src/lib/dhcpsrv/subnet.cc +++ b/src/lib/dhcpsrv/subnet.cc @@ -770,7 +770,7 @@ Subnet4::createAllocators() { (Lease::TYPE_V4, shared_from_this())); setAllocationState(Lease::TYPE_V4, SubnetAllocationStatePtr()); - for (auto pool : pools_) { + for (auto const& pool : pools_) { pool->setAllocationState(PoolRandomAllocationState::create(pool)); } @@ -780,7 +780,7 @@ Subnet4::createAllocators() { (Lease::TYPE_V4, shared_from_this())); setAllocationState(Lease::TYPE_V4, SubnetAllocationStatePtr()); - for (auto pool : pools_) { + for (auto const& pool : pools_) { pool->setAllocationState(PoolFreeLeaseQueueAllocationState::create(pool)); } @@ -791,7 +791,7 @@ Subnet4::createAllocators() { setAllocationState(Lease::TYPE_V4, SubnetIterativeAllocationState::create(shared_from_this())); - for (auto pool : pools_) { + for (auto const& pool : pools_) { pool->setAllocationState(PoolIterativeAllocationState::create(pool)); } } @@ -882,7 +882,7 @@ Subnet6::createAllocators() { setAllocationState(Lease::TYPE_PD, SubnetIterativeAllocationState::create(shared_from_this())); } // Create allocation states for NA pools. - for (auto pool : pools_) { + for (auto const& pool : pools_) { if (allocator_type == "random") { pool->setAllocationState(PoolRandomAllocationState::create(pool)); } else { @@ -890,7 +890,7 @@ Subnet6::createAllocators() { } } // Create allocation states for TA pools. - for (auto pool : pools_ta_) { + for (auto const& pool : pools_ta_) { if (allocator_type == "random") { pool->setAllocationState(PoolRandomAllocationState::create(pool)); } else { @@ -898,7 +898,7 @@ Subnet6::createAllocators() { } } // Create allocation states for PD pools. - for (auto pool : pools_pd_) { + for (auto const& pool : pools_pd_) { if (pd_allocator_type == "random") { pool->setAllocationState(PoolRandomAllocationState::create(pool)); } else if (pd_allocator_type == "flq") { diff --git a/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc index 327a036861..370248b143 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc @@ -3844,7 +3844,7 @@ TEST_F(AllocEngine4Test, updateExtendedInfo4) { // Iterate over the test scenarios. ElementPtr orig_context; ElementPtr exp_context; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); // Create the original user context from JSON. @@ -3976,7 +3976,7 @@ TEST_F(AllocEngine4Test, storeExtendedInfoEnabled4) { // Iterate over the test scenarios. Lease4Ptr lease; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); ElementPtr exp_context; @@ -4082,7 +4082,7 @@ TEST_F(AllocEngine4Test, storeExtendedInfoDisabled4) { Lease4Ptr lease; // Iterate over the test scenarios. - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); // If we have a MAC address this scenario is for a new client. @@ -4657,7 +4657,7 @@ TEST_F(AllocEngine4Test, getValidLft4) { }; // Iterate over the scenarios and verify the correct outcome. - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.desc_); { // Create a context; AllocEngine::ClientContext4 ctx(subnet_, ClientIdPtr(), hwaddr_, @@ -4666,7 +4666,7 @@ TEST_F(AllocEngine4Test, getValidLft4) { ctx.query_.reset(new Pkt4(DHCPDISCOVER, 1234)); // Add client classes (if any) - for (auto class_name : scenario.classes_) { + for (auto const& class_name : scenario.classes_) { ctx.query_->addClass(class_name); } @@ -4802,7 +4802,7 @@ TEST_F(AllocEngine4Test, getTemplateClassValidLft4) { }; // Iterate over the scenarios and verify the correct outcome. - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.desc_); { // Create a context; AllocEngine::ClientContext4 ctx(subnet_, ClientIdPtr(), hwaddr_, @@ -4811,7 +4811,7 @@ TEST_F(AllocEngine4Test, getTemplateClassValidLft4) { ctx.query_.reset(new Pkt4(DHCPDISCOVER, 1234)); // Add client classes (if any) - for (auto class_name : scenario.classes_) { + for (auto const& class_name : scenario.classes_) { if (class_name == "BOOTP") { ctx.query_->addClass(class_name); } else { @@ -5954,7 +5954,7 @@ TEST_F(AllocEngine4Test, getOfferLft4) { }; // Iterate over the scenarios and verify the correct outcome. - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.desc_); { // Create a context; AllocEngine::ClientContext4 ctx(subnet_, ClientIdPtr(), hwaddr_, @@ -5963,7 +5963,7 @@ TEST_F(AllocEngine4Test, getOfferLft4) { ctx.query_.reset(new Pkt4(DHCPDISCOVER, 1234)); // Add client classes (if any) - for (auto class_name : scenario.classes_) { + for (auto const& class_name : scenario.classes_) { ctx.query_->addClass(class_name); } diff --git a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc index 68a0fd4848..59b7646893 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc @@ -4240,7 +4240,7 @@ TEST_F(AllocEngine6ExtendedInfoTest, updateExtendedInfo6) { // Iterate over the test scenarios. ElementPtr orig_context; ElementPtr exp_context; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); // Create the original user context from JSON. @@ -4343,7 +4343,7 @@ TEST_F(AllocEngine6ExtendedInfoTest, storeExtendedInfoEnabled6) { // Iterate over the test scenarios. DuidPtr current_duid; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); ElementPtr exp_context; @@ -4431,7 +4431,7 @@ TEST_F(AllocEngine6ExtendedInfoTest, storeExtendedInfoDisabled6) { // Iterate over the test scenarios. DuidPtr current_duid; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); Pkt6Ptr pkt; @@ -5503,13 +5503,13 @@ TEST_F(AllocEngine6Test, getValidLifetime) { }; // Iterate over the scenarios and verify the correct outcome. - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.desc_); { // Create a context; AllocEngine::ClientContext6 ctx(subnet_, duid_, false, false, "", true, Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234))); // Add client classes (if any) - for (auto class_name : scenario.classes_) { + for (auto const& class_name : scenario.classes_) { ctx.query_->addClass(class_name); } @@ -5641,13 +5641,13 @@ TEST_F(AllocEngine6Test, getTemplateClassValidLifetime) { }; // Iterate over the scenarios and verify the correct outcome. - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.desc_); { // Create a context; AllocEngine::ClientContext6 ctx(subnet_, duid_, false, false, "", true, Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234))); // Add client classes (if any) - for (auto class_name : scenario.classes_) { + for (auto const& class_name : scenario.classes_) { ctx.query_->addClass(class_name); } @@ -5790,7 +5790,7 @@ TEST_F(AllocEngine6Test, getPreferredLifetime) { }; // Iterate over the scenarios and verify the correct outcome. - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.desc_); { // Set the subnet's preferred-lifetime triplet. subnet_->setPreferred(scenario.subnet_pref_); @@ -5799,7 +5799,7 @@ TEST_F(AllocEngine6Test, getPreferredLifetime) { AllocEngine::ClientContext6 ctx(subnet_, duid_, false, false, "", true, Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234))); // Add client classes (if any) - for (auto class_name : scenario.classes_) { + for (auto const& class_name : scenario.classes_) { string subclass(TemplateClientClassDef::SPAWN_CLASS_PREFIX); subclass += class_name; subclass += "_value"; @@ -5935,13 +5935,13 @@ TEST_F(AllocEngine6Test, getTemplateClassPreferredLifetime) { }; // Iterate over the scenarios and verify the correct outcome. - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.desc_); { // Create a context; AllocEngine::ClientContext6 ctx(subnet_, duid_, false, false, "", true, Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234))); // Add client classes (if any) - for (auto class_name : scenario.classes_) { + for (auto const& class_name : scenario.classes_) { string subclass(TemplateClientClassDef::SPAWN_CLASS_PREFIX); subclass += class_name; subclass += "_value"; diff --git a/src/lib/dhcpsrv/tests/cfg_shared_networks4_unittest.cc b/src/lib/dhcpsrv/tests/cfg_shared_networks4_unittest.cc index f737d92863..52ba662b27 100644 --- a/src/lib/dhcpsrv/tests/cfg_shared_networks4_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_shared_networks4_unittest.cc @@ -34,7 +34,7 @@ void checkMergedNetwork(const CfgSharedNetworks4& networks, const std::string& n ASSERT_EQ(exp_valid, network->getValid().get()) << " network valid lifetime wrong"; const Subnet4SimpleCollection* subnets = network->getAllSubnets(); ASSERT_EQ(exp_subnets.size(), subnets->size()) << " wrong number of subnets"; - for (auto exp_id : exp_subnets) { + for (auto const& exp_id : exp_subnets) { ASSERT_TRUE(network->getSubnet(exp_id)) << " did not find expected subnet: " << exp_id; } diff --git a/src/lib/dhcpsrv/tests/cfg_shared_networks6_unittest.cc b/src/lib/dhcpsrv/tests/cfg_shared_networks6_unittest.cc index de33f1ad47..2915b17b89 100644 --- a/src/lib/dhcpsrv/tests/cfg_shared_networks6_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_shared_networks6_unittest.cc @@ -34,7 +34,7 @@ void checkMergedNetwork(const CfgSharedNetworks6& networks, const std::string& n ASSERT_EQ(exp_valid, network->getValid().get()) << " network valid lifetime wrong"; const Subnet6SimpleCollection* subnets = network->getAllSubnets(); ASSERT_EQ(exp_subnets.size(), subnets->size()) << " wrong number of subnets"; - for (auto exp_id : exp_subnets) { + for (auto const& exp_id : exp_subnets) { ASSERT_TRUE(network->getSubnet(exp_id)) << " did not find expected subnet: " << exp_id; } diff --git a/src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc b/src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc index 7d0cf79527..e4e6ce2ca0 100644 --- a/src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc @@ -1955,7 +1955,7 @@ TEST_F(ClientClassDefParserTest, validLifetimeTests) { } }; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.desc_); { std::stringstream oss; oss << "{ \"name\": \"foo\""; @@ -2018,7 +2018,7 @@ TEST_F(ClientClassDefParserTest, preferredLifetimeTests) { } }; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.desc_); { std::stringstream oss; oss << "{ \"name\": \"foo\""; diff --git a/src/lib/dhcpsrv/tests/client_class_def_unittest.cc b/src/lib/dhcpsrv/tests/client_class_def_unittest.cc index 8fc5aed213..bb7b2f67a9 100644 --- a/src/lib/dhcpsrv/tests/client_class_def_unittest.cc +++ b/src/lib/dhcpsrv/tests/client_class_def_unittest.cc @@ -602,7 +602,7 @@ TEST(ClientClassDictionary, initMatchExprError) { ASSERT_THROW(dictionary->initMatchExpr(AF_INET), std::exception); // Ensure that no classes have their match expressions modified. - for (auto c : (*dictionary->getClasses())) { + for (auto const& c : (*dictionary->getClasses())) { EXPECT_FALSE(c->getMatchExpr()); } } @@ -1448,7 +1448,7 @@ TEST(ClientClassDictionary, templateInitMatchExprError) { ASSERT_THROW(dictionary->initMatchExpr(AF_INET), std::exception); // Ensure that no classes have their match expressions modified. - for (auto c : (*dictionary->getClasses())) { + for (auto const& c : (*dictionary->getClasses())) { EXPECT_FALSE(c->getMatchExpr()); } } diff --git a/src/lib/dhcpsrv/tests/d2_client_unittest.cc b/src/lib/dhcpsrv/tests/d2_client_unittest.cc index 0ae23144e0..c3e0e6144e 100644 --- a/src/lib/dhcpsrv/tests/d2_client_unittest.cc +++ b/src/lib/dhcpsrv/tests/d2_client_unittest.cc @@ -851,7 +851,7 @@ TEST_F(D2ClientMgrParamsTest, adjustDomainNameV4) { } }; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { subnet_->setDdnsReplaceClientNameMode(scenario.mode_); @@ -966,7 +966,7 @@ TEST_F(D2ClientMgrParamsTest, adjustDomainNameV6) { } }; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { subnet_->setDdnsReplaceClientNameMode(scenario.mode_); @@ -1145,7 +1145,7 @@ TEST_F(D2ClientMgrParamsTest, sanitizeFqdnV4) { } }; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { Option4ClientFqdn request(0, Option4ClientFqdn::RCODE_CLIENT(), @@ -1232,7 +1232,7 @@ TEST_F(D2ClientMgrParamsTest, sanitizeFqdnV6) { }; Option6ClientFqdnPtr response; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { Option6ClientFqdn request(0, scenario.client_name_, scenario.name_type_); diff --git a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc index e893ce7579..84f429a6e1 100644 --- a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc +++ b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc @@ -1701,7 +1701,7 @@ TEST_F(ParseConfigTest, hexOptionData) { "0x0c000301C0000302" // upper or lower case digits }; - for (auto hex_str : valid_hexes) { + for (auto const& hex_str : valid_hexes) { ostringstream os; os << "{ \n" @@ -1795,7 +1795,7 @@ TEST_F(ParseConfigTest, stringOrHexBinaryData) { }; // Iterate over our test scenarios - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { // Build the configuration text. 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 4f617f671d..c459e0be7c 100644 --- a/src/lib/dhcpsrv/tests/dhcp_queue_control_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/dhcp_queue_control_parser_unittest.cc @@ -96,7 +96,7 @@ TEST_F(DHCPQueueControlParserTest, validContent) { // Iterate over the valid scenarios and verify they succeed. ConstElementPtr config_elems; ConstElementPtr queue_control; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { // Construct the config JSON @@ -161,7 +161,7 @@ TEST_F(DHCPQueueControlParserTest, invalidContent) { // Iterate over the valid scenarios and verify they succeed. ConstElementPtr config_elems; ConstElementPtr queue_control; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { // Construct the config JSON diff --git a/src/lib/dhcpsrv/tests/flq_allocator_unittest.cc b/src/lib/dhcpsrv/tests/flq_allocator_unittest.cc index 350106f11b..5a2fe8348e 100644 --- a/src/lib/dhcpsrv/tests/flq_allocator_unittest.cc +++ b/src/lib/dhcpsrv/tests/flq_allocator_unittest.cc @@ -125,7 +125,7 @@ TEST_F(FreeLeaseQueueAllocatorTest4, singlePoolWithAllocations) { EXPECT_TRUE(candidate.isV4Zero()); auto i = 0; - for (auto address_lease : leases) { + for (auto const& address_lease : leases) { if (i % 2) { EXPECT_TRUE(lease_mgr.deleteLease(address_lease.second)); } @@ -171,7 +171,7 @@ TEST_F(FreeLeaseQueueAllocatorTest4, singlePoolWithReclamations) { EXPECT_TRUE(candidate.isV4Zero()); auto i = 0; - for (auto address_lease : leases) { + for (auto const& address_lease : leases) { if (i % 2) { auto lease = address_lease.second; lease->state_ = Lease::STATE_EXPIRED_RECLAIMED; @@ -453,7 +453,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, singlePoolWithAllocations) { EXPECT_TRUE(candidate.isV6Zero()); auto i = 0; - for (auto address_lease : leases) { + for (auto const& address_lease : leases) { if (i % 2) { EXPECT_TRUE(lease_mgr.deleteLease(address_lease.second)); } @@ -499,7 +499,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, singlePoolWithReclamations) { EXPECT_TRUE(candidate.isV6Zero()); auto i = 0; - for (auto address_lease : leases) { + for (auto const& address_lease : leases) { if (i % 2) { auto lease = address_lease.second; lease->state_ = Lease::STATE_EXPIRED_RECLAIMED; @@ -759,7 +759,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, singlePdPoolWithAllocations) { EXPECT_TRUE(candidate.isV6Zero()); auto i = 0; - for (auto address_lease : leases) { + for (auto const& address_lease : leases) { if (i % 2) { EXPECT_TRUE(lease_mgr.deleteLease(address_lease.second)); } @@ -814,7 +814,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, singlePdPoolWithReclamations) { EXPECT_TRUE(candidate.isV6Zero()); auto i = 0; - for (auto address_lease : leases) { + for (auto const& address_lease : leases) { if (i % 2) { auto lease = address_lease.second; lease->state_ = Lease::STATE_EXPIRED_RECLAIMED; diff --git a/src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc b/src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc index 5cb49a71a0..b7a528ea10 100644 --- a/src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc +++ b/src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc @@ -478,7 +478,7 @@ TEST_F(LeaseFileLoaderTest, maxRowErrors4) { std::ostringstream os; os << v4_hdr_; - for (auto row : rows) { + for (auto const& row : rows) { os << row; } @@ -682,7 +682,7 @@ TEST_F(LeaseFileLoaderTest, maxRowErrors6) { std::ostringstream os; os << v6_hdr_; - for (auto row : rows) { + for (auto const& row : rows) { os << row; } diff --git a/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc index 1bc8428fb5..9f6fdd06cc 100644 --- a/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc @@ -290,7 +290,7 @@ TEST(Lease4ExtendedInfoTest, upgradeLease4ExtendedInfo) { Lease4Ptr lease(new Lease4()); ElementPtr orig_context; ElementPtr exp_context; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); // Create the original user context from JSON. @@ -505,7 +505,7 @@ TEST(Lease4ExtendedInfoTest, extractLease4ExtendedInfo) { Lease4Ptr lease(new Lease4()); ElementPtr user_context; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); // Create the original user context from JSON. @@ -752,7 +752,7 @@ TEST(Lease6ExtendedInfoTest, upgradeLease6ExtendedInfo) { Lease6Ptr lease(new Lease6()); ElementPtr orig_context; ElementPtr exp_context; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); // Create the original user context from JSON. @@ -874,7 +874,7 @@ TEST(Lease6ExtendedInfoTest, invalidSetExtendedInfoTablesEnabled) { Lease6Ptr lease(new Lease6()); ElementPtr user_context; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); // Create the user context from JSON. diff --git a/src/lib/dhcpsrv/tests/memfile_lease_limits_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_limits_unittest.cc index 5344a4b1cc..f13ae56a05 100644 --- a/src/lib/dhcpsrv/tests/memfile_lease_limits_unittest.cc +++ b/src/lib/dhcpsrv/tests/memfile_lease_limits_unittest.cc @@ -58,7 +58,7 @@ public: ElementPtr ctx = Element::createMap(); if (classes.size()) { ElementPtr clist = Element::createList(); - for (auto client_class : classes ) { + for (auto const& client_class : classes ) { clist->add(Element::create(client_class)); } @@ -119,7 +119,7 @@ public: EXPECT_EQ(classes.size(), clc_.size(ltype)); auto expected_count = expected_counts.begin(); - for (auto client_class : classes) { + for (auto const& client_class : classes) { size_t count; ASSERT_NO_THROW_LOG(count = clc_.getClassCount(client_class, ltype)); EXPECT_EQ(count, *expected_count) << ", count is wrong for client_class: " << client_class; @@ -213,7 +213,7 @@ public: std::list<size_t> expected_new_counts, const Lease::Type& ltype) { // Start the map with a count of one for all the old classes. clc_.clear(); - for (auto client_class : old_classes) { + for (auto const& client_class : old_classes) { ASSERT_NO_THROW_LOG(clc_.setClassCount(client_class, 1, ltype)); } @@ -231,7 +231,7 @@ public: // Verify class counts for the old lease's classes are right. auto expected_count = expected_old_counts.begin(); - for (auto client_class : old_classes) { + for (auto const& client_class : old_classes) { size_t count; ASSERT_NO_THROW_LOG(count = clc_.getClassCount(client_class, ltype)); EXPECT_EQ(count, *expected_count) @@ -241,7 +241,7 @@ public: // Verify class counts for the new lease's classes are right. expected_count = expected_new_counts.begin(); - for (auto client_class : new_classes) { + for (auto const& client_class : new_classes) { size_t count; ASSERT_NO_THROW_LOG(count = clc_.getClassCount(client_class, ltype)); EXPECT_EQ(count, *expected_count) @@ -503,7 +503,7 @@ TEST_F(ClassLeaseCounterTest, getLeaseClientClassesTest) { }; // Iterate over the invalid scenarios. - for (auto scenario : invalid_scenarios) { + for (auto const& scenario : invalid_scenarios) { // Construct the lease and context. lease = leaseFactory(Lease::TYPE_V4); ElementPtr ctx; @@ -546,7 +546,7 @@ TEST_F(ClassLeaseCounterTest, getLeaseClientClassesTest) { }; // Iterate over the scenarios. - for (auto scenario : valid_scenarios) { + for (auto const& scenario : valid_scenarios) { // Construct the lease and context. lease = leaseFactory(Lease::TYPE_V4); if (!scenario.ctx_json_.empty()) { diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc index e0a211bddd..f34b308dd6 100644 --- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc @@ -2765,7 +2765,7 @@ TEST_F(MemfileLeaseMgrTest, classLeaseRecount4) { }; // Bake all the leases. - for ( auto recipe : recipes ) { + for (auto const& recipe : recipes) { ElementPtr ctx = makeContextWithClasses(recipe.classes_); ASSERT_TRUE(makeLease4(recipe.address_, 777, recipe.state_, ctx)); } @@ -2844,7 +2844,7 @@ TEST_F(MemfileLeaseMgrTest, classLeaseRecount6) { }; // Bake all the leases. - for ( auto recipe : recipes ) { + for (auto const& recipe : recipes) { ElementPtr ctx = makeContextWithClasses(recipe.classes_); ASSERT_TRUE(makeLease6(recipe.ltype_, recipe.address_, recipe.prefix_len_, 777, recipe.state_, ctx)); } 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 223c4d3dee..2334cc5a6d 100644 --- a/src/lib/dhcpsrv/tests/multi_threading_config_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/multi_threading_config_parser_unittest.cc @@ -84,7 +84,7 @@ TEST_F(MultiThreadingConfigParserTest, validContent) { // Iterate over the valid scenarios and verify they succeed. ConstElementPtr config_elems; ConstElementPtr multi_threading_config; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { SrvConfig srv_config; @@ -172,7 +172,7 @@ TEST_F(MultiThreadingConfigParserTest, invalidContent) { // Iterate over the valid scenarios and verify they succeed. ConstElementPtr config_elems; ConstElementPtr queue_control; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SCOPED_TRACE(scenario.description_); { SrvConfig srv_config; diff --git a/src/lib/dhcpsrv/tests/srv_config_unittest.cc b/src/lib/dhcpsrv/tests/srv_config_unittest.cc index 3cf7032c41..77673c4074 100644 --- a/src/lib/dhcpsrv/tests/srv_config_unittest.cc +++ b/src/lib/dhcpsrv/tests/srv_config_unittest.cc @@ -1412,7 +1412,7 @@ TEST_F(SrvConfigTest, moveDdnsParamsTest) { } }; - for (auto scenario : scenarios) { + for (auto const& scenario : scenarios) { SrvConfig conf(32); ElementPtr input_cfg; ConstElementPtr exp_cfg; diff --git a/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc b/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc index 505813d958..8ab8df7616 100644 --- a/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc +++ b/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc @@ -1326,7 +1326,7 @@ void GenericConfigBackendDHCPv4Test::getAllSubnets4Test() { // Insert test subnets into the database. Note that the second subnet will // overwrite the first subnet as they use the same ID. - for (auto subnet : test_subnets_) { + for (auto const& subnet : test_subnets_) { cbptr_->createUpdateSubnet4(ServerSelector::ALL(), subnet); // That subnet overrides the first subnet so the audit entry should @@ -1853,12 +1853,12 @@ GenericConfigBackendDHCPv4Test::getSharedNetworkSubnets4Test() { test_subnets_[3]->setSharedNetworkName("level2"); // Store shared networks in the database. - for (auto network : test_networks_) { + for (auto const& network : test_networks_) { cbptr_->createUpdateSharedNetwork4(ServerSelector::ALL(), network); } // Store subnets in the database. - for (auto subnet : test_subnets_) { + for (auto const& subnet : test_subnets_) { cbptr_->createUpdateSubnet4(ServerSelector::ALL(), subnet); } @@ -2266,7 +2266,7 @@ void GenericConfigBackendDHCPv4Test::getAllSharedNetworks4Test() { // Insert test shared networks into the database. Note that the second shared // network will overwrite the first shared network as they use the same name. - for (auto network : test_networks_) { + for (auto const& network : test_networks_) { cbptr_->createUpdateSharedNetwork4(ServerSelector::ALL(), network); // That shared network overrides the first one so the audit entry should @@ -3070,7 +3070,7 @@ GenericConfigBackendDHCPv4Test::getAllOptionDefs4Test() { // option definition will overwrite the first option definition as they use // the same code and space. size_t updates_num = 0; - for (auto option_def : test_option_defs_) { + for (auto const& option_def : test_option_defs_) { cbptr_->createUpdateOptionDef4(ServerSelector::ALL(), option_def); // That option definition overrides the first one so the audit entry should @@ -3915,7 +3915,7 @@ GenericConfigBackendDHCPv4Test::subnetOptionIdOrderTest() { ASSERT_EQ(2, subnets.size()); // Verify that the subnets returned are as expected. - for (auto subnet : subnets) { + for (auto const& subnet : subnets) { ASSERT_EQ(1, subnet->getServerTags().size()); EXPECT_EQ("all", subnet->getServerTags().begin()->get()); if (subnet->getID() == 1024) { diff --git a/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc b/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc index 522400920e..584f2998ec 100644 --- a/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc +++ b/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc @@ -1340,7 +1340,7 @@ void GenericConfigBackendDHCPv6Test::getAllSubnets6Test() { // Insert test subnets into the database. Note that the second subnet will // overwrite the first subnet as they use the same ID. - for (auto subnet : test_subnets_) { + for (auto const& subnet : test_subnets_) { cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet); // That subnet overrides the first subnet so the audit entry should @@ -1868,12 +1868,12 @@ GenericConfigBackendDHCPv6Test::getSharedNetworkSubnets6Test() { test_subnets_[3]->setSharedNetworkName("level2"); // Store shared networks in the database. - for (auto network : test_networks_) { + for (auto const& network : test_networks_) { cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(), network); } // Store subnets in the database. - for (auto subnet : test_subnets_) { + for (auto const& subnet : test_subnets_) { cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet); } @@ -2290,7 +2290,7 @@ void GenericConfigBackendDHCPv6Test::getAllSharedNetworks6Test() { // Insert test shared networks into the database. Note that the second shared // network will overwrite the first shared network as they use the same name. - for (auto network : test_networks_) { + for (auto const& network : test_networks_) { cbptr_->createUpdateSharedNetwork6(ServerSelector::ALL(), network); // That shared network overrides the first one so the audit entry should @@ -3096,7 +3096,7 @@ GenericConfigBackendDHCPv6Test::getAllOptionDefs6Test() { // option definition will overwrite the first option definition as they use // the same code and space. size_t updates_num = 0; - for (auto option_def : test_option_defs_) { + for (auto const& option_def : test_option_defs_) { cbptr_->createUpdateOptionDef6(ServerSelector::ALL(), option_def); // That option definition overrides the first one so the audit entry should @@ -4072,7 +4072,7 @@ GenericConfigBackendDHCPv6Test::subnetOptionIdOrderTest() { ASSERT_EQ(2, subnets.size()); // Verify that the subnets returned are as expected. - for (auto subnet : subnets) { + for (auto const& subnet : subnets) { ASSERT_EQ(1, subnet->getServerTags().size()); EXPECT_EQ("all", subnet->getServerTags().begin()->get()); if (subnet->getID() == 1024) { 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 1dbc92026d..0920bc4bba 100644 --- a/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc +++ b/src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc @@ -518,7 +518,7 @@ GenericHostDataSourceTest::testGetAllbyHostname() { bool got1 = false; bool got2 = false; bool got3 = false; - for (auto host : from_hds) { + for (auto const& host : from_hds) { if (host->getIdentifierType() == Host::IDENT_HWADDR) { EXPECT_FALSE(got1); got1 = true; @@ -601,7 +601,7 @@ GenericHostDataSourceTest::testGetAllbyHostnameSubnet4() { bool got1 = false; bool got2 = false; bool got3 = false; - for (auto host : from_hds) { + for (auto const& host : from_hds) { if (host->getIdentifierType() == Host::IDENT_HWADDR) { EXPECT_FALSE(got1); got1 = true; @@ -684,7 +684,7 @@ GenericHostDataSourceTest::testGetAllbyHostnameSubnet6() { bool got1 = false; bool got2 = false; bool got3 = false; - for (auto host : from_hds) { + for (auto const& host : from_hds) { if (host->getIdentifierType() == Host::IDENT_HWADDR) { EXPECT_FALSE(got1); got1 = true; diff --git a/src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc b/src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc index bcc671097f..9e1d87c9eb 100644 --- a/src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc @@ -1335,7 +1335,7 @@ GenericLeaseMgrTest::testGetLeases4Paged() { Lease4Collection page = lmptr_->getLeases4(last_address, LeasePageSize(3)); // Collect leases in a common structure. They may be out of order. - for (Lease4Ptr lease : page) { + for (const Lease4Ptr& lease : page) { all_leases.push_back(lease); } @@ -1356,9 +1356,9 @@ GenericLeaseMgrTest::testGetLeases4Paged() { // Make sure that all leases that we stored in the lease database // have been retrieved. - for (Lease4Ptr lease : leases) { + for (const Lease4Ptr& lease : leases) { bool found = false; - for (Lease4Ptr returned_lease : all_leases) { + for (const Lease4Ptr& returned_lease : all_leases) { if (lease->addr_ == returned_lease->addr_) { found = true; break; @@ -1517,7 +1517,7 @@ GenericLeaseMgrTest::testGetLeases6Paged() { Lease6Collection page = lmptr_->getLeases6(last_address, LeasePageSize(3)); // Collect leases in a common structure. They may be out of order. - for (Lease6Ptr lease : page) { + for (const Lease6Ptr& lease : page) { all_leases.push_back(lease); } @@ -1538,9 +1538,9 @@ GenericLeaseMgrTest::testGetLeases6Paged() { // Make sure that all leases that we stored in the lease database // have been retrieved. - for (Lease6Ptr lease : leases) { + for (const Lease6Ptr& lease : leases) { bool found = false; - for (Lease6Ptr returned_lease : all_leases) { + for (const Lease6Ptr& returned_lease : all_leases) { if (lease->addr_ == returned_lease->addr_) { found = true; break; @@ -3066,7 +3066,7 @@ int GenericLeaseMgrTest::countLogs(TrackingLeaseMgr::CallbackType type, SubnetID subnet_id, Lease::Type lease_type) const { int count = 0; - for (auto log : logs_) { + for (auto const& log : logs_) { if ((log.type == type) && (log.subnet_id == subnet_id) && (log.lease->getType() == lease_type)) { ++count; } @@ -4383,7 +4383,7 @@ GenericLeaseMgrTest::makeContextWithClasses(const std::list<ClientClass>& classe ElementPtr ctx = Element::createMap(); if (classes.size()) { ElementPtr clist = Element::createList(); - for (auto client_class : classes ) { + for (auto const& client_class : classes ) { clist->add(Element::create(client_class)); } diff --git a/src/lib/dhcpsrv/testutils/test_config_backend.h b/src/lib/dhcpsrv/testutils/test_config_backend.h index d78f97f8fd..f6f4e5e2be 100644 --- a/src/lib/dhcpsrv/testutils/test_config_backend.h +++ b/src/lib/dhcpsrv/testutils/test_config_backend.h @@ -96,7 +96,7 @@ public: void mergeServerTags(const StampedElementPtr& elem, const db::ServerSelector& server_selector) const { auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { elem->setServerTag(tag.get()); } } diff --git a/src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc b/src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc index 8648d97f29..a3cfcbd1c8 100644 --- a/src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc +++ b/src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc @@ -50,7 +50,7 @@ TestConfigBackendDHCPv4::getSubnet4(const db::ServerSelector& server_selector, return (subnet->getServerTags().empty() ? subnet : Subnet4Ptr()); } auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { return (subnet); } @@ -74,7 +74,7 @@ TestConfigBackendDHCPv4::getSubnet4(const db::ServerSelector& server_selector, return (subnet->getServerTags().empty() ? subnet : Subnet4Ptr()); } auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { return (subnet); } @@ -85,7 +85,7 @@ TestConfigBackendDHCPv4::getSubnet4(const db::ServerSelector& server_selector, Subnet4Collection TestConfigBackendDHCPv4::getAllSubnets4(const db::ServerSelector& server_selector) const { Subnet4Collection subnets; - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { if (server_selector.amAny()) { subnets.insert(subnet); continue; @@ -98,7 +98,7 @@ TestConfigBackendDHCPv4::getAllSubnets4(const db::ServerSelector& server_selecto } bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { subnets.insert(subnet); got = true; @@ -134,7 +134,7 @@ TestConfigBackendDHCPv4::getModifiedSubnets4(const db::ServerSelector& server_se } bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*subnet)->hasServerTag(ServerTag(tag))) { subnets.insert(*subnet); got = true; @@ -159,7 +159,7 @@ TestConfigBackendDHCPv4::getSharedNetworkSubnets4(const db::ServerSelector& serv // Subnet collection does not include the index by shared network name. // We need to iterate over the subnets and pick those that are associated // with a shared network. - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { // Skip subnets which do not match the server selector. if (server_selector.amUnassigned() && !subnet->getServerTags().empty()) { @@ -168,7 +168,7 @@ TestConfigBackendDHCPv4::getSharedNetworkSubnets4(const db::ServerSelector& serv if (!server_selector.amAny()) { bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { got = true; break; @@ -210,7 +210,7 @@ TestConfigBackendDHCPv4::getSharedNetwork4(const db::ServerSelector& server_sele return (network->getServerTags().empty() ? network : SharedNetwork4Ptr()); } auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (network->hasServerTag(ServerTag(tag))) { return (network); } @@ -221,7 +221,7 @@ TestConfigBackendDHCPv4::getSharedNetwork4(const db::ServerSelector& server_sele SharedNetwork4Collection TestConfigBackendDHCPv4::getAllSharedNetworks4(const db::ServerSelector& server_selector) const{ SharedNetwork4Collection shared_networks; - for (auto shared_network : shared_networks_) { + for (auto const& shared_network : shared_networks_) { if (server_selector.amAny()) { shared_networks.push_back(shared_network); continue; @@ -234,7 +234,7 @@ TestConfigBackendDHCPv4::getAllSharedNetworks4(const db::ServerSelector& server_ } bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (shared_network->hasServerTag(ServerTag(tag))) { shared_networks.push_back(shared_network); got = true; @@ -270,7 +270,7 @@ TestConfigBackendDHCPv4::getModifiedSharedNetworks4(const db::ServerSelector& se } bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*shared_network)->hasServerTag(ServerTag(tag))) { shared_networks.push_back(*shared_network); got = true; @@ -300,7 +300,7 @@ TestConfigBackendDHCPv4::getOptionDef4(const db::ServerSelector& server_selector option_def_it != option_def_it_pair.second; ++option_def_it) { if ((*option_def_it)->getOptionSpaceName() == space) { - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*option_def_it)->hasServerTag(ServerTag(tag))) { return (*option_def_it); } @@ -317,7 +317,7 @@ OptionDefContainer TestConfigBackendDHCPv4::getAllOptionDefs4(const db::ServerSelector& server_selector) const { auto tags = server_selector.getTags(); OptionDefContainer option_defs; - for (auto option_def : option_defs_) { + for (auto const& option_def : option_defs_) { bool got = false; if (server_selector.amUnassigned()) { if (option_def->getServerTags().empty()) { @@ -325,7 +325,7 @@ TestConfigBackendDHCPv4::getAllOptionDefs4(const db::ServerSelector& server_sele got = true; } } else { - for (auto tag : tags) { + for (auto const& tag : tags) { if (option_def->hasServerTag(ServerTag(tag))) { option_defs.push_back(option_def); got = true; @@ -352,7 +352,7 @@ TestConfigBackendDHCPv4::getModifiedOptionDefs4(const db::ServerSelector& server auto lb = index.lower_bound(modification_time); for (auto option_def = lb; option_def != index.end(); ++option_def) { bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*option_def)->hasServerTag(ServerTag(tag))) { option_defs.push_back(*option_def); got = true; @@ -381,7 +381,7 @@ TestConfigBackendDHCPv4::getOption4(const db::ServerSelector& server_selector, for (auto option_it = option_it_pair.first; option_it != option_it_pair.second; ++option_it) { if (option_it->space_name_ == space) { - for (auto tag : tags) { + for (auto const& tag : tags) { if (option_it->hasServerTag(ServerTag(tag))) { return (OptionDescriptorPtr(new OptionDescriptor(*option_it))); } @@ -399,9 +399,9 @@ OptionContainer TestConfigBackendDHCPv4::getAllOptions4(const db::ServerSelector& server_selector) const { auto tags = server_selector.getTags(); OptionContainer options; - for (auto option : options_) { + for (auto const& option : options_) { bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if (option.hasServerTag(ServerTag(tag))) { options.push_back(option); got = true; @@ -427,7 +427,7 @@ TestConfigBackendDHCPv4::getModifiedOptions4(const db::ServerSelector& server_se auto lb = index.lower_bound(modification_time); for (auto option = lb; option != index.end(); ++option) { bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if (option->hasServerTag(ServerTag(tag))) { options.push_back(*option); got = true; @@ -453,7 +453,7 @@ TestConfigBackendDHCPv4::getGlobalParameter4(const db::ServerSelector& server_se auto global_range = index.equal_range(name); for (auto global_it = global_range.first; global_it != global_range.second; ++global_it) { - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*global_it)->hasServerTag(ServerTag(tag))) { return (*global_it); } @@ -471,9 +471,9 @@ StampedValueCollection TestConfigBackendDHCPv4::getAllGlobalParameters4(const db::ServerSelector& server_selector) const { auto tags = server_selector.getTags(); StampedValueCollection globals; - for (auto global : globals_) { + for (auto const& global : globals_) { bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if (global->hasServerTag(ServerTag(tag))) { globals.insert(global); got = true; @@ -499,7 +499,7 @@ TestConfigBackendDHCPv4::getModifiedGlobalParameters4(const db::ServerSelector& auto lb = index.lower_bound(modification_time); for (auto global = lb; global != index.end(); ++global) { bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*global)->hasServerTag(ServerTag(tag))) { globals.insert(*global); got = true; @@ -520,7 +520,7 @@ ClientClassDefPtr TestConfigBackendDHCPv4::getClientClass4(const db::ServerSelector& server_selector, const std::string& name) const { ClientClassDefPtr client_class; - for (auto c : classes_) { + for (auto const& c : classes_) { if (c->getName() == name) { client_class = c; break; @@ -533,7 +533,7 @@ TestConfigBackendDHCPv4::getClientClass4(const db::ServerSelector& server_select return (client_class->getServerTags().empty() ? client_class : ClientClassDefPtr()); } auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (client_class->hasServerTag(ServerTag(tag))) { return (client_class); } @@ -545,7 +545,7 @@ ClientClassDictionary TestConfigBackendDHCPv4::getAllClientClasses4(const db::ServerSelector& server_selector) const { auto tags = server_selector.getTags(); ClientClassDictionary all_classes; - for (auto client_class : classes_) { + for (auto const& client_class : classes_) { if (server_selector.amAny()) { all_classes.addClass(client_class); continue; @@ -557,7 +557,7 @@ TestConfigBackendDHCPv4::getAllClientClasses4(const db::ServerSelector& server_s continue; } bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if (client_class->hasServerTag(ServerTag(tag))) { all_classes.addClass(client_class); got = true; @@ -579,10 +579,10 @@ TestConfigBackendDHCPv4::getModifiedClientClasses4(const db::ServerSelector& ser const boost::posix_time::ptime& modification_time) const { auto tags = server_selector.getTags(); ClientClassDictionary modified_classes; - for (auto client_class : classes_) { + for (auto const& client_class : classes_) { if (client_class->getModificationTime() >= modification_time) { bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if (client_class->hasServerTag(ServerTag(tag))) { modified_classes.addClass(client_class); got = true; @@ -621,7 +621,7 @@ TestConfigBackendDHCPv4::createUpdateClientClass4(const db::ServerSelector& serv mergeServerTags(client_class, server_selector); int existing_class_index = -1; - for (auto i = 0; i < classes_.size(); ++i) { + for (size_t i = 0; i < classes_.size(); ++i) { if (classes_[i]->getName() == client_class->getName()) { existing_class_index = i; break; @@ -778,7 +778,7 @@ TestConfigBackendDHCPv4::createUpdateOption4(const db::ServerSelector& server_se found = true; } else { auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (shared_network->hasServerTag(ServerTag(tag))) { found = true; break; @@ -819,7 +819,7 @@ TestConfigBackendDHCPv4::createUpdateOption4(const db::ServerSelector& server_se found = true; } else { auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { found = true; break; @@ -842,7 +842,7 @@ TestConfigBackendDHCPv4::createUpdateOption4(const db::ServerSelector& server_se const asiolink::IOAddress& pool_end_address, const OptionDescriptorPtr& option) { auto not_in_selected_servers = false; - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { // Get the pool: if it is not here we can directly go to the next subnet. auto pool = subnet->getPool(Lease::TYPE_V4, pool_start_address); if (!pool) { @@ -858,7 +858,7 @@ TestConfigBackendDHCPv4::createUpdateOption4(const db::ServerSelector& server_se } else if (!server_selector.amAny() && !subnet->hasAllServerTag()) { auto in_tags = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { in_tags = true; break; @@ -939,7 +939,7 @@ TestConfigBackendDHCPv4::deleteSubnet4(const db::ServerSelector& server_selector if (!server_selector.amAny()) { bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*subnet_it)->hasServerTag(ServerTag(tag))) { got = true; break; @@ -967,7 +967,7 @@ TestConfigBackendDHCPv4::deleteSubnet4(const db::ServerSelector& server_selector if (!server_selector.amAny()) { bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*subnet_it)->hasServerTag(ServerTag(tag))) { got = true; break; @@ -984,7 +984,7 @@ uint64_t TestConfigBackendDHCPv4::deleteAllSubnets4(const db::ServerSelector& server_selector) { // Collect subnet to remove by ID. std::list<SubnetID> ids; - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { if (server_selector.amAny()) { ids.push_back(subnet->getID()); continue; @@ -997,7 +997,7 @@ TestConfigBackendDHCPv4::deleteAllSubnets4(const db::ServerSelector& server_sele } bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { ids.push_back(subnet->getID()); got = true; @@ -1015,7 +1015,7 @@ TestConfigBackendDHCPv4::deleteAllSubnets4(const db::ServerSelector& server_sele // Erase subnets. uint64_t erased = 0; auto& index = subnets_.get<SubnetSubnetIdIndexTag>(); - for (auto subnet_id : ids) { + for (auto const& subnet_id : ids) { erased += index.erase(subnet_id); } return (erased); @@ -1035,7 +1035,7 @@ TestConfigBackendDHCPv4::deleteSharedNetworkSubnets4(const db::ServerSelector& s if (!server_selector.amAny()) { bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*subnet)->hasServerTag(ServerTag(tag))) { got = true; break; @@ -1079,7 +1079,7 @@ TestConfigBackendDHCPv4::deleteSharedNetwork4(const db::ServerSelector& server_s if (!server_selector.amAny()) { bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*network_it)->hasServerTag(ServerTag(tag))) { got = true; break; @@ -1104,7 +1104,7 @@ uint64_t TestConfigBackendDHCPv4::deleteAllSharedNetworks4(const db::ServerSelector& server_selector) { // Collect shared network to remove. std::list<std::string> names; - for (auto shared_network : shared_networks_) { + for (auto const& shared_network : shared_networks_) { if (server_selector.amAny()) { names.push_back(shared_network->getName()); continue; @@ -1117,7 +1117,7 @@ TestConfigBackendDHCPv4::deleteAllSharedNetworks4(const db::ServerSelector& serv } bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (shared_network->hasServerTag(ServerTag(tag))) { names.push_back(shared_network->getName()); got = true; @@ -1135,7 +1135,7 @@ TestConfigBackendDHCPv4::deleteAllSharedNetworks4(const db::ServerSelector& serv // Erase shared networks. uint64_t erased = 0; auto& index = shared_networks_.get<SharedNetworkNameIndexTag>(); - for (auto name : names) { + for (auto const& name : names) { erased += index.erase(name); } return (erased); @@ -1219,7 +1219,7 @@ TestConfigBackendDHCPv4::deleteOption4(const db::ServerSelector& server_selector found = true; } else { auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (shared_network->hasServerTag(ServerTag(tag))) { found = true; break; @@ -1260,7 +1260,7 @@ TestConfigBackendDHCPv4::deleteOption4(const db::ServerSelector& server_selector found = true; } else { auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { found = true; break; @@ -1283,7 +1283,7 @@ TestConfigBackendDHCPv4::deleteOption4(const db::ServerSelector& server_selector const uint16_t code, const std::string& space) { auto not_in_selected_servers = false; - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { // Get the pool: if it is not here we can directly go to the next subnet. auto pool = subnet->getPool(Lease::TYPE_V4, pool_start_address); @@ -1300,7 +1300,7 @@ TestConfigBackendDHCPv4::deleteOption4(const db::ServerSelector& server_selector } else if (!server_selector.amAny() && !subnet->hasAllServerTag()) { auto in_tags = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { in_tags = true; break; @@ -1381,7 +1381,7 @@ TestConfigBackendDHCPv4::deleteClientClass4(const db::ServerSelector& server_sel if (!server_selector.amAny()) { bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (existing_class->hasServerTag(ServerTag(tag))) { got = true; break; @@ -1414,7 +1414,7 @@ TestConfigBackendDHCPv4::deleteAllClientClasses4(const db::ServerSelector& serve } bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (client_class->hasServerTag(ServerTag(tag))) { c = classes_.erase(c); ++count; diff --git a/src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.cc b/src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.cc index e59ad5dd66..cd9045bfe3 100644 --- a/src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.cc +++ b/src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.cc @@ -49,7 +49,7 @@ TestConfigBackendDHCPv6::getSubnet6(const db::ServerSelector& server_selector, return (subnet->getServerTags().empty() ? subnet : Subnet6Ptr()); } auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { return (subnet); } @@ -73,7 +73,7 @@ TestConfigBackendDHCPv6::getSubnet6(const db::ServerSelector& server_selector, return (subnet->getServerTags().empty() ? subnet : Subnet6Ptr()); } auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { return (subnet); } @@ -84,7 +84,7 @@ TestConfigBackendDHCPv6::getSubnet6(const db::ServerSelector& server_selector, Subnet6Collection TestConfigBackendDHCPv6::getAllSubnets6(const db::ServerSelector& server_selector) const { Subnet6Collection subnets; - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { if (server_selector.amAny()) { subnets.insert(subnet); continue; @@ -97,7 +97,7 @@ TestConfigBackendDHCPv6::getAllSubnets6(const db::ServerSelector& server_selecto } bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { subnets.insert(subnet); got = true; @@ -133,7 +133,7 @@ TestConfigBackendDHCPv6::getModifiedSubnets6(const db::ServerSelector& server_se } bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*subnet)->hasServerTag(ServerTag(tag))) { subnets.insert(*subnet); got = true; @@ -158,7 +158,7 @@ TestConfigBackendDHCPv6::getSharedNetworkSubnets6(const db::ServerSelector& serv // Subnet collection does not include the index by shared network name. // We need to iterate over the subnets and pick those that are associated // with a shared network. - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { // Skip subnets which do not match the server selector. if (server_selector.amUnassigned() && !subnet->getServerTags().empty()) { @@ -167,7 +167,7 @@ TestConfigBackendDHCPv6::getSharedNetworkSubnets6(const db::ServerSelector& serv if (!server_selector.amAny()) { bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { got = true; break; @@ -209,7 +209,7 @@ TestConfigBackendDHCPv6::getSharedNetwork6(const db::ServerSelector& server_sele return (network->getServerTags().empty() ? network : SharedNetwork6Ptr()); } auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (network->hasServerTag(ServerTag(tag))) { return (network); } @@ -220,7 +220,7 @@ TestConfigBackendDHCPv6::getSharedNetwork6(const db::ServerSelector& server_sele SharedNetwork6Collection TestConfigBackendDHCPv6::getAllSharedNetworks6(const db::ServerSelector& server_selector) const{ SharedNetwork6Collection shared_networks; - for (auto shared_network : shared_networks_) { + for (auto const& shared_network : shared_networks_) { if (server_selector.amAny()) { shared_networks.push_back(shared_network); continue; @@ -233,7 +233,7 @@ TestConfigBackendDHCPv6::getAllSharedNetworks6(const db::ServerSelector& server_ } bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (shared_network->hasServerTag(ServerTag(tag))) { shared_networks.push_back(shared_network); got = true; @@ -269,7 +269,7 @@ TestConfigBackendDHCPv6::getModifiedSharedNetworks6(const db::ServerSelector& se } bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*shared_network)->hasServerTag(ServerTag(tag))) { shared_networks.push_back(*shared_network); got = true; @@ -299,7 +299,7 @@ TestConfigBackendDHCPv6::getOptionDef6(const db::ServerSelector& server_selector option_def_it != option_def_it_pair.second; ++option_def_it) { if ((*option_def_it)->getOptionSpaceName() == space) { - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*option_def_it)->hasServerTag(ServerTag(tag))) { return (*option_def_it); } @@ -316,7 +316,7 @@ OptionDefContainer TestConfigBackendDHCPv6::getAllOptionDefs6(const db::ServerSelector& server_selector) const { auto tags = server_selector.getTags(); OptionDefContainer option_defs; - for (auto option_def : option_defs_) { + for (auto const& option_def : option_defs_) { bool got = false; if (server_selector.amUnassigned()) { if (option_def->getServerTags().empty()) { @@ -324,7 +324,7 @@ TestConfigBackendDHCPv6::getAllOptionDefs6(const db::ServerSelector& server_sele got = true; } } else { - for (auto tag : tags) { + for (auto const& tag : tags) { if (option_def->hasServerTag(ServerTag(tag))) { option_defs.push_back(option_def); got = true; @@ -351,7 +351,7 @@ TestConfigBackendDHCPv6::getModifiedOptionDefs6(const db::ServerSelector& server auto lb = index.lower_bound(modification_time); for (auto option_def = lb; option_def != index.end(); ++option_def) { bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*option_def)->hasServerTag(ServerTag(tag))) { option_defs.push_back(*option_def); got = true; @@ -380,7 +380,7 @@ TestConfigBackendDHCPv6::getOption6(const db::ServerSelector& server_selector, for (auto option_it = option_it_pair.first; option_it != option_it_pair.second; ++option_it) { if (option_it->space_name_ == space) { - for (auto tag : tags) { + for (auto const& tag : tags) { if (option_it->hasServerTag(ServerTag(tag))) { return (OptionDescriptorPtr(new OptionDescriptor(*option_it))); } @@ -398,9 +398,9 @@ OptionContainer TestConfigBackendDHCPv6::getAllOptions6(const db::ServerSelector& server_selector) const { auto tags = server_selector.getTags(); OptionContainer options; - for (auto option : options_) { + for (auto const& option : options_) { bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if (option.hasServerTag(ServerTag(tag))) { options.push_back(option); got = true; @@ -426,7 +426,7 @@ TestConfigBackendDHCPv6::getModifiedOptions6(const db::ServerSelector& server_se auto lb = index.lower_bound(modification_time); for (auto option = lb; option != index.end(); ++option) { bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if (option->hasServerTag(ServerTag(tag))) { options.push_back(*option); got = true; @@ -452,7 +452,7 @@ TestConfigBackendDHCPv6::getGlobalParameter6(const db::ServerSelector& server_se auto global_range = index.equal_range(name); for (auto global_it = global_range.first; global_it != global_range.second; ++global_it) { - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*global_it)->hasServerTag(ServerTag(tag))) { return (*global_it); } @@ -470,9 +470,9 @@ StampedValueCollection TestConfigBackendDHCPv6::getAllGlobalParameters6(const db::ServerSelector& server_selector) const { auto tags = server_selector.getTags(); StampedValueCollection globals; - for (auto global : globals_) { + for (auto const& global : globals_) { bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if (global->hasServerTag(ServerTag(tag))) { globals.insert(global); got = true; @@ -498,7 +498,7 @@ TestConfigBackendDHCPv6::getModifiedGlobalParameters6(const db::ServerSelector& auto lb = index.lower_bound(modification_time); for (auto global = lb; global != index.end(); ++global) { bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*global)->hasServerTag(ServerTag(tag))) { globals.insert(*global); got = true; @@ -519,7 +519,7 @@ ClientClassDefPtr TestConfigBackendDHCPv6::getClientClass6(const db::ServerSelector& server_selector, const std::string& name) const { ClientClassDefPtr client_class; - for (auto c : classes_) { + for (auto const& c : classes_) { if (c->getName() == name) { client_class = c; break; @@ -532,7 +532,7 @@ TestConfigBackendDHCPv6::getClientClass6(const db::ServerSelector& server_select return (client_class->getServerTags().empty() ? client_class : ClientClassDefPtr()); } auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (client_class->hasServerTag(ServerTag(tag))) { return (client_class); } @@ -544,7 +544,7 @@ ClientClassDictionary TestConfigBackendDHCPv6::getAllClientClasses6(const db::ServerSelector& server_selector) const { auto tags = server_selector.getTags(); ClientClassDictionary all_classes; - for (auto client_class : classes_) { + for (auto const& client_class : classes_) { if (server_selector.amAny()) { all_classes.addClass(client_class); continue; @@ -556,7 +556,7 @@ TestConfigBackendDHCPv6::getAllClientClasses6(const db::ServerSelector& server_s continue; } bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if (client_class->hasServerTag(ServerTag(tag))) { all_classes.addClass(client_class); got = true; @@ -578,10 +578,10 @@ TestConfigBackendDHCPv6::getModifiedClientClasses6(const db::ServerSelector& ser const boost::posix_time::ptime& modification_time) const { auto tags = server_selector.getTags(); ClientClassDictionary modified_classes; - for (auto client_class : classes_) { + for (auto const& client_class : classes_) { if (client_class->getModificationTime() >= modification_time) { bool got = false; - for (auto tag : tags) { + for (auto const& tag : tags) { if (client_class->hasServerTag(ServerTag(tag))) { modified_classes.addClass(client_class); got = true; @@ -777,7 +777,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se found = true; } else { auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (shared_network->hasServerTag(ServerTag(tag))) { found = true; break; @@ -818,7 +818,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se found = true; } else { auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { found = true; break; @@ -841,7 +841,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se const asiolink::IOAddress& pool_end_address, const OptionDescriptorPtr& option) { auto not_in_selected_servers = false; - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { // Get the pool: if it is not here we can directly go to the next subnet. auto pool = subnet->getPool(Lease::TYPE_NA, pool_start_address); if (!pool) { @@ -857,7 +857,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se } else if (!server_selector.amAny() && !subnet->hasAllServerTag()) { auto in_tags = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { in_tags = true; break; @@ -895,7 +895,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se const uint8_t pd_pool_prefix_length, const OptionDescriptorPtr& option) { auto not_in_selected_servers = false; - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { // Get the pd pool: if it is not here we can directly go to the next subnet. auto pdpool = subnet->getPool(Lease::TYPE_PD, pd_pool_prefix); if (!pdpool) { @@ -911,7 +911,7 @@ TestConfigBackendDHCPv6::createUpdateOption6(const db::ServerSelector& server_se } else if (!server_selector.amAny() && !subnet->hasAllServerTag()) { auto in_tags = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { in_tags = true; break; @@ -992,7 +992,7 @@ TestConfigBackendDHCPv6::deleteSubnet6(const db::ServerSelector& server_selector if (!server_selector.amAny()) { bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*subnet_it)->hasServerTag(ServerTag(tag))) { got = true; break; @@ -1020,7 +1020,7 @@ TestConfigBackendDHCPv6::deleteSubnet6(const db::ServerSelector& server_selector if (!server_selector.amAny()) { bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*subnet_it)->hasServerTag(ServerTag(tag))) { got = true; break; @@ -1037,7 +1037,7 @@ uint64_t TestConfigBackendDHCPv6::deleteAllSubnets6(const db::ServerSelector& server_selector) { // Collect subnet to remove by ID. std::list<SubnetID> ids; - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { if (server_selector.amAny()) { ids.push_back(subnet->getID()); continue; @@ -1050,7 +1050,7 @@ TestConfigBackendDHCPv6::deleteAllSubnets6(const db::ServerSelector& server_sele } bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { ids.push_back(subnet->getID()); got = true; @@ -1068,7 +1068,7 @@ TestConfigBackendDHCPv6::deleteAllSubnets6(const db::ServerSelector& server_sele // Erase subnets. uint64_t erased = 0; auto& index = subnets_.get<SubnetSubnetIdIndexTag>(); - for (auto subnet_id : ids) { + for (auto const& subnet_id : ids) { erased += index.erase(subnet_id); } return (erased); @@ -1088,7 +1088,7 @@ TestConfigBackendDHCPv6::deleteSharedNetworkSubnets6(const db::ServerSelector& s if (!server_selector.amAny()) { bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*subnet)->hasServerTag(ServerTag(tag))) { got = true; break; @@ -1132,7 +1132,7 @@ TestConfigBackendDHCPv6::deleteSharedNetwork6(const db::ServerSelector& server_s if (!server_selector.amAny()) { bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if ((*network_it)->hasServerTag(ServerTag(tag))) { got = true; break; @@ -1157,7 +1157,7 @@ uint64_t TestConfigBackendDHCPv6::deleteAllSharedNetworks6(const db::ServerSelector& server_selector) { // Collect shared network to remove. std::list<std::string> names; - for (auto shared_network : shared_networks_) { + for (auto const& shared_network : shared_networks_) { if (server_selector.amAny()) { names.push_back(shared_network->getName()); continue; @@ -1170,7 +1170,7 @@ TestConfigBackendDHCPv6::deleteAllSharedNetworks6(const db::ServerSelector& serv } bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (shared_network->hasServerTag(ServerTag(tag))) { names.push_back(shared_network->getName()); got = true; @@ -1188,7 +1188,7 @@ TestConfigBackendDHCPv6::deleteAllSharedNetworks6(const db::ServerSelector& serv // Erase shared networks. uint64_t erased = 0; auto& index = shared_networks_.get<SharedNetworkNameIndexTag>(); - for (auto name : names) { + for (auto const& name : names) { erased += index.erase(name); } return (erased); @@ -1272,7 +1272,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector found = true; } else { auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (shared_network->hasServerTag(ServerTag(tag))) { found = true; break; @@ -1313,7 +1313,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector found = true; } else { auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { found = true; break; @@ -1336,7 +1336,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector const uint16_t code, const std::string& space) { auto not_in_selected_servers = false; - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { // Get the pool: if it is not here we can directly go to the next subnet. auto pool = subnet->getPool(Lease::TYPE_NA, pool_start_address); @@ -1353,7 +1353,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector } else if (!server_selector.amAny() && !subnet->hasAllServerTag()) { auto in_tags = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { in_tags = true; break; @@ -1386,7 +1386,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector const uint16_t code, const std::string& space) { auto not_in_selected_servers = false; - for (auto subnet : subnets_) { + for (auto const& subnet : subnets_) { // Get the pd pool: if it is not here we can directly go to the next subnet. auto pdpool = subnet->getPool(Lease::TYPE_PD, pd_pool_prefix); if (!pdpool) { @@ -1402,7 +1402,7 @@ TestConfigBackendDHCPv6::deleteOption6(const db::ServerSelector& server_selector } else if (!server_selector.amAny() && !subnet->hasAllServerTag()) { auto in_tags = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (subnet->hasServerTag(ServerTag(tag))) { in_tags = true; break; @@ -1485,7 +1485,7 @@ TestConfigBackendDHCPv6::deleteClientClass6(const db::ServerSelector& server_sel if (!server_selector.amAny()) { bool got = false; auto tags = server_selector.getTags(); - for (auto tag : tags) { + for (auto const& tag : tags) { if (existing_class->hasServerTag(ServerTag(tag))) { got = true; break; diff --git a/src/lib/dns/zone_checker.cc b/src/lib/dns/zone_checker.cc index def989627f..09f153899b 100644 --- a/src/lib/dns/zone_checker.cc +++ b/src/lib/dns/zone_checker.cc @@ -42,8 +42,7 @@ checkSOA(const Name& zone_name, const RRClass& zone_class, size_t count = 0; if (rrset) { for (RdataIteratorPtr rit = rrset->getRdataIterator(); - !rit->isLast(); - rit->next(), ++count) { + !rit->isLast(); rit->next(), ++count) { if (dynamic_cast<const rdata::generic::SOA*>(&rit->getCurrent()) == NULL) { isc_throw(Unexpected, "Zone checker found bad RDATA in SOA"); @@ -102,8 +101,7 @@ checkNSNames(const Name& zone_name, const RRClass& zone_class, } for (RdataIteratorPtr rit = ns_rrset->getRdataIterator(); - !rit->isLast(); - rit->next()) { + !rit->isLast(); rit->next()) { const rdata::generic::NS* ns_data = dynamic_cast<const rdata::generic::NS*>(&rit->getCurrent()); if (ns_data == NULL) { diff --git a/src/lib/hooks/hooks_parser.cc b/src/lib/hooks/hooks_parser.cc index cfd4a7e8f5..976f6a0bd0 100644 --- a/src/lib/hooks/hooks_parser.cc +++ b/src/lib/hooks/hooks_parser.cc @@ -54,7 +54,7 @@ HooksLibrariesParser::parse(HooksConfig& libraries, ConstElementPtr value) { // values from the previous loop round. parameters.reset(); - BOOST_FOREACH(auto entry_item, library_entry->mapValue()) { + BOOST_FOREACH(auto const& entry_item, library_entry->mapValue()) { if (entry_item.first == "library") { if (entry_item.second->getType() != Element::string) { isc_throw(DhcpConfigError, "hooks library configuration" diff --git a/src/lib/hooks/library_handle.cc b/src/lib/hooks/library_handle.cc index b070448e7a..88cda6f3e4 100644 --- a/src/lib/hooks/library_handle.cc +++ b/src/lib/hooks/library_handle.cc @@ -119,7 +119,7 @@ LibraryHandle::getParameterNames() { (params->size() == 0)) { return (names); } - auto map = params->mapValue(); + auto const& map = params->mapValue(); for (auto elem = map.begin(); elem != map.end(); ++elem) { names.push_back(elem->first); } diff --git a/src/lib/http/basic_auth_config.cc b/src/lib/http/basic_auth_config.cc index 0c98a4a3c3..1d70995e32 100644 --- a/src/lib/http/basic_auth_config.cc +++ b/src/lib/http/basic_auth_config.cc @@ -134,7 +134,7 @@ BasicHttpAuthConfig::toElement() const { // Set clients ElementPtr clients = Element::createList(); - for (auto client : list_) { + for (auto const& client : list_) { clients->add(client.toElement()); } result->set("clients", clients); @@ -209,7 +209,7 @@ BasicHttpAuthConfig::parse(const ConstElementPtr& config) { } // Iterate on clients. - for (auto client : clients->listValue()) { + for (auto const& client : clients->listValue()) { if (client->getType() != Element::map) { isc_throw(DhcpConfigError, "clients items must be maps (" << client->getPosition() << ")"); diff --git a/src/lib/http/tests/post_request_json_unittests.cc b/src/lib/http/tests/post_request_json_unittests.cc index bb717cd1cd..2fa4782680 100644 --- a/src/lib/http/tests/post_request_json_unittests.cc +++ b/src/lib/http/tests/post_request_json_unittests.cc @@ -114,12 +114,10 @@ TEST_F(PostHttpRequestJsonTest, getBodyAsJson) { // Iterate over JSON values and store them in a simple map. std::map<std::string, std::string> config_values; - for (auto config_element = json->mapValue().begin(); - config_element != json->mapValue().end(); - ++config_element) { - ASSERT_FALSE(config_element->first.empty()); - ASSERT_TRUE(config_element->second); - config_values[config_element->first] = config_element->second->stringValue(); + for (auto const& config_element : json->mapValue()) { + ASSERT_FALSE(config_element.first.empty()); + ASSERT_TRUE(config_element.second); + config_values[config_element.first] = config_element.second->stringValue(); } // Verify the values. diff --git a/src/lib/log/logger_impl.cc b/src/lib/log/logger_impl.cc index f0e52981ae..4e2d7b603e 100644 --- a/src/lib/log/logger_impl.cc +++ b/src/lib/log/logger_impl.cc @@ -212,7 +212,7 @@ LoggerImpl::hasAppender(OutputOption::Destination const destination) { appenders = log4cplus::Logger::getInstance(getRootLoggerName()).getAllAppenders(); } - for (log4cplus::helpers::SharedObjectPtr<log4cplus::Appender> logger : appenders) { + for (const log4cplus::helpers::SharedObjectPtr<log4cplus::Appender>& logger : appenders) { if (destination == OutputOption::DEST_CONSOLE && dynamic_cast<log4cplus::ConsoleAppender*>(logger.get())) { return true; diff --git a/src/lib/mysql/mysql_connection.h b/src/lib/mysql/mysql_connection.h index c66da05dfa..5aefae8de4 100644 --- a/src/lib/mysql/mysql_connection.h +++ b/src/lib/mysql/mysql_connection.h @@ -450,7 +450,7 @@ public: checkUnusable(); // Extract native input bindings. std::vector<MYSQL_BIND> in_bind_vec; - for (MySqlBindingPtr in_binding : in_bindings) { + for (const MySqlBindingPtr& in_binding : in_bindings) { in_bind_vec.push_back(in_binding->getMySqlBinding()); } @@ -464,7 +464,7 @@ public: // Bind variables that will receive results as well. std::vector<MYSQL_BIND> out_bind_vec; - for (MySqlBindingPtr out_binding : out_bindings) { + for (const MySqlBindingPtr& out_binding : out_bindings) { out_bind_vec.push_back(out_binding->getMySqlBinding()); } if (!out_bind_vec.empty()) { @@ -527,7 +527,7 @@ public: const MySqlBindingCollection& in_bindings) { checkUnusable(); std::vector<MYSQL_BIND> in_bind_vec; - for (MySqlBindingPtr in_binding : in_bindings) { + for (const MySqlBindingPtr& in_binding : in_bindings) { in_bind_vec.push_back(in_binding->getMySqlBinding()); } @@ -571,7 +571,7 @@ public: const MySqlBindingCollection& in_bindings) { checkUnusable(); std::vector<MYSQL_BIND> in_bind_vec; - for (MySqlBindingPtr in_binding : in_bindings) { + for (const MySqlBindingPtr& in_binding : in_bindings) { in_bind_vec.push_back(in_binding->getMySqlBinding()); } diff --git a/src/lib/pgsql/tests/pgsql_connection_unittest.cc b/src/lib/pgsql/tests/pgsql_connection_unittest.cc index ab09009f19..871a264992 100644 --- a/src/lib/pgsql/tests/pgsql_connection_unittest.cc +++ b/src/lib/pgsql/tests/pgsql_connection_unittest.cc @@ -162,7 +162,7 @@ public: /// @param insert_rows Collection of rows of data to insert. Note that /// each row is inserted as a separate statement execution. void testInsert(const TestRowSet& insert_rows) { - for (auto row : insert_rows ) { + for (const auto& row : insert_rows) { // Set the insert parameters based on the current insert row. PsqlBindArray in_bindings; in_bindings.add(row.int_col); @@ -238,7 +238,7 @@ public: /// @param update_rows Collection of rows of data to update. void testUpdate(const TestRowSet& update_rows) { size_t update_count = 0; - for (auto row : update_rows ) { + for (const auto& row : update_rows) { // Set the text value and where clause parameters based on the // this row's values. PsqlBindArray in_bindings; diff --git a/src/lib/pgsql/tests/pgsql_exchange_unittest.cc b/src/lib/pgsql/tests/pgsql_exchange_unittest.cc index 7bbf747d8f..ae9a2f2c7d 100644 --- a/src/lib/pgsql/tests/pgsql_exchange_unittest.cc +++ b/src/lib/pgsql/tests/pgsql_exchange_unittest.cc @@ -1362,7 +1362,7 @@ TEST_F(PgSqlBasicsTest, tripleTest) { // Insert a row for each reference value PsqlBindArrayPtr bind_array; PgSqlResultPtr r; - for (auto triplet : triplets) { + for (auto const& triplet : triplets) { bind_array.reset(new PsqlBindArray()); bind_array->add(triplet); bind_array->addMin(triplet); @@ -1375,7 +1375,7 @@ TEST_F(PgSqlBasicsTest, tripleTest) { // Iterate over the rows, verifying each value against its reference int row = 0; - for (auto expected : triplets) { + for (auto const& expected : triplets) { Triplet<uint32_t> fetched; // First we test making a triplet only with default value column. ASSERT_NO_THROW_LOG(fetched = PgSqlExchange::getTripletValue(*r, row, INT_COL)); diff --git a/src/lib/process/cb_ctl_base.h b/src/lib/process/cb_ctl_base.h index ecbb73610c..28a3457d33 100644 --- a/src/lib/process/cb_ctl_base.h +++ b/src/lib/process/cb_ctl_base.h @@ -142,7 +142,7 @@ public: } // Iterate over the configured DBs and instantiate them. - for (auto db : config_ctl->getConfigDatabases()) { + for (auto const& db : config_ctl->getConfigDatabases()) { const std::string& redacted = db.redactedAccessString(); LOG_INFO(dctl_logger, DCTL_OPEN_CONFIG_DB) .arg(redacted); diff --git a/src/lib/process/config_ctl_info.cc b/src/lib/process/config_ctl_info.cc index 5c6aca7ca6..b7b87a388f 100644 --- a/src/lib/process/config_ctl_info.cc +++ b/src/lib/process/config_ctl_info.cc @@ -47,7 +47,7 @@ ConfigDbInfo::getParameterValue(const std::string& name, std::string& value) con ConfigControlInfo::ConfigControlInfo(const ConfigControlInfo& other) : config_fetch_wait_time_(other.config_fetch_wait_time_) { - for (auto db : other.db_infos_) { + for (auto const& db : other.db_infos_) { addConfigDatabase(db.getAccessString()); } } @@ -57,7 +57,7 @@ ConfigControlInfo::addConfigDatabase(const std::string& access_str) { ConfigDbInfo new_db; new_db.setAccessString(access_str); - for (auto db : db_infos_) { + for (auto const& db : db_infos_) { if (new_db == db) { // we have a duplicate! isc_throw(BadValue, "database with access parameters: " @@ -106,7 +106,7 @@ ElementPtr ConfigControlInfo::toElement() const { ElementPtr result = Element::createMap(); ElementPtr db_list = Element::createList(); - for (auto db_info : db_infos_) { + for (auto const& db_info : db_infos_) { db_list->add(db_info.toElement()); } diff --git a/src/lib/process/d_controller.cc b/src/lib/process/d_controller.cc index 9b8f65edc4..d6f14d1ea9 100644 --- a/src/lib/process/d_controller.cc +++ b/src/lib/process/d_controller.cc @@ -530,7 +530,7 @@ DControllerBase::handleOtherObjects(ConstElementPtr args) { // Check obsolete or unknown (aka unsupported) objects. const std::string& app_name = getAppName(); std::string errmsg; - for (auto obj : args->mapValue()) { + for (auto const& obj : args->mapValue()) { const std::string& obj_name = obj.first; if (obj_name == app_name) { continue; diff --git a/src/lib/process/tests/cb_ctl_base_unittests.cc b/src/lib/process/tests/cb_ctl_base_unittests.cc index 58d0aa065f..6c6710944c 100644 --- a/src/lib/process/tests/cb_ctl_base_unittests.cc +++ b/src/lib/process/tests/cb_ctl_base_unittests.cc @@ -493,7 +493,7 @@ TEST_F(CBControlBaseTest, fetchConfigElement) { EXPECT_EQ(2, updated.size()); bool saw_create = false; bool saw_update = false; - for (auto entry : updated) { + for (auto const& entry : updated) { EXPECT_EQ("my_object_type", entry->getObjectType()); EXPECT_EQ(5678, entry->getObjectId()); if (AuditEntry::ModificationType::CREATE == entry->getModificationType()) { diff --git a/src/lib/process/tests/config_ctl_parser_unittests.cc b/src/lib/process/tests/config_ctl_parser_unittests.cc index 8e5b328fdf..eecc28c5be 100644 --- a/src/lib/process/tests/config_ctl_parser_unittests.cc +++ b/src/lib/process/tests/config_ctl_parser_unittests.cc @@ -42,7 +42,7 @@ TEST(ConfigCtlInfoParser, validConfigs) { "] } \n" }; - for (auto config : configs) { + for (auto const& config : configs) { ConfigControlParser parser; ConfigControlInfoPtr ctl_info; @@ -87,7 +87,7 @@ TEST(ConfigCtlInfoParser, invalidConfigs) { "{ \"config-fetch-wait-time\": \"a-string\" }", }; - for (auto config : configs) { + for (auto const& config : configs) { ConfigControlParser parser; // Turn the JSON config into Elements. diff --git a/src/lib/stats/context.cc b/src/lib/stats/context.cc index 3675df9fbe..2a560efafd 100644 --- a/src/lib/stats/context.cc +++ b/src/lib/stats/context.cc @@ -60,7 +60,7 @@ StatContext::clear() { void StatContext::resetAll() { // Let's iterate over all stored statistics... - for (auto s : stats_) { + for (auto const& s : stats_) { // ... and reset each statistic. s.second->reset(); } @@ -70,7 +70,7 @@ ConstElementPtr StatContext::getAll() const { ElementPtr map = Element::createMap(); // a map // Let's iterate over all stored statistics... - for (auto s : stats_) { + for (auto const& s : stats_) { // ... and add each of them to the map. map->set(s.first, s.second->getJSON()); } @@ -89,7 +89,7 @@ StatContext::setMaxSampleCountAll(uint32_t max_samples) { void StatContext::setMaxSampleAgeAll(const StatsDuration& duration) { // Let's iterate over all stored statistics... - for (auto s : stats_) { + for (auto const& s : stats_) { // ... and set duration limit for each statistic. s.second->setMaxSampleAge(duration); } diff --git a/src/lib/tcp/tests/tcp_listener_unittests.cc b/src/lib/tcp/tests/tcp_listener_unittests.cc index 31b611ba9f..b04475aff4 100644 --- a/src/lib/tcp/tests/tcp_listener_unittests.cc +++ b/src/lib/tcp/tests/tcp_listener_unittests.cc @@ -76,7 +76,7 @@ public: /// /// Removes active clients. virtual ~TcpListenerTest() { - for (auto client : clients_) { + for (auto const& client : clients_) { client->close(); } } @@ -319,7 +319,7 @@ TEST_F(TcpListenerTest, multipleClientsListen) { ASSERT_EQ(num_clients, clients_.size()); size_t connection_id = 1; - for (auto client : clients_) { + for (auto const& client : clients_) { EXPECT_TRUE(client->receiveDone()); EXPECT_FALSE(client->expectedEof()); // Create the list of expected entries. @@ -329,7 +329,7 @@ TEST_F(TcpListenerTest, multipleClientsListen) { }; // Fetch the entries for this connection. - auto entries = listener.audit_trail_->getConnectionTrail(connection_id); + auto const& entries = listener.audit_trail_->getConnectionTrail(connection_id); ASSERT_EQ(expected_entries, entries); ++connection_id; } @@ -363,7 +363,7 @@ TEST_F(TcpListenerTest, multipleRequetsPerClients) { std::list<std::string>expected_responses{ "echo one", "echo two", "echo three", "good bye"}; size_t connection_id = 1; - for (auto client : clients_) { + for (auto const& client : clients_) { EXPECT_TRUE(client->receiveDone()); EXPECT_FALSE(client->expectedEof()); EXPECT_EQ(expected_responses, client->getResponses()); @@ -382,7 +382,7 @@ TEST_F(TcpListenerTest, multipleRequetsPerClients) { }; // Fetch the entries for this connection. - auto entries = listener.audit_trail_->getConnectionTrail(connection_id); + auto const& entries = listener.audit_trail_->getConnectionTrail(connection_id); ASSERT_EQ(expected_entries, entries); ++connection_id; } @@ -420,7 +420,7 @@ TEST_F(TcpListenerTest, filterClientsTest) { ASSERT_EQ(num_clients, clients_.size()); size_t i = 0; - for (auto client : clients_) { + for (auto const& client : clients_) { if (i % 2 == 0) { // These clients should have been accepted and received responses. EXPECT_TRUE(client->receiveDone()); @@ -433,7 +433,7 @@ TEST_F(TcpListenerTest, filterClientsTest) { { i+1, AuditEntry::OUTBOUND, "good bye" } }; - auto entries = listener.audit_trail_->getConnectionTrail(i+1); + auto const& entries = listener.audit_trail_->getConnectionTrail(i+1); ASSERT_EQ(expected_entries, entries); } else { @@ -442,7 +442,7 @@ TEST_F(TcpListenerTest, filterClientsTest) { EXPECT_TRUE(client->expectedEof()); // Verify connection recorded no audit entries. - auto entries = listener.audit_trail_->getConnectionTrail(i+1); + auto const& entries = listener.audit_trail_->getConnectionTrail(i+1); ASSERT_EQ(entries.size(), 0); } @@ -561,11 +561,11 @@ TEST(TcpStreamRequst, postBufferTest) { } } - for (auto scenario : scenarios ) { + for (auto const& scenario : scenarios ) { SCOPED_TRACE(scenario.desc_); std::list<TcpStreamRequestPtr> requests; TcpStreamRequestPtr request; - for (auto input_buf : scenario.input_buffers_) { + for (auto const& input_buf : scenario.input_buffers_) { // Copy the input buffer. std::vector<uint8_t> buf = input_buf; @@ -593,7 +593,7 @@ TEST(TcpStreamRequst, postBufferTest) { ASSERT_EQ(requests.size(), scenario.expected_strings_.size()); auto exp_string = scenario.expected_strings_.begin(); - for (auto recvd_request : requests) { + for (auto const& recvd_request : requests) { ASSERT_NO_THROW(recvd_request->unpack()); EXPECT_EQ(*exp_string++, recvd_request->getRequestString()); } diff --git a/src/lib/tcp/tests/tcp_test_listener.h b/src/lib/tcp/tests/tcp_test_listener.h index 5522484a84..cc13d42c02 100644 --- a/src/lib/tcp/tests/tcp_test_listener.h +++ b/src/lib/tcp/tests/tcp_test_listener.h @@ -85,7 +85,7 @@ public: std::list<AuditEntry> getConnectionTrail(size_t connection_id) { std::unique_lock<std::mutex> lck(mutex_); std::list<AuditEntry> conn_entries; - for (auto entry : entries_) { + for (auto const& entry : entries_) { if (entry.connection_id_ == connection_id) { conn_entries.push_back(entry); } @@ -98,7 +98,7 @@ public: std::string dump() { std::unique_lock<std::mutex> lck(mutex_); std::stringstream ss; - for (auto entry : entries_) { + for (auto const& entry : entries_) { ss << entry << std::endl; } diff --git a/src/lib/tcp/tests/tls_listener_unittests.cc b/src/lib/tcp/tests/tls_listener_unittests.cc index 9d3fbdb820..c5a7d424c3 100644 --- a/src/lib/tcp/tests/tls_listener_unittests.cc +++ b/src/lib/tcp/tests/tls_listener_unittests.cc @@ -71,7 +71,7 @@ public: /// /// Removes active clients. virtual ~TlsListenerTest() { - for (auto client : clients_) { + for (auto const& client : clients_) { client->close(); } } @@ -359,7 +359,7 @@ TEST_F(TlsListenerTest, multipleClientsListen) { ASSERT_EQ(num_clients, clients_.size()); size_t connection_id = 1; - for (auto client : clients_) { + for (auto const& client : clients_) { EXPECT_TRUE(client->receiveDone()); EXPECT_FALSE(client->expectedEof()); // Create the list of expected entries. @@ -403,7 +403,7 @@ TEST_F(TlsListenerTest, multipleRequetsPerClients) { std::list<std::string>expected_responses{ "echo one", "echo two", "echo three", "good bye"}; size_t connection_id = 1; - for (auto client : clients_) { + for (auto const& client : clients_) { EXPECT_TRUE(client->receiveDone()); EXPECT_FALSE(client->expectedEof()); EXPECT_EQ(expected_responses, client->getResponses()); @@ -458,7 +458,7 @@ TEST_F(TlsListenerTest, filterClientsTest) { ASSERT_EQ(num_clients, clients_.size()); size_t i = 0; - for (auto client : clients_) { + for (auto const& client : clients_) { if (i % 2 == 0) { // These clients should have been accepted and received responses. EXPECT_TRUE(client->receiveDone()); diff --git a/src/lib/util/tests/thread_pool_unittest.cc b/src/lib/util/tests/thread_pool_unittest.cc index 270deefa1d..0c0df198f6 100644 --- a/src/lib/util/tests/thread_pool_unittest.cc +++ b/src/lib/util/tests/thread_pool_unittest.cc @@ -130,7 +130,7 @@ public: // signal threads that are waiting signalThreads(); // wait for all test threads to exit - for (auto thread : threads_) { + for (const auto& thread : threads_) { thread->join(); } // reset all threads @@ -172,7 +172,7 @@ public: void checkRunHistory(uint32_t items_count) { uint32_t count = 0; // iterate over all threads history and count all the processed tasks - for (auto element : history_) { + for (const auto& element : history_) { count += element.second.size(); } ASSERT_EQ(count, items_count); diff --git a/src/lib/util/thread_pool.h b/src/lib/util/thread_pool.h index 82f6300dfe..379cb93b64 100644 --- a/src/lib/util/thread_pool.h +++ b/src/lib/util/thread_pool.h @@ -242,7 +242,7 @@ private: isc_throw(MultiThreadingInvalidOperation, "thread pool stop called by worker thread"); } queue_.disable(); - for (auto thread : threads_) { + for (const auto& thread : threads_) { thread->join(); } threads_.clear(); @@ -252,7 +252,7 @@ private: /// /// @return true if thread is owned, false otherwise bool checkThreadId(std::thread::id id) { - for (auto thread : threads_) { + for (const auto& thread : threads_) { if (id == thread->get_id()) { return (true); } diff --git a/src/lib/util/unittests/testdata.cc b/src/lib/util/unittests/testdata.cc index e3ecc916db..111cc37204 100644 --- a/src/lib/util/unittests/testdata.cc +++ b/src/lib/util/unittests/testdata.cc @@ -34,8 +34,8 @@ addTestDataPath(const string& path) { void openTestData(const char* const datafile, ifstream& ifs) { - vector<string>::const_iterator it = getDataPaths().begin(); - for (; it != getDataPaths().end(); ++it) { + for (vector<string>::const_iterator it = getDataPaths().begin(); + it != getDataPaths().end(); ++it) { string data_path = *it; if (data_path.empty() || *data_path.rbegin() != '/') { data_path.push_back('/'); diff --git a/src/lib/yang/adaptor.cc b/src/lib/yang/adaptor.cc index 5e2de98da4..a4e2c7aac6 100644 --- a/src/lib/yang/adaptor.cc +++ b/src/lib/yang/adaptor.cc @@ -265,7 +265,7 @@ void applyDown(ConstElementPtr path, ConstElementPtr actions, ElementPtr scope, if (name.empty()) { return; } - for (ElementPtr down : downs) { + for (ElementPtr& down : downs) { if (!down || (down->getType() != Element::map)) { continue; } @@ -280,7 +280,7 @@ void applyDown(ConstElementPtr path, ConstElementPtr actions, ElementPtr scope, } int index = step->intValue(); if (index == -1) { - for (ElementPtr down : downs) { + for (ElementPtr& down : downs) { applyDown(path, actions, down, next); } } else if ((index >= 0) && (index < scope->size())) { diff --git a/src/lib/yang/adaptor_pool.cc b/src/lib/yang/adaptor_pool.cc index 6d9aeaee28..fd2ebf7629 100644 --- a/src/lib/yang/adaptor_pool.cc +++ b/src/lib/yang/adaptor_pool.cc @@ -21,7 +21,7 @@ void AdaptorPool::canonizePool(ElementPtr pool) { const string& orig = pool->get("pool")->stringValue(); vector<char> v; - for (char ch : orig) { + for (auto ch : orig) { if ((ch == ' ') || (ch == '\t') || (ch == '\n')) { continue; } else if (ch == '-') { diff --git a/src/lib/yang/tests/adaptor_config_unittests.cc b/src/lib/yang/tests/adaptor_config_unittests.cc index 2109890c58..2baaa1ac09 100644 --- a/src/lib/yang/tests/adaptor_config_unittests.cc +++ b/src/lib/yang/tests/adaptor_config_unittests.cc @@ -92,7 +92,7 @@ TEST_F(AdaptorConfigTest, loadExamples4) { ElementPtr x; - for (int i = 0; i<configs.size(); i++) { + for (int i = 0; i < configs.size(); i++) { x.reset(); testFile(string(CFG_EXAMPLES) + "/kea4/" + configs[i], false, x); ASSERT_TRUE(x); diff --git a/src/lib/yang/tests/config_unittests.cc b/src/lib/yang/tests/config_unittests.cc index 6ffe0afa2f..cb7396ca39 100644 --- a/src/lib/yang/tests/config_unittests.cc +++ b/src/lib/yang/tests/config_unittests.cc @@ -324,7 +324,7 @@ TEST_F(ConfigTestKeaV4, examples4) { "vivso.json", //"with-ddns.json", }; - for (string file : examples) { + for (const string& file : examples) { resetSession(); string path = string(CFG_EXAMPLES) + "/kea4/" + file; SCOPED_TRACE("\n* Tested file: " + path); @@ -367,7 +367,7 @@ TEST_F(ConfigTestKeaV6, examples6) { "tee-times.json", //"with-ddns.json", }; - for (string file : examples) { + for (const string& file : examples) { resetSession(); string path = string(CFG_EXAMPLES) + "/kea6/" + file; SCOPED_TRACE("\n* Tested file: " + path); diff --git a/src/lib/yang/tests/translator_utils_unittests.cc b/src/lib/yang/tests/translator_utils_unittests.cc index ddd4cb91e1..11f3c4ab25 100644 --- a/src/lib/yang/tests/translator_utils_unittests.cc +++ b/src/lib/yang/tests/translator_utils_unittests.cc @@ -280,7 +280,7 @@ void sanityCheckConfig(const string& model, const YRTree& tree) { // This is test environment sanity check. It verifies that all configuration // defined in yang_configs.h are sane. TEST(YangReprTest, verifyConfigs) { - for (auto x : TEST_CONFIGS) { + for (const auto& x : TEST_CONFIGS) { sanityCheckConfig(x.first, x.second); } } |