]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3119] use auto const& whenever possible
authorRazvan Becheriu <razvan@isc.org>
Wed, 20 Dec 2023 19:06:42 +0000 (21:06 +0200)
committerRazvan Becheriu <razvan@isc.org>
Mon, 22 Jan 2024 15:33:26 +0000 (17:33 +0200)
143 files changed:
src/bin/agent/simple_parser.cc
src/bin/agent/tests/parser_unittests.cc
src/bin/d2/tests/parser_unittest.cc
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/json_config_parser.cc
src/bin/dhcp4/tests/config_parser_unittest.cc
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/fqdn_unittest.cc
src/bin/dhcp4/tests/hooks_unittest.cc
src/bin/dhcp4/tests/parser_unittest.cc
src/bin/dhcp4/tests/shared_network_unittest.cc
src/bin/dhcp4/tests/vendor_opts_unittest.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/json_config_parser.cc
src/bin/dhcp6/tests/config_parser_unittest.cc
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/fqdn_unittest.cc
src/bin/dhcp6/tests/hooks_unittest.cc
src/bin/dhcp6/tests/parser_unittest.cc
src/bin/dhcp6/tests/vendor_opts_unittest.cc
src/bin/netconf/netconf.cc
src/bin/netconf/netconf_cfg_mgr.cc
src/bin/netconf/simple_parser.cc
src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc
src/bin/netconf/tests/parser_unittests.cc
src/bin/perfdhcp/perf_socket.cc
src/bin/perfdhcp/test_control.cc
src/hooks/dhcp/flex_option/flex_option.cc
src/hooks/dhcp/flex_option/flex_option.h
src/hooks/dhcp/high_availability/communication_state.cc
src/hooks/dhcp/high_availability/ha_config_parser.cc
src/hooks/dhcp/high_availability/ha_impl.cc
src/hooks/dhcp/high_availability/ha_relationship_mapper.h
src/hooks/dhcp/high_availability/ha_service.cc
src/hooks/dhcp/high_availability/libloadtests/close_unittests.cc
src/hooks/dhcp/high_availability/query_filter.cc
src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc
src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc
src/hooks/dhcp/lease_cmds/tests/lease_cmds4_unittest.cc
src/hooks/dhcp/lease_cmds/tests/lease_cmds6_unittest.cc
src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc
src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc
src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc
src/hooks/dhcp/mysql_cb/mysql_cb_impl.h
src/hooks/dhcp/pgsql_cb/pgsql_cb_dhcp4.cc
src/hooks/dhcp/pgsql_cb/pgsql_cb_dhcp6.cc
src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.cc
src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.h
src/hooks/dhcp/run_script/tests/run_script_unittests.cc
src/lib/asiolink/io_service_thread_pool.cc
src/lib/cc/command_interpreter.cc
src/lib/cc/data.cc
src/lib/cc/simple_parser.cc
src/lib/cc/stamped_element.cc
src/lib/config_backend/base_config_backend_pool.h
src/lib/config_backend/tests/config_backend_mgr_unittest.cc
src/lib/database/database_connection.cc
src/lib/database/dbaccess_parser.cc
src/lib/database/server_selector.cc
src/lib/database/tests/database_connection_unittest.cc
src/lib/dhcp/classify.cc
src/lib/dhcp/duid_factory.cc
src/lib/dhcp/libdhcp++.cc
src/lib/dhcp/option6_auth.cc
src/lib/dhcp/option_space_container.h
src/lib/dhcp/pkt6.cc
src/lib/dhcp/tests/iface_mgr_unittest.cc
src/lib/dhcp/tests/option6_auth_unittest.cc
src/lib/dhcp/tests/pkt6_unittest.cc
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/cfg_hosts.cc
src/lib/dhcpsrv/cfg_iface.cc
src/lib/dhcpsrv/cfg_option.cc
src/lib/dhcpsrv/cfg_option_def.cc
src/lib/dhcpsrv/cfg_subnets4.cc
src/lib/dhcpsrv/cfg_subnets6.cc
src/lib/dhcpsrv/client_class_def.cc
src/lib/dhcpsrv/client_class_def.h
src/lib/dhcpsrv/flq_allocator.cc
src/lib/dhcpsrv/host_data_source_factory.cc
src/lib/dhcpsrv/host_mgr.cc
src/lib/dhcpsrv/lease_mgr.cc
src/lib/dhcpsrv/memfile_lease_mgr.cc
src/lib/dhcpsrv/mysql_lease_mgr.cc
src/lib/dhcpsrv/network_state.cc
src/lib/dhcpsrv/parsers/client_class_def_parser.cc
src/lib/dhcpsrv/parsers/host_reservation_parser.cc
src/lib/dhcpsrv/pgsql_lease_mgr.cc
src/lib/dhcpsrv/random_allocator.cc
src/lib/dhcpsrv/resource_handler.cc
src/lib/dhcpsrv/srv_config.cc
src/lib/dhcpsrv/subnet.cc
src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc
src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc
src/lib/dhcpsrv/tests/cfg_shared_networks4_unittest.cc
src/lib/dhcpsrv/tests/cfg_shared_networks6_unittest.cc
src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc
src/lib/dhcpsrv/tests/client_class_def_unittest.cc
src/lib/dhcpsrv/tests/d2_client_unittest.cc
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
src/lib/dhcpsrv/tests/dhcp_queue_control_parser_unittest.cc
src/lib/dhcpsrv/tests/flq_allocator_unittest.cc
src/lib/dhcpsrv/tests/lease_file_loader_unittest.cc
src/lib/dhcpsrv/tests/lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/memfile_lease_limits_unittest.cc
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/multi_threading_config_parser_unittest.cc
src/lib/dhcpsrv/tests/srv_config_unittest.cc
src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc
src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc
src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc
src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc
src/lib/dhcpsrv/testutils/test_config_backend.h
src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc
src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.cc
src/lib/dns/zone_checker.cc
src/lib/hooks/hooks_parser.cc
src/lib/hooks/library_handle.cc
src/lib/http/basic_auth_config.cc
src/lib/http/tests/post_request_json_unittests.cc
src/lib/log/logger_impl.cc
src/lib/mysql/mysql_connection.h
src/lib/pgsql/tests/pgsql_connection_unittest.cc
src/lib/pgsql/tests/pgsql_exchange_unittest.cc
src/lib/process/cb_ctl_base.h
src/lib/process/config_ctl_info.cc
src/lib/process/d_controller.cc
src/lib/process/tests/cb_ctl_base_unittests.cc
src/lib/process/tests/config_ctl_parser_unittests.cc
src/lib/stats/context.cc
src/lib/tcp/tests/tcp_listener_unittests.cc
src/lib/tcp/tests/tcp_test_listener.h
src/lib/tcp/tests/tls_listener_unittests.cc
src/lib/util/tests/thread_pool_unittest.cc
src/lib/util/thread_pool.h
src/lib/util/unittests/testdata.cc
src/lib/yang/adaptor.cc
src/lib/yang/adaptor_pool.cc
src/lib/yang/tests/adaptor_config_unittests.cc
src/lib/yang/tests/config_unittests.cc
src/lib/yang/tests/translator_utils_unittests.cc

