summaryrefslogtreecommitdiff
path: root/fs/bcachefs/varint.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-07-06 22:47:42 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:10:06 -0400
commit73bd774d28d2b2e6a05c31bf7afb9247e02a8e49 (patch)
tree21ab80d4b966d92647ea178bc5707a8534e5d123 /fs/bcachefs/varint.c
parent236b68da5017b5336b332f941323a5bc450594b3 (diff)
bcachefs: Assorted sparse fixes
- endianness fixes - mark some things static - fix a few __percpu annotations - fix silent enum conversions Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/varint.c')
-rw-r--r--fs/bcachefs/varint.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/bcachefs/varint.c b/fs/bcachefs/varint.c
index 5143b603bf67..ef030fc02448 100644
--- a/fs/bcachefs/varint.c
+++ b/fs/bcachefs/varint.c
@@ -22,12 +22,13 @@ int bch2_varint_encode(u8 *out, u64 v)
{
unsigned bits = fls64(v|1);
unsigned bytes = DIV_ROUND_UP(bits, 7);
+ __le64 v_le;
if (likely(bytes < 9)) {
v <<= bytes;
v |= ~(~0 << (bytes - 1));
- v = cpu_to_le64(v);
- memcpy(out, &v, bytes);
+ v_le = cpu_to_le64(v);
+ memcpy(out, &v_le, bytes);
} else {
*out++ = 255;
bytes = 9;
@@ -57,9 +58,9 @@ int bch2_varint_decode(const u8 *in, const u8 *end, u64 *out)
return -1;
if (likely(bytes < 9)) {
- v = 0;
- memcpy(&v, in, bytes);
- v = le64_to_cpu(v);
+ __le64 v_le = 0;
+ memcpy(&v_le, in, bytes);
+ v = le64_to_cpu(v_le);
v >>= bytes;
} else {
v = get_unaligned_le64(++in);