Skip to content

Commit

Permalink
bcachefs: varint: Avoid left-shift of a negative value
Browse files Browse the repository at this point in the history
Shifting a negative value left is undefined.

Signed-off-by: Tavian Barnes <[email protected]>
Signed-off-by: Kent Overstreet <[email protected]>
  • Loading branch information
tavianator authored and Kent Overstreet committed Jul 18, 2024
1 parent 2e118ba commit ee1b8dc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/bcachefs/varint.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ee1b8dc

Please sign in to comment.