index 218ee21c568e9b53a5b6319bd10ed2061f7eaddb..9c863656d6904871680150555be89f0dd64af365 100644 (file)
@@ -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);
         }
index 166d6f99aa0906997e74a7647b1e6c2839910634..6d86b1152da46e46e1f0484e1839883649f02a25 100644 (file)
@@ -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")) {
index 7190fbdd1b587284f3b11fba02798af26ecf38bc..71bbba5457729dda65c7890f54e42eac2bd7f64a 100644 (file)
@@ -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")) {
index 5e2a448f46217343ae95b18c5da3d212574bf6b1..d2914b46f6525180f0bffc13bb2bad366fa5cb2d 100644 (file)
@@ -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)
index 612e8aa58b73d1bd8076234e2635edcd6456ef19..4761c91ba1a3e355d977ef1fd547483df7d00a79 100644 (file)
@@ -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) {
index 811192c41fb657835da6765ad416a433d401ebbb..b26cfc4e05b56f334909dd79b856faa75f6bcd71 100644 (file)
@@ -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 "
index a0dde7828d5b582670d0641c6a382ceea17446d8..bc19bbc20d64d5f715b9301315164cc5204bc3e9 100644 (file)
@@ -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
index 3be1090ad3d7a1db1d349fced4fcae644c10fc8e..fc3e6ca5efed3d03d298016a77ec9256260ecf28 100644 (file)
@@ -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));
index d7e92bcb6b9b4595df5d25850eddd047ad18274b..24ad943f4bf6e1459b3c35d90278cce1fdfe707b 100644 (file)
@@ -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.
index 5ab9a9a295f78d5d6c5b4bfab0559261b2e2da76..0973a74d5ce4e31eac84bfefbbb7564325a7a132 100644 (file)
@@ -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" } )"}) {
index 48c92783cd115f11e56da9e0ef4b013e1f6e6fc2..c3a88cb53e696a6d98f87b6eaa612351f460b2ea 100644 (file)
@@ -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")) {
index 67bac00040593201ce3bf5aa9d04d61eaddaa64b..bf5964dc1e5663b853e87e479b46b1e2fe6bb933 100644 (file)
@@ -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);
index 44553b5a93b7dac326baab922d2b00e87b88c397..46e9789d25d73562075d2fe4b7fc6174103ba83d 100644 (file)
@@ -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);
index feb4b02f8474f4c31457adbd227af12e2aac7b8e..035f3a93149ddfafa43506370017880ed3e2eea3 100644 (file)
@@ -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)
index 6024cdd2dffc7403f4c78b36feaaf057ef642797..ad4f94a940efdb7cbd1cd34ad4b66b2a4944961a 100644 (file)
@@ -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;
index dbd4291e855c209a4de361bce5a28127b2fb0df8..47a8f3f1001328501af0f72357a18e55df5f0831 100644 (file)
@@ -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 "
index 8ef97b887b107715099cd8fda6a6fe22068c3dbb..a3fd0cd15d776bbf4a74632a65e9dd5282c1f9c5 100644 (file)
@@ -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
index 4a70d6b525b2d9d12d46d80e5142deecde46a1d8..9b595874e33be05b83af24628250b29cd633e686 100644 (file)
@@ -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_);
         }
     }
 }
