From 8459cd928c2dfa0155fbeda5410b14a98805d78a Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Sat, 27 Aug 2022 09:33:01 +0200 Subject: [PATCH] fix some printf format specifiers (#76) use the definition in cinttypes for portability --- src/Cafe/HW/Latte/Core/LatteOverlay.cpp | 10 ++++++---- src/Cafe/OS/libs/nn_acp/nn_acp.cpp | 7 ++++--- src/Cemu/Tools/DownloadManager/DownloadManager.cpp | 3 ++- src/gui/MemorySearcherTool.cpp | 2 +- .../windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp | 6 ++++-- src/util/Zir/Core/IR.cpp | 10 ++++++---- 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteOverlay.cpp b/src/Cafe/HW/Latte/Core/LatteOverlay.cpp index ae483c32..998043d4 100644 --- a/src/Cafe/HW/Latte/Core/LatteOverlay.cpp +++ b/src/Cafe/HW/Latte/Core/LatteOverlay.cpp @@ -13,6 +13,8 @@ #include "input/InputManager.h" +#include + #if BOOST_OS_WINDOWS #include #include @@ -405,16 +407,16 @@ void LatteOverlay_RenderNotifications(ImVec2& position, ImVec2& pivot, sint32 di if (s_pipeline_count_async > 0) { if (s_pipeline_count > 1) - ImGui::Text("Compiled %d new pipelines... (%d async) TotalSync: %lldms", s_pipeline_count, s_pipeline_count_async, totalTime); + ImGui::Text("Compiled %d new pipelines... (%d async) TotalSync: %" PRIu64 "ms", s_pipeline_count, s_pipeline_count_async, totalTime); else - ImGui::Text("Compiled %d new pipeline... (%d async) TotalSync: %lldms", s_pipeline_count, s_pipeline_count_async, totalTime); + ImGui::Text("Compiled %d new pipeline... (%d async) TotalSync: %" PRIu64 "ms", s_pipeline_count, s_pipeline_count_async, totalTime); } else { if (s_pipeline_count > 1) - ImGui::Text("Compiled %d new pipelines... TotalSync: %lldms", s_pipeline_count, totalTime); + ImGui::Text("Compiled %d new pipelines... TotalSync: %" PRIu64 "ms", s_pipeline_count, totalTime); else - ImGui::Text("Compiled %d new pipeline... TotalSync: %lldms", s_pipeline_count, totalTime); + ImGui::Text("Compiled %d new pipeline... TotalSync: %" PRIu64 "ms", s_pipeline_count, totalTime); } #else if (s_pipeline_count_async > 0) diff --git a/src/Cafe/OS/libs/nn_acp/nn_acp.cpp b/src/Cafe/OS/libs/nn_acp/nn_acp.cpp index 97f183c1..48aa3c00 100644 --- a/src/Cafe/OS/libs/nn_acp/nn_acp.cpp +++ b/src/Cafe/OS/libs/nn_acp/nn_acp.cpp @@ -5,6 +5,7 @@ #include "Cafe/OS/libs/coreinit/coreinit_IOS.h" #include "Cafe/OS/libs/coreinit/coreinit_Time.h" +#include #include #include @@ -102,7 +103,7 @@ namespace acp { // found the entry! -> update timestamp xml::XMLElement* timestamp = account->FirstChildElement("timestamp"); - sprintf(tmp, "%016llx", _acpGetTimestamp()); + sprintf(tmp, "%" PRIx64, _acpGetTimestamp()); if (timestamp) timestamp->SetText(tmp); else @@ -125,7 +126,7 @@ namespace acp tinyxml2::XMLElement* timestamp = doc.NewElement("timestamp"); { - sprintf(tmp, "%016llx", _acpGetTimestamp()); + sprintf(tmp, "%" PRIx64, _acpGetTimestamp()); timestamp->SetText(tmp); } @@ -506,4 +507,4 @@ namespace acp osLib_addFunction("nn_acp", "ACPConvertNetworkTimeToOSCalendarTime", export_ACPConvertNetworkTimeToOSCalendarTime); } } -} \ No newline at end of file +} diff --git a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp index 8a0aa895..edaa2e00 100644 --- a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp +++ b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp @@ -15,6 +15,7 @@ #include "Cafe/Filesystem/FST/FST.h" #include "Cafe/TitleList/TitleList.h" +#include #include #include #include @@ -580,7 +581,7 @@ void DownloadManager::searchForIncompleteDownloads() uint64 titleId; uint32 version; std::string name = p.path().filename().generic_string(); - if( sscanf(name.c_str(), "cemu_%016llx_v%u", &titleId, &version) != 2) + if( sscanf(name.c_str(), "cemu_% " PRIx64 "_v%u", &titleId, &version) != 2) continue; std::unique_lock _l(m_mutex); for (auto& itr : m_ticketCache) diff --git a/src/gui/MemorySearcherTool.cpp b/src/gui/MemorySearcherTool.cpp index 9fd55dcd..f86bf462 100644 --- a/src/gui/MemorySearcherTool.cpp +++ b/src/gui/MemorySearcherTool.cpp @@ -400,7 +400,7 @@ void MemorySearcherTool::OnResultListClick(wxMouseEvent& event) auto currValue = m_listResults->GetItemText(selectedIndex, 1); char addressString[256]; - sprintf(addressString, "0x%08x", address); + sprintf(addressString, "0x%08lx", address); // description, address, type, value, freeze wxVector data; diff --git a/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp b/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp index cd509a52..93eaa596 100644 --- a/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp +++ b/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp @@ -5,6 +5,8 @@ #include "Cafe/OS/RPL/rpl.h" #include "Cafe/OS/RPL/rpl_symbol_storage.h" +#include + enum { // options @@ -233,11 +235,11 @@ void DebugPPCThreadsWindow::RefreshThreadList() m_thread_list->SetItem(i, 7, tempStr); // last awake in cycles uint64 lastWakeUpTime = cafeThread->wakeUpTime; - sprintf(tempStr, "%I64u", lastWakeUpTime); + sprintf(tempStr, "%" PRIu64, lastWakeUpTime); m_thread_list->SetItem(i, 8, tempStr); // awake time in cycles uint64 awakeTime = cafeThread->totalCycles; - sprintf(tempStr, "%I64u", awakeTime); + sprintf(tempStr, "%" PRIu64, awakeTime); m_thread_list->SetItem(i, 9, tempStr); // thread name const char* threadName = "NULL"; diff --git a/src/util/Zir/Core/IR.cpp b/src/util/Zir/Core/IR.cpp index 5fdfba61..9e1e3e8b 100644 --- a/src/util/Zir/Core/IR.cpp +++ b/src/util/Zir/Core/IR.cpp @@ -1,6 +1,8 @@ #include "util/Zir/Core/IR.h" #include "util/Zir/Core/ZpIRDebug.h" +#include + namespace ZpIR { @@ -201,15 +203,15 @@ namespace ZpIR void DebugPrinter::debugPrintBlock(ZpIRBasicBlock* block) { // print name - printf("IRBasicBlock %016llx\n", (uintptr_t)block); + printf("IRBasicBlock %" PRIxPTR "\n", (uintptr_t)block); // print imports printf("Imports:\n"); for(auto itr : block->m_imports) - printf(" reg: %s sym:0x%llx\n", getRegisterName(block, itr.reg).c_str(), itr.name); + printf(" reg: %s sym:0x%lux\n", getRegisterName(block, itr.reg).c_str(), itr.name); // print exports printf("Exports:\n"); for (auto itr : block->m_exports) - printf(" reg: %s sym:0x%llx\n", getRegisterName(block, itr.reg).c_str(), itr.name); + printf(" reg: %s sym:0x%lux\n", getRegisterName(block, itr.reg).c_str(), itr.name); // print instructions printf("Assembly:\n"); IR::__InsBase* instruction = block->m_instructionFirst; @@ -233,4 +235,4 @@ namespace ZpIR } } -} \ No newline at end of file +}