C26493, no C-style casts.

This commit is contained in:
Michael Niksa 2019-08-29 12:45:16 -07:00
parent b33a59816e
commit c63289b114
4 changed files with 19 additions and 19 deletions

View file

@ -102,12 +102,12 @@ void TextAttribute::SetLegacyAttributes(const WORD attrs,
{
if (setForeground)
{
const BYTE fgIndex = (BYTE)(attrs & FG_ATTRS);
const BYTE fgIndex = gsl::narrow_cast<BYTE>(attrs & FG_ATTRS);
_foreground = TextColor(fgIndex);
}
if (setBackground)
{
const BYTE bgIndex = (BYTE)(attrs & BG_ATTRS) >> 4;
const BYTE bgIndex = gsl::narrow_cast<BYTE>(attrs & BG_ATTRS) >> 4;
_background = TextColor(bgIndex);
}
if (setMeta)

View file

@ -207,7 +207,7 @@ void Cursor::SetPosition(const COORD cPosition)
void Cursor::SetXPosition(const int NewX)
{
_RedrawCursor();
_cPosition.X = (SHORT)NewX;
_cPosition.X = gsl::narrow<SHORT>(NewX);
_RedrawCursor();
ResetDelayEOLWrap();
}
@ -215,7 +215,7 @@ void Cursor::SetXPosition(const int NewX)
void Cursor::SetYPosition(const int NewY)
{
_RedrawCursor();
_cPosition.Y = (SHORT)NewY;
_cPosition.Y = gsl::narrow<SHORT>(NewY);
_RedrawCursor();
ResetDelayEOLWrap();
}
@ -223,7 +223,7 @@ void Cursor::SetYPosition(const int NewY)
void Cursor::IncrementXPosition(const int DeltaX)
{
_RedrawCursor();
_cPosition.X += (SHORT)DeltaX;
_cPosition.X += gsl::narrow<SHORT>(DeltaX);
_RedrawCursor();
ResetDelayEOLWrap();
}
@ -231,7 +231,7 @@ void Cursor::IncrementXPosition(const int DeltaX)
void Cursor::IncrementYPosition(const int DeltaY)
{
_RedrawCursor();
_cPosition.Y += (SHORT)DeltaY;
_cPosition.Y += gsl::narrow<SHORT>(DeltaY);
_RedrawCursor();
ResetDelayEOLWrap();
}
@ -239,7 +239,7 @@ void Cursor::IncrementYPosition(const int DeltaY)
void Cursor::DecrementXPosition(const int DeltaX)
{
_RedrawCursor();
_cPosition.X -= (SHORT)DeltaX;
_cPosition.X -= gsl::narrow<SHORT>(DeltaX);
_RedrawCursor();
ResetDelayEOLWrap();
}
@ -247,7 +247,7 @@ void Cursor::DecrementXPosition(const int DeltaX)
void Cursor::DecrementYPosition(const int DeltaY)
{
_RedrawCursor();
_cPosition.Y -= (SHORT)DeltaY;
_cPosition.Y -= gsl::narrow<SHORT>(DeltaY);
_RedrawCursor();
ResetDelayEOLWrap();
}
@ -342,7 +342,7 @@ const COLORREF Cursor::GetColor() const
void Cursor::SetColor(const unsigned int color)
{
_color = (COLORREF)color;
_color = static_cast<COLORREF>(color);
}
void Cursor::SetType(const CursorType type)

View file

@ -63,7 +63,7 @@ using namespace Microsoft::Console::Render;
DrawingContext* drawingContext = static_cast<DrawingContext*>(clientDrawingContext);
// Matrix structures are defined identically
drawingContext->renderTarget->GetTransform((D2D1_MATRIX_3X2_F*)transform);
drawingContext->renderTarget->GetTransform(reinterpret_cast<D2D1_MATRIX_3X2_F*>(transform));
return S_OK;
}
#pragma endregion

View file

@ -377,8 +377,8 @@ void DxEngine::_ReleaseDeviceResources() noexcept
return _dwriteFactory->CreateTextLayout(string,
static_cast<UINT32>(stringLength),
_dwriteTextFormat.Get(),
(float)_displaySizePixels.cx,
_glyphCell.cy != 0 ? _glyphCell.cy : (float)_displaySizePixels.cy,
gsl::narrow<float>(_displaySizePixels.cx),
_glyphCell.cy != 0 ? _glyphCell.cy : gsl::narrow<float>( _displaySizePixels.cy),
ppTextLayout);
}
@ -1089,7 +1089,7 @@ enum class CursorPaintType
{
// Enforce min/max cursor height
ULONG ulHeight = std::clamp(options.ulCursorHeightPercent, s_ulMinCursorHeightPercent, s_ulMaxCursorHeightPercent);
ulHeight = (ULONG)((_glyphCell.cy * ulHeight) / 100);
ulHeight = gsl::narrow<ULONG>((_glyphCell.cy * ulHeight) / 100);
rect.top = rect.bottom - ulHeight;
break;
}
@ -1300,10 +1300,10 @@ float DxEngine::GetScaling() const noexcept
[[nodiscard]] SMALL_RECT DxEngine::GetDirtyRectInChars() noexcept
{
SMALL_RECT r;
r.Top = (SHORT)(floor(_invalidRect.top / _glyphCell.cy));
r.Left = (SHORT)(floor(_invalidRect.left / _glyphCell.cx));
r.Bottom = (SHORT)(floor(_invalidRect.bottom / _glyphCell.cy));
r.Right = (SHORT)(floor(_invalidRect.right / _glyphCell.cx));
r.Top = gsl::narrow<SHORT>(floor(_invalidRect.top / _glyphCell.cy));
r.Left = gsl::narrow<SHORT>(floor(_invalidRect.left / _glyphCell.cx));
r.Bottom = gsl::narrow<SHORT>(floor(_invalidRect.bottom / _glyphCell.cy));
r.Right = gsl::narrow<SHORT>(floor(_invalidRect.right / _glyphCell.cx));
// Exclusive to inclusive
r.Bottom--;
@ -1321,7 +1321,7 @@ float DxEngine::GetScaling() const noexcept
// - Nearest integer short x and y values for each cell.
[[nodiscard]] COORD DxEngine::_GetFontSize() const noexcept
{
return { (SHORT)(_glyphCell.cx), (SHORT)(_glyphCell.cy) };
return { gsl::narrow<SHORT>(_glyphCell.cx), gsl::narrow<SHORT>(_glyphCell.cy) };
}
// Routine Description:
@ -1371,7 +1371,7 @@ float DxEngine::GetScaling() const noexcept
// - S_OK
[[nodiscard]] HRESULT DxEngine::_DoUpdateTitle(_In_ const std::wstring& /*newTitle*/) noexcept
{
return PostMessageW(_hwndTarget, CM_UPDATE_TITLE, 0, (LPARAM) nullptr) ? S_OK : E_FAIL;
return PostMessageW(_hwndTarget, CM_UPDATE_TITLE, 0, 0) ? S_OK : E_FAIL;
}
// Routine Description: