Fix CI: bugprone-signed-char-misuse in append_from_block

Convert the (positive) length to its unsigned type before widening it
to std::size_t, as clang-tidy flags the int8_t to std::size_t cast.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-11-06 12:13:09 +01:00
1 parent a33af0a51b
commit 759a847178
2 files changed
+10 -4

No files matched your search

+5 -2
View File
@@ -22956,12 +22956,15 @@ class binary_reader
{
return false;
}
// (len > 0, so the unsigned type holds it; casting a signed char
// straight to std::size_t would trip bugprone-signed-char-misuse)
const auto ulen = static_cast<typename std::make_unsigned<NumberType>::type>(len);
const std::size_t remaining = ia.bulk_remaining();
if (static_cast<std::uintmax_t>(len) > static_cast<std::uintmax_t>(remaining))
if (static_cast<std::uintmax_t>(ulen) > static_cast<std::uintmax_t>(remaining))
{
return false; // (the loop reports the premature end)
}
const auto n = static_cast<std::size_t>(len);
const auto n = static_cast<std::size_t>(ulen);
result.append(reinterpret_cast<const typename string_t::value_type*>(ia.bulk_data()), n);
ia.bulk_skip(n);
chars_read += n;