btrfs: fixed comparison warnings in btree.
* Added static_cast<uint32> to resolve type mismatch warnings between signed integer(fSlots[level] and slot) and unsigned integers(ItemCount()) during compile * eliminated a potential unsigned underflow vunerability when a node is empty in NextLeaf() traversal logic Change-Id: I8534f31cac9dec41e04e16989427dc7d9abb26ef Reviewed-on: https://review.haiku-os.org/c/haiku/+/10363 Haiku-Format: Haiku-format Bot <[email protected]> Reviewed-by: Fruit De La Passion <[email protected]> Reviewed-by: Adrien Destugues <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
05d6e44fc9
commit
4e5ee46880
@@ -360,7 +360,7 @@ BTree::Path::Move(int level, int step)
|
||||
fSlots[level] += step;
|
||||
if (fSlots[level] < 0)
|
||||
return -1;
|
||||
if (fSlots[level] >= fNodes[level]->ItemCount())
|
||||
if (static_cast<uint32>(fSlots[level]) >= fNodes[level]->ItemCount())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -371,7 +371,7 @@ BTree::Path::GetEntry(int slot, btrfs_key* _key, void** _value, uint32* _size,
|
||||
uint32* _offset)
|
||||
{
|
||||
BTree::Node* leaf = fNodes[0];
|
||||
if (slot < 0 || slot >= leaf->ItemCount())
|
||||
if (slot < 0 || static_cast<uint32>(slot) >= leaf->ItemCount())
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
if (_key != NULL)
|
||||
@@ -806,7 +806,7 @@ BTree::NextLeaf(Path* path) const
|
||||
// iterate to the root until satisfy the condition
|
||||
while (true) {
|
||||
node = path->GetNode(level, &slot);
|
||||
if (node == NULL || slot < node->ItemCount() - 1)
|
||||
if (node == NULL || static_cast<uint32>(slot + 1) < node->ItemCount())
|
||||
break;
|
||||
level++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user