[Analyzers][CPP]Changes to fix warning 26493 on src/common (#23467)

* Changes to fix warning 26493 on src/common

It will be multi PR change. This does not turn on the rule but fix the code under src/commom

* int cast
This commit is contained in:
sosssego
2023-02-08 11:00:19 +00:00
committed by GitHub
parent 956eb98125
commit a743e496c5
19 changed files with 66 additions and 69 deletions

View File

@@ -14,7 +14,7 @@ HRESULT GetIconIndexFromPath(_In_ PCWSTR path, _Out_ int* index)
if (!PathIsRelative(path))
{
DWORD attrib = GetFileAttributes(path);
HIMAGELIST himl = (HIMAGELIST)SHGetFileInfo(path, attrib, &shFileInfo, sizeof(shFileInfo), (SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES));
auto himl =SHGetFileInfo(path, attrib, &shFileInfo, sizeof(shFileInfo), (SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES));
if (himl)
{
*index = shFileInfo.iIcon;
@@ -61,14 +61,14 @@ HBITMAP CreateBitmapFromIcon(_In_ HICON hIcon, _In_opt_ UINT width, _In_opt_ UIN
if (hBitmap != NULL)
{
// Select bitmap into DC
HBITMAP hBitmapOld = (HBITMAP)SelectObject(hDC, hBitmap);
HBITMAP hBitmapOld = static_cast<HBITMAP>(SelectObject(hDC, hBitmap));
if (hBitmapOld != NULL)
{
// Draw icon into DC
if (DrawIconEx(hDC, 0, 0, hIcon, rc.right, rc.bottom, 0, NULL, DI_NORMAL))
{
// Restore original bitmap in DC
hBitmapResult = (HBITMAP)SelectObject(hDC, hBitmapOld);
hBitmapResult = static_cast<HBITMAP>(SelectObject(hDC, hBitmapOld));
hBitmapOld = NULL;
hBitmap = NULL;
}