Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence CodeQL false positive warnings #4942

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -4690,7 +4690,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