Skip to content

Commit 94b6c13

Browse files
tannerlovedavem330
authored andcommitted
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: 192dc40 ("selftests: net: add tcp_mmap program") Signed-off-by: Tanner Love <[email protected]> Acked-by: Willem de Bruijn <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b4da96f commit 94b6c13

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/testing/selftests/net/tcp_mmap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ int main(int argc, char *argv[])
344344
{
345345
struct sockaddr_storage listenaddr, addr;
346346
unsigned int max_pacing_rate = 0;
347-
size_t total = 0;
347+
uint64_t total = 0;
348348
char *host = NULL;
349349
int fd, c, on = 1;
350350
char *buffer;
@@ -473,12 +473,12 @@ int main(int argc, char *argv[])
473473
zflg = 0;
474474
}
475475
while (total < FILE_SZ) {
476-
ssize_t wr = FILE_SZ - total;
476+
int64_t wr = FILE_SZ - total;
477477

478478
if (wr > chunk_size)
479479
wr = chunk_size;
480480
/* 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);
482482
if (wr <= 0)
483483
break;
484484
total += wr;

0 commit comments

Comments
 (0)