Re: [PATCH] sunrpc: fix clang-17 warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[ adding Dan Carpenter ]

> On Jun 1, 2023, at 10:33 AM, Dmitry Antipov <dmantipov@xxxxxxxxx> wrote:
> 
> Fix the following warning observed when building 64-bit (actually arm64)
> kernel with clang-17 (make LLVM=1 W=1):
> 
> include/linux/sunrpc/xdr.h:779:10: warning: result of comparison of constant
> 4611686018427387903 with expression of type '__u32' (aka 'unsigned int') is
> always false [-Wtautological-constant-out-of-range-compare]
>  779 |         if (len > SIZE_MAX / sizeof(*p))
> 
> That is, an overflow check makes sense for 32-bit kernel only.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@xxxxxxxxx>
> ---
> include/linux/sunrpc/xdr.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
> index 72014c9216fc..b2d5dc89cf7b 100644
> --- a/include/linux/sunrpc/xdr.h
> +++ b/include/linux/sunrpc/xdr.h
> @@ -776,7 +776,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 (unlikely(SIZE_MAX == U32_MAX ? (len > U32_MAX / sizeof(*p)) : 0))
> return -EBADMSG;
> p = xdr_inline_decode(xdr, len * sizeof(*p));
> if (unlikely(!p))
> -- 
> 2.40.1
> 

--
Chuck Lever






[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux