The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: David Matlack <dmatlack@google.com>
To: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	 llvm@lists.linux.dev
Cc: "Andy Lutomirski" <luto@amacapital.net>,
	"Bill Wendling" <morbo@google.com>,
	"Justin Stitt" <justinstitt@google.com>,
	"Kees Cook" <kees@kernel.org>, "Mickaël Salaün" <mic@digikod.net>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
	"Shuah Khan" <shuah@kernel.org>, "Will Drewry" <wad@chromium.org>,
	"David Matlack" <dmatlack@google.com>,
	"Kuniyuki Iwashima" <kuniyu@google.com>,
	"Aaron Lewis" <aaronlewis@google.com>,
	"Alex Williamson" <alex@shazbot.org>
Subject: [PATCH v3] selftests: harness: Mark test fixture objects __maybe_unused
Date: Mon,  6 Jul 2026 18:31:54 +0000	[thread overview]
Message-ID: <20260706183154.2660394-1-dmatlack@google.com> (raw)

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


             reply	other threads:[~2026-07-06 18:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 18:31 David Matlack [this message]
2026-07-06 21:36 ` [PATCH v3] selftests: harness: Mark test fixture objects __maybe_unused Nathan Chancellor

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=20260706183154.2660394-1-dmatlack@google.com \
    --to=dmatlack@google.com \
    --cc=aaronlewis@google.com \
    --cc=alex@shazbot.org \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=luto@amacapital.net \
    --cc=mic@digikod.net \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=shuah@kernel.org \
    --cc=wad@chromium.org \
    /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