Commit ee1b8dc1 authored by Tavian Barnes's avatar Tavian Barnes Committed by Kent Overstreet

bcachefs: varint: Avoid left-shift of a negative value

Shifting a negative value left is undefined.
Signed-off-by: default avatarTavian Barnes <tavianator@tavianator.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 2e118ba3
...@@ -85,7 +85,7 @@ int bch2_varint_encode_fast(u8 *out, u64 v) ...@@ -85,7 +85,7 @@ int bch2_varint_encode_fast(u8 *out, u64 v)
if (likely(bytes < 9)) { if (likely(bytes < 9)) {
v <<= bytes; v <<= bytes;
v |= ~(~0 << (bytes - 1)); v |= ~(~0U << (bytes - 1));
} else { } else {
*out++ = 255; *out++ = 255;
bytes = 9; bytes = 9;
......
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