KVM Archive mirror
 help / color / mirror / Atom feed
From: Tao Su <tao1.su@linux.intel.com>
To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-sound@vger.kernel.org, kvm@vger.kernel.org,
	netdev@vger.kernel.org, linux-rtc@vger.kernel.org,
	linux-sgx@vger.kernel.org
Cc: akpm@linux-foundation.org, edliaw@google.com,
	ivan.orlov0322@gmail.com, broonie@kernel.org, perex@perex.cz,
	tiwai@suse.com, shuah@kernel.org, seanjc@google.com,
	pbonzini@redhat.com, bongsu.jeon@samsung.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, alexandre.belloni@bootlin.com,
	jarkko@kernel.org, dave.hansen@linux.intel.com,
	tao1.su@linux.intel.com
Subject: [PATCH] selftests: Add _GNU_SOURCE definition when including kselftest_harness.h
Date: Tue,  7 May 2024 14:35:34 +0800	[thread overview]
Message-ID: <20240507063534.4191447-1-tao1.su@linux.intel.com> (raw)

asprintf() is declared in stdio.h when defining _GNU_SOURCE, but stdio.h
is so common that many files don’t define _GNU_SOURCE before including
stdio.h, and defining _GNU_SOURCE after including stdio.h will no longer
take effect.

Since kselftest_harness.h introduces asprintf(), it is necessary to add
_GNU_SOURCE definition in all selftests including kselftest_harness.h,
otherwise, there will be warnings or even errors during compilation.
There are already many selftests that define _GNU_SOURCE or put the
include of kselftest_harness.h at the very beginning of the .c file, just
add the _GNU_SOURCE definition in the tests that have compilation warnings.

Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
Signed-off-by: Tao Su <tao1.su@linux.intel.com>
---
 tools/testing/selftests/alsa/test-pcmtest-driver.c      | 1 +
 tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c | 1 +
 tools/testing/selftests/nci/nci_dev.c                   | 1 +
 tools/testing/selftests/net/bind_wildcard.c             | 1 +
 tools/testing/selftests/net/ip_local_port_range.c       | 1 +
 tools/testing/selftests/net/reuseaddr_ports_exhausted.c | 1 +
 tools/testing/selftests/prctl/set-anon-vma-name-test.c  | 1 +
 tools/testing/selftests/prctl/set-process-name.c        | 1 +
 tools/testing/selftests/rtc/rtctest.c                   | 1 +
 tools/testing/selftests/sgx/main.c                      | 1 +
 tools/testing/selftests/tdx/tdx_guest_test.c            | 1 +
 tools/testing/selftests/user_events/dyn_test.c          | 1 +
 tools/testing/selftests/user_events/ftrace_test.c       | 1 +
 tools/testing/selftests/user_events/perf_test.c         | 1 +
 14 files changed, 14 insertions(+)

diff --git a/tools/testing/selftests/alsa/test-pcmtest-driver.c b/tools/testing/selftests/alsa/test-pcmtest-driver.c
index ca81afa4ee90..5a01100d459d 100644
--- a/tools/testing/selftests/alsa/test-pcmtest-driver.c
+++ b/tools/testing/selftests/alsa/test-pcmtest-driver.c
@@ -5,6 +5,7 @@
  *
  * Copyright 2023 Ivan Orlov <ivan.orlov0322@gmail.com>
  */
+#define _GNU_SOURCE
 #include <string.h>
 #include <alsa/asoundlib.h>
 #include "../kselftest_harness.h"
diff --git a/tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c b/tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c
index f3c2239228b1..40f3e81b1a6c 100644
--- a/tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c
+++ b/tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c
@@ -4,6 +4,7 @@
  *
  * Tests for KVM paravirtual feature disablement
  */
+#define _GNU_SOURCE
 #include <asm/kvm_para.h>
 #include <linux/kvm_para.h>
 #include <linux/stringify.h>
diff --git a/tools/testing/selftests/nci/nci_dev.c b/tools/testing/selftests/nci/nci_dev.c
index 1562aa7d60b0..7cf18aced644 100644
--- a/tools/testing/selftests/nci/nci_dev.c
+++ b/tools/testing/selftests/nci/nci_dev.c
@@ -6,6 +6,7 @@
  * Test code for nci
  */
 
+#define _GNU_SOURCE
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/tools/testing/selftests/net/bind_wildcard.c b/tools/testing/selftests/net/bind_wildcard.c
index b7b54d646b93..f271e2ee6c7a 100644
--- a/tools/testing/selftests/net/bind_wildcard.c
+++ b/tools/testing/selftests/net/bind_wildcard.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /* Copyright Amazon.com Inc. or its affiliates. */
 
+#define _GNU_SOURCE
 #include <sys/socket.h>
 #include <netinet/in.h>
 
diff --git a/tools/testing/selftests/net/ip_local_port_range.c b/tools/testing/selftests/net/ip_local_port_range.c
index 193b82745fd8..fadefb0ab147 100644
--- a/tools/testing/selftests/net/ip_local_port_range.c
+++ b/tools/testing/selftests/net/ip_local_port_range.c
@@ -7,6 +7,7 @@
  * Don't run these directly but with ip_local_port_range.sh script.
  */
 
+#define _GNU_SOURCE
 #include <fcntl.h>
 #include <netinet/ip.h>
 
