uclient-http: fix extra compiler warnings on mips_24kc and cortex-a9+neon
authorPetr Štetiar <ynezz@true.cz>
Tue, 8 Dec 2020 17:13:03 +0000 (18:13 +0100)
committerPetr Štetiar <ynezz@true.cz>
Fri, 11 Dec 2020 10:17:22 +0000 (11:17 +0100)
Fixes following warnings as reported on 32-bit platforms
toolchain-mips_24kc_gcc-8.4.0_musl and toolchain-arm_cortex-a9+neon_gcc-8.4.0_musl_eabi:

 uclient-http.c:1111:10: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
   if (len > data_end - data)
           ^
 uclient-http.c:1115:11: error: comparison of integer expressions of different signedness: 'unsigned int' and 'long int' [-Werror=sign-compare]
    if (len > uh->read_chunked)
            ^
 uclient-http.c:1120:11: error: comparison of integer expressions of different signedness: 'unsigned int' and 'long int' [-Werror=sign-compare]
    if (len > uh->content_length)
            ^

References: https://gitlab.com/ynezz/openwrt-uclient/-/pipelines/226912126
Signed-off-by: Petr Štetiar <ynezz@true.cz>
uclient-http.c

index 7eb469221d7fdc5ae4cb80578aa1dabf0d8fee67..349e69cdd4aeb7a13859d0db71f5f277d3b7e580 100644 (file)
@@ -1108,16 +1108,17 @@ uclient_http_read(struct uclient *cl, char *buf, unsigned int len)
                }
        }
 
-       if (len > data_end - data)
-               len = data_end - data;
+       unsigned int diff = data_end - data;
+       if (len > diff)
+               len = diff;
 
        if (uh->read_chunked >= 0) {
-               if (len > uh->read_chunked)
+               if (len > (unsigned long) uh->read_chunked)
                        len = uh->read_chunked;
 
                uh->read_chunked -= len;
        } else if (uh->content_length >= 0) {
-               if (len > uh->content_length)
+               if (len > (unsigned long) uh->content_length)
                        len = uh->content_length;
 
                uh->content_length -= len;