From: Andrei Pavel Date: Mon, 29 Apr 2024 17:03:15 +0000 (+0300) Subject: [#3163] fix warnings on modified files X-Git-Tag: Kea-2.6.0~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f40fa49ab92d28ce8ce9f2d65d7837ca7f6f66e0;p=thirdparty%2Fkea.git [#3163] fix warnings on modified files - ctrl_dhcp4_srv_unittest.cc:145:6: warning: extra ‘;’ after in-class function definition [-Wextra-semi] - ctrl_dhcp4_srv_unittest.cc:2172:28: warning: comparison of integer expressions of different signedness: ‘std::streamoff’ {aka ‘long int’} and ‘const size_t’ {aka ‘const long unsigned int’} [-Wsign-compare] - ctrl_dhcp4_srv_unittest.cc:2191:33: warning: comparison of integer expressions of different signedness: ‘std::streamoff’ {aka ‘long int’} and ‘const size_t’ {aka ‘const long unsigned int’} [-Wsign-compare] - ctrl_dhcp4_srv_unittest.cc:2295:33: warning: comparison of integer expressions of different signedness: ‘std::streamoff’ {aka ‘long int’} and ‘const size_t’ {aka ‘const long unsigned int’} [-Wsign-compare] - ctrl_dhcp4_srv_unittest.cc:2352:28: warning: declaration of ‘timeout’ shadows a previous local [-Wshadow] - ctrl_dhcp4_srv_unittest.cc:2402:28: warning: declaration of ‘timeout’ shadows a previous local [-Wshadow] - ctrl_dhcp6_srv_unittest.cc:116:6: warning: extra ‘;’ after in-class function definition [-Wextra-semi] - ctrl_dhcp6_srv_unittest.cc:181:6: warning: extra ‘;’ after in-class function definition [-Wextra-semi] - ctrl_dhcp6_srv_unittest.cc:264:10: warning: ‘virtual void {anonymous}::CtrlChannelDhcpv6SrvTest::reset()’ can be marked override [-Wsuggest-override] - ctrl_dhcp6_srv_unittest.cc:2210:28: warning: comparison of integer expressions of different signedness: ‘std::streamoff’ {aka ‘long int’} and ‘const size_t’ {aka ‘const long unsigned int’} [-Wsign-compare] - ctrl_dhcp6_srv_unittest.cc:2229:33: warning: comparison of integer expressions of different signedness: ‘std::streamoff’ {aka ‘long int’} and ‘const size_t’ {aka ‘const long unsigned int’} [-Wsign-compare] - ctrl_dhcp6_srv_unittest.cc:2333:33: warning: comparison of integer expressions of different signedness: ‘std::streamoff’ {aka ‘long int’} and ‘const size_t’ {aka ‘const long unsigned int’} [-Wsign-compare] - ctrl_dhcp6_srv_unittest.cc:2390:28: warning: declaration of ‘timeout’ shadows a previous local [-Wshadow] - ctrl_dhcp6_srv_unittest.cc:2440:28: warning: declaration of ‘timeout’ shadows a previous local [-Wshadow] - dhcp6_srv_unittest.cc:2420:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare] - dhcp6_srv_unittest.cc:2440:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare] - dhcp6_srv_unittest.cc:2932:28: warning: useless cast to type ‘const uint8_t*’ {aka ‘const unsigned char*’} [-Wuseless-cast] - dhcp6_srv_unittest.cc:2964:26: warning: useless cast to type ‘const uint8_t*’ {aka ‘const unsigned char*’} [-Wuseless-cast] --- diff --git a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc index a0be312596..15e49b52ad 100644 --- a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc @@ -142,7 +142,7 @@ public: IfaceMgr::instance().clearIfaces(); IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); - }; + } /// @brief Returns pointer to the server's IO service. /// @@ -2167,7 +2167,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, longCommand) { // This is the desired size of the command sent to the server (1MB). The // actual size sent will be slightly greater than that. - const size_t command_size = 1024 * 1000; + const ssize_t command_size = 1024 * 1000; while (command.tellp() < command_size) { @@ -2280,7 +2280,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, longResponse) { // Remember the response size so as we know when we should stop // receiving. - const size_t long_response_size = reference_response.size(); + const ssize_t long_response_size = reference_response.size(); // Create the client and connect it to the server. boost::scoped_ptr client(new UnixControlClient()); @@ -2349,8 +2349,8 @@ TEST_F(CtrlChannelDhcpv4SrvTest, connectionTimeoutPartialCommand) { // Let's wait up to 15s for the server's response. The response // should arrive sooner assuming that the timeout mechanism for // the server is working properly. - const unsigned int timeout = 15; - ASSERT_TRUE(client->getResponse(response, timeout)); + const unsigned int response_timeout = 15; + ASSERT_TRUE(client->getResponse(response, response_timeout)); // Explicitly close the client's connection. client->disconnectFromServer(); @@ -2399,8 +2399,8 @@ TEST_F(CtrlChannelDhcpv4SrvTest, connectionTimeoutNoData) { // Let's wait up to 15s for the server's response. The response // should arrive sooner assuming that the timeout mechanism for // the server is working properly. - const unsigned int timeout = 15; - ASSERT_TRUE(client->getResponse(response, timeout)); + const unsigned int response_timeout = 15; + ASSERT_TRUE(client->getResponse(response, response_timeout)); // Explicitly close the client's connection. client->disconnectFromServer(); diff --git a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc index 8f2dc86942..98aed2d770 100644 --- a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc @@ -113,7 +113,7 @@ public: CommandMgr::instance().setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT); reset(); - }; + } /// @brief Reset hooks data /// @@ -178,7 +178,7 @@ public: IfaceMgr::instance().clearIfaces(); IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); - }; + } /// @brief Returns pointer to the server's IO service. /// @@ -261,7 +261,7 @@ public: } /// @brief Reset - void reset() { + void reset() override { CtrlDhcpv6SrvTest::reset(); // Remove unix socket file @@ -2205,7 +2205,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, longCommand) { // This is the desired size of the command sent to the server (1MB). The // actual size sent will be slightly greater than that. - const size_t command_size = 1024 * 1000; + const ssize_t command_size = 1024 * 1000; while (command.tellp() < command_size) { @@ -2318,7 +2318,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, longResponse) { // Remember the response size so as we know when we should stop // receiving. - const size_t long_response_size = reference_response.size(); + const ssize_t long_response_size = reference_response.size(); // Create the client and connect it to the server. boost::scoped_ptr client(new UnixControlClient()); @@ -2387,8 +2387,8 @@ TEST_F(CtrlChannelDhcpv6SrvTest, connectionTimeoutPartialCommand) { // Let's wait up to 15s for the server's response. The response // should arrive sooner assuming that the timeout mechanism for // the server is working properly. - const unsigned int timeout = 15; - ASSERT_TRUE(client->getResponse(response, timeout)); + const unsigned int response_timeout = 15; + ASSERT_TRUE(client->getResponse(response, response_timeout)); // Explicitly close the client's connection. client->disconnectFromServer(); @@ -2437,8 +2437,8 @@ TEST_F(CtrlChannelDhcpv6SrvTest, connectionTimeoutNoData) { // Let's wait up to 15s for the server's response. The response // should arrive sooner assuming that the timeout mechanism for // the server is working properly. - const unsigned int timeout = 15; - ASSERT_TRUE(client->getResponse(response, timeout)); + const unsigned int response_timeout = 15; + ASSERT_TRUE(client->getResponse(response, response_timeout)); // Explicitly close the client's connection. client->disconnectFromServer(); diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc index 5577e44259..0de8a2a8e2 100644 --- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc @@ -2418,7 +2418,7 @@ TEST_F(Dhcpv6SrvTest, testUnicast) { DHCPV6_INFORMATION_REQUEST }; // Iterate over these messages and make sure they are discarded. - for (int i = 0; i < sizeof(not_allowed_unicast); ++i) { + for (size_t i = 0; i < sizeof(not_allowed_unicast); ++i) { Pkt6Ptr msg = Pkt6Ptr(new Pkt6(not_allowed_unicast[i], 1234)); msg->setLocalAddr(IOAddress("2001:db8:1::1")); EXPECT_FALSE(srv.testUnicast(msg)) @@ -2438,7 +2438,7 @@ TEST_F(Dhcpv6SrvTest, testUnicast) { }; // Iterate over these messages and check that they are accepted being // sent to unicast. - for (int i = 0; i < sizeof(allowed_unicast); ++i) { + for (size_t i = 0; i < sizeof(allowed_unicast); ++i) { Pkt6Ptr msg = Pkt6Ptr(new Pkt6(allowed_unicast[i], 1234)); msg->setLocalAddr(IOAddress("2001:db8:1::1")); msg->addOption(srv.getServerID()); @@ -2930,8 +2930,7 @@ TEST_F(Dhcpv6SrvTest, relaySourcePort) { // Simulate that we have received that traffic sol->pack(); EXPECT_EQ(DHCPV6_RELAY_FORW, sol->getBuffer()[0]); - Pkt6Ptr query(new Pkt6(static_cast - (sol->getBuffer().getData()), + Pkt6Ptr query(new Pkt6(sol->getBuffer().getData(), sol->getBuffer().getLength())); query->setRemoteAddr(sol->getRemoteAddr()); query->setRemotePort(sol->getRemotePort()); @@ -2962,8 +2961,7 @@ TEST_F(Dhcpv6SrvTest, relaySourcePort) { EXPECT_EQ(DHCPV6_RELAY_REPL, rsp->getBuffer()[0]); // Get Advertise - Pkt6Ptr adv(new Pkt6(static_cast - (rsp->getBuffer().getData()), + Pkt6Ptr adv(new Pkt6(rsp->getBuffer().getData(), rsp->getBuffer().getLength())); adv->unpack();