From: Tavian Barnes Date: Fri, 21 Jun 2024 20:39:58 +0000 (-0400) Subject: bcachefs: varint: Avoid left-shift of a negative value X-Git-Url: https://repo.jachan.dev/J-linux.git/commitdiff_plain/ee1b8dc17ac367f3fbea18fee4f7825eb11eb757 bcachefs: varint: Avoid left-shift of a negative value Shifting a negative value left is undefined. Signed-off-by: Tavian Barnes Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/varint.c b/fs/bcachefs/varint.c index cb4f33ed9ab3..a9ebcd82c602 100644 --- a/fs/bcachefs/varint.c +++ b/fs/bcachefs/varint.c @@ -85,7 +85,7 @@ int bch2_varint_encode_fast(u8 *out, u64 v) if (likely(bytes < 9)) { v <<= bytes; - v |= ~(~0 << (bytes - 1)); + v |= ~(~0U << (bytes - 1)); } else { *out++ = 255; bytes = 9;