diff --git a/PowerEditor/src/MISC/RegExt/regExtDlg.cpp b/PowerEditor/src/MISC/RegExt/regExtDlg.cpp index c7c873309..4cf2f7693 100644 --- a/PowerEditor/src/MISC/RegExt/regExtDlg.cpp +++ b/PowerEditor/src/MISC/RegExt/regExtDlg.cpp @@ -346,9 +346,9 @@ void RegExtDlg::getRegisteredExts() if ((res == ERROR_SUCCESS) && (extName[0] == '.')) { //TCHAR valName[extNameLen]; - TCHAR valData[extNameLen]; + TCHAR valData[extNameLen] = { '\0' }; DWORD valDataLen = extNameLen * sizeof(TCHAR); - DWORD valType; + DWORD valType = 0; HKEY hKey2Check; extNameActualLen = extNameLen; ::RegOpenKeyEx(HKEY_CLASSES_ROOT, extName, 0, KEY_ALL_ACCESS, &hKey2Check); @@ -372,14 +372,14 @@ void RegExtDlg::getDefSupportedExts() void RegExtDlg::addExt(TCHAR *ext) { HKEY hKey; - DWORD dwDisp; + DWORD dwDisp = 0; long nRet; nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, ext, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisp); if (nRet == ERROR_SUCCESS) { - TCHAR valData[MAX_PATH]; + TCHAR valData[MAX_PATH] = { '\0' }; DWORD valDataLen = MAX_PATH * sizeof(TCHAR); if (dwDisp == REG_OPENED_EXISTING_KEY) @@ -388,7 +388,7 @@ void RegExtDlg::addExt(TCHAR *ext) if (res == ERROR_SUCCESS) ::RegSetValueEx(hKey, nppBackup, 0, REG_SZ, reinterpret_cast(valData), valDataLen); } - ::RegSetValueEx(hKey, nullptr, 0, REG_SZ, reinterpret_cast(nppName), (lstrlen(nppName) + 1) * sizeof(TCHAR)); + ::RegSetValueEx(hKey, nullptr, 0, REG_SZ, reinterpret_cast(nppName), static_cast((lstrlen(nppName) + 1) * sizeof(TCHAR))); ::RegCloseKey(hKey); } @@ -411,9 +411,9 @@ bool RegExtDlg::deleteExts(const TCHAR *ext2Delete) } else { - TCHAR valData[extNameLen]; + TCHAR valData[extNameLen] = { '\0' }; DWORD valDataLen = extNameLen*sizeof(TCHAR); - DWORD valType; + DWORD valType = 0; int res = ::RegQueryValueEx(hKey, nppBackup, nullptr, &valType, (LPBYTE)valData, &valDataLen); if (res == ERROR_SUCCESS) @@ -432,8 +432,8 @@ bool RegExtDlg::deleteExts(const TCHAR *ext2Delete) void RegExtDlg::writeNppPath() { HKEY hKey, hRootKey; - DWORD dwDisp; - long nRet; + DWORD dwDisp = 0; + long nRet = 0; generic_string regStr(nppName); regStr += TEXT("\\shell\\open\\command"); @@ -446,17 +446,17 @@ void RegExtDlg::writeNppPath() { // Write the value for new document ::RegOpenKeyEx(HKEY_CLASSES_ROOT, nppName, 0, KEY_ALL_ACCESS, &hRootKey); - ::RegSetValueEx(hRootKey, nullptr, 0, REG_SZ, (LPBYTE)nppDoc, (lstrlen(nppDoc)+1)*sizeof(TCHAR)); + ::RegSetValueEx(hRootKey, nullptr, 0, REG_SZ, (LPBYTE)nppDoc, static_cast((lstrlen(nppDoc) + 1) * sizeof(TCHAR))); RegCloseKey(hRootKey); - TCHAR nppPath[MAX_PATH]; + TCHAR nppPath[MAX_PATH] = { '\0' }; ::GetModuleFileName(_hInst, nppPath, MAX_PATH); TCHAR nppPathParam[MAX_PATH] = TEXT("\""); wcscat_s(nppPathParam, nppPath); wcscat_s(nppPathParam, TEXT("\" \"%1\"")); - ::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR)); + ::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppPathParam, static_cast((lstrlen(nppPathParam) + 1) * sizeof(TCHAR))); } RegCloseKey(hKey); } @@ -470,14 +470,14 @@ void RegExtDlg::writeNppPath() { //if (dwDisp == REG_CREATED_NEW_KEY) { - TCHAR nppPath[MAX_PATH]; + TCHAR nppPath[MAX_PATH] = { '\0' }; ::GetModuleFileName(_hInst, nppPath, MAX_PATH); TCHAR nppPathParam[MAX_PATH] = TEXT("\""); wcscat_s(nppPathParam, nppPath); wcscat_s(nppPathParam, TEXT("\",0")); - ::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR)); + ::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppPathParam, static_cast((lstrlen(nppPathParam) + 1) * sizeof(TCHAR))); } RegCloseKey(hKey); } diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 1f4f530ef..6b6159eb1 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -4223,7 +4223,7 @@ void Notepad_plus::hideView(int whichOne) return; Window * windowToSet = (whichOne == MAIN_VIEW)?&_subDocTab:&_mainDocTab; - if (_mainWindowStatus & WindowUserActive) + if ((_mainWindowStatus & WindowUserActive) == WindowUserActive) { _pMainSplitter->setWin0(windowToSet); } @@ -4250,7 +4250,7 @@ void Notepad_plus::hideView(int whichOne) ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); switchEditViewTo(otherFromView(whichOne)); - int viewToDisable = (whichOne == SUB_VIEW?WindowSubActive:WindowMainActive); + auto viewToDisable = static_cast(whichOne == SUB_VIEW ? WindowSubActive : WindowMainActive); _mainWindowStatus &= ~viewToDisable; } @@ -8430,7 +8430,8 @@ void Notepad_plus::createMonitoringThread(Buffer* pBuf) { MonitorInfo *monitorInfo = new Notepad_plus::MonitorInfo(pBuf, _pPublicInterface->getHSelf()); HANDLE hThread = ::CreateThread(NULL, 0, monitorFileOnChange, (void *)monitorInfo, 0, NULL); // will be deallocated while quitting thread - ::CloseHandle(hThread); + if (hThread != nullptr) + ::CloseHandle(hThread); } // Fill names into the shortcut list. diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 5c771836d..a2afbf029 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -269,7 +269,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) COPYDATASTRUCT fileNamesData{}; fileNamesData.dwData = COPYDATA_FILENAMESW; fileNamesData.lpData = (void *)quotFileName.c_str(); - fileNamesData.cbData = long(quotFileName.length() + 1)*(sizeof(TCHAR)); + fileNamesData.cbData = static_cast((quotFileName.length() + 1) * sizeof(TCHAR)); HWND hWinParent = ::GetParent(hWin); const rsize_t classNameBufferSize = MAX_PATH; diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index 41c237122..c7e66c7ec 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -332,13 +332,13 @@ LRESULT CALLBACK ScintillaEditView::scintillaStatic_Proc(HWND hwnd, UINT Message if (Message == WM_MOUSEWHEEL || Message == WM_MOUSEHWHEEL) { - POINT pt; + POINT pt{}; POINTS pts = MAKEPOINTS(lParam); POINTSTOPOINT(pt, pts); HWND hwndOnMouse = WindowFromPoint(pt); //Hack for Synaptics TouchPad Driver - char synapticsHack[26]; + char synapticsHack[26]{}; GetClassNameA(hwndOnMouse, (LPSTR)&synapticsHack, 26); bool isSynpnatic = std::string(synapticsHack) == "SynTrackCursorWindowClass"; bool makeTouchPadCompetible = ((NppParameters::getInstance()).getSVP())._disableAdvancedScrolling; @@ -399,9 +399,9 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa if (wParam == IMR_RECONVERTSTRING) { - intptr_t textLength; - intptr_t selectSize; - char smallTextBuffer[128]; + intptr_t textLength = 0; + intptr_t selectSize = 0; + char smallTextBuffer[128] = { '\0' }; char * selectedStr = smallTextBuffer; RECONVERTSTRING * reconvert = (RECONVERTSTRING *)lParam; @@ -451,7 +451,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa textLength = ::MultiByteToWideChar( codepage, 0, selectedStr, (int)selectSize, (LPWSTR)((LPSTR)reconvert + sizeof(RECONVERTSTRING)), - reconvert->dwSize - sizeof(RECONVERTSTRING)); + static_cast(reconvert->dwSize - sizeof(RECONVERTSTRING))); // fill the structure reconvert->dwVersion = 0; @@ -1205,7 +1205,7 @@ void ScintillaEditView::setTypeScriptLexer() return basic_string(""); }; - auto keywordListInstruction = getKeywordList(LANG_INDEX_INSTR); + std::string keywordListInstruction = getKeywordList(LANG_INDEX_INSTR); const char* tsInstructions = getCompleteKeywordList(keywordListInstruction, L_TYPESCRIPT, LANG_INDEX_INSTR); string keywordListType = getKeywordList(LANG_INDEX_TYPE); @@ -2368,12 +2368,12 @@ void ScintillaEditView::getVisibleStartAndEndPosition(intptr_t* startPos, intptr { assert(startPos != NULL && endPos != NULL); // Get the position of the 1st and last showing chars from the edit view - RECT rcEditView; + RECT rcEditView{}; getClientRect(rcEditView); LRESULT pos = execute(SCI_POSITIONFROMPOINT, 0, 0); LRESULT line = execute(SCI_LINEFROMPOSITION, pos); *startPos = execute(SCI_POSITIONFROMLINE, line); - pos = execute(SCI_POSITIONFROMPOINT, rcEditView.right - rcEditView.left, rcEditView.bottom - rcEditView.top); + pos = execute(SCI_POSITIONFROMPOINT, static_cast(rcEditView.right - rcEditView.left), static_cast(rcEditView.bottom - rcEditView.top)); line = execute(SCI_LINEFROMPOSITION, pos); *endPos = execute(SCI_GETLINEENDPOSITION, line); } @@ -3991,7 +3991,7 @@ pair ScintillaEditView::getSelectedCharsAndLinesCount(long long } sort(v.begin(), v.end()); intptr_t previousSecondLine = -1; - for (auto lineRange : v) + for (auto& lineRange : v) { selectedCharsAndLines.second += lineRange.second - lineRange.first; if (lineRange.first != static_cast(previousSecondLine)) @@ -4091,7 +4091,7 @@ void ScintillaEditView::markedTextToClipboard(int indiStyle, bool doAll /*= fals TEXT("\r\n----\r\n") : TEXT("\r\n"); generic_string joined; - for (auto item : styledVect) + for (auto& item : styledVect) { joined += delim + item.second; } diff --git a/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp b/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp index e1b7d5039..7b34b1004 100644 --- a/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp +++ b/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp @@ -240,22 +240,22 @@ const char* TiXmlBaseA::GetEntity( const char* p, char* value ) { // Short, one value entity. if ( isalpha( *(p+3) ) ) - *value += (static_cast(tolower(*(p + 3))) - 'a' + 10); + *value += static_cast(static_cast(tolower(*(p + 3))) - 'a' + 10); else - *value += (static_cast(*(p + 3)) - '0'); + *value += static_cast(static_cast(*(p + 3)) - '0'); return p+5; } else { // two value entity - if (isalpha(*(p + 3))) *value += (static_cast(tolower(*(p + 3))) - 'a' + 10) * 16; - else *value += (static_cast(*(p + 3)) - '0') * 16; + if (isalpha(*(p + 3))) *value += static_cast((static_cast(tolower(*(p + 3))) - 'a' + 10) * 16); + else *value += static_cast((static_cast(*(p + 3)) - '0') * 16); if ( isalpha( *(p+4) ) ) - *value += (static_cast(tolower(*(p + 4))) - 'a' + 10); + *value += static_cast(static_cast(tolower(*(p + 4))) - 'a' + 10); else - *value += (static_cast(*(p + 4)) - '0'); + *value += static_cast(static_cast(*(p + 4)) - '0'); return p+6; } diff --git a/PowerEditor/src/Utf8_16.cpp b/PowerEditor/src/Utf8_16.cpp index ea769fc92..d306f44f7 100644 --- a/PowerEditor/src/Utf8_16.cpp +++ b/PowerEditor/src/Utf8_16.cpp @@ -635,12 +635,12 @@ void Utf16_Iter::operator++() m_eState = eStart; } else if (m_nCur16 < 0x800) { pushout(static_cast(0xC0 | m_nCur16 >> 6)); - pushout(0x80 | (m_nCur16 & 0x3f)); + pushout(static_cast(0x80 | (m_nCur16 & 0x3f))); m_eState = eStart; } else { - pushout(0xE0 | (m_nCur16 >> 12)); - pushout(0x80 | ((m_nCur16 >> 6) & 0x3f)); - pushout(0x80 | (m_nCur16 & 0x3f)); + pushout(static_cast(0xE0 | (m_nCur16 >> 12))); + pushout(static_cast(0x80 | ((m_nCur16 >> 6) & 0x3f))); + pushout(static_cast(0x80 | (m_nCur16 & 0x3f))); m_eState = eStart; } break; diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index 669a30755..80ac005d9 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -378,7 +378,7 @@ void stripIgnoredParams(ParamVector & params) -int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int) +int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance*/, _In_ PWSTR pCmdLine, _In_ int /*nShowCmd*/) { bool TheFirstOne = true; ::SetLastError(NO_ERROR); @@ -585,22 +585,22 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int) { CmdLineParamsDTO dto = CmdLineParamsDTO::FromCmdLineParams(cmdLineParams); - COPYDATASTRUCT paramData; + COPYDATASTRUCT paramData{}; paramData.dwData = COPYDATA_PARAMS; paramData.lpData = &dto; paramData.cbData = sizeof(dto); ::SendMessage(hNotepad_plus, WM_COPYDATA, reinterpret_cast(hInstance), reinterpret_cast(¶mData)); - COPYDATASTRUCT cmdLineData; + COPYDATASTRUCT cmdLineData{}; cmdLineData.dwData = COPYDATA_FULL_CMDLINE; cmdLineData.lpData = (void*)cmdLineString.c_str(); - cmdLineData.cbData = long(cmdLineString.length() + 1) * (sizeof(TCHAR)); + cmdLineData.cbData = static_cast((cmdLineString.length() + 1) * sizeof(TCHAR)); ::SendMessage(hNotepad_plus, WM_COPYDATA, reinterpret_cast(hInstance), reinterpret_cast(&cmdLineData)); - COPYDATASTRUCT fileNamesData; + COPYDATASTRUCT fileNamesData{}; fileNamesData.dwData = COPYDATA_FILENAMESW; fileNamesData.lpData = (void *)quotFileName.c_str(); - fileNamesData.cbData = long(quotFileName.length() + 1) * (sizeof(TCHAR)); + fileNamesData.cbData = static_cast((quotFileName.length() + 1) * sizeof(TCHAR)); ::SendMessage(hNotepad_plus, WM_COPYDATA, reinterpret_cast(hInstance), reinterpret_cast(&fileNamesData)); } return 0; @@ -696,7 +696,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int) } } - MSG msg; + MSG msg{}; msg.wParam = 0; Win32Exception::installHandler(); MiniDumper mdump; //for debugging purposes. diff --git a/PowerEditor/visual.net/notepadPlus.Cpp.props b/PowerEditor/visual.net/notepadPlus.Cpp.props index 716a727a4..db6c45f06 100644 --- a/PowerEditor/visual.net/notepadPlus.Cpp.props +++ b/PowerEditor/visual.net/notepadPlus.Cpp.props @@ -18,7 +18,7 @@ true ProgramDatabase true - 4091;4456;4457;4459 + 4456;4457;4459 true stdcpp20