[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;
}

View File

@@ -28,10 +28,7 @@ AppTheme ThemeHelpers::GetAppTheme()
}
// convert bytes written to our buffer to an int, assuming little-endian
auto i = int(buffer[3] << 24 |
buffer[2] << 16 |
buffer[1] << 8 |
buffer[0]);
auto i = static_cast<int>(buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]);
return AppTheme(i);
}

View File

@@ -8,7 +8,7 @@
#pragma warning(disable : 4702)
DWORD WINAPI _checkTheme(LPVOID lpParam)
{
auto listener = (ThemeListener*)lpParam;
auto listener = static_cast<ThemeListener*>(lpParam);
listener->CheckTheme();
return 0;
}

View File

@@ -11,7 +11,7 @@ DWORD WindowsColors::rgb_color(DWORD abgr_color)
}
DWORD WindowsColors::rgb_color(winrt::Windows::UI::Color color)
{
return ((DWORD)color.R << 16) | ((DWORD)color.G << 8) | ((DWORD)color.B);
return static_cast<DWORD>((color.R << 16) | (color.G << 8) | (color.B));
}
WindowsColors::Color WindowsColors::get_button_face_color()
{