The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <jain.abhinav177@gmail.com>
Cc: <davem@davemloft.net>, <edumazet@google.com>,
	<javier.carrasco.cruz@gmail.com>, <kuba@kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
	<netdev@vger.kernel.org>, <pabeni@redhat.com>, <shuah@kernel.org>,
	<skhan@linuxfoundation.org>, <kuniyu@amazon.com>
Subject: Re: [PATCH net] selftest: af_unix: Fix kselftest compilation warnings
Date: Mon, 12 Aug 2024 11:39:44 -0700	[thread overview]
Message-ID: <20240812183944.59844-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20240810134037.669765-1-jain.abhinav177@gmail.com>

From: Abhinav Jain <jain.abhinav177@gmail.com>
Date: Sat, 10 Aug 2024 19:10:37 +0530
> 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’
> ```
>

Fixes: tag is needed here (no space between SOB tag)

> Signed-off-by: Abhinav Jain <jain.abhinav177@gmail.com>
> ---
>  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);

I don't remember why I defined expected_buf as (void *), but more simple
fix would be the following ?

---8<---
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;
---8<---

Thanks!

  reply	other threads:[~2024-08-12 18:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-10 13:40 [PATCH net] selftest: af_unix: Fix kselftest compilation warnings Abhinav Jain
2024-08-12 18:39 ` Kuniyuki Iwashima [this message]
2024-08-12 19:15   ` Abhinav Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240812183944.59844-1-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jain.abhinav177@gmail.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox