Skip to content

Commit

Permalink
Replace auto_ptr by unique_ptr
Browse files Browse the repository at this point in the history
Solve also all ambiguous constructor std::unique_ptr(NULL) calls and fix the linting warnings produces after the find-and-replace of (std::)auto_ptr by (std::)unique_ptr.
  • Loading branch information
aroffringa committed Feb 3, 2024
1 parent 25f4474 commit 8f8c0b9
Show file tree
Hide file tree
Showing 228 changed files with 701 additions and 687 deletions.
6 changes: 3 additions & 3 deletions common/http/OlaHTTPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace ola {
namespace http {

using ola::ExportMap;
using std::auto_ptr;
using std::unique_ptr;
using std::ostringstream;
using std::string;
using std::vector;
Expand Down Expand Up @@ -71,7 +71,7 @@ bool OlaHTTPServer::Init() {
*/
int OlaHTTPServer::DisplayDebug(const HTTPRequest*,
HTTPResponse *raw_response) {
auto_ptr<HTTPResponse> response(raw_response);
unique_ptr<HTTPResponse> response(raw_response);
ola::TimeStamp now;
m_clock.CurrentMonotonicTime(&now);
ola::TimeInterval diff = now - m_start_time;
Expand All @@ -98,7 +98,7 @@ int OlaHTTPServer::DisplayDebug(const HTTPRequest*,
*/
int OlaHTTPServer::DisplayHandlers(const HTTPRequest*,
HTTPResponse *raw_response) {
auto_ptr<HTTPResponse> response(raw_response);
unique_ptr<HTTPResponse> response(raw_response);
vector<string> handlers;
m_server.Handlers(&handlers);
vector<string>::const_iterator iter;
Expand Down
4 changes: 2 additions & 2 deletions common/io/IOQueueTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
using ola::io::IOQueue;
using ola::io::IOVec;
using ola::io::MemoryBlockPool;
using std::auto_ptr;
using std::unique_ptr;
using std::string;


Expand Down Expand Up @@ -59,7 +59,7 @@ class IOQueueTest: public CppUnit::TestFixture {
void testStringRead();

private:
auto_ptr<IOQueue> m_buffer;
unique_ptr<IOQueue> m_buffer;

unsigned int SumLengthOfIOVec(const struct IOVec *iov, int iocnt);
};
Expand Down
2 changes: 1 addition & 1 deletion common/io/OutputStreamTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
using ola::io::IOQueue;
using ola::io::BigEndianOutputStream;
using ola::network::HostToNetwork;
using std::auto_ptr;
using std::unique_ptr;
using std::string;


Expand Down
4 changes: 2 additions & 2 deletions common/io/SelectServerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ using ola::io::SelectServer;
using ola::io::UnixSocket;
using ola::io::WriteFileDescriptor;
using ola::network::UDPSocket;
using std::auto_ptr;
using std::unique_ptr;
using std::set;

/*
Expand Down Expand Up @@ -543,7 +543,7 @@ void SelectServerTest::testReadWriteInteraction() {
m_ss->RemoveWriteDescriptor(&socket);

// now the Write end closes
auto_ptr<UnixSocket> other_end(socket.OppositeEnd());
unique_ptr<UnixSocket> other_end(socket.OppositeEnd());
other_end->CloseClient();

m_ss->RegisterSingleTimeout(
Expand Down
4 changes: 2 additions & 2 deletions common/network/AdvancedTCPConnectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ using ola::network::IPV4Address;
using ola::network::IPV4SocketAddress;
using ola::network::TCPAcceptingSocket;
using ola::network::TCPSocket;
using std::auto_ptr;
using std::unique_ptr;
using std::string;

// used to set a timeout which aborts the tests
Expand Down Expand Up @@ -90,7 +90,7 @@ class AdvancedTCPConnectorTest: public CppUnit::TestFixture {
private:
ola::MockClock m_clock;
SelectServer *m_ss;
auto_ptr<ola::network::TCPSocketFactory> m_tcp_socket_factory;
unique_ptr<ola::network::TCPSocketFactory> m_tcp_socket_factory;
IPV4Address m_localhost;
IPV4SocketAddress m_server_address;
ola::thread::timeout_id m_timeout_id;
Expand Down
6 changes: 3 additions & 3 deletions common/network/IPV4AddressTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

using ola::network::IPV4Address;
using ola::network::HostToNetwork;
using std::auto_ptr;
using std::unique_ptr;
using std::string;
using std::vector;

Expand Down Expand Up @@ -97,11 +97,11 @@ void IPAddressTest::testIPV4Address() {
OLA_ASSERT_EQ(string("192.168.1.1"), str.str());

// test from string
auto_ptr<IPV4Address> string_address(IPV4Address::FromString("10.0.0.1"));
unique_ptr<IPV4Address> string_address(IPV4Address::FromString("10.0.0.1"));
OLA_ASSERT_NOT_NULL(string_address.get());
OLA_ASSERT_EQ(string("10.0.0.1"), string_address->ToString());

auto_ptr<IPV4Address> string_address2(IPV4Address::FromString("foo"));
unique_ptr<IPV4Address> string_address2(IPV4Address::FromString("foo"));
OLA_ASSERT_NULL(string_address2.get());

// and the second form
Expand Down
6 changes: 3 additions & 3 deletions common/network/InterfacePickerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ using ola::network::IPV4Address;
using ola::network::Interface;
using ola::network::InterfacePicker;
using ola::network::MACAddress;
using std::auto_ptr;
using std::unique_ptr;
using std::cout;
using std::endl;
using std::string;
Expand All @@ -62,7 +62,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(InterfacePickerTest);
* Check that we find at least one candidate interface.
*/
void InterfacePickerTest::testGetInterfaces() {
auto_ptr<InterfacePicker> picker(InterfacePicker::NewPicker());
unique_ptr<InterfacePicker> picker(InterfacePicker::NewPicker());
vector<Interface> interfaces = picker->GetInterfaces(true);
#ifndef _WIN32
// If a Windows box is not on a network, and doesn't have it's loopback, there
Expand All @@ -86,7 +86,7 @@ void InterfacePickerTest::testGetInterfaces() {
* Check that we find a loopback interface.
*/
void InterfacePickerTest::testGetLoopbackInterfaces() {
auto_ptr<InterfacePicker> picker(InterfacePicker::NewPicker());
unique_ptr<InterfacePicker> picker(InterfacePicker::NewPicker());
vector<Interface> interfaces = picker->GetInterfaces(true);
#ifndef _WIN32
// If a Windows box is not on a network, and doesn't have it's loopback, there
Expand Down
8 changes: 4 additions & 4 deletions common/network/MACAddressTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "ola/testing/TestUtils.h"

using ola::network::MACAddress;
using std::auto_ptr;
using std::unique_ptr;
using std::string;
using std::vector;

Expand Down Expand Up @@ -76,17 +76,17 @@ void MACAddressTest::testMACAddress() {
OLA_ASSERT_EQ(string("01:23:45:67:89:ab"), str.str());

// test from string
auto_ptr<MACAddress> string_address(
unique_ptr<MACAddress> string_address(
MACAddress::FromString("fe:dc:ba:98:76:54"));
OLA_ASSERT_NOT_NULL(string_address.get());
OLA_ASSERT_EQ(string("fe:dc:ba:98:76:54"), string_address->ToString());

auto_ptr<MACAddress> string_address2(
unique_ptr<MACAddress> string_address2(
MACAddress::FromString("98.76.54.fe.dc.ba"));
OLA_ASSERT_NOT_NULL(string_address2.get());
OLA_ASSERT_EQ(string("98:76:54:fe:dc:ba"), string_address2->ToString());

auto_ptr<MACAddress> string_address3(MACAddress::FromString("foo"));
unique_ptr<MACAddress> string_address3(MACAddress::FromString("foo"));
OLA_ASSERT_NULL(string_address3.get());

// and the second form
Expand Down
2 changes: 1 addition & 1 deletion common/network/NetworkUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ static bool GetDefaultRouteWithNetlink(int32_t *if_index,
return false;
}

std::auto_ptr<NetlinkCallback> cb(
std::unique_ptr<NetlinkCallback> cb(
ola::NewCallback(MessageHandler, if_index, default_gateway));
if (!ReadNetlinkSocket(sd, msg, BUFSIZE, nl_msg->nlmsg_seq, cb.get())) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion common/network/TCPConnectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ using ola::io::SelectServer;
using ola::network::TCPConnector;
using ola::network::TCPAcceptingSocket;
using ola::network::TCPSocket;
using std::auto_ptr;
using std::unique_ptr;
using std::string;

// used to set a timeout which aborts the tests
Expand Down
4 changes: 2 additions & 2 deletions common/rdm/CommandPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ using ola::messaging::Descriptor;
using ola::messaging::Message;
using ola::network::NetworkToHost;
using ola::strings::ToHex;
using std::auto_ptr;
using std::unique_ptr;
using std::endl;
using std::string;

Expand Down Expand Up @@ -423,7 +423,7 @@ void CommandPrinter::DisplayParamData(
}

if (descriptor) {
auto_ptr<const Message> message(
unique_ptr<const Message> message(
m_pid_helper->DeserializeMessage(descriptor, param_data, data_length));

if (message.get()) {
Expand Down
32 changes: 16 additions & 16 deletions common/rdm/MessageDeserializerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ using ola::messaging::UInt32FieldDescriptor;
using ola::messaging::UInt8FieldDescriptor;
using ola::messaging::UIDFieldDescriptor;
using ola::rdm::MessageDeserializer;
using std::auto_ptr;
using std::unique_ptr;
using std::string;
using std::vector;

Expand Down Expand Up @@ -98,7 +98,7 @@ void MessageDeserializerTest::testEmpty() {
vector<const FieldDescriptor*> fields;
Descriptor descriptor("Empty Descriptor", fields);

auto_ptr<const Message> empty_message(m_deserializer.InflateMessage(
unique_ptr<const Message> empty_message(m_deserializer.InflateMessage(
&descriptor,
NULL,
0));
Expand Down Expand Up @@ -154,7 +154,7 @@ void MessageDeserializerTest::testSimpleBigEndian() {
sizeof(big_endian_data) + 1));

// now the correct amount & verify
auto_ptr<const Message> message(m_deserializer.InflateMessage(
unique_ptr<const Message> message(m_deserializer.InflateMessage(
&descriptor,
big_endian_data,
sizeof(big_endian_data)));
Expand Down Expand Up @@ -207,7 +207,7 @@ void MessageDeserializerTest::testSimpleLittleEndian() {
sizeof(little_endian_data) + 1));

// now the correct amount & verify
auto_ptr<const Message> message(m_deserializer.InflateMessage(
unique_ptr<const Message> message(m_deserializer.InflateMessage(
&descriptor,
little_endian_data,
sizeof(little_endian_data)));
Expand All @@ -234,7 +234,7 @@ void MessageDeserializerTest::testIPV4() {
const uint8_t big_endian_data[] = {10, 0, 0, 1};

// now the correct amount & verify
auto_ptr<const Message> message(m_deserializer.InflateMessage(
unique_ptr<const Message> message(m_deserializer.InflateMessage(
&descriptor,
big_endian_data,
sizeof(big_endian_data)));
Expand All @@ -259,7 +259,7 @@ void MessageDeserializerTest::testMAC() {
const uint8_t big_endian_data[] = {1, 35, 69, 103, 137, 171};

// now the correct amount & verify
auto_ptr<const Message> message(m_deserializer.InflateMessage(
unique_ptr<const Message> message(m_deserializer.InflateMessage(
&descriptor,
big_endian_data,
sizeof(big_endian_data)));
Expand Down Expand Up @@ -300,7 +300,7 @@ void MessageDeserializerTest::testString() {
43));

// now to the right amount
auto_ptr<const Message> message(m_deserializer.InflateMessage(
unique_ptr<const Message> message(m_deserializer.InflateMessage(
&descriptor,
data,
sizeof(data)));
Expand All @@ -312,7 +312,7 @@ void MessageDeserializerTest::testString() {
OLA_ASSERT_EQ(expected, m_printer.AsString(message.get()));

// now try with different sizes
auto_ptr<const Message> message2(m_deserializer.InflateMessage(
unique_ptr<const Message> message2(m_deserializer.InflateMessage(
&descriptor,
data,
19));
Expand All @@ -338,7 +338,7 @@ void MessageDeserializerTest::testUID() {
const uint8_t big_endian_data[] = {0x70, 0x7a, 0, 0, 0, 1};

// now the correct amount & verify
auto_ptr<const Message> message(m_deserializer.InflateMessage(
unique_ptr<const Message> message(m_deserializer.InflateMessage(
&descriptor,
big_endian_data,
sizeof(big_endian_data)));
Expand Down Expand Up @@ -367,7 +367,7 @@ void MessageDeserializerTest::testWithGroups() {
const uint8_t data[] = {0, 10, 1, 3, 0, 20, 1, 40};

// an empty message
auto_ptr<const Message> message(m_deserializer.InflateMessage(
unique_ptr<const Message> message(m_deserializer.InflateMessage(
&descriptor,
data,
0));
Expand All @@ -381,7 +381,7 @@ void MessageDeserializerTest::testWithGroups() {
1));

// a single instance of a group
auto_ptr<const Message> message2(m_deserializer.InflateMessage(
unique_ptr<const Message> message2(m_deserializer.InflateMessage(
&descriptor,
data,
2));
Expand All @@ -399,7 +399,7 @@ void MessageDeserializerTest::testWithGroups() {
3));

// two instances of the group
auto_ptr<const Message> message3(m_deserializer.InflateMessage(
unique_ptr<const Message> message3(m_deserializer.InflateMessage(
&descriptor,
data,
4));
Expand All @@ -412,7 +412,7 @@ void MessageDeserializerTest::testWithGroups() {
OLA_ASSERT_EQ(expected2, m_printer.AsString(message3.get()));

// trhee instances of the group
auto_ptr<const Message> message4(m_deserializer.InflateMessage(
unique_ptr<const Message> message4(m_deserializer.InflateMessage(
&descriptor,
data,
6));
Expand Down Expand Up @@ -449,7 +449,7 @@ void MessageDeserializerTest::testWithNestedFixedGroups() {
const uint8_t data[] = {0, 0, 0, 1, 0, 1, 2, 1, 0, 3, 1, 1};

// an empty message
auto_ptr<const Message> message(m_deserializer.InflateMessage(
unique_ptr<const Message> message(m_deserializer.InflateMessage(
&descriptor,
data,
0));
Expand All @@ -467,7 +467,7 @@ void MessageDeserializerTest::testWithNestedFixedGroups() {
2));

// a single instance of a group
auto_ptr<const Message> message2(m_deserializer.InflateMessage(
unique_ptr<const Message> message2(m_deserializer.InflateMessage(
&descriptor,
data,
3));
Expand All @@ -480,7 +480,7 @@ void MessageDeserializerTest::testWithNestedFixedGroups() {
OLA_ASSERT_EQ(expected, m_printer.AsString(message2.get()));

// four instances
auto_ptr<const Message> message3(m_deserializer.InflateMessage(
unique_ptr<const Message> message3(m_deserializer.InflateMessage(
&descriptor,
data,
sizeof(data)));
Expand Down
Loading

0 comments on commit 8f8c0b9

Please sign in to comment.