mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
bcachefs: mean_and_variance: Avoid too-large shift amounts
Shifting a value by the width of its type or more is undefined. Signed-off-by: Tavian Barnes <tavianator@tavianator.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
a97b43fac5
commit
73f88592dd
@ -111,11 +111,11 @@ static inline u128_u u128_shl(u128_u i, s8 shift)
|
||||
{
|
||||
u128_u r;
|
||||
|
||||
r.lo = i.lo << shift;
|
||||
r.lo = i.lo << (shift & 63);
|
||||
if (shift < 64)
|
||||
r.hi = (i.hi << shift) | (i.lo >> (64 - shift));
|
||||
r.hi = (i.hi << (shift & 63)) | (i.lo >> (-shift & 63));
|
||||
else {
|
||||
r.hi = i.lo << (shift - 64);
|
||||
r.hi = i.lo << (-shift & 63);
|
||||
r.lo = 0;
|
||||
}
|
||||
return r;
|
||||
|
Loading…
Reference in New Issue
Block a user