Re: [PATCH] remoteproc: use SIZE_MAX in rproc_u64_fit_in_size_t()

From: Mathieu Poirier

Date: Tue Mar 24 2026 - 12:49:22 EST


On Sat, Mar 14, 2026 at 11:01:37AM +0000, Anas Iqbal wrote:
> Smatch reports:
>
> drivers/remoteproc/remoteproc_elf_loader.c:221
> warn: always true condition '(val <= -1)'
>
> The helper function rproc_u64_fit_in_size_t() compares the value
> against (size_t)-1, which is equivalent to SIZE_MAX but can confuse
> static analysis tools and lead to the above warning.
>
> Replace (size_t)-1 with SIZE_MAX to make the intent explicit and
> avoid the Smatch warning without changing the behavior.
>
> Signed-off-by: Anas Iqbal <mohd.abd.6602@xxxxxxxxx>
> ---
> drivers/remoteproc/remoteproc_internal.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
> index 0cd09e67ac14..0a5e15744b1d 100644
> --- a/drivers/remoteproc/remoteproc_internal.h
> +++ b/drivers/remoteproc/remoteproc_internal.h
> @@ -218,7 +218,7 @@ bool rproc_u64_fit_in_size_t(u64 val)
> if (sizeof(size_t) == sizeof(u64))
> return true;
>
> - return (val <= (size_t) -1);
> + return val <= SIZE_MAX;

Applied.

Thanks,
Mathieu

> }
>
> #endif /* REMOTEPROC_INTERNAL_H */
> --
> 2.43.0
>