index f3b93930d367f4f8a7e60189337296097764a738..c29f5d1c7200be29fc7e21e5f084ac1890a83c19 100644 (file)
@@ -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,
index bdf876d0f24274f30679f484c7e63cc3a1415a92..d72464de6df0397c673ba677af068d71c5dc00d0 100644 (file)
@@ -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" } )"}) {
index d7f45f52194fbcc1e4996d35cc0002c579963435..b0218233af5a6c39be7c9626a9c918ec87f574d3 100644 (file)
@@ -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")) {
index 0cbc224752e5da81c8a76e90ba5e9b1284890e5e..593bf7b00048149ca445bce3a9a8095da528967f 100644 (file)
@@ -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);
index c515dec4ea06a56809b6e6572233b57cb2640e0f..a9091bf02bf09fa72cbc308f633a6c51310dbe43 100644 (file)
@@ -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)
index 019bfaf554ac3c3092317f0563d9593db51e0cfe..55c6adaeb0e963ffb50cb132a939577bc0d6fc25 100644 (file)
@@ -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);
     }
index 0e7b8f808a5c9b77abaac8571f753c466bc9de6a..fefa996c400108367a887e7e6e946e5ed869dc24 100644 (file)
@@ -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));
index 897e2921de408ac511f82e18d49cc13aded0d5e1..05e7ebb50f91efc8d08838d96c7a2dc7af7d4e6a 100644 (file)
@@ -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());
index d4ef6c1d357ebe634478fb7b9a122885e6f5905b..852b5acbfa960953253b61622965847a1216da34 100644 (file)
@@ -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")) {
index aa67796a1deeea952dc96d622cbf8625e828e413..ba69e82ef6fcd969c047b0ed57c3e7cadb360b88 100644 (file)
@@ -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_;
index c15153b6e3a2dbdc8f19dcfa99915ae918a941f6..47165552b7cb9d9fee5075b8387b1f9ac7837fa6 100644 (file)
@@ -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);
     }
 }
index aa6edd9211caf4c9dd9e77d54594058caa538746..b27f937489151e15d742419b09e53ce45d42f943 100644 (file)
@@ -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 << "'");
         }
