public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests net/socket.c: removed warnings from unused returns
@ 2025-08-15  6:06 Alex Tran
  2025-08-19  0:35 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Tran @ 2025-08-15  6:06 UTC (permalink / raw)
  To: davem
  Cc: edumazet, kuba, pabeni, horms, shuah, netdev, linux-kselftest,
	linux-kernel, Alex Tran

socket.c: In function ‘run_tests’:
socket.c:59:25: warning: ignoring return value of ‘strerror_r’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
59 | strerror_r(-s->expect, err_string1, ERR_STRING_SZ);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
socket.c:60:25: warning: ignoring return value of ‘strerror_r’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
60 | strerror_r(errno, err_string2, ERR_STRING_SZ);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
socket.c:73:33: warning: ignoring return value of ‘strerror_r’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
73 | strerror_r(errno, err_string1, ERR_STRING_SZ);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Alex Tran <alex.t.tran@gmail.com>
---
 tools/testing/selftests/net/socket.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/net/socket.c b/tools/testing/selftests/net/socket.c
index db1aeb8c5d1e..7c597c583df3 100644
--- a/tools/testing/selftests/net/socket.c
+++ b/tools/testing/selftests/net/socket.c
@@ -39,6 +39,8 @@ static int run_tests(void)
 {
 	char err_string1[ERR_STRING_SZ];
 	char err_string2[ERR_STRING_SZ];
+	char *err_message1;
+	char *err_message2;
 	int i, err;
 
 	err = 0;
@@ -56,13 +58,13 @@ static int run_tests(void)
 			    errno == -s->expect)
 				continue;
 
-			strerror_r(-s->expect, err_string1, ERR_STRING_SZ);
-			strerror_r(errno, err_string2, ERR_STRING_SZ);
+			err_message1 = strerror_r(-s->expect, err_string1, ERR_STRING_SZ);
+			err_message2 = strerror_r(errno, err_string2, ERR_STRING_SZ);
 
 			fprintf(stderr, "socket(%d, %d, %d) expected "
 				"err (%s) got (%s)\n",
 				s->domain, s->type, s->protocol,
-				err_string1, err_string2);
+				err_message1, err_message2);
 
 			err = -1;
 			break;
@@ -70,12 +72,12 @@ static int run_tests(void)
 			close(fd);
 
 			if (s->expect < 0) {
-				strerror_r(errno, err_string1, ERR_STRING_SZ);
+				err_message1 = strerror_r(errno, err_string1, ERR_STRING_SZ);
 
 				fprintf(stderr, "socket(%d, %d, %d) expected "
 					"success got err (%s)\n",
 					s->domain, s->type, s->protocol,
-					err_string1);
+					err_message1);
 
 				err = -1;
 				break;
-- 
2.34.1


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

end of thread, other threads:[~2025-08-19  2:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-15  6:06 [PATCH] selftests net/socket.c: removed warnings from unused returns Alex Tran
2025-08-19  0:35 ` Jakub Kicinski
2025-08-19  2:27   ` Alex Tran

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox