]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: wget: Fix comparison of unsigned variable
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Tue, 8 Jul 2025 16:51:18 +0000 (17:51 +0100)
committerJerome Forissier <jerome.forissier@linaro.org>
Fri, 1 Aug 2025 07:30:47 +0000 (09:30 +0200)
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@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
net/wget.c

index 3c0fff488ebaa4fab6ea79aa63db011a9dc9f976..428ee072330bf94db4d2fee71f272305e43ac42d 100644 (file)
@@ -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);