From 5e49e09458bbd6f5144568f83444c5fac9d68f9b Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Mon, 15 Aug 2016 12:25:02 +0900 Subject: [PATCH] Cppcheck: %d in format string (no. x) requires 'int' but the argument type is 'UINT {aka unsigned int}'. --- Src/Common/MessageBoxDialog.cpp | 2 +- Src/DirCmpReport.cpp | 6 ++++-- Src/Exceptions.h | 2 +- Src/MergeEditView.cpp | 2 +- Src/diffutils/src/CMP.C | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Src/Common/MessageBoxDialog.cpp b/Src/Common/MessageBoxDialog.cpp index 7bf2c16d3..9d7774b27 100644 --- a/Src/Common/MessageBoxDialog.cpp +++ b/Src/Common/MessageBoxDialog.cpp @@ -804,7 +804,7 @@ void CMessageBoxDialog::OnTimer ( UINT_PTR nIDEvent ) { // Add the remaining seconds to the text of the button. TCHAR szTimeoutSeconds[40]; - wsprintf(szTimeoutSeconds, _T(" = %d"), m_nTimeoutSeconds); + wsprintf(szTimeoutSeconds, _T(" = %u"), m_nTimeoutSeconds); strButtonText += szTimeoutSeconds; } // Set the text of the button. diff --git a/Src/DirCmpReport.cpp b/Src/DirCmpReport.cpp index 5be443411..1751078d3 100644 --- a/Src/DirCmpReport.cpp +++ b/Src/DirCmpReport.cpp @@ -165,8 +165,10 @@ bool DirCmpReport::GenerateReport(String &errStr) DWORD size = GetLength32(file); // Rewrite CF_HTML header with valid offsets file.SeekToBegin(); - wsprintfA(buffer, header, cbHeader, size - 1, - cbHeader + sizeof start - 1, size - sizeof end + 1); + wsprintfA(buffer, header, cbHeader, + static_cast(size - 1), + static_cast(cbHeader + sizeof start - 1), + static_cast(size - sizeof end + 1)); file.Write(buffer, cbHeader); SetClipboardData(CF_HTML, GlobalReAlloc(file.Detach(), size, 0)); } diff --git a/Src/Exceptions.h b/Src/Exceptions.h index d14ed89de..9ae5e9f7c 100644 --- a/Src/Exceptions.h +++ b/Src/Exceptions.h @@ -93,7 +93,7 @@ public: virtual bool GetErrorMessage( TCHAR *lpszError, unsigned nMaxError, unsigned *pnHelpContext = NULL ) { static TCHAR message[512]; - _sntprintf(message, sizeof(message)/sizeof(message[0]), _T("Exception %s (0x%.8x)"), getSeMessage(), getSeNumber()); + _sntprintf(message, sizeof(message)/sizeof(message[0]), _T("Exception %s (0x%.8x)"), getSeMessage(), static_cast(getSeNumber())); StringCchCopy(lpszError, nMaxError, message); return true; } diff --git a/Src/MergeEditView.cpp b/Src/MergeEditView.cpp index c9d89033f..117c070d1 100644 --- a/Src/MergeEditView.cpp +++ b/Src/MergeEditView.cpp @@ -3245,7 +3245,7 @@ void CMergeEditView::OnEditCopyLineNumbers() GetSelection(ptStart, ptEnd); // Get last selected line (having widest linenumber) - UINT line = pDoc->m_ptBuf[m_nThisPane]->ComputeRealLine(ptEnd.y); + int line = pDoc->m_ptBuf[m_nThisPane]->ComputeRealLine(ptEnd.y); size_t nNumWidth = string_to_str(line + 1).length(); for (int i = ptStart.y; i <= ptEnd.y; i++) diff --git a/Src/diffutils/src/CMP.C b/Src/diffutils/src/CMP.C index 7aae42dd7..50460580a 100644 --- a/Src/diffutils/src/CMP.C +++ b/Src/diffutils/src/CMP.C @@ -336,7 +336,7 @@ cmp () { if (opt_print_chars) { - printf ("%6lu %3o ", char_number, c0); + printf ("%6lu %3o ", (unsigned long)char_number, c0); printc (4, c0); printf (" %3o ", c1); printc (0, c1); -- 2.11.0