index e26b437ed9554492dd52cd2480d67e8a0807afd8..55fc4a71a20c24cd1e94292fb71a6fc431976149 100644 (file)
@@ -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();
index 1c72ee287b3d19c7e9def316a0ed695e6ae0b98a..abde103f97546d6163bf061336a10ab0a28f4718 100644 (file)
@@ -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);
index 7b8106e3944c5f7072819a2e7dfaf118d711e6fa..6e4662786a46d6945e8fa28bea43061ebc892b06 100644 (file)
@@ -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");
index c6f546156a19a30c69f657e5cbb6ea9642c10d46..ac3fea0e688353d45030d01ef3ece989349f6b5d 100644 (file)
@@ -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);
index 9990258ef211d3fb0d0df62583fc4de2c25ec6e6..a902f2c105274b1e3b6075120ae4dab9b3f58b21 100644 (file)
@@ -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;
index 55c0bed64742c47ff3d869e24d9decd0aee6971d..09f72ca265942a3da34a399905e71c5ae995aa91 100644 (file)
@@ -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);
index 36df83e94d0fef2cdc420a3d54cdbbc2ea4b364d..2fb05645f828cda33e2cd8336bbc5c96802888cb 100644 (file)
@@ -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;
         }
index 5e5b7b3a44623407dc4596f105c7c0b94bf97fb4..b2538ebdb53a70edc64719b60bff16acd4dd6b0d 100644 (file)
@@ -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]];
     }
 
index 8c33c094ed9375d946205fba39817069d15d0ec0..52d1780b3ff26af483192950ec351c7cde8232bc 100644 (file)
@@ -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);
     }
 }
index 4c4639d4fa8ebe68ebf80a5c790076f5c73e51ee..800d31a2cd956651d7fe7812a401403f6dc699cf 100644 (file)
@@ -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_)
                 << "'";
index 444b4be0240a92f6d5a39c0eca9e9bbcbf5ec261..c01874563d67524ebc54e8c39941630fbbb8971f 100644 (file)
@@ -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.
index 181042b8c4f48755202f3af1cbf9395baf6b3aad..bc5e953fa5c93d9a9a2f9e28cab13d00d49f1141 100644 (file)
@@ -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.
index c89c1316cd28b16f560bfea26391b33f7c3c5499..992ee5740f398895108112f5c8e897cbac11c474 100644 (file)
@@ -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);
         }
     }
index 2f290faad705a1d7a3e43b95c8925c556a9e4f3f..c32babe9f90ecba22b6db4039ff94919fa51ec58 100644 (file)
@@ -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);
         }
     }
index cf080f891468e7771e47ddc72af041a2c9d33653..13284b25480a027d24513dbb7e3b140c68c192cc 100644 (file)
@@ -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() ?
index 78eb87bd640dd18731dcc86cf9bcdf97c9b71e25..8592ecf955188e3d5ba12d4786787f28672ba082 100644 (file)
@@ -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);
         }
     }
index 4e7b77056f8b0571e4d3840baed9280d96e73a46..71eb9fa91f04a1f2172274bf9fefdb5ba277e0d4 100644 (file)
@@ -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);
         }
     }
index 06dff3f3e1e2d1e046d47010dafcf73f5c09fa23..899f912613d2e55029d2b0488280c25c37ff6f67 100644 (file)
@@ -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);
         }
     }
index 2732f7a62c31aae229f0df5020a6506b676ef2bc..a3e1534b4165f381b30386935d6731cbc7fd07fe 100644 (file)
@@ -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)));
     }
 
index aaa76b6056f08c2050a05182146cc8983a8111da..e449cb763c46076592ce6b7e96d07dbf851f6a2e 100644 (file)
@@ -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);
         }
     }
index 5dc284157ebdc90e0dc7a59997e55ed7f4f069d6..33255f0f80287d2704a0da4bea95c7bf5c6a2ab3 100644 (file)
@@ -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);
index 8919385cffd67a8f58e0e6135cdd0b4bc64c35a2..8a4488074e1b1b83e606177acb76b19ab35d4f97 100644 (file)
@@ -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);
         }
