* [PATCH] selftests: kselftest: Fix debug message formatting
@ 2026-09-16 19:04 ZhuangZhuang Wang
2026-09-22 20:06 ` André Almeida
0 siblings, 1 reply; 3+ messages in thread
From: ZhuangZhuang Wang @ 2026-09-16 19:04 UTC (permalink / raw)
To: Shuah Khan
Cc: Thomas Gleixner, André Almeida, linux-kselftest,
linux-kernel, ZhuangZhuang Wang
ksft_print_dbg_msg() passes a va_list to ksft_print_msg() as a regular
variadic argument. As a result, format specifiers consume the va_list
representation instead of the caller's arguments and print garbage.
Add a va_list-based helper and use it from both message printing
functions. Also annotate ksft_print_dbg_msg() so the compiler can check
its format arguments.
Fixes: f2662ec26b26 ("selftests: kselftest: Create ksft_print_dbg_msg()")
Signed-off-by: ZhuangZhuang Wang <wzz_123123@163.com>
---
tools/testing/selftests/kselftest.h | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
index ae18c491a..d815a8667 100644
--- a/tools/testing/selftests/kselftest.h
+++ b/tools/testing/selftests/kselftest.h
@@ -173,19 +173,25 @@ static inline void ksft_print_cnts(void)
ksft_cnt.ksft_xskip, ksft_cnt.ksft_error);
}
-static inline __printf(1, 2) void ksft_print_msg(const char *msg, ...)
+static inline void ksft_vprint_msg(const char *msg, va_list args)
{
int saved_errno = errno;
- va_list args;
- va_start(args, msg);
printf("# ");
errno = saved_errno;
vprintf(msg, args);
+}
+
+static inline __printf(1, 2) void ksft_print_msg(const char *msg, ...)
+{
+ va_list args;
+
+ va_start(args, msg);
+ ksft_vprint_msg(msg, args);
va_end(args);
}
-static inline void ksft_print_dbg_msg(const char *msg, ...)
+static inline __printf(1, 2) void ksft_print_dbg_msg(const char *msg, ...)
{
va_list args;
@@ -193,7 +199,7 @@ static inline void ksft_print_dbg_msg(const char *msg, ...)
return;
va_start(args, msg);
- ksft_print_msg(msg, args);
+ ksft_vprint_msg(msg, args);
va_end(args);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests: kselftest: Fix debug message formatting
2026-09-16 19:04 [PATCH] selftests: kselftest: Fix debug message formatting ZhuangZhuang Wang
@ 2026-09-22 20:06 ` André Almeida
2026-09-26 19:27 ` Shuah Khan
0 siblings, 1 reply; 3+ messages in thread
From: André Almeida @ 2026-09-22 20:06 UTC (permalink / raw)
To: ZhuangZhuang Wang
Cc: Thomas Gleixner, Shuah Khan, linux-kselftest, linux-kernel
Em 16/09/2026 16:04, ZhuangZhuang Wang escreveu:
> ksft_print_dbg_msg() passes a va_list to ksft_print_msg() as a regular
> variadic argument. As a result, format specifiers consume the va_list
> representation instead of the caller's arguments and print garbage.
>
> Add a va_list-based helper and use it from both message printing
> functions. Also annotate ksft_print_dbg_msg() so the compiler can check
> its format arguments.
>
> Fixes: f2662ec26b26 ("selftests: kselftest: Create ksft_print_dbg_msg()")
> Signed-off-by: ZhuangZhuang Wang <wzz_123123@163.com>
Reviewed-by: André Almeida <andrealmeid@igalia.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests: kselftest: Fix debug message formatting
2026-09-22 20:06 ` André Almeida
@ 2026-09-26 19:27 ` Shuah Khan
0 siblings, 0 replies; 3+ messages in thread
From: Shuah Khan @ 2026-09-26 19:27 UTC (permalink / raw)
To: André Almeida, ZhuangZhuang Wang
Cc: Thomas Gleixner, Shuah Khan, linux-kselftest, linux-kernel, Shuah Khan
On 9/22/26 14:06, André Almeida wrote:
> Em 16/09/2026 16:04, ZhuangZhuang Wang escreveu:
>> ksft_print_dbg_msg() passes a va_list to ksft_print_msg() as a regular
>> variadic argument. As a result, format specifiers consume the va_list
>> representation instead of the caller's arguments and print garbage.
>>
>> Add a va_list-based helper and use it from both message printing
>> functions. Also annotate ksft_print_dbg_msg() so the compiler can check
>> its format arguments.
>>
>> Fixes: f2662ec26b26 ("selftests: kselftest: Create ksft_print_dbg_msg()")
Does it really fix this commit? I don't see that is the case. Please don't
add fixes tag unless it fixes the problem in the commit.
>> Signed-off-by: ZhuangZhuang Wang <wzz_123123@163.com>
>
> Reviewed-by: André Almeida <andrealmeid@igalia.com>
Also can you tell me how this problem was found and what;s the output
before and after this change?
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-26 19:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 19:04 [PATCH] selftests: kselftest: Fix debug message formatting ZhuangZhuang Wang
2026-09-22 20:06 ` André Almeida
2026-09-26 19:27 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®