Message ID | 20200724181757.2331172-1-tannerlove.kernel@gmail.com |
---|---|
State | Changes Requested |
Delegated to: | David Miller |
Headers | show |
Series | [net] selftests/net: fix clang issues for target arch PowerPC and others | expand |
On 7/24/20 11:17 AM, Tanner Love wrote: > From: Tanner Love <tannerlove@google.com> > > Address these warnings observed with clang 9. > > > tcp_mmap: > Compilation yielded: > warning: result of comparison of constant 34359738368 with \ > expression of type 'size_t' (aka 'unsigned int') is always true \ size_t is not generally 'unsigned int', not sure how you get this ? > [-Wtautological-constant-out-of-range-compare] > while (total < FILE_SZ) { > > Tested: make -C tools/testing/selftests TARGETS="net" run_tests > > > diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c > index 4555f88252ba..92086d65bd87 100644 > --- a/tools/testing/selftests/net/tcp_mmap.c > +++ b/tools/testing/selftests/net/tcp_mmap.c > @@ -344,7 +344,7 @@ int main(int argc, char *argv[]) > { > struct sockaddr_storage listenaddr, addr; > unsigned int max_pacing_rate = 0; > - size_t total = 0; > + unsigned long total = 0; > char *host = NULL; > int fd, c, on = 1; > char *buffer; > This will break on 32bit arches, where sizeof(unsigned long) == 4
diff --git a/tools/testing/selftests/net/psock_fanout.c b/tools/testing/selftests/net/psock_fanout.c index 8c8c7d79c38d..2c522f7a0aec 100644 --- a/tools/testing/selftests/net/psock_fanout.c +++ b/tools/testing/selftests/net/psock_fanout.c @@ -350,7 +350,8 @@ static int test_datapath(uint16_t typeflags, int port_off, int fds[2], fds_udp[2][2], ret; fprintf(stderr, "\ntest: datapath 0x%hx ports %hu,%hu\n", - typeflags, PORT_BASE, PORT_BASE + port_off); + typeflags, (uint16_t)PORT_BASE, + (uint16_t)(PORT_BASE + port_off)); fds[0] = sock_fanout_open(typeflags, 0); fds[1] = sock_fanout_open(typeflags, 0); diff --git a/tools/testing/selftests/net/rxtimestamp.c b/tools/testing/selftests/net/rxtimestamp.c index 422e7761254d..bcb79ba1f214 100644 --- a/tools/testing/selftests/net/rxtimestamp.c +++ b/tools/testing/selftests/net/rxtimestamp.c @@ -329,8 +329,7 @@ int main(int argc, char **argv) bool all_tests = true; int arg_index = 0; int failures = 0; - int s, t; - char opt; + int s, t, opt; while ((opt = getopt_long(argc, argv, "", long_options, &arg_index)) != -1) { diff --git a/tools/testing/selftests/net/so_txtime.c b/tools/testing/selftests/net/so_txtime.c index ceaad78e9667..3155fbbf644b 100644 --- a/tools/testing/selftests/net/so_txtime.c +++ b/tools/testing/selftests/net/so_txtime.c @@ -121,7 +121,7 @@ static bool do_recv_one(int fdr, struct timed_send *ts) if (rbuf[0] != ts->data) error(1, 0, "payload mismatch. expected %c", ts->data); - if (labs(tstop - texpect) > cfg_variance_us) + if (llabs(tstop - texpect) > cfg_variance_us) error(1, 0, "exceeds variance (%d us)", cfg_variance_us); return false; diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c index 4555f88252ba..92086d65bd87 100644 --- a/tools/testing/selftests/net/tcp_mmap.c +++ b/tools/testing/selftests/net/tcp_mmap.c @@ -344,7 +344,7 @@ int main(int argc, char *argv[]) { struct sockaddr_storage listenaddr, addr; unsigned int max_pacing_rate = 0; - size_t total = 0; + unsigned long total = 0; char *host = NULL; int fd, c, on = 1; char *buffer;