diff --git a/build/dehydra/printf-type-check.js b/build/dehydra/printf-type-check.js index b519145095..e1134d3557 100644 --- a/build/dehydra/printf-type-check.js +++ b/build/dehydra/printf-type-check.js @@ -125,24 +125,34 @@ function compare_format_type(ctype, functype, fmt, arg, loc) { error('Illegal %hs used in printf-style function', loc()); if (functype == 'printf') { - if (t.match(/^[diouxXc]$/)) - return (arg == 'int' || arg == 'unsigned int'); + if (t.match(/^[dic]$/)) + return (arg == 'int'); + if (t.match(/^[ouxX]$/)) + return (arg == 'unsigned int'); if (t.match(/^lc$/)) return (arg == 'int' || arg == 'unsigned int'); // spec says wint_t - if (t.match(/^l[diouxX]$/)) - return (arg == 'long int' || arg == 'long unsigned int'); - if (t.match(/^ll[diouxX]$/)) - return (arg == 'long long int' || arg == 'long long unsigned int'); + if (t.match(/^l[di]$/)) + return (arg == 'long int'); + if (t.match(/^l[ouxX]$/)) + return (arg == 'long unsigned int'); + if (t.match(/^ll[di]$/)) + return (arg == 'long long int'); + if (t.match(/^ll[ouxX]$/)) + return (arg == 'long long unsigned int'); if (t.match(/^[fFeEgGaA]$/)) return (arg == 'double'); if (t.match(/^p$/)) return (arg.match(/\*$/)); // ... } else if (functype == 'scanf') { - if (t.match(/^[dioux]$/)) + if (t.match(/^[di]$/)) return (arg == 'int*'); - if (t.match(/^l[diouxX]$/)) + if (t.match(/^[ouxX]$/)) + return (arg == 'unsigned int*'); + if (t.match(/^l[di]$/)) return (arg == 'long int*'); + if (t.match(/^l[ouxX]$/)) + return (arg == 'long unsigned int*'); if (t.match(/^z[diouxX]$/)) return (arg == 'long unsigned int*'); // spec says size_t* if (t.match(/^[c[]$/)) diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index 18fdf8fb6d..0b7fef008c 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -1060,7 +1060,7 @@ void CGUI::LoadXmlFile(const VfsPath& Filename, boost::unordered_set& P } catch (PSERROR_GUI& e) { - LOGERROR(L"Errors loading GUI file %ls (%d)", Filename.string().c_str(), e.getCode()); + LOGERROR(L"Errors loading GUI file %ls (%u)", Filename.string().c_str(), e.getCode()); return; } } diff --git a/source/lib/ogl.cpp b/source/lib/ogl.cpp index 39f1d7c596..8b8d378fc9 100644 --- a/source/lib/ogl.cpp +++ b/source/lib/ogl.cpp @@ -391,7 +391,7 @@ void ogl_WarnIfError() } if(error_enountered) - debug_printf(L"OpenGL error(s) occurred: %04x\n", (int)first_error); + debug_printf(L"OpenGL error(s) occurred: %04x\n", (unsigned int)first_error); } #endif @@ -430,7 +430,7 @@ bool ogl_SquelchError(GLenum err_to_ignore) } if(error_enountered) - debug_printf(L"OpenGL error(s) occurred: %04x\n", (int)first_error); + debug_printf(L"OpenGL error(s) occurred: %04x\n", (unsigned int)first_error); return error_ignored; } diff --git a/source/lib/res/graphics/ogl_tex.cpp b/source/lib/res/graphics/ogl_tex.cpp index f8fc9f1433..db19a889e3 100644 --- a/source/lib/res/graphics/ogl_tex.cpp +++ b/source/lib/res/graphics/ogl_tex.cpp @@ -505,7 +505,7 @@ static Status OglTex_validate(const OglTex* ot) static Status OglTex_to_string(const OglTex* ot, wchar_t* buf) { - swprintf_s(buf, H_STRING_LEN, L"OglTex id=%d flags=%x", ot->id, ot->flags); + swprintf_s(buf, H_STRING_LEN, L"OglTex id=%u flags=%x", ot->id, (unsigned int)ot->flags); return INFO::OK; } diff --git a/source/lib/res/sound/snd_mgr.cpp b/source/lib/res/sound/snd_mgr.cpp index bfc7d0df2f..68f7a0939c 100644 --- a/source/lib/res/sound/snd_mgr.cpp +++ b/source/lib/res/sound/snd_mgr.cpp @@ -933,7 +933,7 @@ static Status SndData_validate(const SndData* sd) static Status SndData_to_string(const SndData* sd, wchar_t* buf) { const wchar_t* type = (sd->type == SD_CLIP)? L"clip" : L"stream"; - swprintf_s(buf, H_STRING_LEN, L"%ls; al_buf=%d", type, sd->al_buf); + swprintf_s(buf, H_STRING_LEN, L"%ls; al_buf=%u", type, sd->al_buf); return INFO::OK; } @@ -1309,7 +1309,7 @@ static Status VSrc_validate(const VSrc* vs) static Status VSrc_to_string(const VSrc* vs, wchar_t* buf) { - swprintf_s(buf, H_STRING_LEN, L"al_src = %d", vs->al_src); + swprintf_s(buf, H_STRING_LEN, L"al_src = %u", vs->al_src); return INFO::OK; } diff --git a/source/lib/status.cpp b/source/lib/status.cpp index 1fe1cb063e..92415d729f 100644 --- a/source/lib/status.cpp +++ b/source/lib/status.cpp @@ -85,7 +85,7 @@ wchar_t* StatusDescription(Status status, wchar_t* buf, size_t max_chars) return buf; } - swprintf_s(buf, max_chars, L"Unknown error (%lld, 0x%llX)", (long long)status, (long long)status); + swprintf_s(buf, max_chars, L"Unknown error (%lld, 0x%llX)", (long long)status, (unsigned long long)status); return buf; } diff --git a/source/lib/sysdep/arch/x86_x64/cache.cpp b/source/lib/sysdep/arch/x86_x64/cache.cpp index f40099cd25..9b87f42899 100644 --- a/source/lib/sysdep/arch/x86_x64/cache.cpp +++ b/source/lib/sysdep/arch/x86_x64/cache.cpp @@ -530,7 +530,7 @@ static const Characteristics* CharacteristicsFromDescriptor(Descriptor descripto return &characteristics; } - debug_printf(L"Unknown cache/TLB descriptor 0x%x\n", descriptor); + debug_printf(L"Unknown cache/TLB descriptor 0x%x\n", (unsigned int)descriptor); return 0; } diff --git a/source/maths/tests/test_MD5.h b/source/maths/tests/test_MD5.h index c447a7c52d..63ac0e71eb 100644 --- a/source/maths/tests/test_MD5.h +++ b/source/maths/tests/test_MD5.h @@ -26,7 +26,7 @@ public: { char digeststr[MD5::DIGESTSIZE*2+1]; for (size_t i = 0; i < MD5::DIGESTSIZE; ++i) - sprintf_s(digeststr+2*i, 3, "%02x", digest[i]); + sprintf_s(digeststr+2*i, 3, "%02x", (unsigned int)digest[i]); return digeststr; } diff --git a/source/network/NetClient.cpp b/source/network/NetClient.cpp index 548d879510..ceb2b1912d 100644 --- a/source/network/NetClient.cpp +++ b/source/network/NetClient.cpp @@ -266,7 +266,7 @@ bool CNetClient::HandleMessage(CNetMessage* message) std::stringstream stream; - LOGMESSAGERENDER(L"Serializing game at turn %d for rejoining player", m_ClientTurnManager->GetCurrentTurn()); + LOGMESSAGERENDER(L"Serializing game at turn %u for rejoining player", m_ClientTurnManager->GetCurrentTurn()); u32 turn = to_le32(m_ClientTurnManager->GetCurrentTurn()); stream.write((char*)&turn, sizeof(turn)); @@ -306,7 +306,7 @@ void CNetClient::LoadFinished() stream.read((char*)&turn, sizeof(turn)); turn = to_le32(turn); - LOGMESSAGE(L"Rejoining client deserializing state at turn %d\n", turn); + LOGMESSAGE(L"Rejoining client deserializing state at turn %u\n", turn); bool ok = m_Game->GetSimulation2()->DeserializeState(stream); ENSURE(ok); @@ -381,7 +381,7 @@ bool CNetClient::OnAuthenticate(void* context, CFsmEvent* event) CAuthenticateResultMessage* message = (CAuthenticateResultMessage*)event->GetParamRef(); - LOGMESSAGE(L"Net: Authentication result: host=%d, %ls", message->m_HostID, message->m_Message.c_str()); + LOGMESSAGE(L"Net: Authentication result: host=%u, %ls", message->m_HostID, message->m_Message.c_str()); bool isRejoining = (message->m_Code == ARC_OK_REJOINING); diff --git a/source/network/NetServer.cpp b/source/network/NetServer.cpp index 85409d564a..06c6573163 100644 --- a/source/network/NetServer.cpp +++ b/source/network/NetServer.cpp @@ -317,7 +317,7 @@ bool CNetServerWorker::RunStep() // Report the client address char hostname[256] = "(error)"; enet_address_get_host_ip(&event.peer->address, hostname, ARRAY_SIZE(hostname)); - LOGMESSAGE(L"Net server: Received connection from %hs:%u", hostname, event.peer->address.port); + LOGMESSAGE(L"Net server: Received connection from %hs:%u", hostname, (unsigned int)event.peer->address.port); // Set up a session object for this peer diff --git a/source/network/NetSession.cpp b/source/network/NetSession.cpp index 5d92ef0bce..6bdaa57db5 100644 --- a/source/network/NetSession.cpp +++ b/source/network/NetSession.cpp @@ -112,7 +112,7 @@ void CNetClientSession::Poll() // Report the server address char hostname[256] = "(error)"; enet_address_get_host_ip(&event.peer->address, hostname, ARRAY_SIZE(hostname)); - LOGMESSAGE(L"Net client: Connected to %hs:%u", hostname, event.peer->address.port); + LOGMESSAGE(L"Net client: Connected to %hs:%u", hostname, (unsigned int)event.peer->address.port); m_Client.HandleConnect(); diff --git a/source/network/tests/test_Net.h b/source/network/tests/test_Net.h index 5300b0edb4..54d8296fc7 100644 --- a/source/network/tests/test_Net.h +++ b/source/network/tests/test_Net.h @@ -273,7 +273,7 @@ public: for (size_t i = 0; ; ++i) { - debug_printf(L"[%d]\n", client2B.GetCurrState()); + debug_printf(L"[%u]\n", client2B.GetCurrState()); client2B.Poll(); if (client2B.GetCurrState() == NCS_PREGAME) break; diff --git a/source/ps/Profiler2GPU.cpp b/source/ps/Profiler2GPU.cpp index 445471d693..7afd444e9f 100644 --- a/source/ps/Profiler2GPU.cpp +++ b/source/ps/Profiler2GPU.cpp @@ -252,7 +252,7 @@ private: // Associate the frame number with the "frame" region if (i == 0) - m_Storage.RecordAttributePrintf("%d", frame.num); + m_Storage.RecordAttributePrintf("%u", frame.num); } PopFrontFrame(); @@ -404,7 +404,7 @@ private: // Associate the frame number with the "frame" region if (i == 0) - m_Storage.RecordAttributePrintf("%d", frame.num); + m_Storage.RecordAttributePrintf("%u", frame.num); // Advance by the elapsed time to the next event GLuint64 queryElapsed = 0; @@ -636,7 +636,7 @@ private: m_Storage.Record(CProfiler2::ITEM_ENTER, lastTime, frame.events[i].id); if (i == 0) - m_Storage.RecordAttributePrintf("%d", frame.num); + m_Storage.RecordAttributePrintf("%u", frame.num); double elapsed = 0.0; @@ -659,7 +659,7 @@ private: ENSURE(counter.size == 4); GLuint value; memcpy(&value, buf + counter.offset, counter.size); - m_Storage.RecordAttributePrintf("%s: %d", counter.name.c_str(), value); + m_Storage.RecordAttributePrintf("%s: %u", counter.name.c_str(), value); } else if (counter.type == INTEL_PERFQUERIES_TYPE_UNSIGNED_INT64) { @@ -684,7 +684,7 @@ private: GLuint value; memcpy(&value, buf + counter.offset, counter.size); ENSURE(value == 0 || value == 1); - m_Storage.RecordAttributePrintf("%s: %d", counter.name.c_str(), value); + m_Storage.RecordAttributePrintf("%s: %u", counter.name.c_str(), value); } else { diff --git a/source/ps/Replay.cpp b/source/ps/Replay.cpp index 7bd774ba89..f7a22adb8c 100644 --- a/source/ps/Replay.cpp +++ b/source/ps/Replay.cpp @@ -166,7 +166,7 @@ void CReplayPlayer::Replay() else if (type == "turn") { *m_Stream >> turn >> turnLength; - debug_printf(L"Turn %d (%d)... ", turn, turnLength); + debug_printf(L"Turn %u (%u)... ", turn, turnLength); } else if (type == "cmd") { diff --git a/source/ps/UserReport.cpp b/source/ps/UserReport.cpp index c831e5580a..120badd9ab 100644 --- a/source/ps/UserReport.cpp +++ b/source/ps/UserReport.cpp @@ -533,7 +533,7 @@ std::string CUserReporter::LoadUserID() for (size_t i = 0; i < ARRAY_SIZE(bytes); ++i) { char hex[3]; - sprintf_s(hex, ARRAY_SIZE(hex), "%02x", bytes[i]); + sprintf_s(hex, ARRAY_SIZE(hex), "%02x", (unsigned int)bytes[i]); userID += hex; } diff --git a/source/renderer/ShadowMap.cpp b/source/renderer/ShadowMap.cpp index aab722d423..2631ba70bb 100644 --- a/source/renderer/ShadowMap.cpp +++ b/source/renderer/ShadowMap.cpp @@ -401,7 +401,7 @@ void ShadowMapInternals::CreateTexture() if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { - LOGWARNING(L"Framebuffer object incomplete: %04d", status); + LOGWARNING(L"Framebuffer object incomplete: 0x%04X", status); // Disable shadow rendering (but let the user try again if they want) g_Renderer.m_Options.m_Shadows = false; diff --git a/source/simulation2/components/CCmpPathfinder_Tile.cpp b/source/simulation2/components/CCmpPathfinder_Tile.cpp index 273e716a81..f54a19a870 100644 --- a/source/simulation2/components/CCmpPathfinder_Tile.cpp +++ b/source/simulation2/components/CCmpPathfinder_Tile.cpp @@ -493,7 +493,7 @@ void CCmpPathfinder::ComputePath(entity_pos_t x0, entity_pos_t z0, const Goal& g PROFILE2_ATTR("from: (%d, %d)", i0, j0); PROFILE2_ATTR("to: (%d, %d)", state.iGoal, state.jGoal); PROFILE2_ATTR("reached: (%d, %d)", state.iBest, state.jBest); - PROFILE2_ATTR("steps: %d", state.steps); + PROFILE2_ATTR("steps: %u", state.steps); #if PATHFIND_STATS printf("PATHFINDER: steps=%d avgo=%d proc=%d impc=%d impo=%d addo=%d\n", state.steps, state.sumOpenSize/state.steps, state.numProcessed, state.numImproveClosed, state.numImproveOpen, state.numAddToOpen); diff --git a/source/simulation2/components/CCmpRangeManager.cpp b/source/simulation2/components/CCmpRangeManager.cpp index e9c275bd57..9d8c68d641 100644 --- a/source/simulation2/components/CCmpRangeManager.cpp +++ b/source/simulation2/components/CCmpRangeManager.cpp @@ -526,7 +526,7 @@ public: { if (m_Queries.find(tag) == m_Queries.end()) { - LOGERROR(L"CCmpRangeManager: DestroyActiveQuery called with invalid tag %d", tag); + LOGERROR(L"CCmpRangeManager: DestroyActiveQuery called with invalid tag %u", tag); return; } @@ -538,7 +538,7 @@ public: std::map::iterator it = m_Queries.find(tag); if (it == m_Queries.end()) { - LOGERROR(L"CCmpRangeManager: EnableActiveQuery called with invalid tag %d", tag); + LOGERROR(L"CCmpRangeManager: EnableActiveQuery called with invalid tag %u", tag); return; } @@ -551,7 +551,7 @@ public: std::map::iterator it = m_Queries.find(tag); if (it == m_Queries.end()) { - LOGERROR(L"CCmpRangeManager: DisableActiveQuery called with invalid tag %d", tag); + LOGERROR(L"CCmpRangeManager: DisableActiveQuery called with invalid tag %u", tag); return; } @@ -594,7 +594,7 @@ public: std::map::iterator it = m_Queries.find(tag); if (it == m_Queries.end()) { - LOGERROR(L"CCmpRangeManager: ResetActiveQuery called with invalid tag %d", tag); + LOGERROR(L"CCmpRangeManager: ResetActiveQuery called with invalid tag %u", tag); return r; } @@ -777,11 +777,11 @@ public: { // Min range must be non-negative if (minRange < entity_pos_t::Zero()) - LOGWARNING(L"CCmpRangeManager: Invalid min range %f in query for entity %d", minRange.ToDouble(), source); + LOGWARNING(L"CCmpRangeManager: Invalid min range %f in query for entity %u", minRange.ToDouble(), source); // Max range must be non-negative, or else -1 if (maxRange < entity_pos_t::Zero() && maxRange != entity_pos_t::FromInt(-1)) - LOGWARNING(L"CCmpRangeManager: Invalid max range %f in query for entity %d", maxRange.ToDouble(), source); + LOGWARNING(L"CCmpRangeManager: Invalid max range %f in query for entity %u", maxRange.ToDouble(), source); Query q; q.enabled = false; diff --git a/source/simulation2/components/CCmpUnitMotion.cpp b/source/simulation2/components/CCmpUnitMotion.cpp index 9175d88c4c..f08b28901a 100644 --- a/source/simulation2/components/CCmpUnitMotion.cpp +++ b/source/simulation2/components/CCmpUnitMotion.cpp @@ -709,7 +709,7 @@ void CCmpUnitMotion::PathResult(u32 ticket, const ICmpPathfinder::Path& path) } else { - LOGWARNING(L"unexpected PathResult (%d %d %d)", GetEntityId(), m_State, m_PathState); + LOGWARNING(L"unexpected PathResult (%u %d %d)", GetEntityId(), m_State, m_PathState); } } diff --git a/source/simulation2/serialization/DebugSerializer.cpp b/source/simulation2/serialization/DebugSerializer.cpp index 561c58e404..5936033002 100644 --- a/source/simulation2/serialization/DebugSerializer.cpp +++ b/source/simulation2/serialization/DebugSerializer.cpp @@ -161,7 +161,7 @@ void CDebugSerializer::PutRaw(const char* name, const u8* data, size_t len) char buf[4]; for (size_t i = 0; i < len; ++i) { - sprintf_s(buf, ARRAY_SIZE(buf), " %02x", data[i]); + sprintf_s(buf, ARRAY_SIZE(buf), " %02x", (unsigned int)data[i]); m_Stream << buf; } diff --git a/source/simulation2/tests/test_Serializer.h b/source/simulation2/tests/test_Serializer.h index 8df03fad3e..6601472a72 100644 --- a/source/simulation2/tests/test_Serializer.h +++ b/source/simulation2/tests/test_Serializer.h @@ -522,7 +522,7 @@ public: debug_printf(L"# size = %d\n", (int)str.str().length()); debug_printf(L"# hash = "); for (size_t i = 0; i < hash.size(); ++i) - debug_printf(L"%02x", (u8)hash[i]); + debug_printf(L"%02x", (unsigned int)(u8)hash[i]); debug_printf(L"\n"); }