selftests/net: Fix clang warnings on powerpc
Subsystems (4)
cover selftests/net: Fix clang warnings on powerpc
From: Tanner Love <[email protected]>
This is essentially a v2 of http://patchwork.ozlabs.org/project/netdev/patch/[email protected]/, but it has been split up in order to have only one "Fixes" tag per patch.
Tanner Love (4):
selftests/net: rxtimestamp: fix clang issues for target arch PowerPC selftests/net: psock_fanout: fix clang issues for target arch PowerPC selftests/net: so_txtime: fix clang issues for target arch PowerPC selftests/net: tcp_mmap: fix clang warning for target arch PowerPC
tools/testing/selftests/net/psock_fanout.c | 3 ++- tools/testing/selftests/net/rxtimestamp.c | 3 +-- tools/testing/selftests/net/so_txtime.c | 2 +- tools/testing/selftests/net/tcp_mmap.c | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.28.0.rc0.142.g3c755180ce-goog
PATCH 2/4 selftests/net: psock_fanout: fix clang issues for target arch PowerPC
From: Tanner Love <[email protected]>
Clang 9 threw:
warning: format specifies type 'unsigned short' but the argument has \
type 'int' [-Wformat]
typeflags, PORT_BASE, PORT_BASE + port_off);
Tested: make -C tools/testing/selftests TARGETS="net" run_tests
--- tools/testing/selftests/net/psock_fanout.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/net/psock_fanout.c +2 -1
@@ -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 );
Signature · 1 line
2.28.0.rc0.142.g3c755180ce-goog
PATCH 1/4 selftests/net: rxtimestamp: fix clang issues for target arch PowerPC
In reply to Tanner LoveFrom: Tanner Love <[email protected]>
The signedness of char is implementation-dependent. Some systems (including PowerPC and ARM) use unsigned char. Clang 9 threw:
warning: result of comparison of constant -1 with expression of type \
'char' is always true [-Wtautological-constant-out-of-range-compare]
&arg_index)) != -1) {Tested: make -C tools/testing/selftests TARGETS="net" run_tests
--- tools/testing/selftests/net/rxtimestamp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/net/rxtimestamp.c +1 -2
@@ -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 ) {
Signature · 1 line
2.28.0.rc0.142.g3c755180ce-goog
PATCH 3/4 selftests/net: so_txtime: fix clang issues for target arch PowerPC
In reply to Tanner LoveFrom: Tanner Love <[email protected]>
On powerpcle, int64_t maps to long long. Clang 9 threw:
warning: absolute value function 'labs' given an argument of type \
'long long' but has parameter of type 'long' which may cause \
truncation of value [-Wabsolute-value]
if (labs(tstop - texpect) > cfg_variance_us)
Tested: make -C tools/testing/selftests TARGETS="net" run_tests
--- tools/testing/selftests/net/so_txtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/so_txtime.c +1 -1
@@ -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;
Signature · 1 line
2.28.0.rc0.142.g3c755180ce-goog
PATCH 4/4 selftests/net: tcp_mmap: fix clang warning for target arch PowerPC
In reply to Tanner LoveFrom: Tanner Love <[email protected]>
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
--- tools/testing/selftests/net/tcp_mmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/net/tcp_mmap.c +3 -3
@@ -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 ; +uint64_t total =0 ;char *host =NULL ;int fd, c, on =1 ;char *buffer;
@@ -473,12 +473,12 @@ int main(int argc, char *argv[]) zflg =0 ; }while (total <FILE_SZ ) { -ssize_t wr =FILE_SZ - total; +int64_t wr =FILE_SZ - total;if (wr > chunk_size) wr = chunk_size;/* Note : we just want to fill the pipe with 0 bytes */ - wr =send (fd, buffer, wr, zflg ?MSG_ZEROCOPY :0 ); + wr =send (fd, buffer, (size_t )wr, zflg ?MSG_ZEROCOPY :0 );if (wr <=0 )break ; total += wr;
Signature · 1 line
2.28.0.rc0.142.g3c755180ce-goog
Re: [PATCH net 4/4] selftests/net: tcp_mmap: fix clang warning for target arch PowerPC
Quoted 7 lines · Tanner Love
From: Tanner Love <[email protected]>
When
size_tmaps 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]
Quoted 7 lines
while (total < FILE_SZ) {Tested: make -C
tools/testing/selftestsTARGETS="net"run_testsFixes 192dc405f308 ("selftests: net: add tcp_mmap program")Signed-off-by Tanner Love <[email protected]>Acked-by Willem de Bruijn <[email protected]>
Thanks !
David Miller
maintainerFrom: Tanner Love <[email protected]>
Date: Mon, 27 Jul 2020 12:25:27 -0400
Quoted 4 lines
This is essentially a v2 of
http://patchwork.ozlabs.org/project/netdev/patch/[email protected]/,
but it has been split up in order to have only one "Fixes" tag per patch.
Series applied, thank you.