From 707117c04f3eabcd93e980e39c1cf62dbe459491 Mon Sep 17 00:00:00 2001 From: ikrima Date: Sat, 2 May 2020 14:51:52 -0700 Subject: [PATCH] Build sanitization & Static analysis warning fixes - Wrapping FORCEINLINE & WIN32_LEAN_AND_MEAN definess with ifndef bc other libraries may define it and trigger redefinition warning - Possibly contentious given tone in the manual (:P) but removing variable shadowing in TracySysTrace.cpp - Alternate Solution: Add #define TRACY_FORCE_SILENT_WARNINGS toggle-able flag. If flag is enabled, push/pop warning disables that have to be included in client code --- client/TracySysTrace.cpp | 14 +++++++------- client/tracy_rpmalloc.cpp | 14 +++++++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/client/TracySysTrace.cpp b/client/TracySysTrace.cpp index 4241f3ea..076332c4 100644 --- a/client/TracySysTrace.cpp +++ b/client/TracySysTrace.cpp @@ -350,10 +350,10 @@ void SysTraceSendExternalName( uint64_t thread ) { if( (uint64_t)ptr >= (uint64_t)info.lpBaseOfDll && (uint64_t)ptr <= (uint64_t)info.lpBaseOfDll + (uint64_t)info.SizeOfImage ) { - char buf[1024]; - if( _GetModuleBaseNameA( phnd, modules[i], buf, 1024 ) != 0 ) + char buf2[1024]; + if( _GetModuleBaseNameA( phnd, modules[i], buf2, 1024 ) != 0 ) { - GetProfiler().SendString( thread, buf, QueueType::ExternalThreadName ); + GetProfiler().SendString( thread, buf2, QueueType::ExternalThreadName ); threadSent = true; } } @@ -389,13 +389,13 @@ void SysTraceSendExternalName( uint64_t thread ) const auto phnd = OpenProcess( PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid ); if( phnd != INVALID_HANDLE_VALUE ) { - char buf[1024]; - const auto sz = GetProcessImageFileNameA( phnd, buf, 1024 ); + char buf2[1024]; + const auto sz = GetProcessImageFileNameA( phnd, buf2, 1024 ); CloseHandle( phnd ); if( sz != 0 ) { - auto ptr = buf + sz - 1; - while( ptr > buf && *ptr != '\\' ) ptr--; + auto ptr = buf2 + sz - 1; + while( ptr > buf2 && *ptr != '\\' ) ptr--; if( *ptr == '\\' ) ptr++; GetProfiler().SendString( thread, ptr, QueueType::ExternalName ); return; diff --git a/client/tracy_rpmalloc.cpp b/client/tracy_rpmalloc.cpp index e7596aba..a2e2fd38 100644 --- a/client/tracy_rpmalloc.cpp +++ b/client/tracy_rpmalloc.cpp @@ -110,13 +110,17 @@ #define _Static_assert static_assert /// Platform and arch specifics -#if defined(_MSC_VER) && !defined(__clang__) -# define FORCEINLINE inline __forceinline -#else -# define FORCEINLINE inline __attribute__((__always_inline__)) +#ifndef FORCEINLINE +# if defined(_MSC_VER) && !defined(__clang__) +# define FORCEINLINE inline __forceinline +# else +# define FORCEINLINE inline __attribute__((__always_inline__)) +# endif #endif #if PLATFORM_WINDOWS -# define WIN32_LEAN_AND_MEAN +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif # include # if ENABLE_VALIDATE_ARGS # include