index 0ea03bcd48421a547c879364489beaf68a4b3e87..50b390621def1a35658fc20980398a160b353abe 100644 (file)
@@ -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) &&
index 9b13bcea5ca4e9197035cb3a6627279ddf54216e..83504628446ed857927b76ca8e42369d3d7114a4 100644 (file)
@@ -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) {
index 8140d133793e25deef7bd5de805b2ad991ec596c..e0baa31fd1c7c3cd9bb53616141d4638dc5d89b7 100644 (file)
@@ -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;
index 3c53b3826f4b91d5a094f069cabe4befe0339afc..93915d63ca9b1b8852e4026b6a086e739cd6fe58 100644 (file)
@@ -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()));
     }
 
index 1c836771a06d79ab27a09dc185bcb7362aab9f7d..55ed91d01e15fdca145bb595e32fa3221eedc58a 100644 (file)
@@ -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) &&
index 09645e3e5c8a0abd798ca27ca5c827258d8bd6d6..7a4fad632ca490cad517efeb4c53cabbac2ffc38 100644 (file)
@@ -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);
             }
index d0bf207277bd01b5c8d5cc054ea887dcae9a8156..43bdfaaae6703e015b28b7f1957a350325462e4c 100644 (file)
@@ -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;
 
index e31ae7a1a1bc7263398f31e644d0e146acf0ce5c..f6e70eacaf3f391ac08feed34f5cbb3d5be3be1a 100644 (file)
@@ -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).
index 18fbdbd0feb428a170657d2b0f53abb8cf827577..09e39a6e857c3a61c33455cf3ecad718f4b549cb 100644 (file)
@@ -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));
     }
 
index b34f2e8fa6ac2b0e824df2ac85801941bb87a518..ff37ef95ffbd56177e951d2447033dca10d128a5 100644 (file)
@@ -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));
     }
index 7b0be454f1ac26c47db44c9fd0915d098c137ff9..9f1461604ebcdfe785a066fe874b94d6b9712e61 100644 (file)
@@ -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);
index 1a023445bd2eb99601167663b516b6f13c3e85f3..6303e9ea1f7c9893a3cabe193dff8dbd220849b2 100644 (file)
@@ -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,
index 5512a96b1050e97facf8152ce24be1f5154ad7e1..a9bdb69d7a0a51dbefebb7b14f1b1ea26294cbb1 100644 (file)
@@ -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)));
index b859886d3dde89d5ed95e36da348763fd5308f16..c87402136c6b7c38bf9efa424d9f3bd8f7597a57 100644 (file)
@@ -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);
     }
 }
index d1c2952cb697b95329faa6018793a2fd124356af..017eeec695809e69ff9460f1a928960f7153caad 100644 (file)
@@ -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);
index 6ab5894250cd14fb176e86ede9941a262cc10047..eb800f90aeea55f2652a04c3ffd00e2fea9d4c34 100644 (file)
@@ -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;
         }
index 82b877aca2de975308a80dbcbd20843d3c5f8f6f..a0a7a28f01d372e2a6ae7f2477c3eb55c1da984c 100644 (file)
@@ -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;
     }
 
index 41b7799d577d39275f9b3e8f27f7724a9a221dd8..bcbc87aa4e6874804ce78ee1b87a742135125a57 100644 (file)
@@ -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
     }
 
index 953a67a0bbc4dbed86f517b0cdc6db8ce5900547..caee2d2fdb2bb121744ea29e67d821d9bfd768e6 100644 (file)
@@ -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());
index 8097e5ffc4ead00809ed9edaa89b87007e54e12a..4819e3be6ae2cb092e08d8c02ef3f3639dbcd655 100644 (file)
@@ -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())));
index 1b263f30b507f3a6894ce51bebd6eb0acb5ca855..febf9882854521d9def8da3397858e1cf9d678db 100644 (file)
@@ -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;
index e129a4f482086cb131ea68ab5c37d4f6e17191fd..16f523cadaec9e7d84680fa2fa2a2c82fc87d551 100644 (file)
@@ -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);
         }
index 9a241dfa9fe9bfd576afdf5d934cd083cd6fed26..4c1cddc069126d1148efbe989a7bd16cced8a276 100644 (file)
@@ -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();
index 02de922ee111ba2fbbf27cef2715bd46d1e17666..e154d1944184ee576a9d42da94ad3b2914cdaf6e 100644 (file)
@@ -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);
         }
     }
 
