SUNRPC: Add helpers for decoding list discriminators symbolically

Use these helpers in a few spots to demonstrate their use.

The remaining open-coded discriminator checks in rpcrdma will be
addressed in subsequent patches.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
Chuck Lever
2020-03-28 13:43:22 -04:00
parent 0b8dc1b699
commit 07e9a6325a
3 changed files with 40 additions and 15 deletions

View File

@@ -474,6 +474,32 @@ xdr_stream_encode_uint32_array(struct xdr_stream *xdr,
return ret;
}
/**
* xdr_item_is_absent - symbolically handle XDR discriminators
* @p: pointer to undecoded discriminator
*
* Return values:
* %true if the following XDR item is absent
* %false if the following XDR item is present
*/
static inline bool xdr_item_is_absent(const __be32 *p)
{
return *p == xdr_zero;
}
/**
* xdr_item_is_present - symbolically handle XDR discriminators
* @p: pointer to undecoded discriminator
*
* Return values:
* %true if the following XDR item is present
* %false if the following XDR item is absent
*/
static inline bool xdr_item_is_present(const __be32 *p)
{
return *p != xdr_zero;
}
/**
* xdr_stream_decode_u32 - Decode a 32-bit integer
* @xdr: pointer to xdr_stream