diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-07-03 18:56:19 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-07-10 16:53:39 +0300 |
commit | 8ed58789fc43343d5a55565b204db40a514c06fc (patch) | |
tree | 5075cf0807933f6060def8f3d720547acf3857e1 /fs | |
parent | 86d81ec5f5f05846c7c6e48ffb964b24cba2e669 (diff) | |
download | linux-8ed58789fc43343d5a55565b204db40a514c06fc.tar.xz |
bcachefs: Fix undefined behaviour in eytzinger1_first()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/eytzinger.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/bcachefs/eytzinger.h b/fs/bcachefs/eytzinger.h index 24840aee335c..795f4fc0bab1 100644 --- a/fs/bcachefs/eytzinger.h +++ b/fs/bcachefs/eytzinger.h @@ -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, |