From: Francis Dupont Date: Wed, 18 Apr 2018 17:43:44 +0000 (+0200) Subject: [5591] Fixed all spurious captures by lambdas reported by last Xcode X-Git-Tag: trac5382a_base~7^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7bed3ef5357c19fe8802a112279e24e67df505b9;p=thirdparty%2Fkea.git [5591] Fixed all spurious captures by lambdas reported by last Xcode --- diff --git a/src/bin/dhcp4/tests/kea_controller_unittest.cc b/src/bin/dhcp4/tests/kea_controller_unittest.cc index 8f72c24710..5b843fde7e 100644 --- a/src/bin/dhcp4/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp4/tests/kea_controller_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -91,7 +91,7 @@ public: /// @param timeout_ms Amount of time after which the method returns. void runTimersWithTimeout(const IOServicePtr& io_service, const long timeout_ms) { IntervalTimer timer(*io_service); - timer.setup([this, &io_service]() { + timer.setup([&io_service]() { io_service->stop(); }, timeout_ms, IntervalTimer::ONE_SHOT); io_service->run(); diff --git a/src/bin/dhcp4/tests/shared_network_unittest.cc b/src/bin/dhcp4/tests/shared_network_unittest.cc index 47005f3f3a..7afcbe2077 100644 --- a/src/bin/dhcp4/tests/shared_network_unittest.cc +++ b/src/bin/dhcp4/tests/shared_network_unittest.cc @@ -1311,7 +1311,7 @@ TEST_F(Dhcpv4SharedNetworkTest, poolInSharedNetworkShortage) { // the server has no more addresses to assign. Dhcp4Client client3(client1.getServer(), Dhcp4Client::SELECTING); client3.setIfaceName("eth1"); - testAssigned([this, &client3]() { + testAssigned([&client3]() { ASSERT_NO_THROW(client3.doDiscover()); Pkt4Ptr resp3 = client3.getContext().response_; ASSERT_FALSE(resp3); @@ -1447,7 +1447,7 @@ TEST_F(Dhcpv4SharedNetworkTest, hintWithinSharedNetwork) { // Asking for an address that is not in address pool should result in getting // an address from one of the subnets, but generally hard to tell from which one. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doDiscover(boost::shared_ptr(new IOAddress("10.0.0.23")))); }); @@ -1481,7 +1481,7 @@ TEST_F(Dhcpv4SharedNetworkTest, subnetInSharedNetworkSelectedByClass) { // Release the lease that the client has got, because we'll need this address // further in the test. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doRelease()); }); @@ -1770,7 +1770,7 @@ TEST_F(Dhcpv4SharedNetworkTest, variousFieldsInReservation) { configure(NETWORKS_CONFIG[10], *client.getServer()); // Perform 4-way exchange. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doDORA()); }); Pkt4Ptr resp = client.getContext().response_; @@ -1816,7 +1816,7 @@ TEST_F(Dhcpv4SharedNetworkTest, sharedNetworkSelectionByInterface) { configure(NETWORKS_CONFIG[8], *client1.getServer()); // Perform 4-way exchange. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doDORA()); }); Pkt4Ptr resp1 = client1.getContext().response_; @@ -1831,7 +1831,7 @@ TEST_F(Dhcpv4SharedNetworkTest, sharedNetworkSelectionByInterface) { client2.setIfaceName("eth0"); // Perform 4-way exchange. - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doDORA()); }); Pkt4Ptr resp2 = client2.getContext().response_; @@ -1853,7 +1853,7 @@ TEST_F(Dhcpv4SharedNetworkTest, sharedNetworkSelectionByRelay) { configure(NETWORKS_CONFIG[9], *client1.getServer()); // Perform 4-way exchange. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doDORA()); }); Pkt4Ptr resp1 = client1.getContext().response_; @@ -1868,7 +1868,7 @@ TEST_F(Dhcpv4SharedNetworkTest, sharedNetworkSelectionByRelay) { client2.useRelay(true, IOAddress("192.1.2.3")); // Perform 4-way exchange. - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doDORA()); }); Pkt4Ptr resp2 = client2.getContext().response_; @@ -1892,7 +1892,7 @@ TEST_F(Dhcpv4SharedNetworkTest, matchClientId) { configure(NETWORKS_CONFIG[11], *client.getServer()); // Perform 4-way exchange. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doDORA()); }); Pkt4Ptr resp1 = client.getContext().response_; @@ -1909,7 +1909,7 @@ TEST_F(Dhcpv4SharedNetworkTest, matchClientId) { client.setState(Dhcp4Client::RENEWING); // Try to renew the lease with modified MAC address. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doRequest()); }); Pkt4Ptr resp2 = client.getContext().response_; @@ -1936,7 +1936,7 @@ TEST_F(Dhcpv4SharedNetworkTest, sharedNetworkSelectedByClass) { configure(NETWORKS_CONFIG[13], *client1.getServer()); // Simply send DHCPDISCOVER to avoid allocating a lease. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doDiscover()); }); Pkt4Ptr resp1 = client1.getContext().response_; @@ -1969,7 +1969,7 @@ TEST_F(Dhcpv4SharedNetworkTest, customServerIdentifier) { // Configure DHCP server. ASSERT_NO_THROW(configure(NETWORKS_CONFIG[15], *client1.getServer())); - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doDORA()); }); @@ -1986,7 +1986,7 @@ TEST_F(Dhcpv4SharedNetworkTest, customServerIdentifier) { Dhcp4Client client2(client1.getServer(), Dhcp4Client::SELECTING); client2.setIfaceName("eth0"); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doDORA()); }); @@ -2020,7 +2020,7 @@ TEST_F(Dhcpv4SharedNetworkTest, poolInSharedNetworkSelectedByClass) { // Release the lease that the client has got, because we'll need this address // further in the test. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doRelease()); }); @@ -2079,7 +2079,7 @@ TEST_F(Dhcpv4SharedNetworkTest, poolInSubnetSelectedByClass) { // Release the lease that the client has got, because we'll need this address // further in the test. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doRelease()); }); diff --git a/src/bin/dhcp6/tests/kea_controller_unittest.cc b/src/bin/dhcp6/tests/kea_controller_unittest.cc index f737051307..62ef1ba4fb 100644 --- a/src/bin/dhcp6/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp6/tests/kea_controller_unittest.cc @@ -78,7 +78,7 @@ public: /// @param timeout_ms Amount of time after which the method returns. void runTimersWithTimeout(const IOServicePtr& io_service, const long timeout_ms) { IntervalTimer timer(*io_service); - timer.setup([this, &io_service]() { + timer.setup([&io_service]() { io_service->stop(); }, timeout_ms, IntervalTimer::ONE_SHOT); io_service->run(); diff --git a/src/bin/dhcp6/tests/shared_network_unittest.cc b/src/bin/dhcp6/tests/shared_network_unittest.cc index b3081aa9a5..7ffe9fc24d 100644 --- a/src/bin/dhcp6/tests/shared_network_unittest.cc +++ b/src/bin/dhcp6/tests/shared_network_unittest.cc @@ -1398,7 +1398,7 @@ public: IOAddress requested_address = exp_addr1.empty() ? IOAddress::IPV6_ZERO_ADDRESS() : IOAddress(exp_addr1); ASSERT_NO_THROW(client1.requestAddress(0xabca0, requested_address)); - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSolicit()); }); @@ -1428,7 +1428,7 @@ public: // first subnet is already full (it's a really small subnet) and the second // subnet does not allow rapid-commit. ASSERT_NO_THROW(client2.requestAddress(0xabca0)); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doSolicit()); }); @@ -1538,7 +1538,7 @@ TEST_F(Dhcpv6SharedNetworkTest, addressPoolInSharedNetworkShortage) { // Client #1 requests an address in first subnet within a shared network. ASSERT_NO_THROW(client1.requestAddress(0xabca0, IOAddress("2001:db8:1::20"))); - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:1::20"))); @@ -1548,7 +1548,7 @@ TEST_F(Dhcpv6SharedNetworkTest, addressPoolInSharedNetworkShortage) { Dhcp6Client client2(client1.getServer()); client2.setInterface("eth1"); ASSERT_NO_THROW(client2.requestAddress(0xabca0)); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client2, IOAddress("2001:db8:2::20"))); @@ -1558,27 +1558,27 @@ TEST_F(Dhcpv6SharedNetworkTest, addressPoolInSharedNetworkShortage) { Dhcp6Client client3(client1.getServer()); client3.setInterface("eth1"); ASSERT_NO_THROW(client3.requestAddress(0xabca0)); - testAssigned([this, &client3] { + testAssigned([&client3] { ASSERT_NO_THROW(client3.doSolicit(true)); }); EXPECT_EQ(0, client3.getLeaseNum()); // Client #3 should be assigned an address if subnet 3 is selected for it. client3.setInterface("eth0"); - testAssigned([this, &client3] { + testAssigned([&client3] { ASSERT_NO_THROW(client3.doSolicit(true)); }); EXPECT_EQ(1, client3.getLeaseNum()); // Client #1 should be able to renew its lease. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doRenew()); }); EXPECT_EQ(1, client1.getLeaseNum()); EXPECT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:1::20"))); // Client #2 should be able to renew its lease too. - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doRenew()); }); EXPECT_EQ(1, client2.getLeaseNum()); @@ -1598,7 +1598,7 @@ TEST_F(Dhcpv6SharedNetworkTest, sharedNetworkSelectedByRelay) { // Client #1 should be assigned an address from shared network. ASSERT_NO_THROW(client1.requestAddress(0xabca0)); - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:1::20"))); @@ -1608,7 +1608,7 @@ TEST_F(Dhcpv6SharedNetworkTest, sharedNetworkSelectedByRelay) { Dhcp6Client client2(client1.getServer()); client2.useRelay(true, IOAddress("3001::2")); ASSERT_NO_THROW(client2.requestAddress(0xabca0)); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client2, IOAddress("2001:db8:2::20"))); @@ -1627,7 +1627,7 @@ TEST_F(Dhcpv6SharedNetworkTest, hintWithinSharedNetwork) { // Provide a hint to an existing address within first subnet. This address // should be offered out of this subnet. ASSERT_NO_THROW(client.requestAddress(0xabca, IOAddress("2001:db8:1::20"))); - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doSolicit(true)); }); ASSERT_TRUE(hasLeaseForAddress(client, IOAddress("2001:db8:1::20"), @@ -1637,7 +1637,7 @@ TEST_F(Dhcpv6SharedNetworkTest, hintWithinSharedNetwork) { // the same shared network when we ask for it. client.clearRequestedIAs(); ASSERT_NO_THROW(client.requestAddress(0xabca, IOAddress("2001:db8:2::20"))); - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doSolicit(true)); }); ASSERT_TRUE(hasLeaseForAddress(client, IOAddress("2001:db8:2::20"), @@ -1647,7 +1647,7 @@ TEST_F(Dhcpv6SharedNetworkTest, hintWithinSharedNetwork) { // an address from one of the subnets, but generally hard to tell from which one. client.clearRequestedIAs(); ASSERT_NO_THROW(client.requestAddress(0xabca, IOAddress("3002::123"))); - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doSolicit(true)); }); std::vector leases = client.getLeasesByType(Lease::TYPE_NA); @@ -1673,14 +1673,14 @@ TEST_F(Dhcpv6SharedNetworkTest, subnetInSharedNetworkSelectedByClass) { // Client #1 requests an address in the restricted subnet but can't be assigned // this address because the client doesn't belong to a certain class. ASSERT_NO_THROW(client1.requestAddress(0xabca, IOAddress("2001:db8:1::20"))); - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:2::20"))); // Release the lease that the client has got, because we'll need this address // further in the test. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doRelease()); }); @@ -1689,7 +1689,7 @@ TEST_F(Dhcpv6SharedNetworkTest, subnetInSharedNetworkSelectedByClass) { client1.addExtraOption(option1234); // This time, the allocation of the address provided as hint should be successful. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:1::20"))); @@ -1698,7 +1698,7 @@ TEST_F(Dhcpv6SharedNetworkTest, subnetInSharedNetworkSelectedByClass) { Dhcp6Client client2(client1.getServer()); client2.setInterface("eth1"); ASSERT_NO_THROW(client2.requestAddress(0xabca0)); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client2, IOAddress("2001:db8:2::20"))); @@ -1707,7 +1707,7 @@ TEST_F(Dhcpv6SharedNetworkTest, subnetInSharedNetworkSelectedByClass) { // subnet to which client2 now belongs. ASSERT_NO_FATAL_FAILURE(configure(NETWORKS_CONFIG[3], *client1.getServer())); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doRenew()); }); EXPECT_EQ(0, client2.getLeaseNum()); @@ -1716,7 +1716,7 @@ TEST_F(Dhcpv6SharedNetworkTest, subnetInSharedNetworkSelectedByClass) { // get renewed. OptionPtr option1234_bis(new OptionUint16(Option::V6, 1234, 0x0002)); client2.addExtraOption(option1234_bis); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doRenew()); }); EXPECT_EQ(1, client2.getLeaseNum()); @@ -1736,7 +1736,7 @@ TEST_F(Dhcpv6SharedNetworkTest, reservationInSharedNetwork) { // Client #1 should get his reserved address from the second subnet. ASSERT_NO_THROW(client1.requestAddress(0xabca, IOAddress("2001:db8:1::20"))); - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:2::28"))); @@ -1748,7 +1748,7 @@ TEST_F(Dhcpv6SharedNetworkTest, reservationInSharedNetwork) { // Client #2 should get its reserved address from the first subnet. ASSERT_NO_THROW(client2.requestAddress(0xabca, IOAddress("2001:db8:1::30"))); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client2, IOAddress("2001:db8:1::28"))); @@ -1761,7 +1761,7 @@ TEST_F(Dhcpv6SharedNetworkTest, reservationInSharedNetwork) { // because its lease is now reserved for some other client. The client won't be // assigned a lease for which it has a reservation because another client holds // this lease. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doRenew()); }); ASSERT_TRUE(client1.hasLeaseWithZeroLifetimeForAddress(IOAddress("2001:db8:2::28"))); @@ -1774,14 +1774,14 @@ TEST_F(Dhcpv6SharedNetworkTest, reservationInSharedNetwork) { } // Client #2 is now renewing its lease and should get its newly reserved address. - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doRenew()); }); ASSERT_TRUE(client2.hasLeaseWithZeroLifetimeForAddress(IOAddress("2001:db8:1::28"))); ASSERT_TRUE(hasLeaseForAddress(client2, IOAddress("2001:db8:2::28"))); // Same for client #1. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doRenew()); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:1::28"))); @@ -1803,7 +1803,7 @@ TEST_F(Dhcpv6SharedNetworkTest, reservationAccessRestrictedByClass) { // Assigned address should be allocated from the second subnet, because the // client doesn't belong to the "a-devices" class. ASSERT_NO_THROW(client.requestAddress(0xabca)); - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client, IOAddress("2001:db8:2::16"))); @@ -1813,7 +1813,7 @@ TEST_F(Dhcpv6SharedNetworkTest, reservationAccessRestrictedByClass) { client.addExtraOption(option1234); // The client should now be assigned the reserved address from the first subnet. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doRenew()); }); ASSERT_TRUE(client.hasLeaseWithZeroLifetimeForAddress(IOAddress("2001:db8:2::16"))); @@ -1836,7 +1836,7 @@ TEST_F(Dhcpv6SharedNetworkTest, renewalRestrictedByClass) { // Client requests an address from the second subnet which should be successful. ASSERT_NO_THROW(client.requestAddress(0xabca, IOAddress("2001:db8:2::20"))); - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client, IOAddress("2001:db8:2::20"))); @@ -1847,7 +1847,7 @@ TEST_F(Dhcpv6SharedNetworkTest, renewalRestrictedByClass) { // The client should not be able to renew the existing lease because it is now // prohibited by the classification. Instead, the client should get a lease from the // unrestricted subnet. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doRenew()); }); ASSERT_TRUE(client.hasLeaseWithZeroLifetimeForAddress(IOAddress("2001:db8:2::20"))); @@ -1875,7 +1875,7 @@ TEST_F(Dhcpv6SharedNetworkTest, optionsDerivation) { // Perform 4-way exchange and make sure we have been assigned address from the // subnet we wanted. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:1::20"))); @@ -1907,7 +1907,7 @@ TEST_F(Dhcpv6SharedNetworkTest, optionsDerivation) { // Perform 4-way exchange and make sure we have been assigned address from the // subnet we wanted. - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client2, IOAddress("2001:db8:2::20"))); @@ -1934,7 +1934,7 @@ TEST_F(Dhcpv6SharedNetworkTest, optionsDerivation) { // Perform 4-way exchange and make sure we have been assigned address from the // subnet we wanted. - testAssigned([this, &client3] { + testAssigned([&client3] { ASSERT_NO_THROW(client3.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client3, IOAddress("3000::1"))); @@ -1966,7 +1966,7 @@ TEST_F(Dhcpv6SharedNetworkTest, optionsFromSelectedSubnet) { // Send solicit without a hint. The client should be offerred an address from the // shared network. Depending on the subnet from which the address has been allocated // a specific value of the Name Servers option should be returned. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doSolicit(true)); }); @@ -1984,7 +1984,7 @@ TEST_F(Dhcpv6SharedNetworkTest, optionsFromSelectedSubnet) { client.clearRequestedIAs(); client.requestAddress(0xabca, IOAddress("2001:db8:2::20")); - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doSolicit(true)); }); @@ -1992,7 +1992,7 @@ TEST_F(Dhcpv6SharedNetworkTest, optionsFromSelectedSubnet) { ASSERT_TRUE(client.hasOptionWithAddress(D6O_NAME_SERVERS, "5555::33")); // This time, let's do the 4-way exchange. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doSARR()); }); @@ -2000,7 +2000,7 @@ TEST_F(Dhcpv6SharedNetworkTest, optionsFromSelectedSubnet) { ASSERT_TRUE(client.hasOptionWithAddress(D6O_NAME_SERVERS, "5555::33")); // And renew the lease. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doRenew()); }); ASSERT_TRUE(client.hasLeaseForAddress(IOAddress("2001:db8:2::20"))); @@ -2022,7 +2022,7 @@ TEST_F(Dhcpv6SharedNetworkTest, sharedNetworkSelectionByInterface) { // Client #1 should be assigned an address from one of the two subnets // belonging to the first shared network. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); if (!hasLeaseForAddress(client1, IOAddress("2001:db8:1::20")) && @@ -2037,7 +2037,7 @@ TEST_F(Dhcpv6SharedNetworkTest, sharedNetworkSelectionByInterface) { // Client #2 should be assigned an address from one of the two subnets // belonging to the second shared network. - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doSARR()); }); if (!hasLeaseForAddress(client2, IOAddress("2001:db8:3::20")) && @@ -2059,7 +2059,7 @@ TEST_F(Dhcpv6SharedNetworkTest, sharedNetworkSelectionByRelay) { // Client #1 should be assigned an address from one of the two subnets // belonging to the first shared network. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); if (!hasLeaseForAddress(client1, IOAddress("2001:db8:1::20")) && @@ -2074,7 +2074,7 @@ TEST_F(Dhcpv6SharedNetworkTest, sharedNetworkSelectionByRelay) { // Client #2 should be assigned an address from one of the two subnets // belonging to the second shared network - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doSARR()); }); if (!hasLeaseForAddress(client2, IOAddress("2001:db8:3::20")) && @@ -2099,7 +2099,7 @@ TEST_F(Dhcpv6SharedNetworkTest, variousFieldsInReservation) { ASSERT_NO_FATAL_FAILURE(configure(NETWORKS_CONFIG[10], *client.getServer())); // Perform 4-way exchange. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doSARR()); }); @@ -2145,7 +2145,7 @@ TEST_F(Dhcpv6SharedNetworkTest, sharedNetworkSelectedByClass) { ASSERT_NO_FATAL_FAILURE(configure(NETWORKS_CONFIG[11], *client1.getServer())); // The client 1 should be offerred an address from the second subnet. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSolicit(true)); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:2::20"), @@ -2161,7 +2161,7 @@ TEST_F(Dhcpv6SharedNetworkTest, sharedNetworkSelectedByClass) { client2.addExtraOption(option1234); // Client 2 should be offerred an address from the first subnet. - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doSolicit(true)); }); ASSERT_TRUE(hasLeaseForAddress(client2, IOAddress("2001:db8:1::20"), @@ -2185,7 +2185,7 @@ TEST_F(Dhcpv6SharedNetworkTest, assignmentsFromDifferentSubnets) { ASSERT_NO_FATAL_FAILURE(configure(NETWORKS_CONFIG[0], *client.getServer())); // 4-way exchange. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doSARR()); }); // The two addresses should come from different subnets. @@ -2196,7 +2196,7 @@ TEST_F(Dhcpv6SharedNetworkTest, assignmentsFromDifferentSubnets) { ASSERT_TRUE(hasLeaseForPrefixPool(client, IOAddress("5000::"), 96, 96)); // Try to renew. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doRenew()); }); ASSERT_TRUE(hasLeaseForAddress(client, IOAddress("2001:db8:1::20"))); @@ -2225,7 +2225,7 @@ TEST_F(Dhcpv6SharedNetworkTest, reservedAddressAndPrefix) { ASSERT_NO_FATAL_FAILURE(configure(NETWORKS_CONFIG[4], *client.getServer())); // 4-way exchange. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doSARR()); }); ASSERT_EQ(4, client.getLeaseNum()); @@ -2245,7 +2245,7 @@ TEST_F(Dhcpv6SharedNetworkTest, reservedAddressAndPrefix) { ASSERT_NE("1234::", leases_2222[0].addr_.toText()); // Try to renew and check this again. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doRenew()); }); ASSERT_EQ(4, client.getLeaseNum()); @@ -2277,7 +2277,7 @@ TEST_F(Dhcpv6SharedNetworkTest, relaySpecifiedForEachSubnet) { ASSERT_NO_FATAL_FAILURE(configure(NETWORKS_CONFIG[13], *client.getServer())); // 4-way exchange. - testAssigned([this, &client] { + testAssigned([&client] { ASSERT_NO_THROW(client.doSARR()); }); ASSERT_EQ(2, client.getLeaseNum()); @@ -2303,7 +2303,7 @@ TEST_F(Dhcpv6SharedNetworkTest, sharedNetworkSelectedByInterfaceId) { // Client #1 should be assigned an address from shared network. ASSERT_NO_THROW(client1.requestAddress(0xabca0)); - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:1::20"))); @@ -2314,7 +2314,7 @@ TEST_F(Dhcpv6SharedNetworkTest, sharedNetworkSelectedByInterfaceId) { client2.useRelay(true, IOAddress("3001::2")); client2.useInterfaceId("vlan1000"); ASSERT_NO_THROW(client2.requestAddress(0xabca0)); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client2, IOAddress("2001:db8:2::20"))); @@ -2336,7 +2336,7 @@ TEST_F(Dhcpv6SharedNetworkTest, sharedNetworkSelectedByInterfaceIdInSubnet) { // Client #1 should be assigned an address from shared network. ASSERT_NO_THROW(client1.requestAddress(0xabca0)); - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:1::20"))); @@ -2347,7 +2347,7 @@ TEST_F(Dhcpv6SharedNetworkTest, sharedNetworkSelectedByInterfaceIdInSubnet) { client2.useRelay(true, IOAddress("3001::2")); client2.useInterfaceId("vlan1000"); ASSERT_NO_THROW(client2.requestAddress(0xabca0)); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client2, IOAddress("2001:db8:2::20"))); @@ -2385,14 +2385,14 @@ TEST_F(Dhcpv6SharedNetworkTest, poolInSharedNetworkSelectedByClass) { // Client #1 requests an address in the restricted pool but can't be assigned // this address because the client doesn't belong to a certain class. ASSERT_NO_THROW(client1.requestAddress(0xabca, IOAddress("2001:db8:1::20"))); - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:1::50"))); // Release the lease that the client has got, because we'll need this address // further in the test. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doRelease()); }); @@ -2401,7 +2401,7 @@ TEST_F(Dhcpv6SharedNetworkTest, poolInSharedNetworkSelectedByClass) { client1.addExtraOption(option1234); // This time, the allocation of the address provided as hint should be successful. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:1::20"))); @@ -2410,7 +2410,7 @@ TEST_F(Dhcpv6SharedNetworkTest, poolInSharedNetworkSelectedByClass) { Dhcp6Client client2(client1.getServer()); client2.setInterface("eth1"); ASSERT_NO_THROW(client2.requestAddress(0xabca0)); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client2, IOAddress("2001:db8:1::50"))); @@ -2419,7 +2419,7 @@ TEST_F(Dhcpv6SharedNetworkTest, poolInSharedNetworkSelectedByClass) { // pool to which client2 now belongs. ASSERT_NO_FATAL_FAILURE(configure(NETWORKS_CONFIG[20], *client1.getServer())); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doRenew()); }); EXPECT_EQ(0, client2.getLeasesWithNonZeroLifetime().size()); @@ -2428,7 +2428,7 @@ TEST_F(Dhcpv6SharedNetworkTest, poolInSharedNetworkSelectedByClass) { // get renewed. OptionPtr option1234_bis(new OptionUint16(Option::V6, 1234, 0x0002)); client2.addExtraOption(option1234_bis); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doRenew()); }); EXPECT_EQ(1, client2.getLeaseNum()); @@ -2448,14 +2448,14 @@ TEST_F(Dhcpv6SharedNetworkTest, poolInSubnetSelectedByClass) { // Client #1 requests an address in the restricted pool but can't be assigned // this address because the client doesn't belong to a certain class. ASSERT_NO_THROW(client1.requestAddress(0xabca, IOAddress("2001:db8:1::20"))); - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:1::50"))); // Release the lease that the client has got, because we'll need this address // further in the test. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doRelease()); }); @@ -2464,7 +2464,7 @@ TEST_F(Dhcpv6SharedNetworkTest, poolInSubnetSelectedByClass) { client1.addExtraOption(option1234); // This time, the allocation of the address provided as hint should be successful. - testAssigned([this, &client1] { + testAssigned([&client1] { ASSERT_NO_THROW(client1.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client1, IOAddress("2001:db8:1::20"))); @@ -2473,7 +2473,7 @@ TEST_F(Dhcpv6SharedNetworkTest, poolInSubnetSelectedByClass) { Dhcp6Client client2(client1.getServer()); client2.setInterface("eth1"); ASSERT_NO_THROW(client2.requestAddress(0xabca0)); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doSARR()); }); ASSERT_TRUE(hasLeaseForAddress(client2, IOAddress("2001:db8:1::50"))); @@ -2482,7 +2482,7 @@ TEST_F(Dhcpv6SharedNetworkTest, poolInSubnetSelectedByClass) { // pool to which client2 now belongs. ASSERT_NO_FATAL_FAILURE(configure(NETWORKS_CONFIG[22], *client1.getServer())); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doRenew()); }); EXPECT_EQ(0, client2.getLeasesWithNonZeroLifetime().size()); @@ -2491,7 +2491,7 @@ TEST_F(Dhcpv6SharedNetworkTest, poolInSubnetSelectedByClass) { // get renewed. OptionPtr option1234_bis(new OptionUint16(Option::V6, 1234, 0x0002)); client2.addExtraOption(option1234_bis); - testAssigned([this, &client2] { + testAssigned([&client2] { ASSERT_NO_THROW(client2.doRenew()); }); EXPECT_EQ(1, client2.getLeaseNum()); diff --git a/src/lib/asiolink/tests/unix_domain_socket_unittest.cc b/src/lib/asiolink/tests/unix_domain_socket_unittest.cc index 62c16c9f3a..916e8dccea 100644 --- a/src/lib/asiolink/tests/unix_domain_socket_unittest.cc +++ b/src/lib/asiolink/tests/unix_domain_socket_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -168,7 +168,7 @@ TEST_F(UnixDomainSocketTest, asyncSendReceive) { // when the connection is established or if an error occurs. bool connect_handler_invoked = false; ASSERT_NO_THROW(socket.asyncConnect(unixSocketFilePath(), - [this, &connect_handler_invoked](const boost::system::error_code& ec) { + [&connect_handler_invoked](const boost::system::error_code& ec) { // Indicate that the handler has been called so as the loop below gets // interrupted. connect_handler_invoked = true; @@ -189,7 +189,7 @@ TEST_F(UnixDomainSocketTest, asyncSendReceive) { const std::string outbound_data = "foo"; size_t sent_size = 0; ASSERT_NO_THROW(socket.asyncSend(outbound_data.c_str(), outbound_data.size(), - [this, &sent_size](const boost::system::error_code& ec, size_t length) { + [&sent_size](const boost::system::error_code& ec, size_t length) { // If we have been successful sending the data, record the number of // bytes we have sent. if (!ec) { @@ -257,7 +257,7 @@ TEST_F(UnixDomainSocketTest, asyncClientErrors) { // Connect bool connect_handler_invoked = false; socket.asyncConnect(unixSocketFilePath(), - [this, &connect_handler_invoked](const boost::system::error_code& ec) { + [&connect_handler_invoked](const boost::system::error_code& ec) { connect_handler_invoked = true; EXPECT_TRUE(ec); }); @@ -269,7 +269,7 @@ TEST_F(UnixDomainSocketTest, asyncClientErrors) { const std::string outbound_data = "foo"; bool send_handler_invoked = false; socket.asyncSend(outbound_data.c_str(), outbound_data.size(), - [this, &send_handler_invoked] + [&send_handler_invoked] (const boost::system::error_code& ec, size_t length) { send_handler_invoked = true; EXPECT_TRUE(ec); @@ -282,7 +282,7 @@ TEST_F(UnixDomainSocketTest, asyncClientErrors) { bool receive_handler_invoked = false; std::array read_buf; socket.asyncReceive(&read_buf[0], read_buf.size(), - [this, &receive_handler_invoked] + [&receive_handler_invoked] (const boost::system::error_code& ec, size_t length) { receive_handler_invoked = true; EXPECT_TRUE(ec); diff --git a/src/lib/config/tests/client_connection_unittests.cc b/src/lib/config/tests/client_connection_unittests.cc index 1502bb8481..0b27cbce37 100644 --- a/src/lib/config/tests/client_connection_unittests.cc +++ b/src/lib/config/tests/client_connection_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -105,8 +105,8 @@ TEST_F(ClientConnectionTest, success) { bool handler_invoked = false; conn.start(ClientConnection::SocketPath(unixSocketFilePath()), ClientConnection::ControlCommand(command), - [this, &handler_invoked](const boost::system::error_code& ec, - const ConstJSONFeedPtr& feed) { + [&handler_invoked](const boost::system::error_code& ec, + const ConstJSONFeedPtr& feed) { // Indicate that the handler has been called to break from the // while loop below. handler_invoked = true; @@ -146,8 +146,8 @@ TEST_F(ClientConnectionTest, timeout) { bool handler_invoked = false; conn.start(ClientConnection::SocketPath(unixSocketFilePath()), ClientConnection::ControlCommand(command), - [this, &handler_invoked](const boost::system::error_code& ec, - const ConstJSONFeedPtr& /*feed*/) { + [&handler_invoked](const boost::system::error_code& ec, + const ConstJSONFeedPtr& /*feed*/) { // Indicate that the callback has been invoked to break the loop // below. handler_invoked = true; @@ -172,8 +172,8 @@ TEST_F(ClientConnectionTest, connectionError) { bool handler_invoked = false; conn.start(ClientConnection::SocketPath(unixSocketFilePath()), ClientConnection::ControlCommand(command), - [this, &handler_invoked](const boost::system::error_code& ec, - const ConstJSONFeedPtr& /*feed*/) { + [&handler_invoked](const boost::system::error_code& ec, + const ConstJSONFeedPtr& /*feed*/) { handler_invoked = true; ASSERT_TRUE(ec); }); diff --git a/src/lib/http/tests/server_client_unittests.cc b/src/lib/http/tests/server_client_unittests.cc index 8415724ec5..69df06972f 100644 --- a/src/lib/http/tests/server_client_unittests.cc +++ b/src/lib/http/tests/server_client_unittests.cc @@ -1181,9 +1181,9 @@ TEST_F(HttpClientTest, malformedResponse) { HttpResponseJsonPtr response(new HttpResponseJson()); unsigned resp_num = 0; ASSERT_NO_THROW(client.asyncSendRequest(url, request, response, - [this, &resp_num](const boost::system::error_code& ec, - const HttpResponsePtr& response, - const std::string& parsing_error) { + [this](const boost::system::error_code& ec, + const HttpResponsePtr& response, + const std::string& parsing_error) { io_service_.stop(); // There should be no IO error (answer from the server is received). EXPECT_FALSE(ec); diff --git a/src/lib/process/tests/d_cfg_mgr_unittests.cc b/src/lib/process/tests/d_cfg_mgr_unittests.cc index 2ab501ddb5..cb62a551dd 100644 --- a/src/lib/process/tests/d_cfg_mgr_unittests.cc +++ b/src/lib/process/tests/d_cfg_mgr_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -572,7 +572,7 @@ TEST_F(DStubCfgMgrTest, simpleParseConfigWithCallback) { ASSERT_NO_THROW(fromJSON(config)); answer_ = cfg_mgr_->simpleParseConfig(config_set_, false, - [this]() { + []() { isc_throw(Unexpected, "unexpected configuration error"); }); EXPECT_TRUE(checkAnswer(1));