mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Thelen <gthelen@google.com>
To: Shuah Khan <shuah@kernel.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	 Thomas Gleixner <tglx@kernel.org>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	x86@kernel.org
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Greg Thelen <gthelen@google.com>
Subject: [PATCH] selftests/x86/ioperm: exit non-zero on child error
Date: Wed, 21 Oct 2026 14:17:44 -0700	[thread overview]
Message-ID: <20261021211744.4047370-1-gthelen@google.com> (raw)

ioperm.c increments the file-scope nerrs counter when the forked child
dies or exits with a non-zero status, but main() unconditionally returns
0 at the end without inspecting nerrs. In addition to masking child test
failures, this triggers a Clang 23 warning:

  ioperm.c:25:12: error: variable 'nerrs' set but not used
  [-Werror,-Wunused-but-set-global]

Return 'nerrs ? 1 : 0' from main(), matching other x86 selftests such as
iopl.c and ldt_gdt.c.

Fixes: 0eb1d0fa6a68 ("selftests/x86: Add a basic selftest for ioperm")
Signed-off-by: Greg Thelen <gthelen@google.com>
---
 tools/testing/selftests/x86/ioperm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/x86/ioperm.c b/tools/testing/selftests/x86/ioperm.c
index 69d5fb7050c2..6c36e316de95 100644
--- a/tools/testing/selftests/x86/ioperm.c
+++ b/tools/testing/selftests/x86/ioperm.c
@@ -144,7 +144,7 @@ int main(void)
 	printf("\tDrop privileges\n");
 	if (setresuid(1, 1, 1) != 0) {
 		printf("[WARN]\tDropping privileges failed\n");
-		return 0;
+		return nerrs ? 1 : 0;
 	}
 
 	printf("[RUN]\tdisable 0x80\n");
@@ -160,5 +160,5 @@ int main(void)
 		return 1;
 	}
 	printf("[OK]\tit failed\n");
-	return 0;
+	return nerrs ? 1 : 0;
 }
-- 
2.56.0.218.g1ec904b173-goog


                 reply	other threads:[~2026-10-21 21:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261021211744.4047370-1-gthelen@google.com \
    --to=gthelen@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=shuah@kernel.org \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®