SUNRPC: Add xdr_pad_size() helper
Introduce a helper function to compute the XDR pad size of a variable-length XDR object. Clean up: Replace open-coded calculation of XDR pad sizes. I'm sure I haven't found every instance of this calculation. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
@@ -300,6 +300,21 @@ xdr_align_size(size_t n)
|
||||
return (n + mask) & ~mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* xdr_pad_size - Calculate size of an object's pad
|
||||
* @n: Size of an object being XDR encoded (in bytes)
|
||||
*
|
||||
* This implementation avoids the need for conditional
|
||||
* branches or modulo division.
|
||||
*
|
||||
* Return value:
|
||||
* Size (in bytes) of the needed XDR pad
|
||||
*/
|
||||
static inline size_t xdr_pad_size(size_t n)
|
||||
{
|
||||
return xdr_align_size(n) - n;
|
||||
}
|
||||
|
||||
/**
|
||||
* xdr_stream_encode_u32 - Encode a 32-bit integer
|
||||
* @xdr: pointer to xdr_stream
|
||||
|
Reference in New Issue
Block a user