Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Mirsad Todorovac <mtodorovac69@gmail.com>
To: Simon Horman <horms@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Shuah Khan <shuah@kernel.org>
Subject: Re: [PATCH v1 1/1] selftests: net: af_unix: cast void* to char* in call to macro TH_LOG()
Date: Tue, 13 Aug 2024 17:36:41 +0200	[thread overview]
Message-ID: <391af1fe-53ff-4678-a78c-74262724c2e9@gmail.com> (raw)
In-Reply-To: <20240812151725.GB21855@kernel.org>

Hi, Simon,

On 8/12/24 17:17, Simon Horman wrote:
> On Mon, Aug 12, 2024 at 02:22:58AM +0200, Mirsad Todorovac wrote:
>> GCC 13.2.0 reported warning about (void *) beeing used as a param where (char *) is expected:
> 
> nit: being

Ouch! No patch is small enough that one should take its correctness for granted. :-O

>> 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);
>>       |                 ^~~~~~
> 
> Thanks, I see this too.
> 
>> Casting param to (char *) silences the warning.
> 
> It seems that all callers pass a string as the expected_errno argument.
> Perhaps it's type could be updated to char *, if that is what it is.
> I think this would avoid the need to cast.

Agreed and verified. If it is OK with you, I might post a v2.

Best regards,
Mirsad Todorovac

>> Fixes: d098d77232c37 ("selftest: af_unix: Add msg_oob.c.")
>> 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
>> Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>
> 
> ...

  reply	other threads:[~2024-08-13 15:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-12  0:22 [PATCH v1 1/1] selftests: net: af_unix: cast void* to char* in call to macro TH_LOG() Mirsad Todorovac
2024-08-12 15:17 ` Simon Horman
2024-08-13 15:36   ` Mirsad Todorovac [this message]
2024-08-12 18:45 ` Kuniyuki Iwashima

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=391af1fe-53ff-4678-a78c-74262724c2e9@gmail.com \
    --to=mtodorovac69@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --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 \
    /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