]> Git Repo - J-linux.git/commitdiff
bcachefs: varint: Avoid left-shift of a negative value
authorTavian Barnes <[email protected]>
Fri, 21 Jun 2024 20:39:58 +0000 (16:39 -0400)
committerKent Overstreet <[email protected]>
Thu, 18 Jul 2024 22:33:30 +0000 (18:33 -0400)
Shifting a negative value left is undefined.

Signed-off-by: Tavian Barnes <[email protected]>
Signed-off-by: Kent Overstreet <[email protected]>
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;
This page took 0.050344 seconds and 4 git commands to generate.