mirror of https://github.com/torvalds/linux.git
sunrpc: Change ret code of xdr_stream_decode_opaque_fixed
Since the opaque is fixed in size, the caller already knows how many bytes were decoded, on success. Thus, xdr_stream_decode_opaque_fixed() doesn't need to return that value. And, xdr_stream_decode_u32 and _u64 both return zero on success. This patch simplifies the caller's error checking to avoid potential integer promotion issues. Suggested-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Sergey Bashirov <sergeybashirov@gmail.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
parent
2ee3a75e42
commit
c97b737ef8
|
|
@ -721,7 +721,7 @@ xdr_stream_decode_u64(struct xdr_stream *xdr, __u64 *ptr)
|
||||||
* @len: size of buffer pointed to by @ptr
|
* @len: size of buffer pointed to by @ptr
|
||||||
*
|
*
|
||||||
* Return values:
|
* Return values:
|
||||||
* On success, returns size of object stored in @ptr
|
* %0 on success
|
||||||
* %-EBADMSG on XDR buffer overflow
|
* %-EBADMSG on XDR buffer overflow
|
||||||
*/
|
*/
|
||||||
static inline ssize_t
|
static inline ssize_t
|
||||||
|
|
@ -732,7 +732,7 @@ xdr_stream_decode_opaque_fixed(struct xdr_stream *xdr, void *ptr, size_t len)
|
||||||
if (unlikely(!p))
|
if (unlikely(!p))
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
xdr_decode_opaque_fixed(p, ptr, len);
|
xdr_decode_opaque_fixed(p, ptr, len);
|
||||||
return len;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,5 @@ xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ classifier }}{{ name }} *ptr
|
||||||
{% if annotate %}
|
{% if annotate %}
|
||||||
/* (fixed-length opaque) */
|
/* (fixed-length opaque) */
|
||||||
{% endif %}
|
{% endif %}
|
||||||
return xdr_stream_decode_opaque_fixed(xdr, ptr, {{ size }}) >= 0;
|
return xdr_stream_decode_opaque_fixed(xdr, ptr, {{ size }}) == 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue