Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: pidfd: ksft_exit functions do not return

After commit f7d5bcd35d42 ("selftests: kselftest: Mark functions that
unconditionally call exit() as __noreturn"), ksft_exit_...() functions
are marked as __noreturn, which means the return type should not be
'int' but 'void' because they are not returning anything (and never were
since exit() has always been called).

To facilitate updating the return type of these functions, remove
'return' before the calls to ksft_exit_{pass,fail}(), as __noreturn
prevents the compiler from warning that a caller of the ksft_exit
functions does not return a value because the program will terminate
upon calling these functions.

Just removing 'return' would have resulted in

!ret ? ksft_exit_pass() : ksft_exit_fail();

so convert that into the more idiomatic

if (ret)
ksft_exit_fail();
ksft_exit_pass();

Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Nathan Chancellor and committed by
Shuah Khan
a3bf0755 69e545ed

+6 -4
+1 -1
tools/testing/selftests/pidfd/pidfd_fdinfo_test.c
··· 307 307 test_pidfd_fdinfo_nspid(); 308 308 test_pidfd_dead_fdinfo(); 309 309 310 - return ksft_exit_pass(); 310 + ksft_exit_pass(); 311 311 }
+3 -1
tools/testing/selftests/pidfd/pidfd_open_test.c
··· 159 159 if (pidfd >= 0) 160 160 close(pidfd); 161 161 162 - return !ret ? ksft_exit_pass() : ksft_exit_fail(); 162 + if (ret) 163 + ksft_exit_fail(); 164 + ksft_exit_pass(); 163 165 }
+1 -1
tools/testing/selftests/pidfd/pidfd_poll_test.c
··· 112 112 } 113 113 114 114 ksft_test_result_pass("pidfd poll test: pass\n"); 115 - return ksft_exit_pass(); 115 + ksft_exit_pass(); 116 116 }
+1 -1
tools/testing/selftests/pidfd/pidfd_test.c
··· 572 572 test_pidfd_send_signal_exited_fail(); 573 573 test_pidfd_send_signal_recycled_pid_fail(); 574 574 575 - return ksft_exit_pass(); 575 + ksft_exit_pass(); 576 576 }