summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2020-11-17 01:16:52 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-06-21 15:52:37 +0300
commitd27f2dcedae2ab3afe6a82f0f449abbe081c4d01 (patch)
treed7e4033607775c3f6affddbaec3330ba6a6bd63f /include
parent0c281b7083f23ad0c5612f9dc6110388dadadf0e (diff)
downloadlinux-d27f2dcedae2ab3afe6a82f0f449abbe081c4d01.tar.xz
NFSD: Add helper for decoding locker4
[ Upstream commit 8918cc0d2b72db9997390626010b182c4500d749 ] Refactor for clarity. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/sunrpc/xdr.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 6b1757543747..f6569b620bea 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -549,6 +549,27 @@ static inline bool xdr_item_is_present(const __be32 *p)
}
/**
+ * xdr_stream_decode_bool - Decode a boolean
+ * @xdr: pointer to xdr_stream
+ * @ptr: pointer to a u32 in which to store the result
+ *
+ * Return values:
+ * %0 on success
+ * %-EBADMSG on XDR buffer overflow
+ */
+static inline ssize_t
+xdr_stream_decode_bool(struct xdr_stream *xdr, __u32 *ptr)
+{
+ const size_t count = sizeof(*ptr);
+ __be32 *p = xdr_inline_decode(xdr, count);
+
+ if (unlikely(!p))
+ return -EBADMSG;
+ *ptr = (*p != xdr_zero);
+ return 0;
+}
+
+/**
* xdr_stream_decode_u32 - Decode a 32-bit integer
* @xdr: pointer to xdr_stream
* @ptr: location to store integer