index 5241269cfabc127910a5725b4d9c9f90528e7326..3e7c58bed513a906caf772bac10b981741265029 100644 (file)
@@ -619,7 +619,7 @@ CfgSubnets4::updateStatistics() {
 
 void
 CfgSubnets4::initAllocatorsAfterConfigure() {
-    for (auto subnet : subnets_) {
+    for (auto const& subnet : subnets_) {
         subnet->initAllocatorsAfterConfigure();
     }
 }
index f1725ae16c30f2722c62c578757151488916863d..bf2b6be5195a500deb38e71ed1d7f157e4e7b8ed 100644 (file)
@@ -565,7 +565,7 @@ CfgSubnets6::updateStatistics() {
 
 void
 CfgSubnets6::initAllocatorsAfterConfigure() {
-    for (auto subnet : subnets_) {
+    for (auto const& subnet : subnets_) {
         subnet->initAllocatorsAfterConfigure();
     }
 }
index a5c92aaade08597b19f456c9824c9469584d809e..168288343cf710bb2deb3d5d5e9f77126f863ddf 100644 (file)
@@ -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);
         }
index 0cede454c8746f3d9b87fb75e12bb524017cb11a..d645b5274aeda6a5898dad16b12fe4f1742674d6 100644 (file)
@@ -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
     ///
index 8da982f6c1b9d08b00f9343c44171d6dbce893e4..088283eac3597e3ed0a177f3b7f0874d5c3210d0 100644 (file)
@@ -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;
index fa27d08f8fa99256310246065e10c37dc2b7c122..374df12c3bb4f7d9364776a8fdf8d18558709ac9 100644 (file)
@@ -167,7 +167,7 @@ void
 HostDataSourceFactory::printRegistered() {
     std::stringstream txt;
 
-    for (auto x : map_) {
+    for (auto const& x : map_) {
         txt << x.first << " ";
     }
 
index b81181af6b04befd529c4aedc6744f7e4ffc83ac..47997a968da58a860a05143dd8b97b159d12643f 100644 (file)
@@ -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);
index 9287f1d28fc67c54dd600d1fe67555ed575b4ac7..00a3200341d5210aa896db045e01d749de32273b 100644 (file)
@@ -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") &&
index 577f6943d3ec9bd59838674adf0cfd6958dbe744..42d754c757640335e824556033d2a61782c7d642 100644 (file)
@@ -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;
index c33482b460dc7e83619f04813f96f9f38f8f59a9..9a7092e7e5ad108a7062bb737f849f8249debb2b 100644 (file)
@@ -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_;
index 521d9ed82b687ff8a28bb0268d9e840c39e1fff1..98f99673bd5b86c289ea84c0dbf1aff8976acc74 100644 (file)
@@ -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);
         }
index a62af4d9f781bb866e9df48c8d1bc705e8d9519d..d84ca12a10c8eae0f81865f241a70f65e205f823 100644 (file)
@@ -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))) {
index 751ca094d2e169afe57ee86c902f0dd84e16060c..ed89b3b5f287424d1fded38c7b58d6799cdfd762 100644 (file)
@@ -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
index b4e7ff35a25454f0adb2455dfd1efdb7f3476b1d..a2d3fa4701376c554e45d76c881b100dc4c1caec 100644 (file)
@@ -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_;
index 4d4643b94d36434eb60f6b610314fdd9b7b38ef9..5298078f6c799e23b052ae05ab5e1641821cd1b6 100644 (file)
@@ -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.
index 9ae2ee55b747875ff3de27c67b0e16d315d6e200..4ba4dae7c7c89704fd64b8c6f71bbd7cf15115b1 100644 (file)
@@ -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();
index 750b0797c963a915f5c4f4c0b1f6547df2d010a0..5783eac252b644708d4161f7940281ea6aa3e312 100644 (file)
@@ -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.
index d0a380d7a20a6ebf459cbca4da27ac2b94016676..0477fc17b118456b85ebb819fd2a61b14427a41a 100644 (file)
@@ -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") {
index 327a036861b70b228a948882ac7e39db60cf01dd..370248b143bc9588302cf7a56cb9714530df3dcf 100644 (file)
@@ -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);
             }
 
index 68a0fd4848817beff34b9f860c6ce9bd9e1d6527..59b76468932fa74f9ac424899a3b95846fdd2f59 100644 (file)
@@ -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";
index f737d92863a002caaec3e3126b1ad14ded7bd363..52ba662b273b04f744be8dc4374e91c384f4c6be 100644 (file)
@@ -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;
     }
