Re: [PATCH net-next v2 2/2] selftests: net: improve error handling in passive TFO test
From: Yohei Kojima <hidden>
Date: 2026-01-13 15:57:42
Also in:
linux-kselftest, lkml
From: Yohei Kojima <hidden>
Date: 2026-01-13 15:57:42
Also in:
linux-kselftest, lkml
On Tue, Jan 13, 2026 at 03:48:11PM +0100, Markus Elfring wrote:
…quoted
+++ b/tools/testing/selftests/net/tfo.c@@ -82,8 +82,10 @@ static void run_server(void)…quoted
if (read(connfd, buf, 64) < 0) - perror("read()"); - fprintf(outfile, "%d\n", opt); + error(1, errno, "read()"); + + if (fprintf(outfile, "%d\n", opt) < 0) + error(1, errno, "fprintf()"); fclose(outfile); close(connfd);… Why was error detection omitted for close() calls here so far?
Because I believe that checking the return value of fclose() would not provide additional value in this test case, which is focused on testing the behavior of passive TFO. I understand that fclose() could fail there, but considering the trade-off between test reliability and code complexity (which increases review and maintenance costs), I think checking the return value there does not provide benefits to justify the added complexity. In fact, as far as I can see, none of the existing tests in selftests/net check the fclose() return value. Thank you, Yohei
https://pubs.opengroup.org/onlinepubs/9799919799/functions/fclose.html Regards, Markus