Skip to content

Commit

Permalink
Silence CodeQL false positive warnings (#4942)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej authored Sep 9, 2024
1 parent e067e3e commit e34645f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions stl/inc/__msvc_string_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ class _String_bitmap { // _String_bitmap for character types
}

constexpr bool _Match(const _Elem _Ch) const noexcept { // test if _Ch is in the bitmap
return _Matches[static_cast<unsigned char>(_Ch)];
return _Matches[static_cast<unsigned char>(_Ch)]; // lgtm [cpp/unclear-array-index-validation]
}

private:
Expand Down Expand Up @@ -1331,7 +1331,7 @@ class basic_string_view { // wrapper for any kind of contiguous character buffer
#if _CONTAINER_DEBUG_LEVEL > 0
_STL_VERIFY(_Off < _Mysize, "string_view subscript out of range");
#endif // _CONTAINER_DEBUG_LEVEL > 0
return _Mydata[_Off];
return _Mydata[_Off]; // lgtm [cpp/unclear-array-index-validation]
}

_NODISCARD constexpr const_reference at(const size_type _Off) const {
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/charconv
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ _STL_INTERNAL_STATIC_ASSERT(_STD size(_Digit_from_byte) == 256);

_NODISCARD _CONSTEXPR23 unsigned char _Digit_from_char(const char _Ch) noexcept {
// convert ['0', '9'] ['A', 'Z'] ['a', 'z'] to [0, 35], everything else to 255
return _Digit_from_byte[static_cast<unsigned char>(_Ch)];
return _Digit_from_byte[static_cast<unsigned char>(_Ch)]; // lgtm [cpp/unclear-array-index-validation]
}

template <class _RawTy>
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -4707,7 +4707,7 @@ _OutCtgIt _Copy_memmove(_CtgIt _First, _CtgIt _Last, _OutCtgIt _Dest) {
const auto _Count = static_cast<size_t>(_Last_ch - _First_ch);
_CSTD memmove(_Dest_ch, _First_ch, _Count);
if constexpr (is_pointer_v<_OutCtgIt>) {
return reinterpret_cast<_OutCtgIt>(_Dest_ch + _Count);
return reinterpret_cast<_OutCtgIt>(_Dest_ch + _Count); // lgtm [cpp/incorrect-string-type-conversion]
} else {
return _Dest + static_cast<_Iter_diff_t<_OutCtgIt>>(_LastPtr - _FirstPtr);
}
Expand Down
6 changes: 4 additions & 2 deletions stl/src/StlLCMapStringA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ extern "C" _CRTIMP2 int __cdecl __crtLCMapStringA(_In_opt_z_ LPCWSTR LocaleName,
return retval;
}

const auto wide_dest = reinterpret_cast<LPWSTR>(lpDestStr); // lgtm [cpp/incorrect-string-type-conversion]

// do string mapping
if (0
== LCMapStringEx(LocaleName, dwMapFlags, inwbuffer.get(), inbuff_size,
reinterpret_cast<LPWSTR>(lpDestStr), cchDest, nullptr, nullptr, 0)) {
== LCMapStringEx(
LocaleName, dwMapFlags, inwbuffer.get(), inbuff_size, wide_dest, cchDest, nullptr, nullptr, 0)) {
return retval;
}
}
Expand Down

0 comments on commit e34645f

Please sign in to comment.