diff --git a/tools/testing/selftests/net/reuseaddr_ports_exhausted.c b/tools/testing/selftests/net/reuseaddr_ports_exhausted.c
index 066efd30e294..4f6fb2fbb96d 100644
--- a/tools/testing/selftests/net/reuseaddr_ports_exhausted.c
+++ b/tools/testing/selftests/net/reuseaddr_ports_exhausted.c
@@ -17,6 +17,7 @@
  *
  * Author: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
  */
+#define _GNU_SOURCE
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
diff --git a/tools/testing/selftests/prctl/set-anon-vma-name-test.c b/tools/testing/selftests/prctl/set-anon-vma-name-test.c
index 4275cb256dce..e5ea821be241 100644
--- a/tools/testing/selftests/prctl/set-anon-vma-name-test.c
+++ b/tools/testing/selftests/prctl/set-anon-vma-name-test.c
@@ -3,6 +3,7 @@
  * This test covers the anonymous VMA naming functionality through prctl calls
  */
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <sys/prctl.h>
 #include <stdio.h>
diff --git a/tools/testing/selftests/prctl/set-process-name.c b/tools/testing/selftests/prctl/set-process-name.c
index 562f707ba771..9cbfe9d38d72 100644
--- a/tools/testing/selftests/prctl/set-process-name.c
+++ b/tools/testing/selftests/prctl/set-process-name.c
@@ -3,6 +3,7 @@
  * This test covers the PR_SET_NAME functionality of prctl calls
  */
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <sys/prctl.h>
 #include <string.h>
diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c
index 63ce02d1d5cc..2ace7a75c638 100644
--- a/tools/testing/selftests/rtc/rtctest.c
+++ b/tools/testing/selftests/rtc/rtctest.c
@@ -5,6 +5,7 @@
  * Copyright (c) 2018 Alexandre Belloni <alexandre.belloni@bootlin.com>
  */
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <fcntl.h>
 #include <linux/rtc.h>
diff --git a/tools/testing/selftests/sgx/main.c b/tools/testing/selftests/sgx/main.c
index 9820b3809c69..bb6e795d06e2 100644
--- a/tools/testing/selftests/sgx/main.c
+++ b/tools/testing/selftests/sgx/main.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*  Copyright(c) 2016-20 Intel Corporation. */
 
+#define _GNU_SOURCE
 #include <cpuid.h>
 #include <elf.h>
 #include <errno.h>
diff --git a/tools/testing/selftests/tdx/tdx_guest_test.c b/tools/testing/selftests/tdx/tdx_guest_test.c
index 81d8cb88ea1a..f966467d1ef1 100644
--- a/tools/testing/selftests/tdx/tdx_guest_test.c
+++ b/tools/testing/selftests/tdx/tdx_guest_test.c
@@ -7,6 +7,7 @@
  * Author: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
  */
 
+#define _GNU_SOURCE
 #include <sys/ioctl.h>
 
 #include <errno.h>
diff --git a/tools/testing/selftests/user_events/dyn_test.c b/tools/testing/selftests/user_events/dyn_test.c
index bdf9ab127488..9d090ba3bfc3 100644
--- a/tools/testing/selftests/user_events/dyn_test.c
+++ b/tools/testing/selftests/user_events/dyn_test.c
@@ -5,6 +5,7 @@
  * Copyright (c) 2021 Beau Belgrave <beaub@linux.microsoft.com>
  */
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <linux/user_events.h>
 #include <stdio.h>
diff --git a/tools/testing/selftests/user_events/ftrace_test.c b/tools/testing/selftests/user_events/ftrace_test.c
index dcd7509fe2e0..25adef590a94 100644
--- a/tools/testing/selftests/user_events/ftrace_test.c
+++ b/tools/testing/selftests/user_events/ftrace_test.c
@@ -5,6 +5,7 @@
  * Copyright (c) 2021 Beau Belgrave <beaub@linux.microsoft.com>
  */
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <linux/user_events.h>
 #include <stdio.h>
diff --git a/tools/testing/selftests/user_events/perf_test.c b/tools/testing/selftests/user_events/perf_test.c
index 5288e768b207..176740a0fc02 100644
--- a/tools/testing/selftests/user_events/perf_test.c
+++ b/tools/testing/selftests/user_events/perf_test.c
@@ -5,6 +5,7 @@
  * Copyright (c) 2021 Beau Belgrave <beaub@linux.microsoft.com>
  */
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <linux/user_events.h>
 #include <linux/perf_event.h>

base-commit: dccb07f2914cdab2ac3a5b6c98406f765acab803
-- 
2.34.1


             reply	other threads:[~2024-05-07  6:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-07  6:35 Tao Su [this message]
2024-05-07 17:06 ` [PATCH] selftests: Add _GNU_SOURCE definition when including kselftest_harness.h Andrew Morton
2024-05-08  2:55   ` Tao Su
2024-05-08 14:00     ` Jakub Kicinski
2024-05-08 17:57       ` Edward Liaw
2024-05-09  5:10         ` Tao Su
2024-05-09  5:08       ` Tao Su
2024-05-09 18:27         ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240507063534.4191447-1-tao1.su@linux.intel.com \
    --to=tao1.su@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=bongsu.jeon@samsung.com \
    --cc=broonie@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=edliaw@google.com \
    --cc=edumazet@google.com \
    --cc=ivan.orlov0322@gmail.com \
    --cc=jarkko@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=perex@perex.cz \
    --cc=seanjc@google.com \
    --cc=shuah@kernel.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).