diff mbox series

SUNRPC: Silence compiler complaints about tautological comparisons

Message ID 20230913201233.126405-1-trondmy@kernel.org (mailing list archive)
State New, archived
Headers show
Series SUNRPC: Silence compiler complaints about tautological comparisons | expand

Commit Message

Trond Myklebust Sept. 13, 2023, 8:12 p.m. UTC
From: Trond Myklebust <trond.myklebust@hammerspace.com>

On 64-bit systems, the compiler will complain that the comparison
between SIZE_MAX and the 32-bit unsigned int 'len' is unnecessary.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 This still checks for whether or not there is an overflow, and
 returns an error message if that is the case.

 include/linux/sunrpc/xdr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index f89ec4b5ea16..915b2e7fa38d 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -775,7 +775,7 @@  xdr_stream_decode_uint32_array(struct xdr_stream *xdr,
 
 	if (unlikely(xdr_stream_decode_u32(xdr, &len) < 0))
 		return -EBADMSG;
-	if (len > SIZE_MAX / sizeof(*p))
+	if (U32_MAX >= SIZE_MAX / sizeof(*p) && len > SIZE_MAX / sizeof(*p))
 		return -EBADMSG;
 	p = xdr_inline_decode(xdr, len * sizeof(*p));
 	if (unlikely(!p))