selftest: net: Check return value from read
Subsystems (3)
PATCH 1/1 selftest: net: Check return value from read
Fix to retrieve the return value from the read() function and raise an error if negative.
When building the test with the commandmake -C tools/testing/selftests TARGETS=net emits the following warning:
tfo.c: In function ‘run_server’:
tfo.c:84:9: warning: ignoring return value of ‘read’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
84 | read(connfd, buf, 64);
--- tools/testing/selftests/net/tfo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/selftests/net/tfo.c +4 -1
@@ -50,6 +50,7 @@ static void run_server(void)socklen_t len;char buf[64 ];FILE *outfile; +int ret; outfile =fopen (cfg_outfile,"w" );if (!outfile)
@@ -81,7 +82,9 @@ static void run_server(void)if (getsockopt (connfd,SOL_SOCKET ,SO_INCOMING_NAPI_ID , &opt, &len) <0 )error (1 , errno,"getsockopt(SO_INCOMING_NAPI_ID)" ); -read (connfd, buf,64 ); + ret =read (connfd, buf,64 ); +if (ret <0 ) +error (1 , errno,"read()" );fprintf (outfile,"%d\n" , opt);fclose (outfile);
Signature · 1 line
2.43.0
Jakub Kicinski
maintainerQuoted 2 lines · On Fri, 26 Sep 2025 18:15:37 +0200 Alessandro Zanni wrote:
make -C tools/testing/selftests TARGETS=netemits the
[...] ‘warn_unused_result’ [-Wunused-result]
Sorry if I already said this but it does not repro, for me.
Please clearly explain to us how this can be reproduced so we can make our CI catch any future occurrences. Getting follow up fixes for this sort of non-issues after patches are merged is not a great use of reviewer bandwidth, so we should really catch this in CI..
Signature · 1 line
pw-bot: cr