netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftest: net: Check return value from read
@ 2025-09-26 16:15 Alessandro Zanni
  2025-09-29 19:14 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Alessandro Zanni @ 2025-09-26 16:15 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, horms, shuah
  Cc: Alessandro Zanni, netdev, linux-kselftest, linux-kernel

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);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] selftest: net: Check return value from read
  2025-09-26 16:15 [PATCH] selftest: net: Check return value from read Alessandro Zanni
@ 2025-09-29 19:14 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2025-09-29 19:14 UTC (permalink / raw)
  To: Alessandro Zanni
  Cc: davem, edumazet, pabeni, horms, shuah, netdev, linux-kselftest,
	linux-kernel

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..
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-29 19:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-26 16:15 [PATCH] selftest: net: Check return value from read Alessandro Zanni
2025-09-29 19:14 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).