Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/net: tcp_mmap: fix clang warning for target arch PowerPC

When size_t maps to unsigned int (e.g. on 32-bit powerpc), then the
comparison with 1<<35 is always true. Clang 9 threw:
warning: result of comparison of constant 34359738368 with \
expression of type 'size_t' (aka 'unsigned int') is always true \
[-Wtautological-constant-out-of-range-compare]
while (total < FILE_SZ) {

Tested: make -C tools/testing/selftests TARGETS="net" run_tests

Fixes: 192dc405f308 ("selftests: net: add tcp_mmap program")
Signed-off-by: Tanner Love <tannerlove@google.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Tanner Love and committed by
David S. Miller
94b6c13b b4da96ff

+3 -3
+3 -3
tools/testing/selftests/net/tcp_mmap.c
··· 344 344 { 345 345 struct sockaddr_storage listenaddr, addr; 346 346 unsigned int max_pacing_rate = 0; 347 - size_t total = 0; 347 + uint64_t total = 0; 348 348 char *host = NULL; 349 349 int fd, c, on = 1; 350 350 char *buffer; ··· 473 473 zflg = 0; 474 474 } 475 475 while (total < FILE_SZ) { 476 - ssize_t wr = FILE_SZ - total; 476 + int64_t wr = FILE_SZ - total; 477 477 478 478 if (wr > chunk_size) 479 479 wr = chunk_size; 480 480 /* Note : we just want to fill the pipe with 0 bytes */ 481 - wr = send(fd, buffer, wr, zflg ? MSG_ZEROCOPY : 0); 481 + wr = send(fd, buffer, (size_t)wr, zflg ? MSG_ZEROCOPY : 0); 482 482 if (wr <= 0) 483 483 break; 484 484 total += wr;