Skip to content

Commit 5284984

Browse files
ahunter6KAGA-KOKO
authored andcommitted
bug: Fix no-return-statement warning with !CONFIG_BUG
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: e8e9d21 ("timekeeping: Refactor timekeeping helpers") Reported-by: Naresh Kamboju <[email protected]> Signed-off-by: Adrian Hunter <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Linux Kernel Functional Testing <[email protected]> Link: https://lore.kernel.org/r/[email protected] Closes: https://lore.kernel.org/all/CA+G9fYvjdZCW=7ZGxS6A_3bysjQ56YF7S-+PNLQ_8a4DKh1Bhg@mail.gmail.com/
1 parent f87cbcb commit 5284984

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/asm-generic/bug.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...);
156156

157157
#else /* !CONFIG_BUG */
158158
#ifndef HAVE_ARCH_BUG
159-
#define BUG() do {} while (1)
159+
#define BUG() do { \
160+
do {} while (1); \
161+
unreachable(); \
162+
} while (0)
160163
#endif
161164

162165
#ifndef HAVE_ARCH_BUG_ON

0 commit comments

Comments
 (0)