* [PATCH v2 1/1] selftests: net: af_unix: convert param to const char* in __recvpair() to fix warning
@ 2024-08-13 16:20 Mirsad Todorovac
2024-08-13 19:22 ` Kuniyuki Iwashima
0 siblings, 1 reply; 2+ messages in thread
From: Mirsad Todorovac @ 2024-08-13 16:20 UTC (permalink / raw)
To: Paolo Abeni, Kuniyuki Iwashima, netdev, linux-kselftest,
linux-kernel
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Shuah Khan,
Mirsad Todorovac, Simon Horman
GCC 13.2.0 reported warning about (void *) being used as a param where (char *)
is expected:
In file included from msg_oob.c:14:
msg_oob.c: In function ‘__recvpair’:
../../kselftest_harness.h:106:40: warning: format ‘%s’ expects argument of type ‘char *’, \
but argument 6 has type ‘const void *’ [-Wformat=]
106 | fprintf(TH_LOG_STREAM, "# %s:%d:%s:" fmt "\n", \
| ^~~~~~~~~~~~~
../../kselftest_harness.h:101:17: note: in expansion of macro ‘__TH_LOG’
101 | __TH_LOG(fmt, ##__VA_ARGS__); \
| ^~~~~~~~
msg_oob.c:235:17: note: in expansion of macro ‘TH_LOG’
235 | TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf);
| ^~~~~~
../../kselftest_harness.h:106:40: warning: format ‘%s’ expects argument of type ‘char *’, \
but argument 6 has type ‘const void *’ [-Wformat=]
106 | fprintf(TH_LOG_STREAM, "# %s:%d:%s:" fmt "\n", \
| ^~~~~~~~~~~~~
../../kselftest_harness.h:101:17: note: in expansion of macro ‘__TH_LOG’
101 | __TH_LOG(fmt, ##__VA_ARGS__); \
| ^~~~~~~~
msg_oob.c:259:25: note: in expansion of macro ‘TH_LOG’
259 | TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf);
| ^~~~~~
As Simon suggested, all calls to __recvpair() have char * as expected_buf param, so
it is safe to change param type from (const void *) to (const char *), which silences
the warning.
Fixes: d098d77232c37 ("selftest: af_unix: Add msg_oob.c.")
Reported-by: Mirsad Todorovac <mtodorovac69@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>
Cc: netdev@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org
Suggested-by: Simon Horman <horms@kernel.org>
Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>
---
v1 -> v2:
fixed a typo.
change funct param type rather than making two casts, as Simon suggested.
changed Subject: line to reflect the modification.
minor formatting changes.
v1:
initial version to fix the compiler warning.
tools/testing/selftests/net/af_unix/msg_oob.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/af_unix/msg_oob.c b/tools/testing/selftests/net/af_unix/msg_oob.c
index 16d0c172eaeb..535eb2c3d7d1 100644
--- a/tools/testing/selftests/net/af_unix/msg_oob.c
+++ b/tools/testing/selftests/net/af_unix/msg_oob.c
@@ -209,7 +209,7 @@ static void __sendpair(struct __test_metadata *_metadata,
static void __recvpair(struct __test_metadata *_metadata,
FIXTURE_DATA(msg_oob) *self,
- const void *expected_buf, int expected_len,
+ const char *expected_buf, int expected_len,
int buf_len, int flags)
{
int i, ret[2], recv_errno[2], expected_errno = 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 1/1] selftests: net: af_unix: convert param to const char* in __recvpair() to fix warning
2024-08-13 16:20 [PATCH v2 1/1] selftests: net: af_unix: convert param to const char* in __recvpair() to fix warning Mirsad Todorovac
@ 2024-08-13 19:22 ` Kuniyuki Iwashima
0 siblings, 0 replies; 2+ messages in thread
From: Kuniyuki Iwashima @ 2024-08-13 19:22 UTC (permalink / raw)
To: mtodorovac69
Cc: davem, edumazet, horms, kuba, kuniyu, linux-kernel,
linux-kselftest, netdev, pabeni, shuah
From: Mirsad Todorovac <mtodorovac69@gmail.com>
Date: Tue, 13 Aug 2024 18:20:06 +0200
> GCC 13.2.0 reported warning about (void *) being used as a param where (char *)
> is expected:
[...]
> As Simon suggested, all calls to __recvpair() have char * as expected_buf param, so
> it is safe to change param type from (const void *) to (const char *), which silences
> the warning.
>
> Fixes: d098d77232c37 ("selftest: af_unix: Add msg_oob.c.")
> Reported-by: Mirsad Todorovac <mtodorovac69@gmail.com>
Usually Reported-by is not needed if it's same with SOB.
and the same feedback to v1.
Abhinav posted a fix earlier.
https://lore.kernel.org/netdev/20240812191122.1092806-1-jain.abhinav177@gmail.com/
Thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-13 19:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-13 16:20 [PATCH v2 1/1] selftests: net: af_unix: convert param to const char* in __recvpair() to fix warning Mirsad Todorovac
2024-08-13 19:22 ` Kuniyuki Iwashima
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox