[Analyzers][CPP]Turn on warning 26471 (#23103)
Don't use reinterpret_cast. A cast from void* can use static_cast
This commit is contained in:
Родитель
1a1f4351ca
Коммит
d84a13bb7e
|
@ -64,7 +64,7 @@
|
|||
<Rule Id="C26464" Action="Error" />
|
||||
<Rule Id="C26465" Action="Hidden" />
|
||||
<Rule Id="C26466" Action="Error" />
|
||||
<Rule Id="C26471" Action="Hidden" />
|
||||
<Rule Id="C26471" Action="Error" />
|
||||
<Rule Id="C26472" Action="Hidden" />
|
||||
<Rule Id="C26473" Action="Hidden" />
|
||||
<Rule Id="C26474" Action="Hidden" />
|
||||
|
|
|
@ -79,7 +79,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
|
|||
hMapFile = OpenFileMappingW(FILE_MAP_WRITE, FALSE, pidFile.data());
|
||||
if (hMapFile)
|
||||
{
|
||||
pidBuffer = reinterpret_cast<PDWORD>(MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(DWORD)));
|
||||
pidBuffer = static_cast<PDWORD>(MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(DWORD)));
|
||||
if (pidBuffer)
|
||||
{
|
||||
*pidBuffer = 0;
|
||||
|
|
|
@ -2,7 +2,12 @@
|
|||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
// disable warning 26471 - Don't use reinterpret_cast. A cast from void* can use static_cast
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 26471)
|
||||
#include <wil/resource.h>
|
||||
#pragma warning(pop)
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
|
|
@ -24,7 +24,7 @@ protected:
|
|||
if (!thisRef && (message == WM_CREATE))
|
||||
{
|
||||
const auto createStruct = reinterpret_cast<LPCREATESTRUCT>(lparam);
|
||||
thisRef = reinterpret_cast<AlwaysOnTop*>(createStruct->lpCreateParams);
|
||||
thisRef = static_cast<AlwaysOnTop*>(createStruct->lpCreateParams);
|
||||
SetWindowLongPtr(window, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(thisRef));
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ protected:
|
|||
if ((thisRef == nullptr) && (message == WM_CREATE))
|
||||
{
|
||||
auto createStruct = reinterpret_cast<LPCREATESTRUCT>(lparam);
|
||||
thisRef = reinterpret_cast<WindowBorder*>(createStruct->lpCreateParams);
|
||||
thisRef = static_cast<WindowBorder*>(createStruct->lpCreateParams);
|
||||
SetWindowLongPtr(window, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(thisRef));
|
||||
}
|
||||
|
||||
|
|
|
@ -748,7 +748,7 @@ LRESULT CALLBACK FancyZones::s_WndProc(HWND window, UINT message, WPARAM wparam,
|
|||
if (!thisRef && (message == WM_CREATE))
|
||||
{
|
||||
const auto createStruct = reinterpret_cast<LPCREATESTRUCT>(lparam);
|
||||
thisRef = reinterpret_cast<FancyZones*>(createStruct->lpCreateParams);
|
||||
thisRef = static_cast<FancyZones*>(createStruct->lpCreateParams);
|
||||
SetWindowLongPtr(window, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(thisRef));
|
||||
}
|
||||
|
||||
|
|
|
@ -680,7 +680,7 @@ LRESULT CALLBACK WorkArea::s_WndProc(HWND window, UINT message, WPARAM wparam, L
|
|||
if ((thisRef == nullptr) && (message == WM_CREATE))
|
||||
{
|
||||
auto createStruct = reinterpret_cast<LPCREATESTRUCT>(lparam);
|
||||
thisRef = reinterpret_cast<WorkArea*>(createStruct->lpCreateParams);
|
||||
thisRef = static_cast<WorkArea*>(createStruct->lpCreateParams);
|
||||
SetWindowLongPtr(window, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(thisRef));
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ BOOL RegisterDLLWindowClass(LPCWSTR szClassName, Mocks::HwndCreator* creator)
|
|||
DWORD WINAPI ThreadProc(LPVOID lpParam)
|
||||
{
|
||||
MSG messages;
|
||||
Mocks::HwndCreator* creator = reinterpret_cast<Mocks::HwndCreator*>(lpParam);
|
||||
Mocks::HwndCreator* creator = static_cast<Mocks::HwndCreator*>(lpParam);
|
||||
if (!creator)
|
||||
return static_cast<DWORD>(-1);
|
||||
|
||||
|
|
|
@ -727,7 +727,7 @@ DWORD WINAPI CPowerRenameManager::s_fileOpWorkerThread(_In_ void* pv)
|
|||
{
|
||||
if (SUCCEEDED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)))
|
||||
{
|
||||
WorkerThreadData* pwtd = reinterpret_cast<WorkerThreadData*>(pv);
|
||||
WorkerThreadData* pwtd = static_cast<WorkerThreadData*>(pv);
|
||||
if (pwtd)
|
||||
{
|
||||
bool closeUIWindowAfterRenaming = true;
|
||||
|
@ -914,7 +914,7 @@ DWORD WINAPI CPowerRenameManager::s_regexWorkerThread(_In_ void* pv)
|
|||
try
|
||||
{
|
||||
winrt::check_hresult(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
|
||||
WorkerThreadData* pwtd = reinterpret_cast<WorkerThreadData*>(pv);
|
||||
WorkerThreadData* pwtd = static_cast<WorkerThreadData*>(pv);
|
||||
if (pwtd)
|
||||
{
|
||||
PostMessage(pwtd->hwndManager, SRM_REGEX_STARTED, GetCurrentThreadId(), 0);
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
#include <windows.h>
|
||||
#include <dshow.h>
|
||||
|
||||
// disable warning 26471 - Don't use reinterpret_cast. A cast from void* can use static_cast
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 26471)
|
||||
#include <wil/com.h>
|
||||
#pragma warning(push)
|
||||
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
|
||||
#include <vector>
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
#include <dshow.h>
|
||||
#include <cguid.h>
|
||||
|
||||
// disable warning 26471 - Don't use reinterpret_cast. A cast from void* can use static_cast
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 26471)
|
||||
#include <wil/com.h>
|
||||
#pragma warning(push)
|
||||
|
||||
#include <wil/resource.h>
|
||||
|
||||
#include <iostream>
|
||||
|
|
Загрузка…
Ссылка в новой задаче