From 56a23fe4157953cd2a1116a176957c26a707b3ac Mon Sep 17 00:00:00 2001 From: AMS21 Date: Wed, 6 Dec 2023 19:22:26 +0100 Subject: [PATCH] Fix incorrect format specifiers --- src/xrCore/Animation/SkeletonMotions.cpp | 2 +- src/xrCore/LocatorAPI.cpp | 2 +- src/xrCore/log.cpp | 18 +++++++++++++ src/xrCore/xrMemory.cpp | 2 +- src/xrGame/configs_dumper.cpp | 2 +- src/xrGame/debug_text_tree.h | 32 +++++++++++++----------- 6 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/xrCore/Animation/SkeletonMotions.cpp b/src/xrCore/Animation/SkeletonMotions.cpp index 4336edda9ef..41cedbea6a9 100644 --- a/src/xrCore/Animation/SkeletonMotions.cpp +++ b/src/xrCore/Animation/SkeletonMotions.cpp @@ -332,7 +332,7 @@ void motions_container::dump() sz += it->second->mem_usage(); Msg("#%3d: [%3d/%5d Kb] - %s", k, it->second->m_dwReference, it->second->mem_usage() / 1024, it->first.c_str()); } - Msg("--- items: %d, mem usage: %d Kb ", container.size(), sz / 1024); + Msg("--- items: %zu, mem usage: %zu Kb ", container.size(), sz / 1024); Log("--- motion container --- end."); } diff --git a/src/xrCore/LocatorAPI.cpp b/src/xrCore/LocatorAPI.cpp index 73a08a99367..b14f56bb490 100644 --- a/src/xrCore/LocatorAPI.cpp +++ b/src/xrCore/LocatorAPI.cpp @@ -1021,7 +1021,7 @@ void CLocatorAPI::_initialize(u32 flags, pcstr target_folder, pcstr fs_name) }; const size_t M2 = Memory.mem_usage(); - Msg("FS: %d files cached %d archives, %dKb memory used.", m_files.size(), m_archives.size(), (M2 - M1) / 1024); + Msg("FS: %zu files cached %zu archives, %zuKb memory used.", m_files.size(), m_archives.size(), (M2 - M1) / 1024); m_Flags.set(flReady, true); diff --git a/src/xrCore/log.cpp b/src/xrCore/log.cpp index 9d515ccedbd..b9c97e9af30 100644 --- a/src/xrCore/log.cpp +++ b/src/xrCore/log.cpp @@ -131,6 +131,24 @@ void Log(const char* msg, const char* dop) Log(buf); } +void Log(const char* msg, u32 dop) +{ + const u32 buffer_size = (xr_strlen(msg) + 1 + 10 + 1) * sizeof(char); + pstr buf = static_cast(xr_alloca(buffer_size)); + + xr_sprintf(buf, buffer_size, "%s %d", msg, dop); + Log(buf); +} + +void Log(const char* msg, u64 dop) +{ + const u32 buffer_size = (xr_strlen(msg) + 1 + 64 + 1) * sizeof(char); + pstr buf = static_cast(xr_alloca(buffer_size)); + + xr_sprintf(buf, buffer_size, "%s %ull", msg, dop); + Log(buf); +} + void Log(const char* msg, int dop) { const u32 buffer_size = (xr_strlen(msg) + 1 + 11 + 1) * sizeof(char); diff --git a/src/xrCore/xrMemory.cpp b/src/xrCore/xrMemory.cpp index df3e00842e4..efe68a972f0 100644 --- a/src/xrCore/xrMemory.cpp +++ b/src/xrCore/xrMemory.cpp @@ -133,7 +133,7 @@ XRCORE_API void log_vminfo() { size_t w_free, w_reserved, w_committed; vminfo(&w_free, &w_reserved, &w_committed); - Msg("* [ %s ]: free[%d K], reserved[%d K], committed[%d K]", SDL_GetPlatform(), w_free / 1024, w_reserved / 1024, w_committed / 1024); + Msg("* [ %s ]: free[%zu K], reserved[%zu K], committed[%zu K]", SDL_GetPlatform(), w_free / 1024, w_reserved / 1024, w_committed / 1024); } size_t xrMemory::mem_usage() diff --git a/src/xrGame/configs_dumper.cpp b/src/xrGame/configs_dumper.cpp index 1ec934800ea..ea914df358c 100644 --- a/src/xrGame/configs_dumper.cpp +++ b/src/xrGame/configs_dumper.cpp @@ -146,7 +146,7 @@ void configs_dumper::write_configs() string16 tmp_strbuff; for (active_objects_t::size_type i = 0; i < aobjs_count; ++i) { - xr_sprintf(tmp_strbuff, "%d", i + 1); + xr_sprintf(tmp_strbuff, "%zu", i + 1); m_active_params.dump(active_objects[i], tmp_strbuff, active_params_dumper); } active_params_dumper.save_as(m_dump_result); diff --git a/src/xrGame/debug_text_tree.h b/src/xrGame/debug_text_tree.h index 57d3970284f..d6cf8b2495b 100644 --- a/src/xrGame/debug_text_tree.h +++ b/src/xrGame/debug_text_tree.h @@ -1,9 +1,9 @@ //////////////////////////////////////////////////////////////////////////// -// Module : debug_text_tree.h -// Created : 02.04.2008 -// Modified : 03.04.2008 -// Author : Lain -// Description : Text tree for onscreen debugging +// Module : debug_text_tree.h +// Created : 02.04.2008 +// Modified : 03.04.2008 +// Author : Lain +// Description : Text tree for onscreen debugging //////////////////////////////////////////////////////////////////////////// #ifndef AI_DEBUG_TEXT_TREE_H_INCLUDED @@ -23,15 +23,19 @@ IC xr_string __cdecl make_xrstr(pcstr format, ...) IC xr_string __cdecl make_xrstr(bool b) { return b ? "+" : "-"; } IC xr_string __cdecl make_xrstr(float f) { return make_xrstr("%f", f); } - -IC xr_string __cdecl make_xrstr(int d) { return make_xrstr("%i", d); } -IC xr_string __cdecl make_xrstr(unsigned int d) { return make_xrstr("%u", d); } - -IC xr_string __cdecl make_xrstr(long d) { return make_xrstr("%li", d); } -IC xr_string __cdecl make_xrstr(unsigned long d) { return make_xrstr("%lu", d); } - -IC xr_string __cdecl make_xrstr(long long d) { return make_xrstr("%lli", d); } -IC xr_string __cdecl make_xrstr(unsigned long long d) { return make_xrstr("%llu", d); } +IC xr_string __cdecl make_xrstr(s32 d) { return make_xrstr("%i", d); } +IC xr_string __cdecl make_xrstr(u32 d) { return make_xrstr("%u", d); } +IC xr_string __cdecl make_xrstr(s64 d) { return make_xrstr("%ill", d); } +IC xr_string __cdecl make_xrstr(u64 d) { return make_xrstr("%ull", d); } +#ifdef XR_PLATFORM_APPLE +ICF xr_string __cdecl make_xrstr(size_t d) +{ + if constexpr (sizeof(size_t) == sizeof(u32)) + return make_xrstr(static_cast(d)); + else + return make_xrstr(static_cast(d)); +} +#endif IC xr_string __cdecl make_xrstr(Fvector3 v) { return make_xrstr("[%f][%f][%f]", v.x, v.y, v.z); } IC xr_string __cdecl make_xrstr(const xr_string& s) { return s; }