summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/x86_64/set_sregs_test.c
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2024-04-23 22:03:08 +0300
committerSean Christopherson <seanjc@google.com>2024-04-29 22:49:10 +0300
commit730cfa45b5f4f170095707b526dc7af99c9f0959 (patch)
treedf1d67784e0f2803aa79117c9fa78dcfa65ef16b /tools/testing/selftests/kvm/x86_64/set_sregs_test.c
parenta96cb3bf390eebfead5fc7a2092f8452a7997d1b (diff)
downloadlinux-730cfa45b5f4f170095707b526dc7af99c9f0959.tar.xz
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: Muhammad Usama Anjum <usama.anjum@collabora.com> Acked-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Acked-by: Oliver Upton <oliver.upton@linux.dev> Acked-by: Anup Patel <anup@brainfault.org> Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com> Link: https://lore.kernel.org/r/20240423190308.2883084-1-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/testing/selftests/kvm/x86_64/set_sregs_test.c')
-rw-r--r--tools/testing/selftests/kvm/x86_64/set_sregs_test.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/tools/testing/selftests/kvm/x86_64/set_sregs_test.c b/tools/testing/selftests/kvm/x86_64/set_sregs_test.c
index 3610981d9162..c021c0795a96 100644
--- a/tools/testing/selftests/kvm/x86_64/set_sregs_test.c
+++ b/tools/testing/selftests/kvm/x86_64/set_sregs_test.c
@@ -10,7 +10,6 @@
* That bug allowed a user-mode program that called the KVM_SET_SREGS
* ioctl to put a VCPU's local APIC into an invalid state.
*/
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>