Fix signed integer overflow

Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
Anthony Fieroni 2022-07-07 08:09:01 +03:00
parent d019e3605f
commit 329c5064d7
2 changed files with 5 additions and 5 deletions

View File

@ -47,7 +47,7 @@ Status WriteBatch::Iterate(Handler* handler) const {
input.remove_prefix(kHeader);
Slice key, value;
int found = 0;
uint32_t found = 0;
while (!input.empty()) {
found++;
char tag = input[0];
@ -79,11 +79,11 @@ Status WriteBatch::Iterate(Handler* handler) const {
}
}
int WriteBatchInternal::Count(const WriteBatch* b) {
uint32_t WriteBatchInternal::Count(const WriteBatch* b) {
return DecodeFixed32(b->rep_.data() + 8);
}
void WriteBatchInternal::SetCount(WriteBatch* b, int n) {
void WriteBatchInternal::SetCount(WriteBatch* b, uint32_t n) {
EncodeFixed32(&b->rep_[8], n);
}

View File

@ -17,10 +17,10 @@ class MemTable;
class WriteBatchInternal {
public:
// Return the number of entries in the batch.
static int Count(const WriteBatch* batch);
static uint32_t Count(const WriteBatch* batch);
// Set the count for the number of entries in the batch.
static void SetCount(WriteBatch* batch, int n);
static void SetCount(WriteBatch* batch, uint32_t n);
// Return the sequence number for the start of this batch.
static SequenceNumber Sequence(const WriteBatch* batch);