[PATCH net] selftest: af_unix: Fix kselftest compilation warnings

From: Abhinav Jain
Date: Sat Aug 10 2024 - 09:41:07 EST


Add proper type cast (char *) to the buffer being passed to TH_LOG
macro in __recvpair function.

This change fixes the below warnings during test compilation:

```
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=]

../../kselftest_harness.h:101:17: note: in expansion of macro ‘__TH_LOG’
msg_oob.c:235:17: note: in expansion of macro ‘TH_LOG’

../../kselftest_harness.h:106:40: warning: format ‘%s’ expects argument
of type ‘char *’,but argument 6 has type ‘const void *’ [-Wformat=]

../../kselftest_harness.h:101:17: note: in expansion of macro ‘__TH_LOG’
msg_oob.c:259:25: note: in expansion of macro ‘TH_LOG’
```

Signed-off-by: Abhinav Jain <jain.abhinav177@xxxxxxxxx>
---
tools/testing/selftests/net/af_unix/msg_oob.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/af_unix/msg_oob.c b/tools/testing/selftests/net/af_unix/msg_oob.c
index 16d0c172eaeb..66d76ab38251 100644
--- a/tools/testing/selftests/net/af_unix/msg_oob.c
+++ b/tools/testing/selftests/net/af_unix/msg_oob.c
@@ -232,7 +232,8 @@ static void __recvpair(struct __test_metadata *_metadata,

if (ret[0] != expected_len || recv_errno[0] != expected_errno) {
TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
- TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf);
+ TH_LOG("Expected:%s",
+ expected_errno ? strerror(expected_errno) : (char *)expected_buf);

ASSERT_EQ(ret[0], expected_len);
ASSERT_EQ(recv_errno[0], expected_errno);
@@ -256,7 +257,8 @@ static void __recvpair(struct __test_metadata *_metadata,
cmp = strncmp(expected_buf, recv_buf[0], expected_len);
if (cmp) {
TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
- TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf);
+ TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno)
+ : (char *)expected_buf);

ASSERT_EQ(cmp, 0);
}
--
2.34.1