selftests/net: fix clang issues for target arch PowerPC and others
Subsystems (4)
PATCH 1/1 selftests/net: fix clang issues for target arch PowerPC and others
From: Tanner Love <[email protected]>
Address these warnings observed with clang 9.
rxtimestamp:
The signedness of char is implementation-dependent. Some systems (including PowerPC and ARM) use unsigned char.
Compilation yielded:
warning: result of comparison of constant -1 with expression of type \
'char' is always true [-Wtautological-constant-out-of-range-compare]
&arg_index)) != -1) {psock_fanout:
Compilation yielded warnings like:
warning: format specifies type 'unsigned short' but the argument has \
type 'int' [-Wformat]
typeflags, PORT_BASE, PORT_BASE + port_off);
so_txtime:
On powerpcle, int64_t maps to long long.
Compilation yielded:
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)
tcp_mmap:
Compilation yielded:
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/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 | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
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 );
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 ) {
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;
tools/testing/selftests/net/tcp_mmap.c +1 -1
@@ -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;
Signature · 1 line
2.28.0.rc0.142.g3c755180ce-goog
Quoted 9 lines · Tanner Love
From: Tanner Love <[email protected]>
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 ?
Quoted 14 lines
[-Wtautological-constant-out-of-range-compare]
while (total < FILE_SZ) {Tested: make -C
tools/testing/selftestsTARGETS="net"run_teststools/testing/selftests/net/tcp_mmap.c +0
-0
tools/testing/selftests/net/tcp_mmap.c int main(int argc, char *argv[]) · line 350
Quoted 8 lines
tools/testing/selftests/net/tcp_mmap.c +1
-1@@ -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