index de33f1ad47ff3ebc82037cdfe30c8bfb50d2bfbf..2915b17b896eba91755d527e589f0ea3d98f5cb5 100644 (file)
@@ -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;
     }
index 7d0cf79527c09c9a3298a226729ecf2a9a919346..e4e6ce2ca01fea10953d533dd443a4f39694bc8a 100644 (file)
@@ -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\"";
index 8fc5aed213d2fc984336f3cd6b6e0f0d8f1d7db3..bb7b2f67a9f66937b2604e41a9290edc2c80c8e6 100644 (file)
@@ -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());
     }
 }
index 0ae23144e0e880600cd29221106d184ac97a2ba7..c3e0e6144ef5b0dcf78c26990c88ba6bd2a5c7e6 100644 (file)
@@ -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_);
index e893ce75792eee8f619c8ca0f3d3a8bfeaa22c50..84f429a6e106bda44a0d906bb598e8717f20342a 100644 (file)
@@ -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.
index 4f617f671d41b922e750a3fa9377c9bbf5ddc67a..c459e0be7c82bd8d967bc61640da33e7d9b7eb09 100644 (file)
@@ -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
index 350106f11b0f8b7dd2e28d1f19ed925a8b1b0238..5a2fe8348e99ea950788fe47b3f142cf6f8a6ff0 100644 (file)
@@ -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;
index 5cb49a71a00b706574d7e403bc299b541a5d0a1a..b7a528ea10960acdba0edb6426cf044b0fb715c6 100644 (file)
@@ -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;
     }
 
index 1bc8428fb55bf1ff82e992d16020d0ef7571d095..9f6fdd06cc6b6adafdab7e76c4ece0c6dc056fa5 100644 (file)
@@ -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.
index 5344a4b1cc853d33cda1b32fb77f89fde11ee3ba..f13ae56a059806043cea04c4cf5be521323bf91b 100644 (file)
@@ -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()) {
index e0a211bddd8f69755c8bd9f64b9dc229b5703112..f34b308dd60ef1032c95bec25a8d9e6a967e0eab 100644 (file)
@@ -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));
     }
index 223c4d3dee137883fb25917e892874b2a97b2c89..2334cc5a6d8f29e6cd33f6b60d37ea570b90459f 100644 (file)
@@ -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;
index 3cf7032c41d0c50c59e54ffeb231b43a052f7eb3..77673c407438851a73c0695d1efa90951842dd41 100644 (file)
@@ -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;
index 505813d95817c4c34a617f9037c3ee5ecc394add..8ab8df761686905ddb1e14d9d6ab20d03b6b8a0c 100644 (file)
@@ -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) {
index 522400920e371112c9da9e31fa29a6f011b07a01..584f2998ec5db19e60920aa500a34efac7ec1312 100644 (file)
@@ -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) {
index 1dbc92026db68fc67da59c95f23bff5991f86666..0920bc4bbad471797242225de68b735fdea26dd3 100644 (file)
@@ -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;
index bcc671097f8d7a1bf3b292e672842315699818a0..9e1d87c9eb351e268492fe53b709a967d6652d5a 100644 (file)
@@ -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));
         }
 
index d78f97f8fd57b9c288efa17d291ccf8eb46d3f31..f6f4e5e2beb9b9c5ceb1d91a7cf4ae8869a2c4ca 100644 (file)
@@ -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());
         }
     }
index 8648d97f295ed0e36555a4b49e65869b482d88aa..a3cfcbd1c8fee05c5fb8625ce6667b3215a9cef2 100644 (file)
@@ -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;
index e59ad5dd668cef0ea5e3c3a2456be1022ae71028..cd9045bfe3c2773dd417672e6e87744d4350de46 100644 (file)
@@ -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;
index def989627f34560c7d0d1f6730abe0351b9e924d..09f153899bf6e716f483c255e58c11c22d382e1c 100644 (file)
@@ -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) {
index cfd4a7e8f52b8b5d5e159cf0966c8a8519e02dbb..976f6a0bd00e6c89f991cf9cd713b0a3d084b64e 100644 (file)
@@ -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"
index b070448e7a7f1246c95212cc5f8502dacb65460b..88cda6f3e4e89c7809ca57467720d8cba6739a17 100644 (file)
@@ -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);
     }
