From fadf8e3e0a2f6da21d5993dd9dfa0de02c8bbea5 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 22 Jun 2019 14:08:48 +0200 Subject: [PATCH] Can't read negative number of bytes. This completely ignores error handling, which probably should be added. The code behavior doesn't change, as the existing comparisons and asserts already promoted the signed value to unsigned. --- common/TracySocket.cpp | 4 ++-- common/TracySocket.hpp | 2 +- profiler/src/main.cpp | 2 +- server/TracyFileRead.hpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/TracySocket.cpp b/common/TracySocket.cpp index dd6867f2..70cafb22 100644 --- a/common/TracySocket.cpp +++ b/common/TracySocket.cpp @@ -518,7 +518,7 @@ void UdpListen::Close() m_sock = -1; } -const char* UdpListen::Read( int& len, IpAddress& addr ) +const char* UdpListen::Read( size_t& len, IpAddress& addr ) { static char buf[2048]; @@ -529,7 +529,7 @@ const char* UdpListen::Read( int& len, IpAddress& addr ) sockaddr sa; socklen_t salen = sizeof( struct sockaddr ); - len = recvfrom( m_sock, buf, 2048, 0, &sa, &salen ); + len = (size_t)recvfrom( m_sock, buf, 2048, 0, &sa, &salen ); addr.Set( sa ); return buf; diff --git a/common/TracySocket.hpp b/common/TracySocket.hpp index 6e9f66c9..e01889d4 100644 --- a/common/TracySocket.hpp +++ b/common/TracySocket.hpp @@ -115,7 +115,7 @@ public: bool Listen( int port ); void Close(); - const char* Read( int& len, IpAddress& addr ); + const char* Read( size_t& len, IpAddress& addr ); UdpListen( const UdpListen& ) = delete; UdpListen( UdpListen&& ) = delete; diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 493ea3ee..1485bb6b 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -295,7 +295,7 @@ int main( int argc, char** argv ) else { tracy::IpAddress addr; - int len; + size_t len; auto msg = broadcastListen->Read( len, addr ); if( msg ) { diff --git a/server/TracyFileRead.hpp b/server/TracyFileRead.hpp index 2b07255d..4191ccd0 100644 --- a/server/TracyFileRead.hpp +++ b/server/TracyFileRead.hpp @@ -202,7 +202,7 @@ private: if( fread( &sz, 1, sizeof( sz ), m_file ) == sizeof( sz ) ) { fread( m_lz4buf, 1, sz, m_file ); - m_lastBlock = LZ4_decompress_safe_continue( m_stream, m_lz4buf, m_second, sz, BufSize ); + m_lastBlock = (size_t)LZ4_decompress_safe_continue( m_stream, m_lz4buf, m_second, sz, BufSize ); } else { @@ -219,7 +219,7 @@ private: char* m_buf; char* m_second; size_t m_offset; - int m_lastBlock; + size_t m_lastBlock; std::atomic m_signalSwitch; std::atomic m_signalAvailable;