Commit 8ed58789 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Fix undefined behaviour in eytzinger1_first()

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 86d81ec5
......@@ -48,7 +48,7 @@ static inline unsigned eytzinger1_right_child(unsigned i)
static inline unsigned eytzinger1_first(unsigned size)
{
return rounddown_pow_of_two(size);
return size ? rounddown_pow_of_two(size) : 0;
}
static inline unsigned eytzinger1_last(unsigned size)
......@@ -101,7 +101,9 @@ static inline unsigned eytzinger1_prev(unsigned i, unsigned size)
static inline unsigned eytzinger1_extra(unsigned size)
{
return (size + 1 - rounddown_pow_of_two(size)) << 1;
return size
? (size + 1 - rounddown_pow_of_two(size)) << 1
: 0;
}
static inline unsigned __eytzinger1_to_inorder(unsigned i, unsigned size,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment