All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] selftests: harness: Mark test fixture objects __maybe_unused
@ 2026-07-06 18:31 David Matlack
  2026-07-06 21:36 ` Nathan Chancellor
  2026-07-14 16:24 ` David Matlack
  0 siblings, 2 replies; 4+ messages in thread
From: David Matlack @ 2026-07-06 18:31 UTC (permalink / raw)
  To: linux-kernel, linux-kselftest, llvm
  Cc: Andy Lutomirski, Bill Wendling, Justin Stitt, Kees Cook,
	Mickaël Salaün, Nathan Chancellor, Nick Desaulniers,
	Shuah Khan, Will Drewry, David Matlack, Kuniyuki Iwashima,
	Aaron Lewis, Alex Williamson

Mark _##fixture_name##_##test_name##_object __maybe_unused since it may
not ever be read. This pointer is only read in XFAIL_ADD(), which tests
are not required to use.

clang made a change to -Wunused-but-set-variable (split out into its own
subwarning, -Wunused-but-set-global) that causes this warning to be
emitted for various selftests and can be upgraded to an error in
selftest that set -Werror.

VFIO selftests have been broken since commit ff556bd98348 ("vfio:
selftests: Add -Wall and -Werror to the Makefile"), and the net
selftests builds have been noisy due to -Wall.

Fixes: 24cf65a62266 ("selftests/harness: Share _metadata between forked processes")
Reported-by: Kuniyuki Iwashima <kuniyu@google.com>
Reported-by: Aaron Lewis <aaronlewis@google.com>
Reviewed-by: Alex Williamson <alex@shazbot.org>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: David Matlack <dmatlack@google.com>
---
v3:
 - Pick up Kuniyuki's Reviewed-by tag.
 - Pick up Alex's Reviewed-by tag from v1.
 - Fix commit description accuracy (Kuniyuki)

v2: https://lore.kernel.org/linux-kselftest/20260706175228.2468730-1-dmatlack@google.com/

v1: https://lore.kernel.org/linux-kselftest/20260630213341.1664345-1-dmatlack@google.com/

Note: The fixes tag is commit 24cf65a62266 ("selftests/harness: Share
_metadata between forked processes"), which refactored TEST_F to share
test metadata across processes using mmap and convereted the test
fixture object from a static struct to a static pointer. Prior to commit
24cf65a62266 the static struct was always used once (the address of it
was taken and passed to __register_test()), but after the static pointer
was always assigned but potentially never read.

Cc: Nathan Chancellor <nathan@kernel.org>

 tools/testing/selftests/kselftest_harness.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index 261e4df94d9d..29a19bc87084 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -467,7 +467,7 @@ static inline void __kselftest_memset_safe(void *s, int c, size_t n)
 				!__atomic_test_and_set(_metadata->no_teardown, __ATOMIC_RELAXED)) \
 			fixture_name##_teardown(_metadata, self, variant); \
 	} \
-	static struct __test_metadata *_##fixture_name##_##test_name##_object; \
+	static struct __test_metadata *_##fixture_name##_##test_name##_object __maybe_unused; \
 	static void __attribute__((constructor(KSELFTEST_PRIO_TEST))) \
 			_register_##fixture_name##_##test_name(void) \
 	{ \

base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
-- 
2.55.0.rc2.803.g1fd1e6609c-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] selftests: harness: Mark test fixture objects __maybe_unused
  2026-07-06 18:31 [PATCH v3] selftests: harness: Mark test fixture objects __maybe_unused David Matlack
@ 2026-07-06 21:36 ` Nathan Chancellor
  2026-07-14 16:24 ` David Matlack
  1 sibling, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2026-07-06 21:36 UTC (permalink / raw)
  To: David Matlack
  Cc: linux-kernel, linux-kselftest, llvm, Andy Lutomirski,
	Bill Wendling, Justin Stitt, Kees Cook, Mickaël Salaün,
	Nick Desaulniers, Shuah Khan, Will Drewry, Kuniyuki Iwashima,
	Aaron Lewis, Alex Williamson

On Mon, Jul 06, 2026 at 06:31:54PM +0000, David Matlack wrote:
> Mark _##fixture_name##_##test_name##_object __maybe_unused since it may
> not ever be read. This pointer is only read in XFAIL_ADD(), which tests
> are not required to use.
> 
> clang made a change to -Wunused-but-set-variable (split out into its own
> subwarning, -Wunused-but-set-global) that causes this warning to be
> emitted for various selftests and can be upgraded to an error in
> selftest that set -Werror.
> 
> VFIO selftests have been broken since commit ff556bd98348 ("vfio:
> selftests: Add -Wall and -Werror to the Makefile"), and the net
> selftests builds have been noisy due to -Wall.
> 
> Fixes: 24cf65a62266 ("selftests/harness: Share _metadata between forked processes")
> Reported-by: Kuniyuki Iwashima <kuniyu@google.com>
> Reported-by: Aaron Lewis <aaronlewis@google.com>
> Reviewed-by: Alex Williamson <alex@shazbot.org>
> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
> Signed-off-by: David Matlack <dmatlack@google.com>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> v3:
>  - Pick up Kuniyuki's Reviewed-by tag.
>  - Pick up Alex's Reviewed-by tag from v1.
>  - Fix commit description accuracy (Kuniyuki)
> 
> v2: https://lore.kernel.org/linux-kselftest/20260706175228.2468730-1-dmatlack@google.com/
> 
> v1: https://lore.kernel.org/linux-kselftest/20260630213341.1664345-1-dmatlack@google.com/
> 
> Note: The fixes tag is commit 24cf65a62266 ("selftests/harness: Share
> _metadata between forked processes"), which refactored TEST_F to share
> test metadata across processes using mmap and convereted the test
> fixture object from a static struct to a static pointer. Prior to commit
> 24cf65a62266 the static struct was always used once (the address of it
> was taken and passed to __register_test()), but after the static pointer
> was always assigned but potentially never read.
> 
> Cc: Nathan Chancellor <nathan@kernel.org>
> 
>  tools/testing/selftests/kselftest_harness.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
> index 261e4df94d9d..29a19bc87084 100644
> --- a/tools/testing/selftests/kselftest_harness.h
> +++ b/tools/testing/selftests/kselftest_harness.h
> @@ -467,7 +467,7 @@ static inline void __kselftest_memset_safe(void *s, int c, size_t n)
>  				!__atomic_test_and_set(_metadata->no_teardown, __ATOMIC_RELAXED)) \
>  			fixture_name##_teardown(_metadata, self, variant); \
>  	} \
> -	static struct __test_metadata *_##fixture_name##_##test_name##_object; \
> +	static struct __test_metadata *_##fixture_name##_##test_name##_object __maybe_unused; \
>  	static void __attribute__((constructor(KSELFTEST_PRIO_TEST))) \
>  			_register_##fixture_name##_##test_name(void) \
>  	{ \
> 
> base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
> -- 
> 2.55.0.rc2.803.g1fd1e6609c-goog
> 

-- 
Cheers,
Nathan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] selftests: harness: Mark test fixture objects __maybe_unused
  2026-07-06 18:31 [PATCH v3] selftests: harness: Mark test fixture objects __maybe_unused David Matlack
  2026-07-06 21:36 ` Nathan Chancellor
@ 2026-07-14 16:24 ` David Matlack
  2026-07-15 16:03   ` Kees Cook
  1 sibling, 1 reply; 4+ messages in thread
From: David Matlack @ 2026-07-14 16:24 UTC (permalink / raw)
  To: linux-kernel, linux-kselftest, llvm
  Cc: Andy Lutomirski, Bill Wendling, Justin Stitt, Kees Cook,
	Mickaël Salaün, Nathan Chancellor, Nick Desaulniers,
	Shuah Khan, Will Drewry, Kuniyuki Iwashima, Aaron Lewis,
	Alex Williamson

On Mon, Jul 6, 2026 at 11:32 AM David Matlack <dmatlack@google.com> wrote:
>
> Mark _##fixture_name##_##test_name##_object __maybe_unused since it may
> not ever be read. This pointer is only read in XFAIL_ADD(), which tests
> are not required to use.
>
> clang made a change to -Wunused-but-set-variable (split out into its own
> subwarning, -Wunused-but-set-global) that causes this warning to be
> emitted for various selftests and can be upgraded to an error in
> selftest that set -Werror.
>
> VFIO selftests have been broken since commit ff556bd98348 ("vfio:
> selftests: Add -Wall and -Werror to the Makefile"), and the net
> selftests builds have been noisy due to -Wall.
>
> Fixes: 24cf65a62266 ("selftests/harness: Share _metadata between forked processes")
> Reported-by: Kuniyuki Iwashima <kuniyu@google.com>
> Reported-by: Aaron Lewis <aaronlewis@google.com>
> Reviewed-by: Alex Williamson <alex@shazbot.org>
> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
> Signed-off-by: David Matlack <dmatlack@google.com>

Kees and Shuah, is it ok if Alex takes this through the VFIO tree? [1]
This fixes a bug exposed by recent VFIO selftests commit ff556bd98348
("vfio: selftests: Add -Wall and -Werror to the Makefile").

[1] https://lore.kernel.org/linux-kselftest/20260630165244.0d013bbc@shazbot.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] selftests: harness: Mark test fixture objects __maybe_unused
  2026-07-14 16:24 ` David Matlack
