]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
bcachefs: varint: Avoid left-shift of a negative value
authorTavian Barnes <tavianator@tavianator.com>
Fri, 21 Jun 2024 20:39:58 +0000 (16:39 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 18 Jul 2024 22:33:30 +0000 (18:33 -0400)
Shifting a negative value left is undefined.

Signed-off-by: Tavian Barnes <tavianator@tavianator.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/varint.c

index cb4f33ed9ab374fbd50bbf74419335564f55df9a..a9ebcd82c60254080c077d7fc4b907fb6634a424 100644 (file)
@@ -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;