Code enhancement: remove some MSVS analisis warning

This commit is contained in:
Don Ho 2023-03-06 17:55:53 +01:00
parent 34545beddd
commit c8e4e671da
16 changed files with 24 additions and 26 deletions

View File

@ -16,7 +16,7 @@ constexpr T RVA2VA(T1 base, T2 rva)
template <typename T>
constexpr T DataDirectoryFromModuleBase(void *moduleBase, size_t entryID)
{
auto dosHdr = reinterpret_cast<PIMAGE_DOS_HEADER>(moduleBase);
auto dosHdr = static_cast<PIMAGE_DOS_HEADER>(moduleBase);
auto ntHdr = RVA2VA<PIMAGE_NT_HEADERS>(moduleBase, dosHdr->e_lfanew);
auto dataDir = ntHdr->OptionalHeader.DataDirectory;
return RVA2VA<T>(moduleBase, dataDir[entryID].VirtualAddress);

View File

@ -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
}

View File

@ -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<BufferID>(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<BufferID>(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<BufferID>(newBuf);
BufferID id = newBuf;
newBuf->_id = id;
const NewDocDefaultSettings& ndds = (nppParamInst.getNppGUI()).getNewDocDefaultSettings();
newBuf->_lang = ndds._lang;

View File

@ -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<Buffer*>(id);}
Buffer * getBufferByID(BufferID id) {return id;}
void beNotifiedOfBufferChange(Buffer * theBuf, int mask);

View File

@ -81,7 +81,7 @@ bool DocTabView::activateBuffer(BufferID buffer)
BufferID DocTabView::activeBuffer()
{
int index = getCurrentTabIndex();
return static_cast<BufferID>(getBufferByIndex(index));
return getBufferByIndex(index);
}

View File

@ -5582,7 +5582,7 @@ LRESULT APIENTRY Progress::wndProc(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM l
{
case WM_CREATE:
{
Progress* pw = reinterpret_cast<Progress*>(reinterpret_cast<LPCREATESTRUCT>(lparam)->lpCreateParams);
Progress* pw = static_cast<Progress*>(reinterpret_cast<LPCREATESTRUCT>(lparam)->lpCreateParams);
::SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pw));
return 0;
}

View File

@ -1727,7 +1727,7 @@ void StringDlg::HandlePaste(HWND hEdit)
HANDLE hClipboardData = GetClipboardData(CF_UNICODETEXT);
if (NULL != hClipboardData)
{
LPTSTR pszText = reinterpret_cast<LPTSTR>(GlobalLock(hClipboardData));
LPTSTR pszText = static_cast<LPTSTR>(GlobalLock(hClipboardData));
if (NULL != pszText && isAllowed(pszText))
{
SendMessage(hEdit, EM_REPLACESEL, TRUE, reinterpret_cast<LPARAM>(pszText));

View File

@ -37,7 +37,7 @@ public:
virtual void init(HINSTANCE hInst, HWND parent) {
StaticDialog::init(hInst, parent);
TCHAR temp[MAX_PATH];
::GetModuleFileName(reinterpret_cast<HMODULE>(hInst), temp, MAX_PATH);
::GetModuleFileName(hInst, temp, MAX_PATH);
_moduleName = ::PathFindFileName(temp);
}

View File

@ -175,7 +175,7 @@ LRESULT CALLBACK DockingManager::staticWinProc(HWND hwnd, UINT message, WPARAM w
switch (message)
{
case WM_NCCREATE :
pDockingManager = reinterpret_cast<DockingManager *>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
pDockingManager = static_cast<DockingManager *>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
pDockingManager->_hSelf = hwnd;
::SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pDockingManager));
return TRUE;

View File

@ -92,7 +92,7 @@ LRESULT CALLBACK DockingSplitter::staticWinProc(HWND hwnd, UINT message, WPARAM
switch (message)
{
case WM_NCCREATE :
pDockingSplitter = reinterpret_cast<DockingSplitter *>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
pDockingSplitter = static_cast<DockingSplitter *>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
pDockingSplitter->_hSelf = hwnd;
::SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pDockingSplitter));
return TRUE;

View File

@ -130,7 +130,7 @@ LRESULT CALLBACK Gripper::staticWinProc(HWND hwnd, UINT message, WPARAM wParam,
switch (message)
{
case WM_NCCREATE :
pDlgMoving = reinterpret_cast<Gripper *>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
pDlgMoving = static_cast<Gripper *>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
pDlgMoving->_hSelf = hwnd;
::SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pDlgMoving));
return TRUE;

View File

@ -220,7 +220,7 @@ LRESULT CALLBACK Splitter::staticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
{
case WM_NCCREATE:
{
Splitter * pSplitter = reinterpret_cast<Splitter *>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
Splitter * pSplitter = static_cast<Splitter *>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
pSplitter->_hSelf = hWnd;
::SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pSplitter));
return TRUE;

View File

@ -150,7 +150,7 @@ LRESULT CALLBACK SplitterContainer::staticWinProc(HWND hwnd, UINT message, WPARA
{
case WM_NCCREATE:
{
pSplitterContainer = reinterpret_cast<SplitterContainer *>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
pSplitterContainer = static_cast<SplitterContainer *>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
pSplitterContainer->_hSelf = hwnd;
::SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pSplitterContainer));
return TRUE;

View File

@ -146,7 +146,7 @@ intptr_t CALLBACK TaskListDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
{
case LVN_GETDISPINFO:
{
LV_ITEM &lvItem = reinterpret_cast<LV_DISPINFO*>(reinterpret_cast<LV_DISPINFO FAR *>(lParam))->item;
LV_ITEM &lvItem = reinterpret_cast<LV_DISPINFO FAR *>(lParam)->item;
TaskLstFnStatus & fileNameStatus = _taskListInfo._tlfsLst[lvItem.iItem];

View File

@ -205,7 +205,7 @@ int VerticalFileSwitcherListView::newItem(BufferID bufferID, int iView)
void VerticalFileSwitcherListView::setItemIconStatus(BufferID bufferID)
{
Buffer *buf = static_cast<Buffer *>(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<Buffer*>(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<Buffer *>(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);

View File

@ -81,26 +81,26 @@ uchardet_t uchardet_new()
void uchardet_delete(uchardet_t ud)
{
delete reinterpret_cast<HandleUniversalDetector*>(ud);
delete static_cast<HandleUniversalDetector*>(ud);
}
int uchardet_handle_data(uchardet_t ud, const char * data, size_t len)
{
nsresult ret = reinterpret_cast<HandleUniversalDetector*>(ud)->HandleData(data, (PRUint32)len);
nsresult ret = static_cast<HandleUniversalDetector*>(ud)->HandleData(data, (PRUint32)len);
return (ret != NS_OK);
}
void uchardet_data_end(uchardet_t ud)
{
reinterpret_cast<HandleUniversalDetector*>(ud)->DataEnd();
static_cast<HandleUniversalDetector*>(ud)->DataEnd();
}
void uchardet_reset(uchardet_t ud)
{
reinterpret_cast<HandleUniversalDetector*>(ud)->Reset();
static_cast<HandleUniversalDetector*>(ud)->Reset();
}
const char* uchardet_get_charset(uchardet_t ud)
{
return reinterpret_cast<HandleUniversalDetector*>(ud)->GetCharset();
return static_cast<HandleUniversalDetector*>(ud)->GetCharset();
}