@ 2026-07-15 16:03   ` Kees Cook
  0 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2026-07-15 16:03 UTC (permalink / raw)
  To: David Matlack
  Cc: linux-kernel, linux-kselftest, llvm, Andy Lutomirski,
	Bill Wendling, Justin Stitt, Mickaël Salaün,
	Nathan Chancellor, Nick Desaulniers, Shuah Khan, Will Drewry,
	Kuniyuki Iwashima, Aaron Lewis, Alex Williamson

On Tue, Jul 14, 2026 at 09:24:36AM -0700, David Matlack wrote:
> On Mon, Jul 6, 2026 at 11:32 AM David Matlack <dmatlack@google.com> wrote:
> >
> > Mark _##fixture_name##_##test_name##_object __maybe_unused since it may
> > not ever be read. This pointer is only read in XFAIL_ADD(), which tests
> > are not required to use.
> >
> > clang made a change to -Wunused-but-set-variable (split out into its own
> > subwarning, -Wunused-but-set-global) that causes this warning to be
> > emitted for various selftests and can be upgraded to an error in
> > selftest that set -Werror.
> >
> > VFIO selftests have been broken since commit ff556bd98348 ("vfio:
> > selftests: Add -Wall and -Werror to the Makefile"), and the net
> > selftests builds have been noisy due to -Wall.
> >
> > Fixes: 24cf65a62266 ("selftests/harness: Share _metadata between forked processes")
> > Reported-by: Kuniyuki Iwashima <kuniyu@google.com>
> > Reported-by: Aaron Lewis <aaronlewis@google.com>
> > Reviewed-by: Alex Williamson <alex@shazbot.org>
> > Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
> > Signed-off-by: David Matlack <dmatlack@google.com>
> 
> Kees and Shuah, is it ok if Alex takes this through the VFIO tree? [1]
> This fixes a bug exposed by recent VFIO selftests commit ff556bd98348
> ("vfio: selftests: Add -Wall and -Werror to the Makefile").
> 
> [1] https://lore.kernel.org/linux-kselftest/20260630165244.0d013bbc@shazbot.org/

Yeah, please do. This has ample review. :)

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-15 16:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 18:31 [PATCH v3] selftests: harness: Mark test fixture objects __maybe_unused David Matlack
2026-07-06 21:36 ` Nathan Chancellor
2026-07-14 16:24 ` David Matlack
2026-07-15 16:03   ` Kees Cook

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.