public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bug: Fix no-return-statement warning with !CONFIG_BUG
@ 2024-04-10 15:32 Adrian Hunter
  2024-04-10 17:02 ` Naresh Kamboju
  2024-04-11  7:04 ` Arnd Bergmann
  0 siblings, 2 replies; 15+ messages in thread
From: Adrian Hunter @ 2024-04-10 15:32 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Naresh Kamboju, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Aneesh Kumar K.V, Naveen N. Rao, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, Christian Borntraeger,
	Sven Schnelle, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Andy Lutomirski, Vincenzo Frascino, John Stultz,
	Stephen Boyd, Peter Zijlstra, Randy Dunlap, Bjorn Helgaas,
	Arnd Bergmann, Anna-Maria Behnsen, linuxppc-dev, linux-kernel,
	linux-s390

BUG() does not return, and arch implementations of BUG() use unreachable()
or other non-returning code. However with !CONFIG_BUG, the default
implementation is often used instead, and that does not do that. x86 always
uses its own implementation, but powerpc with !CONFIG_BUG gives a build
error:

  kernel/time/timekeeping.c: In function ‘timekeeping_debug_get_ns’:
  kernel/time/timekeeping.c:286:1: error: no return statement in function
  returning non-void [-Werror=return-type]

Add unreachable() to default !CONFIG_BUG BUG() implementation.

Fixes: e8e9d21a5df6 ("timekeeping: Refactor timekeeping helpers")
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Closes: https://lore.kernel.org/all/CA+G9fYvjdZCW=7ZGxS6A_3bysjQ56YF7S-+PNLQ_8a4DKh1Bhg@mail.gmail.com/
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 include/asm-generic/bug.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 6e794420bd39..b7de3a4eade1 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -156,7 +156,10 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...);
 
 #else /* !CONFIG_BUG */
 #ifndef HAVE_ARCH_BUG
-#define BUG() do {} while (1)
+#define BUG() do {		\
+	do {} while (1);	\
+	unreachable();		\
+} while (0)
 #endif
 
 #ifndef HAVE_ARCH_BUG_ON
-- 
2.34.1


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

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

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-10 15:32 [PATCH] bug: Fix no-return-statement warning with !CONFIG_BUG Adrian Hunter
2024-04-10 17:02 ` Naresh Kamboju
2024-04-11  7:04 ` Arnd Bergmann
2024-04-11  7:16   ` Adrian Hunter
2024-04-11  7:56     ` Arnd Bergmann
2024-04-11  9:03       ` Adrian Hunter
2024-04-11 10:27         ` David Laight
2024-04-11  8:13     ` Christophe Leroy
2024-04-11  8:22       ` Christophe Leroy
2024-04-11  9:27         ` Adrian Hunter
2024-04-11 11:26           ` Arnd Bergmann
2024-04-15  2:19             ` Michael Ellerman
2024-04-15 15:35               ` Arnd Bergmann
2024-04-15 17:07                 ` Christophe Leroy
2024-04-15 17:32                   ` Arnd Bergmann

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