From c8e4e671dad405d60e95ba483991a4b3b77bf2c2 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 6 Mar 2023 17:55:53 +0100 Subject: [PATCH] Code enhancement: remove some MSVS analisis warning --- PowerEditor/src/DarkMode/IatHook.h | 2 +- PowerEditor/src/MISC/Common/verifySignedfile.cpp | 4 +--- PowerEditor/src/ScintillaComponent/Buffer.cpp | 6 +++--- PowerEditor/src/ScintillaComponent/Buffer.h | 2 +- PowerEditor/src/ScintillaComponent/DocTabView.cpp | 2 +- PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp | 2 +- .../src/ScintillaComponent/UserDefineDialog.cpp | 2 +- .../src/WinControls/DockingWnd/DockingDlgInterface.h | 2 +- .../src/WinControls/DockingWnd/DockingManager.cpp | 2 +- .../src/WinControls/DockingWnd/DockingSplitter.cpp | 2 +- PowerEditor/src/WinControls/DockingWnd/Gripper.cpp | 2 +- .../src/WinControls/SplitterContainer/Splitter.cpp | 2 +- .../SplitterContainer/SplitterContainer.cpp | 2 +- PowerEditor/src/WinControls/TaskList/TaskListDlg.cpp | 2 +- .../VerticalFileSwitcherListView.cpp | 6 +++--- PowerEditor/src/uchardet/uchardet.cpp | 10 +++++----- 16 files changed, 24 insertions(+), 26 deletions(-) diff --git a/PowerEditor/src/DarkMode/IatHook.h b/PowerEditor/src/DarkMode/IatHook.h index 7d5d153db..6f1a5d358 100644 --- a/PowerEditor/src/DarkMode/IatHook.h +++ b/PowerEditor/src/DarkMode/IatHook.h @@ -16,7 +16,7 @@ constexpr T RVA2VA(T1 base, T2 rva) template constexpr T DataDirectoryFromModuleBase(void *moduleBase, size_t entryID) { - auto dosHdr = reinterpret_cast(moduleBase); + auto dosHdr = static_cast(moduleBase); auto ntHdr = RVA2VA(moduleBase, dosHdr->e_lfanew); auto dataDir = ntHdr->OptionalHeader.DataDirectory; return RVA2VA(moduleBase, dataDir[entryID].VirtualAddress); diff --git a/PowerEditor/src/MISC/Common/verifySignedfile.cpp b/PowerEditor/src/MISC/Common/verifySignedfile.cpp index 95512996f..4a166ba06 100644 --- a/PowerEditor/src/MISC/Common/verifySignedfile.cpp +++ b/PowerEditor/src/MISC/Common/verifySignedfile.cpp @@ -43,7 +43,7 @@ SecurityGuard::SecurityGuard() _pluginListSha256.push_back(TEXT("1c404fd3578273f5ecde585af82179ff3b63c635fb4fa24be21ebde708e403e4")); // v1.0.8 64 bit (unsigned) } -bool SecurityGuard::checkModule(const std::wstring& filePath, NppModule module2check) +bool SecurityGuard::checkModule([[maybe_unused]] const std::wstring& filePath, [[maybe_unused]] NppModule module2check) { #ifndef _DEBUG if (_securityMode == sm_certif) @@ -56,8 +56,6 @@ bool SecurityGuard::checkModule(const std::wstring& filePath, NppModule module2c // Do not check integrity if npp is running in debug mode // This is helpful for developers to skip signature checking // while analyzing issue or modifying the lexer dll - (void)filePath; - (void)module2check; return true; #endif } diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 9669a6c95..12d0d25c3 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -754,7 +754,7 @@ BufferID FileManager::loadFile(const TCHAR* filename, Document doc, int encoding if (res) { Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_REGULAR, fullpath, isLargeFile); - BufferID id = static_cast(newBuf); + BufferID id = newBuf; newBuf->_id = id; if (backupFileName != NULL) @@ -1330,7 +1330,7 @@ BufferID FileManager::newEmptyDocument() const NewDocDefaultSettings& ndds = (nppParamInst.getNppGUI()).getNewDocDefaultSettings(); newBuf->_lang = ndds._lang; - BufferID id = static_cast(newBuf); + BufferID id = newBuf; newBuf->_id = id; _buffers.push_back(newBuf); ++_nbBufs; @@ -1349,7 +1349,7 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d if (!dontRef) _pscratchTilla->execute(SCI_ADDREFDOCUMENT, 0, doc); //set reference for FileManager Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle.c_str(), false); - BufferID id = static_cast(newBuf); + BufferID id = newBuf; newBuf->_id = id; const NewDocDefaultSettings& ndds = (nppParamInst.getNppGUI()).getNewDocDefaultSettings(); newBuf->_lang = ndds._lang; diff --git a/PowerEditor/src/ScintillaComponent/Buffer.h b/PowerEditor/src/ScintillaComponent/Buffer.h index 923b4d5ae..958dbc2c3 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.h +++ b/PowerEditor/src/ScintillaComponent/Buffer.h @@ -69,7 +69,7 @@ public: size_t getNbDirtyBuffers() const; int getBufferIndexByID(BufferID id); Buffer * getBufferByIndex(size_t index); - Buffer * getBufferByID(BufferID id) {return static_cast(id);} + Buffer * getBufferByID(BufferID id) {return id;} void beNotifiedOfBufferChange(Buffer * theBuf, int mask); diff --git a/PowerEditor/src/ScintillaComponent/DocTabView.cpp b/PowerEditor/src/ScintillaComponent/DocTabView.cpp index ce555e030..ffae54b24 100644 --- a/PowerEditor/src/ScintillaComponent/DocTabView.cpp +++ b/PowerEditor/src/ScintillaComponent/DocTabView.cpp @@ -81,7 +81,7 @@ bool DocTabView::activateBuffer(BufferID buffer) BufferID DocTabView::activeBuffer() { int index = getCurrentTabIndex(); - return static_cast(getBufferByIndex(index)); + return getBufferByIndex(index); } diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index 5e2c9dc63..4befb72fd 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -5582,7 +5582,7 @@ LRESULT APIENTRY Progress::wndProc(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM l { case WM_CREATE: { - Progress* pw = reinterpret_cast(reinterpret_cast(lparam)->lpCreateParams); + Progress* pw = static_cast(reinterpret_cast(lparam)->lpCreateParams); ::SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast(pw)); return 0; } diff --git a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp index ae03ca032..c283614d4 100644 --- a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp @@ -1727,7 +1727,7 @@ void StringDlg::HandlePaste(HWND hEdit) HANDLE hClipboardData = GetClipboardData(CF_UNICODETEXT); if (NULL != hClipboardData) { - LPTSTR pszText = reinterpret_cast(GlobalLock(hClipboardData)); + LPTSTR pszText = static_cast(GlobalLock(hClipboardData)); if (NULL != pszText && isAllowed(pszText)) { SendMessage(hEdit, EM_REPLACESEL, TRUE, reinterpret_cast(pszText)); diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h b/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h index ecfd00525..f67eadd80 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h @@ -37,7 +37,7 @@ public: virtual void init(HINSTANCE hInst, HWND parent) { StaticDialog::init(hInst, parent); TCHAR temp[MAX_PATH]; - ::GetModuleFileName(reinterpret_cast(hInst), temp, MAX_PATH); + ::GetModuleFileName(hInst, temp, MAX_PATH); _moduleName = ::PathFindFileName(temp); } diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp index db1e76d8b..1937a2a0a 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp @@ -175,7 +175,7 @@ LRESULT CALLBACK DockingManager::staticWinProc(HWND hwnd, UINT message, WPARAM w switch (message) { case WM_NCCREATE : - pDockingManager = reinterpret_cast(reinterpret_cast(lParam)->lpCreateParams); + pDockingManager = static_cast(reinterpret_cast(lParam)->lpCreateParams); pDockingManager->_hSelf = hwnd; ::SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast(pDockingManager)); return TRUE; diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp index cb4540a97..f6e62aba2 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp @@ -92,7 +92,7 @@ LRESULT CALLBACK DockingSplitter::staticWinProc(HWND hwnd, UINT message, WPARAM switch (message) { case WM_NCCREATE : - pDockingSplitter = reinterpret_cast(reinterpret_cast(lParam)->lpCreateParams); + pDockingSplitter = static_cast(reinterpret_cast(lParam)->lpCreateParams); pDockingSplitter->_hSelf = hwnd; ::SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast(pDockingSplitter)); return TRUE; diff --git a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp index 2cf3890a5..301c356ef 100644 --- a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp @@ -130,7 +130,7 @@ LRESULT CALLBACK Gripper::staticWinProc(HWND hwnd, UINT message, WPARAM wParam, switch (message) { case WM_NCCREATE : - pDlgMoving = reinterpret_cast(reinterpret_cast(lParam)->lpCreateParams); + pDlgMoving = static_cast(reinterpret_cast(lParam)->lpCreateParams); pDlgMoving->_hSelf = hwnd; ::SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast(pDlgMoving)); return TRUE; diff --git a/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp b/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp index 11ccad83e..e252f48b5 100644 --- a/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp +++ b/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp @@ -220,7 +220,7 @@ LRESULT CALLBACK Splitter::staticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP { case WM_NCCREATE: { - Splitter * pSplitter = reinterpret_cast(reinterpret_cast(lParam)->lpCreateParams); + Splitter * pSplitter = static_cast(reinterpret_cast(lParam)->lpCreateParams); pSplitter->_hSelf = hWnd; ::SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast(pSplitter)); return TRUE; diff --git a/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.cpp b/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.cpp index eefd76fe5..407643c42 100644 --- a/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.cpp +++ b/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.cpp @@ -150,7 +150,7 @@ LRESULT CALLBACK SplitterContainer::staticWinProc(HWND hwnd, UINT message, WPARA { case WM_NCCREATE: { - pSplitterContainer = reinterpret_cast(reinterpret_cast(lParam)->lpCreateParams); + pSplitterContainer = static_cast(reinterpret_cast(lParam)->lpCreateParams); pSplitterContainer->_hSelf = hwnd; ::SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast(pSplitterContainer)); return TRUE; diff --git a/PowerEditor/src/WinControls/TaskList/TaskListDlg.cpp b/PowerEditor/src/WinControls/TaskList/TaskListDlg.cpp index 611490193..d7d9f95e6 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskListDlg.cpp +++ b/PowerEditor/src/WinControls/TaskList/TaskListDlg.cpp @@ -146,7 +146,7 @@ intptr_t CALLBACK TaskListDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l { case LVN_GETDISPINFO: { - LV_ITEM &lvItem = reinterpret_cast(reinterpret_cast(lParam))->item; + LV_ITEM &lvItem = reinterpret_cast(lParam)->item; TaskLstFnStatus & fileNameStatus = _taskListInfo._tlfsLst[lvItem.iItem]; diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp index 4eaa0f844..3aa09d52b 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp @@ -205,7 +205,7 @@ int VerticalFileSwitcherListView::newItem(BufferID bufferID, int iView) void VerticalFileSwitcherListView::setItemIconStatus(BufferID bufferID) { - Buffer *buf = static_cast(bufferID); + Buffer *buf = bufferID; TCHAR fn[MAX_PATH] = { '\0' }; wcscpy_s(fn, ::PathFindFileName(buf->getFileName())); @@ -251,7 +251,7 @@ void VerticalFileSwitcherListView::setItemIconStatus(BufferID bufferID) void VerticalFileSwitcherListView::setItemColor(BufferID bufferID) { - Buffer* buf = static_cast(bufferID); + Buffer* buf = bufferID; LVITEM item{}; item.mask = LVIF_PARAM; @@ -311,7 +311,7 @@ void VerticalFileSwitcherListView::activateItem(BufferID bufferID, int iView) int VerticalFileSwitcherListView::add(BufferID bufferID, int iView) { _currentIndex = ListView_GetItemCount(_hSelf); - Buffer *buf = static_cast(bufferID); + Buffer *buf = bufferID; const TCHAR *fileName = buf->getFileName(); NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); TaskLstFnStatus *tl = new TaskLstFnStatus(iView, 0, buf->getFullPathName(), 0, (void *)bufferID, -1); diff --git a/PowerEditor/src/uchardet/uchardet.cpp b/PowerEditor/src/uchardet/uchardet.cpp index 35b84092a..86e160536 100644 --- a/PowerEditor/src/uchardet/uchardet.cpp +++ b/PowerEditor/src/uchardet/uchardet.cpp @@ -81,26 +81,26 @@ uchardet_t uchardet_new() void uchardet_delete(uchardet_t ud) { - delete reinterpret_cast(ud); + delete static_cast(ud); } int uchardet_handle_data(uchardet_t ud, const char * data, size_t len) { - nsresult ret = reinterpret_cast(ud)->HandleData(data, (PRUint32)len); + nsresult ret = static_cast(ud)->HandleData(data, (PRUint32)len); return (ret != NS_OK); } void uchardet_data_end(uchardet_t ud) { - reinterpret_cast(ud)->DataEnd(); + static_cast(ud)->DataEnd(); } void uchardet_reset(uchardet_t ud) { - reinterpret_cast(ud)->Reset(); + static_cast(ud)->Reset(); } const char* uchardet_get_charset(uchardet_t ud) { - return reinterpret_cast(ud)->GetCharset(); + return static_cast(ud)->GetCharset(); }