aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-10-10 13:29:02 +0100
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-10-10 18:22:41 +0100
commit67ef2a52c3cdcc37538d77711bbcea2f0e5655e5 (patch)
tree8d25bcb2c10cba8945ae4638695d879e88b9d259
parent8efc500a7465c03877db8bbe443134f2b1bbc1af (diff)
downloadarmnn-67ef2a52c3cdcc37538d77711bbcea2f0e5655e5.tar.gz
IVGCVSW-3964 Change the type held by the Packet class to unsigned char
* Updated the Packet class * Updated the pertinent code accordingly Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: I73eab5b1ead67a610cd17fd33f8a74f764ad8cc4
-rw-r--r--src/profiling/Packet.hpp18
-rw-r--r--src/profiling/ProfilingConnectionDumpToFileDecorator.cpp10
-rw-r--r--src/profiling/ProfilingConnectionDumpToFileDecorator.hpp2
-rw-r--r--src/profiling/SocketProfilingConnection.cpp4
-rw-r--r--src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp8
-rw-r--r--src/profiling/test/ProfilingTests.cpp26
-rw-r--r--src/profiling/test/ProfilingTests.hpp6
7 files changed, 37 insertions, 37 deletions
diff --git a/src/profiling/Packet.hpp b/src/profiling/Packet.hpp
index fae368b64e..ff6de69f53 100644
--- a/src/profiling/Packet.hpp
+++ b/src/profiling/Packet.hpp
@@ -33,7 +33,7 @@ public:
m_PacketFamily = (header >> 26);
}
- Packet(uint32_t header, uint32_t length, std::unique_ptr<char[]>& data)
+ Packet(uint32_t header, uint32_t length, std::unique_ptr<unsigned char[]>& data)
: m_Header(header)
, m_Length(length)
, m_Data(std::move(data))
@@ -66,13 +66,13 @@ public:
Packet& operator=(const Packet&) = delete;
Packet& operator=(Packet&&) = default;
- uint32_t GetHeader() const { return m_Header; }
- uint32_t GetPacketFamily() const { return m_PacketFamily; }
- uint32_t GetPacketId() const { return m_PacketId; }
- uint32_t GetPacketClass() const { return m_PacketId >> 3; }
- uint32_t GetPacketType() const { return m_PacketId & 7; }
- uint32_t GetLength() const { return m_Length; }
- const char* const GetData() const { return m_Data.get(); }
+ uint32_t GetHeader() const { return m_Header; }
+ uint32_t GetPacketFamily() const { return m_PacketFamily; }
+ uint32_t GetPacketId() const { return m_PacketId; }
+ uint32_t GetPacketClass() const { return m_PacketId >> 3; }
+ uint32_t GetPacketType() const { return m_PacketId & 7; }
+ uint32_t GetLength() const { return m_Length; }
+ const unsigned char* const GetData() const { return m_Data.get(); }
bool IsEmpty() { return m_Header == 0 && m_Length == 0; }
@@ -81,7 +81,7 @@ private:
uint32_t m_PacketFamily;
uint32_t m_PacketId;
uint32_t m_Length;
- std::unique_ptr<char[]> m_Data;
+ std::unique_ptr<unsigned char[]> m_Data;
};
} // namespace profiling
diff --git a/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp b/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp
index 3d4b6bf927..d7915624f6 100644
--- a/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp
+++ b/src/profiling/ProfilingConnectionDumpToFileDecorator.cpp
@@ -51,7 +51,7 @@ bool ProfilingConnectionDumpToFileDecorator::WritePacket(const unsigned char* bu
bool success = true;
if (m_Settings.m_DumpOutgoing)
{
- success &= DumpOutgoingToFile(reinterpret_cast<const char*>(buffer), length);
+ success &= DumpOutgoingToFile(buffer, length);
}
success &= m_Connection->WritePacket(buffer, length);
return success;
@@ -105,7 +105,8 @@ void ProfilingConnectionDumpToFileDecorator::DumpIncomingToFile(const Packet& pa
m_IncomingDumpFileStream.write(reinterpret_cast<const char*>(&header), sizeof header);
m_IncomingDumpFileStream.write(reinterpret_cast<const char*>(&packetLength), sizeof packetLength);
- m_IncomingDumpFileStream.write(packet.GetData(), boost::numeric_cast<std::streamsize>(packetLength));
+ m_IncomingDumpFileStream.write(reinterpret_cast<const char*>(packet.GetData()),
+ boost::numeric_cast<std::streamsize>(packetLength));
success &= m_IncomingDumpFileStream.good();
if (!(success || m_Settings.m_IgnoreFileErrors))
@@ -122,7 +123,7 @@ void ProfilingConnectionDumpToFileDecorator::DumpIncomingToFile(const Packet& pa
/// @param buffer pointer to data to write
/// @param length number of bytes to write
/// @return true if write successful, false otherwise
-bool ProfilingConnectionDumpToFileDecorator::DumpOutgoingToFile(const char* buffer, uint32_t length)
+bool ProfilingConnectionDumpToFileDecorator::DumpOutgoingToFile(const unsigned char* buffer, uint32_t length)
{
bool success = true;
if (!m_OutgoingDumpFileStream.is_open())
@@ -136,7 +137,8 @@ bool ProfilingConnectionDumpToFileDecorator::DumpOutgoingToFile(const char* buff
}
// attempt to write binary data
- m_OutgoingDumpFileStream.write(buffer, boost::numeric_cast<std::streamsize>(length));
+ m_OutgoingDumpFileStream.write(reinterpret_cast<const char*>(buffer),
+ boost::numeric_cast<std::streamsize>(length));
success &= m_OutgoingDumpFileStream.good();
if (!(success || m_Settings.m_IgnoreFileErrors))
{
diff --git a/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp b/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp
index c2ae538138..cc79d954d9 100644
--- a/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp
+++ b/src/profiling/ProfilingConnectionDumpToFileDecorator.hpp
@@ -64,7 +64,7 @@ private:
void DumpIncomingToFile(const Packet& packet);
- bool DumpOutgoingToFile(const char* buffer, uint32_t length);
+ bool DumpOutgoingToFile(const unsigned char* buffer, uint32_t length);
void Fail(const std::string& errorMessage);
diff --git a/src/profiling/SocketProfilingConnection.cpp b/src/profiling/SocketProfilingConnection.cpp
index 0ae7b0e1fe..ad629928f9 100644
--- a/src/profiling/SocketProfilingConnection.cpp
+++ b/src/profiling/SocketProfilingConnection.cpp
@@ -119,10 +119,10 @@ Packet SocketProfilingConnection::ReadPacket(uint32_t timeout)
uint32_t dataLength = 0;
std::memcpy(&dataLength, header + 4u, sizeof(dataLength));
- std::unique_ptr<char[]> packetData;
+ std::unique_ptr<unsigned char[]> packetData;
if (dataLength > 0)
{
- packetData = std::make_unique<char[]>(dataLength);
+ packetData = std::make_unique<unsigned char[]>(dataLength);
}
ssize_t receivedLength = recv(m_Socket[0].fd, packetData.get(), dataLength, 0);
diff --git a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
index fac93c5ddf..a7acdd63cc 100644
--- a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
+++ b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
@@ -32,7 +32,7 @@ class DummyProfilingConnection : public IProfilingConnection
public:
DummyProfilingConnection()
: m_Open(true)
- , m_PacketData(std::make_unique<char[]>(g_DataLength))
+ , m_PacketData(std::make_unique<unsigned char[]>(g_DataLength))
{
// populate packet data and construct packet
std::memcpy(m_PacketData.get(), g_DataPtr, g_DataLength);
@@ -65,8 +65,8 @@ public:
}
private:
- bool m_Open;
- std::unique_ptr<char[]> m_PacketData;
+ bool m_Open;
+ std::unique_ptr<unsigned char[]> m_PacketData;
std::unique_ptr<Packet> m_Packet;
};
@@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE(DumpIncomingValidFile)
decorator.Close();
std::vector<char> data = ReadDumpFile(settings.m_IncomingDumpFileName);
- const char* packetData = packet->GetData();
+ const char* packetData = reinterpret_cast<const char*>(packet->GetData());
// check if the data read back from the dump file matches the original
constexpr unsigned int bytesToSkip = 2u * sizeof(uint32_t); // skip header and packet length
diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp
index 57a11d0503..27bacf7145 100644
--- a/src/profiling/test/ProfilingTests.cpp
+++ b/src/profiling/test/ProfilingTests.cpp
@@ -198,9 +198,9 @@ BOOST_AUTO_TEST_CASE(CheckEncodeVersion)
BOOST_AUTO_TEST_CASE(CheckPacketClass)
{
uint32_t length = 4;
- std::unique_ptr<char[]> packetData0 = std::make_unique<char[]>(length);
- std::unique_ptr<char[]> packetData1 = std::make_unique<char[]>(0);
- std::unique_ptr<char[]> nullPacketData;
+ std::unique_ptr<unsigned char[]> packetData0 = std::make_unique<unsigned char[]>(length);
+ std::unique_ptr<unsigned char[]> packetData1 = std::make_unique<unsigned char[]>(0);
+ std::unique_ptr<unsigned char[]> nullPacketData;
Packet packetTest0(472580096, length, packetData0);
@@ -218,7 +218,7 @@ BOOST_AUTO_TEST_CASE(CheckPacketClass)
BOOST_CHECK(packetTest3.GetLength() == 0);
BOOST_CHECK(packetTest3.GetData() == nullptr);
- const char* packetTest0Data = packetTest0.GetData();
+ const unsigned char* packetTest0Data = packetTest0.GetData();
Packet packetTest4(std::move(packetTest0));
BOOST_CHECK(packetTest0.GetData() == nullptr);
@@ -260,9 +260,9 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerFunctor)
it++;
BOOST_CHECK(it->first==keyC);
- std::unique_ptr<char[]> packetDataA;
- std::unique_ptr<char[]> packetDataB;
- std::unique_ptr<char[]> packetDataC;
+ std::unique_ptr<unsigned char[]> packetDataA;
+ std::unique_ptr<unsigned char[]> packetDataB;
+ std::unique_ptr<unsigned char[]> packetDataC;
Packet packetA(500000000, 0, packetDataA);
Packet packetB(600000000, 0, packetDataB);
@@ -302,9 +302,9 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry)
registry.RegisterFunctor(&testFunctorB);
registry.RegisterFunctor(&testFunctorC);
- std::unique_ptr<char[]> packetDataA;
- std::unique_ptr<char[]> packetDataB;
- std::unique_ptr<char[]> packetDataC;
+ std::unique_ptr<unsigned char[]> packetDataA;
+ std::unique_ptr<unsigned char[]> packetDataB;
+ std::unique_ptr<unsigned char[]> packetDataC;
Packet packetA(500000000, 0, packetDataA);
Packet packetB(600000000, 0, packetDataB);
@@ -1707,7 +1707,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData)
uint32_t dataLength1 = 8;
uint32_t offset = 0;
- std::unique_ptr<char[]> uniqueData1 = std::make_unique<char[]>(dataLength1);
+ std::unique_ptr<unsigned char[]> uniqueData1 = std::make_unique<unsigned char[]>(dataLength1);
unsigned char* data1 = reinterpret_cast<unsigned char*>(uniqueData1.get());
WriteUint32(data1, offset, period1);
@@ -1758,7 +1758,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData)
uint32_t period2 = 11;
uint32_t dataLength2 = 4;
- std::unique_ptr<char[]> uniqueData2 = std::make_unique<char[]>(dataLength2);
+ std::unique_ptr<unsigned char[]> uniqueData2 = std::make_unique<unsigned char[]>(dataLength2);
WriteUint32(reinterpret_cast<unsigned char*>(uniqueData2.get()), 0, period2);
@@ -1802,7 +1802,7 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged)
uint32_t dataLength1 = 8;
uint32_t offset = 0;
- std::unique_ptr<char[]> uniqueData1 = std::make_unique<char[]>(dataLength1);
+ std::unique_ptr<unsigned char[]> uniqueData1 = std::make_unique<unsigned char[]>(dataLength1);
unsigned char* data1 = reinterpret_cast<unsigned char*>(uniqueData1.get());
WriteUint32(data1, offset, period1);
diff --git a/src/profiling/test/ProfilingTests.hpp b/src/profiling/test/ProfilingTests.hpp
index e1686162db..4d2f974344 100644
--- a/src/profiling/test/ProfilingTests.hpp
+++ b/src/profiling/test/ProfilingTests.hpp
@@ -71,8 +71,7 @@ public:
std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
// Return connection acknowledged packet
- std::unique_ptr<char[]> packetData;
- return Packet(65536, 0, packetData);
+ return Packet(65536);
}
};
@@ -94,8 +93,7 @@ public:
}
// Return connection acknowledged packet after three timeouts
- std::unique_ptr<char[]> packetData;
- return Packet(65536, 0, packetData);
+ return Packet(65536);
}
private: