[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250926161538.57896-1-alessandro.zanni87@gmail.com>
Date: Fri, 26 Sep 2025 18:15:37 +0200
From: Alessandro Zanni <alessandro.zanni87@...il.com>
To: davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
horms@...nel.org,
shuah@...nel.org
Cc: Alessandro Zanni <alessandro.zanni87@...il.com>,
netdev@...r.kernel.org,
linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] 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 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@...il.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);
--
2.43.0
Powered by blists - more mailing lists