]> www.infradead.org Git - users/willy/linux.git/commitdiff
selftests/net/socket.c: removed warnings from unused returns
authorAlex Tran <alex.t.tran@gmail.com>
Tue, 19 Aug 2025 02:52:27 +0000 (19:52 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 21 Aug 2025 02:26:21 +0000 (19:26 -0700)
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);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

changelog:
v2
- const char* messages and fixed patch warnings of max 75 chars
  per line

Signed-off-by: Alex Tran <alex.t.tran@gmail.com>
Link: https://patch.msgid.link/20250819025227.239885-1-alex.t.tran@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/socket.c

index db1aeb8c5d1eb4166136ee0b3200e60a3fad7323..be1080003c614a1794078cb3b670e8b5f5fa2285 100644 (file)
@@ -39,6 +39,7 @@ static int run_tests(void)
 {
        char err_string1[ERR_STRING_SZ];
        char err_string2[ERR_STRING_SZ];
+       const char *msg1, *msg2;
        int i, err;
 
        err = 0;
@@ -56,13 +57,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);
+                       msg1 = strerror_r(-s->expect, err_string1, ERR_STRING_SZ);
+                       msg2 = 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);
+                               msg1, msg2);
 
                        err = -1;
                        break;
@@ -70,12 +71,12 @@ static int run_tests(void)
                        close(fd);
 
                        if (s->expect < 0) {
-                               strerror_r(errno, err_string1, ERR_STRING_SZ);
+                               msg1 = 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);
+                                       msg1);
 
                                err = -1;
                                break;