Skip to content

Commit f82babb

Browse files
authored
[Analyzers][CPP] Turn on warning 26493 (#23990)
and change the remaining files
1 parent 6e4a289 commit f82babb

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

CppRuleSet.ruleset

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<Rule Id="C26490" Action="Hidden" />
8181
<Rule Id="C26491" Action="Hidden" />
8282
<Rule Id="C26492" Action="Error" />
83-
<Rule Id="C26493" Action="Hidden" />
83+
<Rule Id="C26493" Action="Error" />
8484
<Rule Id="C26494" Action="Hidden" />
8585
<Rule Id="C26495" Action="Error" />
8686
<Rule Id="C26496" Action="Hidden" />

installer/PowerToysSetupCustomActions/CustomAction.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ UINT __stdcall CreateScheduledTaskCA(MSIHANDLE hInstall)
264264
nullptr,
265265
CLSCTX_INPROC_SERVER,
266266
IID_ITaskService,
267-
(void**)&pService);
267+
reinterpret_cast<void**>(&pService));
268268
ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr);
269269

270270
// Connect to the task service.
@@ -490,7 +490,7 @@ UINT __stdcall RemoveScheduledTasksCA(MSIHANDLE hInstall)
490490
nullptr,
491491
CLSCTX_INPROC_SERVER,
492492
IID_ITaskService,
493-
(void**)&pService);
493+
reinterpret_cast<void**>(&pService));
494494
ExitOnFailure(hr, "Failed to create an instance of ITaskService: %x", hr);
495495

496496
// Connect to the task service.
@@ -809,7 +809,7 @@ UINT __stdcall CertifyVirtualCameraDriverCA(MSIHANDLE hInstall)
809809
ExitOnFailure(hr, "Certificate file size not valid", hr);
810810
}
811811

812-
pFileContent = (char*)malloc(size);
812+
pFileContent = static_cast<char*>(malloc(size));
813813

814814
DWORD sizeread;
815815
if (!ReadFile(hfile, pFileContent, size, &sizeread, nullptr))
@@ -820,7 +820,7 @@ UINT __stdcall CertifyVirtualCameraDriverCA(MSIHANDLE hInstall)
820820

821821
if (!CertAddEncodedCertificateToStore(hCertStore,
822822
X509_ASN_ENCODING,
823-
(const BYTE*)pFileContent,
823+
reinterpret_cast<const BYTE*>(pFileContent),
824824
size,
825825
CERT_STORE_ADD_ALWAYS,
826826
nullptr))

tools/StylesReportTool/StylesReportTool.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ inline std::wstring get_process_path(DWORD pid) noexcept
4949
{
5050
name.resize(MAX_PATH);
5151
DWORD name_length = static_cast<DWORD>(name.length());
52-
if (QueryFullProcessImageNameW(process, 0, (LPWSTR)name.data(), &name_length) == 0)
52+
if (QueryFullProcessImageNameW(process, 0, static_cast<LPWSTR>(name.data()), &name_length) == 0)
5353
{
5454
name_length = 0;
5555
}
@@ -410,7 +410,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
410410

411411
LPCWSTR text = L"Please select the target window (using a mouse or Alt+Tab), \r\nand press Ctrl+Alt+S to capture its styles. \r\nYou can find the output file \"window_styles.txt\" on your desktop.";
412412
RECT rc{0,50,600,200};
413-
DrawText(hdc, text, (int)wcslen(text), &rc, DT_CENTER | DT_WORDBREAK);
413+
DrawText(hdc, text, static_cast<int>(wcslen(text)), &rc, DT_CENTER | DT_WORDBREAK);
414414

415415
EndPaint(hWnd, &ps);
416416
}

0 commit comments

Comments
 (0)