summaryrefslogtreecommitdiff
path: root/fs/bcachefs/varint.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/varint.c')
-rw-r--r--fs/bcachefs/varint.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/bcachefs/varint.c b/fs/bcachefs/varint.c
index cb4f33ed9ab3..6620ecae26af 100644
--- a/fs/bcachefs/varint.c
+++ b/fs/bcachefs/varint.c
@@ -3,12 +3,13 @@
#include <linux/bitops.h>
#include <linux/math.h>
#include <linux/string.h>
-#include <asm/unaligned.h>
+#include <linux/unaligned.h>
#ifdef CONFIG_VALGRIND
#include <valgrind/memcheck.h>
#endif
+#include "errcode.h"
#include "varint.h"
/**
@@ -53,7 +54,7 @@ int bch2_varint_decode(const u8 *in, const u8 *end, u64 *out)
u64 v;
if (unlikely(in + bytes > end))
- return -1;
+ return -BCH_ERR_varint_decode_error;
if (likely(bytes < 9)) {
__le64 v_le = 0;
@@ -85,7 +86,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;
@@ -115,7 +116,7 @@ int bch2_varint_decode_fast(const u8 *in, const u8 *end, u64 *out)
unsigned bytes = ffz(*in) + 1;
if (unlikely(in + bytes > end))
- return -1;
+ return -BCH_ERR_varint_decode_error;
if (likely(bytes < 9)) {
v >>= bytes;