diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2020-11-17 01:16:52 +0300 |
---|---|---|
committer | Chuck Lever <chuck.lever@oracle.com> | 2020-11-30 22:46:38 +0300 |
commit | 8918cc0d2b72db9997390626010b182c4500d749 (patch) | |
tree | c28d7ff1df2dce55ef2e742cd4c390fc7a28ed54 /include/linux/sunrpc | |
parent | 144e82694092ff80b5e64749d6822cd8947587f2 (diff) | |
download | linux-8918cc0d2b72db9997390626010b182c4500d749.tar.xz |
NFSD: Add helper for decoding locker4
Refactor for clarity.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'include/linux/sunrpc')
-rw-r--r-- | include/linux/sunrpc/xdr.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index cc669d95c484..9b35ce50cf2b 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -551,6 +551,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 |