Skip to content

Commit e34645f

Browse files
Silence CodeQL false positive warnings (#4942)
1 parent e067e3e commit e34645f

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

stl/inc/__msvc_string_view.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ class _String_bitmap { // _String_bitmap for character types
665665
}
666666

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

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

13371337
_NODISCARD constexpr const_reference at(const size_type _Off) const {

stl/inc/charconv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ _STL_INTERNAL_STATIC_ASSERT(_STD size(_Digit_from_byte) == 256);
228228

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

234234
template <class _RawTy>

stl/inc/xutility

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4707,7 +4707,7 @@ _OutCtgIt _Copy_memmove(_CtgIt _First, _CtgIt _Last, _OutCtgIt _Dest) {
47074707
const auto _Count = static_cast<size_t>(_Last_ch - _First_ch);
47084708
_CSTD memmove(_Dest_ch, _First_ch, _Count);
47094709
if constexpr (is_pointer_v<_OutCtgIt>) {
4710-
return reinterpret_cast<_OutCtgIt>(_Dest_ch + _Count);
4710+
return reinterpret_cast<_OutCtgIt>(_Dest_ch + _Count); // lgtm [cpp/incorrect-string-type-conversion]
47114711
} else {
47124712
return _Dest + static_cast<_Iter_diff_t<_OutCtgIt>>(_LastPtr - _FirstPtr);
47134713
}

stl/src/StlLCMapStringA.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ extern "C" _CRTIMP2 int __cdecl __crtLCMapStringA(_In_opt_z_ LPCWSTR LocaleName,
8282
return retval;
8383
}
8484

85+
const auto wide_dest = reinterpret_cast<LPWSTR>(lpDestStr); // lgtm [cpp/incorrect-string-type-conversion]
86+
8587
// do string mapping
8688
if (0
87-
== LCMapStringEx(LocaleName, dwMapFlags, inwbuffer.get(), inbuff_size,
88-
reinterpret_cast<LPWSTR>(lpDestStr), cchDest, nullptr, nullptr, 0)) {
89+
== LCMapStringEx(
90+
LocaleName, dwMapFlags, inwbuffer.get(), inbuff_size, wide_dest, cchDest, nullptr, nullptr, 0)) {
8991
return retval;
9092
}
9193
}

0 commit comments

Comments
 (0)