Re: [PATCH v7 4/7] selftests: ksft_exit_fail_perror: support printf style arguments

Chunyu Hu
2026-04-01T13:46:58Z

On Wed, Apr 01, 2026 at 12:03:09PM +0100, Mark Brown wrote:
> On Mon, Mar 30, 2026 at 11:15:00PM +0800, Chunyu Hu wrote:
>
> > The ksft_exit_fail_perror function previously only accepted a single string
> > argument, which limited its flexibility for providing specific context to
> > failure messages.
>
> > This change updates ksft_exit_fail_perror to support variable arguments,
> > similar to ksft_exit_fail_msg. Adding the __printf(1, 2) attribute enables
> > compile-time checking for format string correctness.
>
> This is causing build regressions on the arm64 selftests:
>
> /arm64/fp/za-fork-asm.o -o /build/stage/build-work/kselftest/arm64/fp/za-fork
> In file included from za-fork.c:12:
> ../../kselftest.h: In function ‘ksft_exit_fail_perror’:
> ../../kselftest.h:427:13: error: implicit declaration of function ‘vasprintf’; d
> id you mean ‘vsprintf’? [-Wimplicit-function-declaration]
> 427 | if (vasprintf(&buf, msg, args) == -1) {
> | ^~~~~~~~~
> | vsprintf
>
> This is because za-fork uses nolibc which does not implement
> vasprintf().
>
> I need to look at why this managed to pass the build testing I do in
> -next...

I can reproduce this issue with nolibc compile. Thanks for the
debugging. It's great if we have that definition in nolibc lib.

For thsi series, because according to man page, vasprintf()
requires _GNU_SOURCE, and implemeted it in kselftest.h will
add the burden to all c files, or fore a _GNU_SOURCE to
all c files included, I tend to go back to ksft_exit_fail_msg.
;)