BIND 10 trac2587, updated. b88f6fb05d83b5ee7b7594630e02093398f995c7 [2587] Use scoped_ptr and convertSockAddr()
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Jan 17 13:45:22 UTC 2013
The branch, trac2587 has been updated
via b88f6fb05d83b5ee7b7594630e02093398f995c7 (commit)
from 914eb9b64bfcf703c2538cbf20b9c82bfbdfb525 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b88f6fb05d83b5ee7b7594630e02093398f995c7
Author: Jelte Jansen <jelte at isc.org>
Date: Thu Jan 17 14:44:45 2013 +0100
[2587] Use scoped_ptr and convertSockAddr()
As proposed by reviewer
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/tests/auth_srv_unittest.cc | 15 +++++++--------
src/lib/testutils/srv_test.cc | 29 ++++++++++-------------------
src/lib/testutils/srv_test.h | 11 ++++++-----
3 files changed, 23 insertions(+), 32 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/tests/auth_srv_unittest.cc b/src/bin/auth/tests/auth_srv_unittest.cc
index c3b794b..826d1b8 100644
--- a/src/bin/auth/tests/auth_srv_unittest.cc
+++ b/src/bin/auth/tests/auth_srv_unittest.cc
@@ -1286,12 +1286,12 @@ TEST_F(AuthSrvTest, queryCounterUnexpected) {
createRequestPacket(request_message, IPPROTO_UDP);
// Modify the message.
- delete io_message;
- endpoint = IOEndpoint::create(IPPROTO_UDP,
- IOAddress(DEFAULT_REMOTE_ADDRESS), 53210);
- io_message = new IOMessage(request_renderer.getData(),
- request_renderer.getLength(),
- getDummyUnknownSocket(), *endpoint);
+ endpoint.reset(IOEndpoint::create(IPPROTO_UDP,
+ IOAddress(DEFAULT_REMOTE_ADDRESS),
+ 53210));
+ io_message.reset(new IOMessage(request_renderer.getData(),
+ request_renderer.getLength(),
+ getDummyUnknownSocket(), *endpoint));
EXPECT_FALSE(dnsserv.hasAnswer());
}
@@ -1723,8 +1723,7 @@ checkAddrPort(const struct sockaddr& actual_sa,
struct sockaddr_storage ss;
memcpy(&ss, &actual_sa, sa_len);
- struct sockaddr* sa =
- static_cast<struct sockaddr*>(static_cast<void*>(&ss));
+ struct sockaddr* sa = convertSockAddr(&ss);
#ifdef HAVE_SA_LEN
sa->sa_len = sa_len;
#endif
diff --git a/src/lib/testutils/srv_test.cc b/src/lib/testutils/srv_test.cc
index 0d21f28..3486656 100644
--- a/src/lib/testutils/srv_test.cc
+++ b/src/lib/testutils/srv_test.cc
@@ -48,27 +48,20 @@ SrvTestBase::SrvTestBase() : request_message(Message::RENDER),
response_obuffer(new OutputBuffer(0))
{}
-SrvTestBase::~SrvTestBase() {
- delete io_message;
- delete endpoint;
-}
-
void
SrvTestBase::createDataFromFile(const char* const datafile,
const int protocol)
{
- delete io_message;
data.clear();
- delete endpoint;
-
- endpoint = IOEndpoint::create(protocol,
- IOAddress(DEFAULT_REMOTE_ADDRESS),
- DEFAULT_REMOTE_PORT);
+ endpoint.reset(IOEndpoint::create(protocol,
+ IOAddress(DEFAULT_REMOTE_ADDRESS),
+ DEFAULT_REMOTE_PORT));
UnitTestUtil::readWireData(datafile, data);
io_sock = (protocol == IPPROTO_UDP) ? &IOSocket::getDummyUDPSocket() :
&IOSocket::getDummyTCPSocket();
- io_message = new IOMessage(&data[0], data.size(), *io_sock, *endpoint);
+ io_message.reset(new IOMessage(&data[0], data.size(), *io_sock,
+ *endpoint));
}
void
@@ -83,16 +76,14 @@ SrvTestBase::createRequestPacket(Message& message,
message.toWire(request_renderer, *context);
}
- delete endpoint;
- endpoint = IOEndpoint::create(protocol, IOAddress(remote_address),
- remote_port);
+ endpoint.reset(IOEndpoint::create(protocol, IOAddress(remote_address),
+ remote_port));
io_sock = (protocol == IPPROTO_UDP) ? &IOSocket::getDummyUDPSocket() :
&IOSocket::getDummyTCPSocket();
- delete io_message;
- io_message = new IOMessage(request_renderer.getData(),
- request_renderer.getLength(),
- *io_sock, *endpoint);
+ io_message.reset(new IOMessage(request_renderer.getData(),
+ request_renderer.getLength(),
+ *io_sock, *endpoint));
}
// Unsupported requests. Should result in NOTIMP.
diff --git a/src/lib/testutils/srv_test.h b/src/lib/testutils/srv_test.h
index e867595..45116d1 100644
--- a/src/lib/testutils/srv_test.h
+++ b/src/lib/testutils/srv_test.h
@@ -25,6 +25,7 @@
#include <dns/rrtype.h>
#include "mockups.h"
+#include <boost/scoped_ptr.hpp>
namespace asiolink {
class IOSocket;
@@ -52,7 +53,7 @@ extern const unsigned int CD_FLAG;
class SrvTestBase : public ::testing::Test {
protected:
SrvTestBase();
- virtual ~SrvTestBase();
+ virtual ~SrvTestBase() {};
/// Let the server process a DNS message.
///
@@ -104,8 +105,8 @@ protected:
const isc::dns::RRClass qclass;
const isc::dns::RRType qtype;
asiolink::IOSocket* io_sock;
- asiolink::IOMessage* io_message;
- const asiolink::IOEndpoint* endpoint;
+ boost::scoped_ptr<asiolink::IOMessage> io_message;
+ boost::scoped_ptr<const asiolink::IOEndpoint> endpoint;
isc::dns::MessageRenderer request_renderer;
isc::util::OutputBufferPtr response_obuffer;
std::vector<uint8_t> data;
@@ -114,6 +115,6 @@ protected:
} // end of namespace isc
#endif // ISC_TESTUTILS_SRVTEST_H
-// Local Variables:
+// Local Variables:
// mode: c++
-// End:
+// End:
More information about the bind10-changes
mailing list