Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH] selftests: Mark ksft_exit_fail_perror() as __noreturn
@ 2024-04-14  6:26 Muhammad Usama Anjum
  2024-04-15 15:41 ` Nathan Chancellor
  0 siblings, 1 reply; 3+ messages in thread
From: Muhammad Usama Anjum @ 2024-04-14  6:26 UTC (permalink / raw)
  To: Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt
  Cc: Muhammad Usama Anjum, kernel, linux-kselftest, linux-kernel, llvm

Let the compilers (clang) know that this function would just call
exit() and would never return. It is needed to avoid false positive
static analysis errors. All similar functions calling exit()
unconditionally have been marked as __noreturn.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
This patch has been suggested [1] and tested on top of the following
patches:
- f07041728422 ("selftests: add ksft_exit_fail_perror()") which is
  in kselftest tree already
- ("kselftest: Mark functions that unconditionally call exit() as
  __noreturn") would appear in tip/timers/urgent

[1] https://lore.kernel.org/all/8254ab4d-9cb6-402e-80dd-d9ec70d77de5@linuxfoundation.org
---
 tools/testing/selftests/kselftest.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
index 050c5fd018400..b43a7a7ca4b40 100644
--- a/tools/testing/selftests/kselftest.h
+++ b/tools/testing/selftests/kselftest.h
@@ -372,7 +372,7 @@ static inline __printf(1, 2) int ksft_exit_fail_msg(const char *msg, ...)
 	exit(KSFT_FAIL);
 }
 
-static inline void ksft_exit_fail_perror(const char *msg)
+static inline __noreturn void ksft_exit_fail_perror(const char *msg)
 {
 #ifndef NOLIBC
 	ksft_exit_fail_msg("%s: %s (%d)\n", msg, strerror(errno), errno);
-- 
2.39.2


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

end of thread, other threads:[~2024-04-17  0:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-14  6:26 [PATCH] selftests: Mark ksft_exit_fail_perror() as __noreturn Muhammad Usama Anjum
2024-04-15 15:41 ` Nathan Chancellor
2024-04-17  0:03   ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox