Skip to content

Commit c97b737

Browse files
sbashirochucklever
authored andcommitted
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>
1 parent 2ee3a75 commit c97b737

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

include/linux/sunrpc/xdr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ xdr_stream_decode_u64(struct xdr_stream *xdr, __u64 *ptr)
721721
* @len: size of buffer pointed to by @ptr
722722
*
723723
* Return values:
724-
* On success, returns size of object stored in @ptr
724+
* %0 on success
725725
* %-EBADMSG on XDR buffer overflow
726726
*/
727727
static inline ssize_t
@@ -732,7 +732,7 @@ xdr_stream_decode_opaque_fixed(struct xdr_stream *xdr, void *ptr, size_t len)
732732
if (unlikely(!p))
733733
return -EBADMSG;
734734
xdr_decode_opaque_fixed(p, ptr, len);
735-
return len;
735+
return 0;
736736
}
737737

738738
/**

tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_opaque.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ classifier }}{{ name }} *ptr
1313
{% if annotate %}
1414
/* (fixed-length opaque) */
1515
{% endif %}
16-
return xdr_stream_decode_opaque_fixed(xdr, ptr, {{ size }}) >= 0;
16+
return xdr_stream_decode_opaque_fixed(xdr, ptr, {{ size }}) == 0;
1717
};

0 commit comments

Comments
 (0)