[PATCH 14/27] panic: Mark abort() __noreturn

Josh Poimboeuf <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.kernel.rust,gmane.linux.kbuild.devel
Message-ID <ce84b125053b74045fd59906c082bc2123e73aca.1787890035.git.jpoimboe@kernel.org>
abort() is a C compiler builtin interface, so compilers already know it
doesn't return, but mark it as such explicitly for documentation
purposes.

Signed-off-by: Josh Poimboeuf <[email protected]>
---
 arch/arc/kernel/traps.c | 4 +++-
 arch/arm/kernel/traps.c | 2 +-
 include/linux/panic.h   | 2 +-
 kernel/exit.c           | 2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c
index 8d2ea2cbd98b0..803c131c6aa78 100644
--- a/arch/arc/kernel/traps.c
+++ b/arch/arc/kernel/traps.c
@@ -153,7 +153,9 @@ void do_insterror_or_kprobe(unsigned long address, struct pt_regs *regs)
 /*
  * abort() call generated by older gcc for __builtin_trap()
  */
-void abort(void)
+void __noreturn abort(void)
 {
 	__asm__ __volatile__("trap_s  5\n");
+
+	unreachable();
 }
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index afbd2ebe5c39d..a3bd26d41612f 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -777,7 +777,7 @@ asmlinkage void __div0(void)
 }
 EXPORT_SYMBOL(__div0);
 
-void abort(void)
+void __noreturn abort(void)
 {
 	BUG();
 
diff --git a/include/linux/panic.h b/include/linux/panic.h
index f1dd417e54b29..da8778360dadf 100644
--- a/include/linux/panic.h
+++ b/include/linux/panic.h
@@ -33,7 +33,7 @@ extern int sysctl_panic_on_stackoverflow;
 extern bool crash_kexec_post_notifiers;
 
 extern void __stack_chk_fail(void);
-void abort(void);
+void abort(void) __noreturn;
 
 /*
  * panic_cpu is used for synchronizing panic() and crash_kexec() execution. It
diff --git a/kernel/exit.c b/kernel/exit.c
index 2c0b1c02920f4..2c55dc0fbbec8 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -2028,7 +2028,7 @@ COMPAT_SYSCALL_DEFINE5(waitid,
  *
  * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88345#c11
  */
-__weak __function_aligned void abort(void)
+__weak __function_aligned void __noreturn abort(void)
 {
 	BUG();
 
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.