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

Andrew Morton
2026-03-31T19:09:03Z

On Tue, 31 Mar 2026 18:31:42 +0800 Chunyu Hu <chuhu@redhat.com> wrote:

> > - ksft_exit_fail_msg("%s: %s (%d)\n", msg, strerror(errno), errno);
> > + va_list args;
> > + char *buf = NULL;
> > + int saved_errno = errno;
> > +
> > + va_start(args, msg);
> > + if (vasprintf(&buf, msg, args) == -1) {
>
> kernel test robot reported compile error on this, as the vasprintf
> required _GNU_SOURCE. Looks like it's not appropriate to be used
> in the common header. Looks like it can be replaced with a buf and
> vsnprintf instead.

I like vasprintf()!

"#define _GNU_SOURCE" occurs 402 times in selftests/, so perhaps we can
find a way to keep it?

(err, *why* 402 times? Can't it be just once?)