From cd0554c6bc43867bab37fbfccf56274a3d4db1b0 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Sat, 25 Jul 2009 20:35:48 +0000 Subject: [PATCH] Fix Linux build warnings This was SVN commit r7034. --- source/lib/sysdep/os/linux/ldbg.cpp | 4 +++- source/ps/Util.cpp | 4 ++-- source/renderer/Renderer.cpp | 10 +++++----- source/renderer/WaterManager.cpp | 4 ++-- source/scripting/ScriptGlue.cpp | 2 +- source/tools/atlas/GameInterface/MessagePasserImpl.cpp | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/source/lib/sysdep/os/linux/ldbg.cpp b/source/lib/sysdep/os/linux/ldbg.cpp index 5e2dbec10e..fa1bdbb638 100644 --- a/source/lib/sysdep/os/linux/ldbg.cpp +++ b/source/lib/sysdep/os/linux/ldbg.cpp @@ -85,6 +85,8 @@ void* debug_GetCaller(void* UNUSED(context), const char* UNUSED(lastFuncToSkip)) // instead just returning the caller of the function calling us void *bt[3]; int bt_size = backtrace(bt, 3); + if (bt_size < 3) + return NULL; return bt[2]; } @@ -300,7 +302,7 @@ static LibError debug_resolve_symbol_dladdr(void *ptr, char* sym_name, char* fil demangle_buf(sym_name, syminfo.dli_sname, DBG_SYMBOL_LEN); else { - snprintf(sym_name, DBG_SYMBOL_LEN, "0x%08x", (size_t)ptr); + snprintf(sym_name, DBG_SYMBOL_LEN, "%p", ptr); sym_name[DBG_SYMBOL_LEN-1]=0; } } diff --git a/source/ps/Util.cpp b/source/ps/Util.cpp index c863cea671..04d550e31e 100644 --- a/source/ps/Util.cpp +++ b/source/ps/Util.cpp @@ -93,7 +93,7 @@ void WriteSystemInfo() // CPU const CpuTopology* topology = cpu_topology_Detect(); - fprintf(f, "CPU : %s, %s (%dx%dx%d)", un.machine, cpu_IdentifierString(), cpu_topology_NumPackages(topology), cpu_topology_CoresPerPackage(topology), cpu_topology_LogicalPerCore(topology)); + fprintf(f, "CPU : %s, %s (%dx%dx%d)", un.machine, cpu_IdentifierString(), (int)cpu_topology_NumPackages(topology), (int)cpu_topology_CoresPerPackage(topology), (int)cpu_topology_LogicalPerCore(topology)); const double cpu_freq = os_cpu_ClockFrequency(); if(cpu_freq != 0.0f) { @@ -106,7 +106,7 @@ void WriteSystemInfo() fprintf(f, "\n"); // memory - fprintf(f, "Memory : %u MiB; %u MiB free\n", os_cpu_MemorySize(), os_cpu_MemoryAvailable()); + fprintf(f, "Memory : %u MiB; %u MiB free\n", (unsigned)os_cpu_MemorySize(), (unsigned)os_cpu_MemoryAvailable()); // graphics fprintf(f, "Graphics Card : %s\n", gfx_card); diff --git a/source/renderer/Renderer.cpp b/source/renderer/Renderer.cpp index e172347b12..0f45cc42d0 100644 --- a/source/renderer/Renderer.cpp +++ b/source/renderer/Renderer.cpp @@ -149,31 +149,31 @@ CStr CRendererStatsTable::GetCellText(size_t row, size_t col) case Row_Counter: if (col == 0) return "counter"; - snprintf(buf, sizeof(buf), "%d", Stats.m_Counter); + snprintf(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_Counter); return buf; case Row_DrawCalls: if (col == 0) return "# draw calls"; - snprintf(buf, sizeof(buf), "%d", Stats.m_DrawCalls); + snprintf(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_DrawCalls); return buf; case Row_TerrainTris: if (col == 0) return "# terrain tris"; - snprintf(buf, sizeof(buf), "%d", Stats.m_TerrainTris); + snprintf(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_TerrainTris); return buf; case Row_ModelTris: if (col == 0) return "# model tris"; - snprintf(buf, sizeof(buf), "%d", Stats.m_ModelTris); + snprintf(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_ModelTris); return buf; case Row_BlendSplats: if (col == 0) return "# blend splats"; - snprintf(buf, sizeof(buf), "%d", Stats.m_BlendSplats); + snprintf(buf, sizeof(buf), "%lu", (unsigned long)Stats.m_BlendSplats); return buf; default: diff --git a/source/renderer/WaterManager.cpp b/source/renderer/WaterManager.cpp index 1b350e5952..6104782290 100644 --- a/source/renderer/WaterManager.cpp +++ b/source/renderer/WaterManager.cpp @@ -111,7 +111,7 @@ int WaterManager::LoadWaterTextures() while (cur_loading_water_tex < num_textures) { snprintf(filename, ARRAY_SIZE(filename), "art/textures/animated/water/%s/diffuse%02d.dds", - water_type, cur_loading_water_tex+1); + water_type, (int)cur_loading_water_tex+1); Handle ht = ogl_tex_load(filename); if (ht <= 0) { @@ -128,7 +128,7 @@ int WaterManager::LoadWaterTextures() while (cur_loading_normal_map < num_normal_maps) { snprintf(filename, ARRAY_SIZE(filename), "art/textures/animated/water/%s/normal%02d.dds", - water_type, cur_loading_normal_map+1); + water_type, (int)cur_loading_normal_map+1); Handle ht = ogl_tex_load(filename); if (ht <= 0) { diff --git a/source/scripting/ScriptGlue.cpp b/source/scripting/ScriptGlue.cpp index 235d384c8e..6b70efc8e1 100644 --- a/source/scripting/ScriptGlue.cpp +++ b/source/scripting/ScriptGlue.cpp @@ -645,7 +645,7 @@ static void InitJsTimers() for(size_t i = 0; i < MAX_JS_TIMERS; i++) { const char* description = pos; - pos += sprintf(pos, "js_timer %d", i)+1; + pos += sprintf(pos, "js_timer %d", (int)i)+1; timer_AddClient(&js_timer_clients[i], description); } diff --git a/source/tools/atlas/GameInterface/MessagePasserImpl.cpp b/source/tools/atlas/GameInterface/MessagePasserImpl.cpp index 078370feba..53ab2201f0 100644 --- a/source/tools/atlas/GameInterface/MessagePasserImpl.cpp +++ b/source/tools/atlas/GameInterface/MessagePasserImpl.cpp @@ -34,7 +34,7 @@ MessagePasserImpl::MessagePasserImpl() { static char name[1024]; sprintf(name, "/wfg-atlas-msgpass-%d-%d", - rand(1, 1000), (int)(time(0)%1000)); + (int)rand(1, 1000), (int)(time(0)%1000)); sem_t* sem = sem_open(name, O_CREAT | O_EXCL, 0700, 0); // This cast should not be necessary, but apparently SEM_FAILED is not