Fix to retrieve the return value from the read() function and raise an error if negative.
When building the test with the command `make -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);
Signed-off-by: Alessandro Zanni alessandro.zanni87@gmail.com --- tools/testing/selftests/net/tfo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/tfo.c b/tools/testing/selftests/net/tfo.c index eb3cac5e583c..8fce369e6c37 100644 --- a/tools/testing/selftests/net/tfo.c +++ b/tools/testing/selftests/net/tfo.c @@ -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);
On Fri, 26 Sep 2025 18:15:37 +0200 Alessandro Zanni wrote:
`make -C tools/testing/selftests TARGETS=net` emits 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..
linux-kselftest-mirror@lists.linaro.org