Update CodeQL warning suppressions (#4985)

This commit is contained in:
Stephan T. Lavavej 2024-09-28 13:28:10 -07:00 коммит произвёл GitHub
Родитель d194fcd5a1
Коммит faccf0084e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
7 изменённых файлов: 39 добавлений и 18 удалений

Просмотреть файл

@ -676,7 +676,8 @@ public:
}
constexpr bool _Match(const _Elem _Ch) const noexcept { // test if _Ch is in the bitmap
return _Matches[static_cast<unsigned char>(_Ch)]; // lgtm [cpp/unclear-array-index-validation]
// CodeQL [SM01954] This index is valid: we cast to unsigned char and the array has 256 elements.
return _Matches[static_cast<unsigned char>(_Ch)];
}
private:
@ -1337,7 +1338,9 @@ public:
#if _CONTAINER_DEBUG_LEVEL > 0
_STL_VERIFY(_Off < _Mysize, "string_view subscript out of range");
#endif // _CONTAINER_DEBUG_LEVEL > 0
return _Mydata[_Off]; // lgtm [cpp/unclear-array-index-validation]
// CodeQL [SM01954] This index is optionally validated above.
return _Mydata[_Off];
}
_NODISCARD constexpr const_reference at(const size_type _Off) const {

Просмотреть файл

@ -228,7 +228,9 @@ _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)]; // lgtm [cpp/unclear-array-index-validation]
// CodeQL [SM01954] This index is valid: we cast to unsigned char and the array has 256 elements.
return _Digit_from_byte[static_cast<unsigned char>(_Ch)];
}
template <class _RawTy>
@ -456,7 +458,9 @@ _NODISCARD inline uint32_t _Bit_scan_reverse(const _Big_integer_flt& _Xval) noex
unsigned long _Index; // Intentionally uninitialized for better codegen
_STL_INTERNAL_CHECK(_Xval._Mydata[_Bx] != 0); // _Big_integer_flt should always be trimmed
_BitScanReverse(&_Index, _Xval._Mydata[_Bx]); // lgtm [cpp/conditionallyuninitializedvariable]
// CodeQL [SM02313] _Index is always initialized: we've guaranteed that _Xval._Mydata[_Bx] is non-zero.
_BitScanReverse(&_Index, _Xval._Mydata[_Bx]);
return _Index + 1 + _Bx * _Big_integer_flt::_Element_bits;
}

Просмотреть файл

@ -573,13 +573,14 @@ public:
_NODISCARD string message(int _Errcode) const override {
const _System_error_message _Msg(static_cast<unsigned long>(_Errcode));
if (_Msg._Length == 0) {
if (_Msg._Str && _Msg._Length != 0) {
// CodeQL [SM02310] _Msg's ctor inits _Str(nullptr) before doing work, then we test _Msg._Str above.
return string{_Msg._Str, _Msg._Length};
} else {
static constexpr char _Unknown_error[] = "unknown error";
constexpr size_t _Unknown_error_length = sizeof(_Unknown_error) - 1; // TRANSITION, DevCom-906503
return string{_Unknown_error, _Unknown_error_length};
} else {
_STL_INTERNAL_CHECK(_Msg._Str != nullptr);
return string{_Msg._Str, _Msg._Length}; // lgtm [cpp/uninitializedptrfield]
}
}

Просмотреть файл

@ -37,9 +37,11 @@ _NODISCARD inline unsigned long _Floor_of_log_2(size_t _Value) noexcept { // ret
}
#else // ^^^ defined(_M_CEE_PURE) / !defined(_M_CEE_PURE) vvv
#ifdef _WIN64
_BitScanReverse64(&_Result, _Value); // lgtm [cpp/conditionallyuninitializedvariable]
// CodeQL [SM02313] _Result is always initialized: the code above guarantees that _Value is non-zero.
_BitScanReverse64(&_Result, _Value);
#else // ^^^ 64-bit / 32-bit vvv
_BitScanReverse(&_Result, _Value); // lgtm [cpp/conditionallyuninitializedvariable]
// CodeQL [SM02313] _Result is always initialized: the code above guarantees that _Value is non-zero.
_BitScanReverse(&_Result, _Value);
#endif // ^^^ 32-bit ^^^
#endif // ^^^ !defined(_M_CEE_PURE) ^^^

Просмотреть файл

@ -4684,7 +4684,8 @@ _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); // lgtm [cpp/incorrect-string-type-conversion]
// CodeQL [SM02986] This cast is correct: we're bypassing pointer arithmetic for performance.
return reinterpret_cast<_OutCtgIt>(_Dest_ch + _Count);
} else {
return _Dest + static_cast<_Iter_diff_t<_OutCtgIt>>(_LastPtr - _FirstPtr);
}

