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
>
> 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.
> Fixes: d098d77232c37 ("selftest: af_unix: Add msg_oob.c.")
> Cc: "David S. Miller" <[email protected]>
> Cc: Eric Dumazet <[email protected]>
> Cc: Jakub Kicinski <[email protected]>
> Cc: Paolo Abeni <[email protected]>
> Cc: Shuah Khan <[email protected]>
> Cc: Kuniyuki Iwashima <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Mirsad Todorovac <[email protected]>
...