[PATCH 3/3] net: wget: Fix comparison of unsigned variable

Jerome Forissier jerome.forissier at linaro.org
Wed Jul 9 15:20:11 CEST 2025



On 7/8/25 18:51, Andrew Goodbody wrote:
> content_length is an unsigned long and so testing that it is >= 0 will
> always be true. Instead test that it is != -1 as that is the condition
> set on error.
> 
> This issue found by Smatch.
> 
> Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
> ---
>  net/wget.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/wget.c b/net/wget.c
> index 3c0fff488eb..428ee072330 100644
> --- a/net/wget.c
> +++ b/net/wget.c
> @@ -214,7 +214,7 @@ static void tcp_stream_on_rcv_nxt_update(struct tcp_stream *tcp, u32 rx_bytes)
>  			content_length = -1;
>  	}
>  
> -	if (content_length >= 0) {
> +	if (content_length != -1) {
>  		debug_cond(DEBUG_WGET,
>  			   "wget: Connected Len %lu\n",
>  			   content_length);
> 

Reviewed-by: Jerome Forissier <jerome.forissier at linaro.org>

Thanks,
-- 
Jerome


More information about the U-Boot mailing list