index 0c98a4a3c3b386adc938d1b40ecdb5607ae60bbb..1d70995e329b267b23f9f66cd804956768290071 100644 (file)
@@ -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() << ")");
index bb717cd1cd7ed7608fb3fefd63ffbdba741dc75a..2fa478268066e69ecfdd894cb79140ca6b5b31aa 100644 (file)
@@ -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.
index f0e52981aec05d719d965c72c64cd7b8a5dc8c02..4e2d7b603e635236594ddffbb6b202b6e76c52d0 100644 (file)
@@ -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;
index c66da05dfacb9a202f698444798e9d302e05f4a8..5aefae8de4a5694f8cccb82517527dd83332c09b 100644 (file)
@@ -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());
         }
 
index ab09009f19127ab934a2268f9c4939eab74657fd..871a2649927a54ddf8f11bc6e3bf6629628cebd2 100644 (file)
@@ -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;
index 7bbf747d8f791cd66159b8c9ef76f574aa1dbaba..ae9a2f2c7dc9bffe9b85e7e66d88414525837f8e 100644 (file)
@@ -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));
index ecbb73610cf2e62e0b0f2ba392011342663cbb9f..28a3457d3351920b698d1e2db87a4cbeac0f15a7 100644 (file)
@@ -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);
index 5c6aca7ca6eae9bc24285671eba0821692f65db6..b7b87a388fcd35b9a9de68ef1a55868459b9f4c7 100644 (file)
@@ -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());
     }
 
index 9b8f65edc494672686014c1d12ab9f3e2baf7eab..d6f14d1ea92717853efa2de7b97aa8a9d715082e 100644 (file)
@@ -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;
index 58d0aa065f9fc45cc6ba695126f1326d57b69aa1..6c6710944c6eb31c3c9ecec005b73f851036ff5b 100644 (file)
@@ -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()) {
index 8e5b328fdf976a346dcf319cd23ee0f5f9556144..eecc28c5be169d9a49327130f1054fce4cc57227 100644 (file)
@@ -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.
index 3675df9fbe214ba78bb2a6bb4eec0d8e4126ae81..2a560efafd1c2925dd7e0ccd2dc74d2019cc077d 100644 (file)
@@ -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);
     }
index 31b611ba9f908ab53fb27384b41437ac456d47ef..b04475aff4036593f263cd07d15c3de94644a569 100644 (file)
@@ -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());
         }
index 5522484a84832dd71f3be592120db3caaa4ffb1d..cc13d42c02c1e7a2719d8957a64ac718cade1dcb 100644 (file)
@@ -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;
         }
 
index 9d3fbdb8203a51cb63b8789303cef8305824bee3..c5a7d424c3eb49a20c1d3becab5094150387ddc9 100644 (file)
@@ -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());
index 270deefa1db9458b38b5cc65839437615cf3060a..0c0df198f641b9a3192a4c599a4c6369b3d74f38 100644 (file)
@@ -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);
index 82f6300dfe4b010674200b5786227582a4a37099..379cb93b641d49f7856f491b3bc73aff204e0347 100644 (file)
@@ -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);
             }
index e3ecc916db3a8bb5e7fc77533d1567f875f31bc1..111cc37204057ab4be58cd60ccfc6f8bb5705423 100644 (file)
@@ -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('/');
index 5e2de98da446b6646c171af6cd83d0a3a9a22e73..a4e2c7aac6ef98bca273ea1471b56b5012915e9a 100644 (file)
@@ -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())) {
index 6d9aeaee287433e53b2ee287dcd265707ad69edf..fd2ebf7629b5f15f0231e164bcba2ed8f1b0b464 100644 (file)
@@ -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 == '-') {
index 2109890c58dcd8b339c54fabb39edb720c4622aa..2baaa1ac0972bd85a4a581ecd9b50af18ba1e5f4 100644 (file)
@@ -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);
index 6ffe0afa2f092b44afa66b7d66354b92e6420a9d..cb7396ca391ec85bd3748fa9e75fe001da8e3067 100644 (file)
@@ -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);
index ddd4cb91e11695d3f46260880adfbf982c5bdd84..11f3c4ab25f4e4918000742885c9f15c3ea0c298 100644 (file)
@@ -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);
     }
 }