From 405de2be1410d7ce5636afcdb22adbe324d9a7af Mon Sep 17 00:00:00 2001 From: tomcw Date: Wed, 28 Jul 2021 12:47:05 +0100 Subject: [PATCH] Fix Coverity - High Impact defects: . uninitialised vars in Debug & Win32Frame --- source/Debugger/Debug.cpp | 12 +++++------- source/Windows/Win32Frame.cpp | 12 ++++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index 25854672..1f0392b2 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -5416,14 +5416,14 @@ Update_t _CmdMemorySearch (int nArgs, bool bTextIsAscii = true ) // Get search "string" Arg_t *pArg = & g_aArgs[ iArgFirstByte ]; - WORD nTarget; for (iArg = iArgFirstByte; iArg <= nArgs; iArg++, pArg++ ) { - MemorySearch_t ms; + WORD nTarget = pArg->nValue; - nTarget = pArg->nValue; + MemorySearch_t ms; ms.m_nValue = nTarget & 0xFF; ms.m_iType = MEM_SEARCH_BYTE_EXACT; + ms.m_bFound = false; if (nTarget > 0xFF) // searching for 16-bit address { @@ -5810,7 +5810,8 @@ Update_t CmdOutputPrintf (int nArgs) TCHAR sText[ CONSOLE_WIDTH ] = TEXT(""); std::vector aValues; - Arg_t entry; + Arg_t entry; + entry.sArg[0] = 0; int iValue = 0; int nValue = 0; @@ -5833,11 +5834,8 @@ Update_t CmdOutputPrintf (int nArgs) continue; else { -// entry.eType = PS_LITERAL; entry.nValue = g_aArgs[ iArg ].nValue; aValues.push_back( entry ); -// nValue = g_aArgs[ iArg ].nValue; -// aValues.push_back( nValue ); } } const int nParamValues = (int) aValues.size(); diff --git a/source/Windows/Win32Frame.cpp b/source/Windows/Win32Frame.cpp index 8a47a37a..2ae4d47c 100644 --- a/source/Windows/Win32Frame.cpp +++ b/source/Windows/Win32Frame.cpp @@ -40,6 +40,11 @@ Win32Frame::Win32Frame() m_bestHeightForFullScreen = 0; m_changedDisplaySettings = false; + g_nViewportCX = GetVideo().GetFrameBufferBorderlessWidth() * kDEFAULT_VIEWPORT_SCALE; + g_nViewportCY = GetVideo().GetFrameBufferBorderlessHeight() * kDEFAULT_VIEWPORT_SCALE; + g_nViewportScale = kDEFAULT_VIEWPORT_SCALE; // saved REGSAVE + g_nMaxViewportScale = kDEFAULT_VIEWPORT_SCALE; // Max scale in Windowed mode with borders, buttons etc (full-screen may be +1) + btnfacebrush = (HBRUSH)0; btnfacepen = (HPEN)0; btnhighlightpen = (HPEN)0; @@ -47,7 +52,7 @@ Win32Frame::Win32Frame() buttonactive = -1; buttondown = -1; buttonover = -1; - buttonx = BUTTONX; + buttonx = BUTTONX; // NB. macro uses g_nViewportCX buttony = BUTTONY; g_hFrameDC = (HDC)0; memset(&framerect, 0, sizeof(framerect)); @@ -71,11 +76,6 @@ Win32Frame::Win32Frame() g_eStatusDrive1 = DISK_STATUS_OFF; g_eStatusDrive2 = DISK_STATUS_OFF; - - g_nViewportCX = GetVideo().GetFrameBufferBorderlessWidth() * kDEFAULT_VIEWPORT_SCALE; - g_nViewportCY = GetVideo().GetFrameBufferBorderlessHeight() * kDEFAULT_VIEWPORT_SCALE; - g_nViewportScale = kDEFAULT_VIEWPORT_SCALE; // saved REGSAVE - g_nMaxViewportScale = kDEFAULT_VIEWPORT_SCALE; // Max scale in Windowed mode with borders, buttons etc (full-screen may be +1) } void Win32Frame::videoCreateDIBSection(Video & video)