From 9ad6b11cf930d87f9f4e08bd1809b50858123f08 Mon Sep 17 00:00:00 2001 From: Andrea Date: Sat, 26 Feb 2022 17:15:09 +0000 Subject: [PATCH] Fix some format errors. (PR #1042) --- source/CmdLine.cpp | 2 +- source/Debugger/Debug.cpp | 4 ++-- source/Debugger/Debugger_Console.h | 12 ++++++++---- source/Debugger/Debugger_Help.cpp | 10 ++++++---- source/YamlHelper.h | 4 ++-- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/source/CmdLine.cpp b/source/CmdLine.cpp index d39a8bae..9c650968 100644 --- a/source/CmdLine.cpp +++ b/source/CmdLine.cpp @@ -76,7 +76,7 @@ static LPSTR GetNextArg(LPSTR lpCmdLine) { *lpCmdLine++ = 0x00; - while ((*lpCmdLine == ' ')) // Skip multiple spaces between args + while (*lpCmdLine == ' ') // Skip multiple spaces between args lpCmdLine++; break; } diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index 56d49e43..f4037065 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -4163,7 +4163,7 @@ Update_t CmdMemoryLoad (int nArgs) CmdConfigGetDebugDir( 0 ); - ConsoleBufferPushFormat( "File: ", g_sMemoryLoadSaveFileName.c_str() ); + ConsoleBufferPushFormat( "File: %s", g_sMemoryLoadSaveFileName.c_str() ); } return ConsoleUpdate(); @@ -7479,7 +7479,7 @@ int FindCommand( LPCTSTR pName, CmdFuncPtr_t & pFunction_, int * iCommand_ ) //=========================================================================== void DisplayAmbigiousCommands( int nFound ) { - ConsolePrintFormat("Ambiguous %s%d%s Commands:" + ConsolePrintFormat("Ambiguous %s%" SIZE_T_FMT "%s Commands:" , CHC_NUM_DEC , g_vPotentialCommands.size() , CHC_DEFAULT diff --git a/source/Debugger/Debugger_Console.h b/source/Debugger/Debugger_Console.h index d73b18d3..5e57e28d 100644 --- a/source/Debugger/Debugger_Console.h +++ b/source/Debugger/Debugger_Console.h @@ -263,7 +263,8 @@ std::string strText = StrFormatV(pFormat, va); ConsolePrint(strText.c_str()); } - inline void ConsolePrintFormat( const char* pFormat, ... ) ATTRIBUTE_FORMAT_PRINTF(1, 2) + inline void ConsolePrintFormat( const char* pFormat, ... ) ATTRIBUTE_FORMAT_PRINTF(1, 2); + inline void ConsolePrintFormat( const char* pFormat, ... ) { va_list va; va_start(va, pFormat); @@ -281,7 +282,8 @@ std::string strText = StrFormatV(pFormat, va); ConsoleBufferPush(strText.c_str()); } - inline void ConsoleBufferPushFormat( const char* pFormat, ... ) ATTRIBUTE_FORMAT_PRINTF(1, 2) + inline void ConsoleBufferPushFormat( const char* pFormat, ... ) ATTRIBUTE_FORMAT_PRINTF(1, 2); + inline void ConsoleBufferPushFormat( const char* pFormat, ... ) { va_list va; va_start(va, pFormat); @@ -298,7 +300,8 @@ std::string strText = StrFormatV(pFormat, va); return ConsoleDisplayError(strText.c_str()); } - inline Update_t ConsoleDisplayErrorFormat(const char* pFormat, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2) + inline Update_t ConsoleDisplayErrorFormat(const char* pFormat, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2); + inline Update_t ConsoleDisplayErrorFormat(const char* pFormat, ...) { va_list va; va_start(va, pFormat); @@ -313,7 +316,8 @@ std::string strText = StrFormatV(pFormat, va); ConsoleDisplayPush(strText.c_str()); } - inline void ConsoleDisplayPushFormat(const char* pFormat, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2) + inline void ConsoleDisplayPushFormat(const char* pFormat, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2); + inline void ConsoleDisplayPushFormat(const char* pFormat, ...) { va_list va; va_start(va, pFormat); diff --git a/source/Debugger/Debugger_Help.cpp b/source/Debugger/Debugger_Help.cpp index 49807f8a..b8003253 100644 --- a/source/Debugger/Debugger_Help.cpp +++ b/source/Debugger/Debugger_Help.cpp @@ -496,7 +496,9 @@ inline bool ConsoleColorizePrintVa( const char* format, va_list va ) return ConsoleColorizePrint(strText.c_str()); } -inline bool ConsoleColorizePrintFormat( const char* format, ... ) ATTRIBUTE_FORMAT_PRINTF(1, 2) +inline bool ConsoleColorizePrintFormat( const char* format, ... ) ATTRIBUTE_FORMAT_PRINTF(1, 2); + +inline bool ConsoleColorizePrintFormat( const char* format, ... ) { va_list va; va_start(va, format); @@ -1071,7 +1073,7 @@ Update_t CmdHelpSpecific (int nArgs) { ConsoleColorizePrint( " Note: All arguments effect the disassembly view" ); - ConsoleColorizePrintFormat( " Usage: [%s%s | %s | %s%s | %s%s | %s%s | %s%s]" + ConsoleColorizePrintFormat( " Usage: [%s%s | %s%s | %s%s | %s%s | %s%s | %s%s]" , CHC_COMMAND , g_aParameters[ PARAM_CONFIG_BRANCH ].m_sName , CHC_COMMAND @@ -1592,10 +1594,10 @@ Update_t CmdVersion (int nArgs) if ((! _tcscmp( g_aArgs[ iArg ].sArg, g_aParameters[ PARAM_WILDSTAR ].m_sName )) || (! _tcscmp( g_aArgs[ iArg ].sArg, g_aParameters[ PARAM_MEM_SEARCH_WILD ].m_sName )) ) { - ConsoleBufferPushFormat( " Arg: %d bytes * %d = %d bytes", + ConsoleBufferPushFormat( " Arg: %" SIZE_T_FMT " bytes * %d = %" SIZE_T_FMT " bytes", sizeof(Arg_t), MAX_ARGS, sizeof(g_aArgs) ); - ConsoleBufferPushFormat( " Console: %d bytes * %d height = %d bytes", + ConsoleBufferPushFormat( " Console: %" SIZE_T_FMT " bytes * %d height = %" SIZE_T_FMT " bytes", sizeof( g_aConsoleDisplay[0] ), CONSOLE_HEIGHT, sizeof(g_aConsoleDisplay) ); ConsoleBufferPushFormat( " Commands: %d (Aliased: %d) Params: %d", diff --git a/source/YamlHelper.h b/source/YamlHelper.h index e3655dee..a95cdb3c 100644 --- a/source/YamlHelper.h +++ b/source/YamlHelper.h @@ -214,7 +214,7 @@ public: delete[] m_pMbStr; } - void Save(const char* format, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2); + void Save(const char* format, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3); // 1 is "this" void SaveInt(const char* key, int value); void SaveUint(const char* key, UINT value); @@ -235,7 +235,7 @@ public: class Label { public: - Label(YamlSaveHelper& rYamlSaveHelper, const char* format, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3) : + Label(YamlSaveHelper& rYamlSaveHelper, const char* format, ...) ATTRIBUTE_FORMAT_PRINTF(3, 4) : // 1 is "this" yamlSaveHelper(rYamlSaveHelper) { fwrite(yamlSaveHelper.m_szIndent, 1, yamlSaveHelper.m_indent, yamlSaveHelper.m_hFile);