1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00

chore: add more descriptive assertion in bitfield (#2748)

Related to #2727
This commit is contained in:
Charles Kerr 2022-03-09 17:43:42 -06:00 committed by GitHub
parent 7a227917ff
commit 1bafbd18ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -218,7 +218,12 @@ void tr_bitfield::freeArray()
void tr_bitfield::setTrueCount(size_t n)
{
TR_ASSERT(bit_count_ == 0 || n <= bit_count_);
TR_ASSERT_MSG(
bit_count_ == 0 || n <= bit_count_,
"bit_count_:%zu, n:%zu, std::size(flags_):%zu",
bit_count_,
n,
size_t(std::size(flags_)));
true_count_ = n;
have_all_hint_ = n == bit_count_;
@ -285,7 +290,7 @@ void tr_bitfield::setHasAll()
void tr_bitfield::setRaw(uint8_t const* raw, size_t byte_count)
{
flags_ = std::vector<uint8_t>(raw, raw + byte_count);
flags_.assign(raw, raw + byte_count);
// ensure any excess bits at the end of the array are set to '0'.
if (byte_count == getBytesNeeded(bit_count_))

View file

@ -10,6 +10,7 @@
#endif
#include <cstddef>
#include <cstdint>
#include <vector>
/**