[PATCH] selftests/x86/ioperm: exit non-zero on child error

From: Greg Thelen

Date: Wed Oct 21 2026 - 17:17:51 EST


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@xxxxxxxxxx>
---
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