From 270233fc7c57486026f381cd8ba6a71b84d7be2d Mon Sep 17 00:00:00 2001 From: Rob Hughes Date: Wed, 13 Nov 2019 11:53:48 +0000 Subject: Fix a few compile errors: * Replace use of non-standard integral types (e.g. u_char) * Convert boost::filesystem::paths to std::strings using the .string() method rather than .c_str(), because on Windows .c_str() returns a wide character string, which is not convertible to a std::string. Change-Id: Ia86b0653697033bb1afa01e64b5b2103dd042ffd Signed-off-by: Robert Hughes --- src/profiling/DirectoryCaptureCommandHandler.cpp | 2 +- .../test/FileOnlyProfilingDecoratorTests.cpp | 8 ++--- ...ProfilingConnectionDumpToFileDecoratorTests.cpp | 4 +-- tests/profiling/gatordmock/GatordMockService.cpp | 36 +++++++++++----------- tests/profiling/gatordmock/GatordMockService.hpp | 12 ++++---- .../profiling/gatordmock/tests/GatordMockTests.cpp | 6 ++-- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/profiling/DirectoryCaptureCommandHandler.cpp b/src/profiling/DirectoryCaptureCommandHandler.cpp index c5a2d97293..65a7880d50 100644 --- a/src/profiling/DirectoryCaptureCommandHandler.cpp +++ b/src/profiling/DirectoryCaptureCommandHandler.cpp @@ -320,7 +320,7 @@ const ICounterDirectory& DirectoryCaptureCommandHandler::GetCounterDirectory() c std::string DirectoryCaptureCommandHandler::GetStringNameFromBuffer(const unsigned char* const data, uint32_t offset) { std::string deviceName; - u_char nextChar = profiling::ReadUint8(data, offset); + uint8_t nextChar = profiling::ReadUint8(data, offset); while (isprint(nextChar)) { diff --git a/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp b/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp index 9bf177c096..5524ed4fbf 100644 --- a/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp +++ b/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp @@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(DumpOutgoingValidFileEndToEnd) options.m_EnableProfiling = true; options.m_FileOnly = true; options.m_IncomingCaptureFile = ""; - options.m_OutgoingCaptureFile = tempPath.c_str(); + options.m_OutgoingCaptureFile = tempPath.string(); options.m_CapturePeriod = 100; // Enable the profiling service @@ -45,9 +45,9 @@ BOOST_AUTO_TEST_CASE(DumpOutgoingValidFileEndToEnd) profilingService.Update(); profilingService.Update(); - u_int32_t timeout = 2000; - u_int32_t sleepTime = 50; - u_int32_t timeSlept = 0; + uint32_t timeout = 2000; + uint32_t sleepTime = 50; + uint32_t timeSlept = 0; // Give the profiling service sending thread time start executing and send the stream metadata. while (profilingService.GetCurrentState() != ProfilingState::WaitingForAck) diff --git a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp index c393ec9b07..6a092815b2 100644 --- a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp +++ b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp @@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(DumpIncomingValidFile) boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); armnn::Runtime::CreationOptions::ExternalProfilingOptions options; - options.m_IncomingCaptureFile = fileName.c_str(); + options.m_IncomingCaptureFile = fileName.string(); options.m_OutgoingCaptureFile = ""; ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), options, false); @@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(DumpOutgoingValidFile) armnn::Runtime::CreationOptions::ExternalProfilingOptions options; options.m_IncomingCaptureFile = ""; - options.m_OutgoingCaptureFile = fileName.c_str(); + options.m_OutgoingCaptureFile = fileName.string(); ProfilingConnectionDumpToFileDecorator decorator(std::make_unique(), options, false); diff --git a/tests/profiling/gatordmock/GatordMockService.cpp b/tests/profiling/gatordmock/GatordMockService.cpp index 46f6547b41..1cdb024273 100644 --- a/tests/profiling/gatordmock/GatordMockService.cpp +++ b/tests/profiling/gatordmock/GatordMockService.cpp @@ -74,7 +74,7 @@ bool GatordMockService::WaitForStreamMetaData() std::cout << "Waiting for stream meta data..." << std::endl; } // The start of the stream metadata is 2x32bit words, 0 and packet length. - u_char header[8]; + uint8_t header[8]; if (!ReadFromSocket(header, 8)) { return false; @@ -87,7 +87,7 @@ bool GatordMockService::WaitForStreamMetaData() return false; } - u_char pipeMagic[4]; + uint8_t pipeMagic[4]; if (!ReadFromSocket(pipeMagic, 4)) { return false; @@ -112,7 +112,7 @@ bool GatordMockService::WaitForStreamMetaData() // Remember we already read the pipe magic 4 bytes. uint32_t metaDataLength = ToUint32(&header[4], m_Endianness) - 4; // Read the entire packet. - u_char packetData[metaDataLength]; + uint8_t packetData[metaDataLength]; if (metaDataLength != boost::numeric_cast(read(m_ClientConnection, &packetData, metaDataLength))) { std::cerr << ": Protocol read error. Data length mismatch." << std::endl; @@ -342,7 +342,7 @@ armnn::profiling::Packet GatordMockService::ReceivePacket() return packetRx; } -bool GatordMockService::SendPacket(uint32_t packetFamily, uint32_t packetId, const u_char* data, uint32_t dataLength) +bool GatordMockService::SendPacket(uint32_t packetFamily, uint32_t packetId, const uint8_t* data, uint32_t dataLength) { // Construct a packet from the id and data given and send it to the client. // Encode the header. @@ -350,7 +350,7 @@ bool GatordMockService::SendPacket(uint32_t packetFamily, uint32_t packetId, con header[0] = packetFamily << 26 | packetId << 16; header[1] = dataLength; // Add the header to the packet. - u_char packet[8 + dataLength]; + uint8_t packet[8 + dataLength]; InsertU32(header[0], packet, m_Endianness); InsertU32(header[1], packet + 4, m_Endianness); // And the rest of the data if there is any. @@ -370,7 +370,7 @@ bool GatordMockService::SendPacket(uint32_t packetFamily, uint32_t packetId, con bool GatordMockService::ReadHeader(uint32_t headerAsWords[2]) { // The header will always be 2x32bit words. - u_char header[8]; + uint8_t header[8]; if (!ReadFromSocket(header, 8)) { return false; @@ -381,7 +381,7 @@ bool GatordMockService::ReadHeader(uint32_t headerAsWords[2]) return true; } -bool GatordMockService::ReadFromSocket(u_char* packetData, uint32_t expectedLength) +bool GatordMockService::ReadFromSocket(uint8_t* packetData, uint32_t expectedLength) { // This is a blocking read until either expectedLength has been received or an error is detected. ssize_t totalBytesRead = 0; @@ -403,7 +403,7 @@ bool GatordMockService::ReadFromSocket(u_char* packetData, uint32_t expectedLeng return true; }; -void GatordMockService::EchoPacket(PacketDirection direction, u_char* packet, size_t lengthInBytes) +void GatordMockService::EchoPacket(PacketDirection direction, uint8_t* packet, size_t lengthInBytes) { // If enabled print the contents of the data packet to the console. if (m_EchoPackets) @@ -433,7 +433,7 @@ void GatordMockService::EchoPacket(PacketDirection direction, u_char* packet, si } } -uint32_t GatordMockService::ToUint32(u_char* data, TargetEndianness endianness) +uint32_t GatordMockService::ToUint32(uint8_t* data, TargetEndianness endianness) { // Extract the first 4 bytes starting at data and push them into a 32bit integer based on the // specified endianness. @@ -449,23 +449,23 @@ uint32_t GatordMockService::ToUint32(u_char* data, TargetEndianness endianness) } } -void GatordMockService::InsertU32(uint32_t value, u_char* data, TargetEndianness endianness) +void GatordMockService::InsertU32(uint32_t value, uint8_t* data, TargetEndianness endianness) { // Take the bytes of a 32bit integer and copy them into char array starting at data considering // the endianness value. if (endianness == TargetEndianness::BeWire) { - *data = static_cast((value >> 24) & 0xFF); - *(data + 1) = static_cast((value >> 16) & 0xFF); - *(data + 2) = static_cast((value >> 8) & 0xFF); - *(data + 3) = static_cast(value & 0xFF); + *data = static_cast((value >> 24) & 0xFF); + *(data + 1) = static_cast((value >> 16) & 0xFF); + *(data + 2) = static_cast((value >> 8) & 0xFF); + *(data + 3) = static_cast(value & 0xFF); } else { - *(data + 3) = static_cast((value >> 24) & 0xFF); - *(data + 2) = static_cast((value >> 16) & 0xFF); - *(data + 1) = static_cast((value >> 8) & 0xFF); - *data = static_cast(value & 0xFF); + *(data + 3) = static_cast((value >> 24) & 0xFF); + *(data + 2) = static_cast((value >> 16) & 0xFF); + *(data + 1) = static_cast((value >> 8) & 0xFF); + *data = static_cast(value & 0xFF); } } diff --git a/tests/profiling/gatordmock/GatordMockService.hpp b/tests/profiling/gatordmock/GatordMockService.hpp index deafcfdc92..a77d7ff480 100644 --- a/tests/profiling/gatordmock/GatordMockService.hpp +++ b/tests/profiling/gatordmock/GatordMockService.hpp @@ -90,7 +90,7 @@ public: void SendPeriodicCounterSelectionList(uint32_t period, std::vector counters); /// Execute the WAIT command from the comamnd file. - void WaitCommand(uint timeout); + void WaitCommand(uint32_t timeout); uint32_t GetStreamMetadataVersion() { @@ -117,17 +117,17 @@ private: armnn::profiling::Packet ReceivePacket(); - bool SendPacket(uint32_t packetFamily, uint32_t packetId, const u_char* data, uint32_t dataLength); + bool SendPacket(uint32_t packetFamily, uint32_t packetId, const uint8_t* data, uint32_t dataLength); - void EchoPacket(PacketDirection direction, u_char* packet, size_t lengthInBytes); + void EchoPacket(PacketDirection direction, uint8_t* packet, size_t lengthInBytes); bool ReadHeader(uint32_t headerAsWords[2]); - bool ReadFromSocket(u_char* packetData, uint32_t expectedLength); + bool ReadFromSocket(uint8_t* packetData, uint32_t expectedLength); - uint32_t ToUint32(u_char* data, TargetEndianness endianness); + uint32_t ToUint32(uint8_t* data, TargetEndianness endianness); - void InsertU32(uint32_t value, u_char* data, TargetEndianness endianness); + void InsertU32(uint32_t value, uint8_t* data, TargetEndianness endianness); static const uint32_t PIPE_MAGIC = 0x45495434; diff --git a/tests/profiling/gatordmock/tests/GatordMockTests.cpp b/tests/profiling/gatordmock/tests/GatordMockTests.cpp index 1440f90905..53f580deaf 100644 --- a/tests/profiling/gatordmock/tests/GatordMockTests.cpp +++ b/tests/profiling/gatordmock/tests/GatordMockTests.cpp @@ -107,9 +107,9 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd) // performance data. //These variables are used to wait for the profiling service - u_int32_t timeout = 2000; - u_int32_t sleepTime = 50; - u_int32_t timeSlept = 0; + uint32_t timeout = 2000; + uint32_t sleepTime = 50; + uint32_t timeSlept = 0; profiling::PacketVersionResolver packetVersionResolver; -- cgit v1.2.1