Skip to content

Commit

Permalink
Fix incorrect format specifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
AMS21 committed Feb 5, 2024
1 parent ecfc127 commit 56a23fe
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/xrCore/Animation/SkeletonMotions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}

Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/LocatorAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
18 changes: 18 additions & 0 deletions src/xrCore/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<pstr>(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<pstr>(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);
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/xrMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/configs_dumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
32 changes: 18 additions & 14 deletions src/xrGame/debug_text_tree.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<u32>(d));
else
return make_xrstr(static_cast<u64>(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; }
Expand Down

0 comments on commit 56a23fe

Please sign in to comment.