From f38c6b67ed16446c068a1cabe2f2cfbc09d57ebb Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 4 Jan 2022 03:03:20 +0000 Subject: [PATCH] samples: big_http_download: make num_iterations unsigned It is documented as unsigned in samples/net/sockets/big_http_download/Kconfig Signed overflow is undefined behavior, unsigned is not. This fixes the following warning: -Wstrict-overflow=1 samples/net/sockets/big_http_download/src/big_http_download.c:346:2: In function 'main': error: iteration 2147483648 invokes undefined behavior [-Werror=aggressive-loop-optimizations] 346 | } while (--num_iterations != 0); Signed-off-by: Marc Herbert --- samples/net/sockets/big_http_download/src/big_http_download.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/net/sockets/big_http_download/src/big_http_download.c b/samples/net/sockets/big_http_download/src/big_http_download.c index 89d259eb578..2effa272df3 100644 --- a/samples/net/sockets/big_http_download/src/big_http_download.c +++ b/samples/net/sockets/big_http_download/src/big_http_download.c @@ -244,7 +244,7 @@ void main(void) unsigned int total_bytes = 0U; int resolve_attempts = 10; bool is_tls = false; - int num_iterations = CONFIG_SAMPLE_BIG_HTTP_DL_NUM_ITER; + unsigned int num_iterations = CONFIG_SAMPLE_BIG_HTTP_DL_NUM_ITER; #if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS) tls_credential_add(CA_CERTIFICATE_TAG, TLS_CREDENTIAL_CA_CERTIFICATE,