Rewrite the loop in btree_get_prev() so that the compiler
can see that it returns if the cur->index is zero so it
doesn't complain about possible array bound underflows
when getting the key out of the buffer. Version 2 fixes
a height overflow in the reworked loop.
Fix the directory name sign warnings by casting to (uchar_t *)
appropriately.
Signed-off-by: Dave Chinner <david@fromorbit.com>
}
/* else need to go up and back down the tree to find the previous */
-
- while (cur->index == 0) {
- if (++level == root->height)
- return NULL;
+ do {
+ if (cur->index)
+ break;
cur++;
- }
+ } while (++level < root->height);
+
+ if (level == root->height)
+ return NULL;
/* the key is in the current level */
if (key)