* [PATCH] selftests/proc: proc-pid-vm: fix unused variable warning on non-x86
@ 2026-10-11 22:33 Sasha Levin
2026-10-12 2:17 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2026-10-11 22:33 UTC (permalink / raw)
To: Shuah Khan, Alexey Dobriyan, Andrew Morton
Cc: Sasha Levin, linux-kernel, linux-fsdevel, linux-kselftest
g_vsyscall is only used by the x86_64 test, so other architectures get:
proc-pid-vm.c:224:21: warning: unused variable 'g_vsyscall' [-Wunused-variable]
Mark it __maybe_unused, like str_vsyscall next to it.
Fixes: 17415606f9d8b ("tools/testing/selftests/proc/proc-pid-vm.c: test with vsyscall in mind")
Assisted-by: LLM
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/testing/selftests/proc/proc-pid-vm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/proc/proc-pid-vm.c b/tools/testing/selftests/proc/proc-pid-vm.c
index 4e6a3e53f9757..c5a66f481ab4d 100644
--- a/tools/testing/selftests/proc/proc-pid-vm.c
+++ b/tools/testing/selftests/proc/proc-pid-vm.c
@@ -221,7 +221,7 @@ static int make_exe(const uint8_t *payload, size_t len)
* 1: vsyscall VMA is --xp vsyscall=xonly
* 2: vsyscall VMA is r-xp vsyscall=emulate
*/
-static volatile int g_vsyscall;
+static volatile int g_vsyscall __maybe_unused;
static const char *str_vsyscall __maybe_unused;
static const char str_vsyscall_0[] __maybe_unused = "";
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] selftests/proc: proc-pid-vm: fix unused variable warning on non-x86
2026-10-11 22:33 [PATCH] selftests/proc: proc-pid-vm: fix unused variable warning on non-x86 Sasha Levin
@ 2026-10-12 2:17 ` Andrew Morton
2026-10-12 11:53 ` [PATCH v2] " Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2026-10-12 2:17 UTC (permalink / raw)
To: Sasha Levin
Cc: Shuah Khan, Alexey Dobriyan, linux-kernel, linux-fsdevel,
linux-kselftest
On Sun, 11 Oct 2026 18:33:39 -0400 Sasha Levin <sashal@kernel.org> wrote:
> g_vsyscall is only used by the x86_64 test, so other architectures get:
>
> proc-pid-vm.c:224:21: warning: unused variable 'g_vsyscall' [-Wunused-variable]
>
> Mark it __maybe_unused, like str_vsyscall next to it.
>
> ...
>
> --- a/tools/testing/selftests/proc/proc-pid-vm.c
> +++ b/tools/testing/selftests/proc/proc-pid-vm.c
> @@ -221,7 +221,7 @@ static int make_exe(const uint8_t *payload, size_t len)
> * 1: vsyscall VMA is --xp vsyscall=xonly
> * 2: vsyscall VMA is r-xp vsyscall=emulate
> */
> -static volatile int g_vsyscall;
> +static volatile int g_vsyscall __maybe_unused;
> static const char *str_vsyscall __maybe_unused;
>
> static const char str_vsyscall_0[] __maybe_unused = "";
Can't all the x86-specific stuff be moved after the #ifdef __x86_64__
which is a few lines later?
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] selftests/proc: proc-pid-vm: fix unused variable warning on non-x86
2026-10-12 2:17 ` Andrew Morton
@ 2026-10-12 11:53 ` Sasha Levin
0 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2026-10-12 11:53 UTC (permalink / raw)
To: Shuah Khan, Andrew Morton, Alexey Dobriyan
Cc: Sasha Levin, linux-kernel, linux-fsdevel, linux-kselftest
g_vsyscall is only used by the x86_64 test, so clang builds for other
architectures get:
proc-pid-vm.c:224:21: warning: unused variable 'g_vsyscall' [-Wunused-variable]
The vsyscall strings next to it had the same problem and were marked
__maybe_unused for it. Move all of the vsyscall variables into the
__x86_64__ block that uses them instead, and drop those annotations
along with the local __maybe_unused fallback that was added for them.
Fixes: 17415606f9d8b ("tools/testing/selftests/proc/proc-pid-vm.c: test with vsyscall in mind")
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Assisted-by: LLM
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Changes in v2:
- Move the vsyscall variables into the __x86_64__ block instead of marking
g_vsyscall __maybe_unused, and drop the existing annotations (Andrew Morton)
- Link to v1: https://lore.kernel.org/r/20261011223358.2327625-11-sashal@kernel.org
tools/testing/selftests/proc/proc-pid-vm.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/tools/testing/selftests/proc/proc-pid-vm.c b/tools/testing/selftests/proc/proc-pid-vm.c
index 4e6a3e53f9757..98e882e568154 100644
--- a/tools/testing/selftests/proc/proc-pid-vm.c
+++ b/tools/testing/selftests/proc/proc-pid-vm.c
@@ -47,10 +47,6 @@
#include <sys/resource.h>
#include <linux/fs.h>
-#ifndef __maybe_unused
-#define __maybe_unused __attribute__((__unused__))
-#endif
-
#include "kselftest.h"
static inline long sys_execveat(int dirfd, const char *pathname, char **argv, char **envp, int flags)
@@ -214,7 +210,6 @@ static int make_exe(const uint8_t *payload, size_t len)
return fd1;
}
-#endif
/*
* 0: vsyscall VMA doesn't exist vsyscall=none
@@ -222,15 +217,14 @@ static int make_exe(const uint8_t *payload, size_t len)
* 2: vsyscall VMA is r-xp vsyscall=emulate
*/
static volatile int g_vsyscall;
-static const char *str_vsyscall __maybe_unused;
+static const char *str_vsyscall;
-static const char str_vsyscall_0[] __maybe_unused = "";
-static const char str_vsyscall_1[] __maybe_unused =
+static const char str_vsyscall_0[] = "";
+static const char str_vsyscall_1[] =
"ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0 [vsyscall]\n";
-static const char str_vsyscall_2[] __maybe_unused =
+static const char str_vsyscall_2[] =
"ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]\n";
-#ifdef __x86_64__
static void sigaction_SIGSEGV(int _, siginfo_t *__, void *___)
{
_exit(g_vsyscall);
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-12 11:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-11 22:33 [PATCH] selftests/proc: proc-pid-vm: fix unused variable warning on non-x86 Sasha Levin
2026-10-12 2:17 ` Andrew Morton
2026-10-12 11:53 ` [PATCH v2] " Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®