Skip to content

Commit 7442b5c

Browse files
author
Kent Overstreet
committed
bcachefs: Don't rely on implicit unsigned -> signed integer conversion
implicit integer conversion is a fertile source of bugs, and we really would rather not have the min()/max() macros doing it implicitly. bcachefs appears to be the only place in the kernel where this happens, so let's fix it. Signed-off-by: Kent Overstreet <[email protected]>
1 parent ff9bf4b commit 7442b5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/bcachefs/alloc_background.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ static inline u64 alloc_lru_idx_fragmentation(struct bch_alloc_v4 a,
166166
* avoid overflowing LRU_TIME_BITS on a corrupted fs, when
167167
* bucket_sectors_dirty is (much) bigger than bucket_size
168168
*/
169-
u64 d = min(bch2_bucket_sectors_dirty(a),
170-
ca->mi.bucket_size);
169+
u64 d = min_t(s64, bch2_bucket_sectors_dirty(a),
170+
ca->mi.bucket_size);
171171

172172
return div_u64(d * (1ULL << 31), ca->mi.bucket_size);
173173
}

0 commit comments

Comments
 (0)