Просмотреть файл

@ -82,7 +82,8 @@ 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]
// CodeQL [SM02986] This cast is correct: LCMAP_SORTKEY stores "an opaque array of bytes".
const auto wide_dest = reinterpret_cast<LPWSTR>(lpDestStr);
// do string mapping
if (0

Просмотреть файл

@ -1837,7 +1837,9 @@ namespace {
unsigned long _H_pos;
// Find the smallest horizontal index
_BitScanForward(&_H_pos, _Mask); // lgtm [cpp/conditionallyuninitializedvariable]
// CodeQL [SM02313] _H_pos is always initialized: element exists, so _Mask is non-zero.
_BitScanForward(&_H_pos, _Mask);
const auto _V_pos = _Traits::_Get_v_pos(_Cur_idx_min, _H_pos); // Extract its vertical index
// Finally, compute the pointer
@ -1869,7 +1871,9 @@ namespace {
_Mask &= _Traits::_Mask(_Traits::_Cmp_eq_idx(_Idx_max, _Idx_max_val));
// Find the largest horizontal index
_BitScanReverse(&_H_pos, _Mask); // lgtm [cpp/conditionallyuninitializedvariable]
// CodeQL [SM02313] _H_pos is always initialized: element exists, so _Mask is non-zero.
_BitScanReverse(&_H_pos, _Mask);
_H_pos -= sizeof(_Cur_max_val) - 1; // Correct from highest val bit to lowest
} else {
@ -1882,7 +1886,9 @@ namespace {
_Mask &= _Traits::_Mask(_Traits::_Cmp_eq_idx(_Idx_max, _Idx_max_val));
// Find the smallest horizontal index
_BitScanForward(&_H_pos, _Mask); // lgtm [cpp/conditionallyuninitializedvariable]
// CodeQL [SM02313] _H_pos is always initialized: element exists, so _Mask is non-zero.
_BitScanForward(&_H_pos, _Mask);
}
const auto _V_pos = _Traits::_Get_v_pos(_Cur_idx_max, _H_pos); // Extract its vertical index
@ -2495,7 +2501,8 @@ namespace {
if (_Bingo != 0) {
unsigned long _Offset;
_BitScanForward(&_Offset, _Bingo); // lgtm [cpp/conditionallyuninitializedvariable]
// CodeQL [SM02313] _Offset is always initialized: we just tested `if (_Bingo != 0)`.
_BitScanForward(&_Offset, _Bingo);
_Advance_bytes(_First, _Offset);
return _First;
}
@ -2565,7 +2572,8 @@ namespace {
if (_Bingo != 0) {
unsigned long _Offset;
_BitScanReverse(&_Offset, _Bingo); // lgtm [cpp/conditionallyuninitializedvariable]
// CodeQL [SM02313] _Offset is always initialized: we just tested `if (_Bingo != 0)`.
_BitScanReverse(&_Offset, _Bingo);
_Advance_bytes(_Last, _Offset - (sizeof(_Ty) - 1));
return _Last;
}
@ -3242,7 +3250,8 @@ namespace {
static_cast<unsigned int>(_mm_movemask_epi8(_Traits::_Cmp_sse(_Elem1, _Elem2))) ^ 0xFFFF;
if (_Bingo != 0) {
unsigned long _Offset;
_BitScanForward(&_Offset, _Bingo); // lgtm [cpp/conditionallyuninitializedvariable]
// CodeQL [SM02313] _Offset is always initialized: we just tested `if (_Bingo != 0)`.
_BitScanForward(&_Offset, _Bingo);
return (_Result + _Offset) / sizeof(_Ty);
}
}