Skip to content
Commit 730cfa45 authored by Sean Christopherson's avatar Sean Christopherson
Browse files

KVM: selftests: Define _GNU_SOURCE for all selftests code



Define _GNU_SOURCE is the base CFLAGS instead of relying on selftests to
manually #define _GNU_SOURCE, which is repetitive and error prone.  E.g.
kselftest_harness.h requires _GNU_SOURCE for asprintf(), but if a selftest
includes kvm_test_harness.h after stdio.h, the include guards result in
the effective version of stdio.h consumed by kvm_test_harness.h not
defining asprintf():

  In file included from x86_64/fix_hypercall_test.c:12:
  In file included from include/kvm_test_harness.h:11:
 ../kselftest_harness.h:1169:2: error: call to undeclared function
  'asprintf'; ISO C99 and later do not support implicit function declarations
  [-Wimplicit-function-declaration]
   1169 |         asprintf(&test_name, "%s%s%s.%s", f->name,
        |         ^

When including the rseq selftest's "library" code, #undef _GNU_SOURCE so
that rseq.c controls whether or not it wants to build with _GNU_SOURCE.

Reported-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
Acked-by: default avatarClaudio Imbrenda <imbrenda@linux.ibm.com>
Acked-by: default avatarOliver Upton <oliver.upton@linux.dev>
Acked-by: default avatarAnup Patel <anup@brainfault.org>
Reviewed-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
Link: https://lore.kernel.org/r/20240423190308.2883084-1-seanjc@google.com


Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
parent a96cb3bf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment