Skip to content

Commit

Permalink
Fix audit warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lhecker committed Nov 16, 2023
1 parent 26ee5b9 commit 6ba2b45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/buffer/out/TextColor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ COLORREF TextColor::GetColor(const std::array<COLORREF, TextColor::TABLE_SIZE>&
const auto result2 = _mm_cmpeq_epi32(haystack2, needle);
const auto result = _mm_packs_epi32(result1, result2); // 3.5
const auto mask = _mm_movemask_epi8(result);
#pragma warning(suppress : 26494) // BODGY: This is a misdiagnosis that is fixed in VS 17.8
unsigned long index;
return _BitScanForward(&index, mask) ? til::at(colorTable, static_cast<size_t>(index / 2) + 8) : defaultColor;
#else
Expand Down
16 changes: 6 additions & 10 deletions src/buffer/out/textBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1775,9 +1775,8 @@ const std::vector<til::inclusive_rect> TextBuffer::GetTextRects(til::point start
// (0,0) is the top-left of the screen
// the physically "higher" coordinate is closer to the top-left
// the physically "lower" coordinate is closer to the bottom-right
const auto [higherCoord, lowerCoord] = bufferSize.CompareInBounds(start, end) <= 0 ?
std::make_tuple(start, end) :
std::make_tuple(end, start);
const auto lowerCoord = std::min(start, end);
const auto higherCoord = std::max(start, end);

const auto textRectSize = 1 + lowerCoord.y - higherCoord.y;
textRects.reserve(textRectSize);
Expand Down Expand Up @@ -1845,14 +1844,11 @@ std::vector<til::point_span> TextBuffer::GetTextSpans(til::point start, til::poi
}
else
{
const auto bufferSize = GetSize();

// (0,0) is the top-left of the screen
// the physically "higher" coordinate is closer to the top-left
// the physically "lower" coordinate is closer to the bottom-right
auto [higherCoord, lowerCoord] = start <= end ?
std::make_tuple(start, end) :
std::make_tuple(end, start);
auto lowerCoord = std::min(start, end);
auto higherCoord = std::max(start, end);

textSpans.reserve(1);

Expand Down Expand Up @@ -2324,8 +2320,8 @@ std::string TextBuffer::GenRTF(const TextAndColor& rows, const int fontHeightPoi
colorTableBuilder << "{\\colortbl ;";

const auto getColorTableIndex = [&](const COLORREF color) -> size_t {
// Exclude the 0 index for the default color, and start with 1.

// Exclude the 0 index for the default color, and start with 1.
#pragma warning(suppress : 26478) // BODGY: This is a misdiagnosis that is fixed in VS 17.8
const auto [it, inserted] = colorMap.emplace(color, colorMap.size() + 1);
if (inserted)
{
Expand Down
1 change: 1 addition & 0 deletions src/renderer/atlas/BackendD3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ void BackendD3D::_resetGlyphAtlas(const RenderingPayload& p)
// For instance, for an area of 985x1946 = 1916810 it would result in a u/v of 2048x1024 (area = 2097152).
// This has 2 benefits: GPUs like power-of-2 textures and it ensures that we don't resize the texture
// every time you resize the window by a pixel. Instead it only grows/shrinks by a factor of 2.
#pragma warning(suppress : 26494) // BODGY: This is a misdiagnosis that is fixed in VS 17.8
unsigned long index;
_BitScanReverse(&index, area - 1);
const auto u = static_cast<u16>(1u << ((index + 2) / 2));
Expand Down

0 comments on commit 6ba2b45

Please sign in to comment.