From b6cce4ddb6958de436a96ae069ef285758774554 Mon Sep 17 00:00:00 2001 From: Tobias Widlund Date: Sat, 30 Jun 2018 15:36:06 +0200 Subject: [PATCH] Improve fixes for warnings as per request --- client/TracyCallstack.cpp | 2 +- client/TracyProfiler.cpp | 8 ++++---- common/TracyAlloc.hpp | 1 + common/TracySystem.cpp | 30 ++++++++++++++++-------------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/client/TracyCallstack.cpp b/client/TracyCallstack.cpp index 9857a827..daf5ce02 100644 --- a/client/TracyCallstack.cpp +++ b/client/TracyCallstack.cpp @@ -1,5 +1,5 @@ +#include "stdio.h" #include "TracyCallstack.hpp" -#include #ifdef TRACY_HAS_CALLSTACK diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index b14289dd..be4a769c 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -775,10 +775,10 @@ void Profiler::CalibrateDelay() auto mindiff = std::numeric_limits::max(); for( int i=0; i 0 && dt_inner < mindiff ) mindiff = dt_inner; + const auto t0i = GetTime(); + const auto t1i = GetTime(); + const auto dti = t1i - t0i; + if( dti > 0 && dti < mindiff ) mindiff = dti; } m_resolution = mindiff; diff --git a/common/TracyAlloc.hpp b/common/TracyAlloc.hpp index ae19312c..3fde086e 100644 --- a/common/TracyAlloc.hpp +++ b/common/TracyAlloc.hpp @@ -1,5 +1,6 @@ #ifndef __TRACYALLOC_HPP__ #define __TRACYALLOC_HPP__ + #include #ifdef TRACY_ENABLE diff --git a/common/TracySystem.cpp b/common/TracySystem.cpp index bef0c22e..bfe06266 100644 --- a/common/TracySystem.cpp +++ b/common/TracySystem.cpp @@ -69,26 +69,28 @@ void SetThreadName( std::thread::native_handle_type handle, const char* name ) } # endif #elif defined _GNU_SOURCE && !defined __EMSCRIPTEN__ - const auto sz = strlen( name ); - if( sz <= 15 ) { - pthread_setname_np( handle, name ); - } - else - { - char buf[16]; - memcpy( buf, name, 15 ); - buf[15] = '\0'; - pthread_setname_np( handle, buf ); + const auto sz = strlen( name ); + if( sz <= 15 ) + { + pthread_setname_np( handle, name ); + } + else + { + char buf[16]; + memcpy( buf, name, 15 ); + buf[15] = '\0'; + pthread_setname_np( handle, buf ); + } } #endif #ifdef TRACY_COLLECT_THREAD_NAMES { rpmalloc_thread_initialize(); - const auto sz_inner = strlen( name ); - char* buf = (char*)tracy_malloc( sz_inner+1 ); - memcpy( buf, name, sz_inner ); - buf[sz_inner+1] = '\0'; + const auto sz = strlen( name ); + char* buf = (char*)tracy_malloc( sz+1 ); + memcpy( buf, name, sz ); + buf[sz+1] = '\0'; auto data = (ThreadNameData*)tracy_malloc( sizeof( ThreadNameData ) ); # ifdef _WIN32 data->id = GetThreadId( static_cast( handle ) );