Skip to contentSkip to conversation

sh: bug: add unreachable() to silence warnings

PATCH In review Nick Krause 2 participants 2 messages Aug 7, 2014 SuperH

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh: bug: add unreachable() to silence warnings

SuperH BUG() have warnings like

kernel/sched/core.c:2692:1: warning: control reaches end of non-void function [-Wreturn-type]
net/core/ethtool.c:236:1: warning: control reaches end of non-void function [-Wreturn-type]

Other BUG() implementations
have added unreachable() at end becuase of which I guess
it does not showthese errors. We can silence them using unreachable().

---
 arch/sh/include/asm/bug.h | 1 +
 1 file changed, 1 insertion(+)
arch/sh/include/asm/bug.h +1 -0
index dcf2780..1ae948f 100644
@@ -48,6 +48,7 @@ do {							\
 		   "i" (__FILE__),			\
 		   "i" (__LINE__), "i" (0),		\
 		   "i" (sizeof(struct bug_entry)));	\
+	unreachable();					\
 } while (0)
 
 #define __WARN_TAINT(taint)				\
Signature · 1 line
2.0.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Nick Krause

SuperH BUG() have warnings like

kernel/sched/core.c:2692:1: warning: control reaches end of non-void function [-Wreturn-type]
net/core/ethtool.c:236:1: warning: control reaches end of non-void function [-Wreturn-type]

Quoted 5 lines

Other BUG() implementations
have added unreachable() at end becuase of which I guess
it does not showthese errors. We can silence them using unreachable().

This change seems reasonable to me. Unlike the generic version of BUG(), this one doesn't call panic() or anything else flagged as __noreturn, so it seems reasonable to add a call to unreachable() here to tell the compiler that the assembly will trap and not return.

Quoted 18 lines
 arch/sh/include/asm/bug.h | 1 +
 1 file changed, 1 insertion(+)
arch/sh/include/asm/bug.h +1 -0
index dcf2780..1ae948f 100644
@@ -48,6 +48,7 @@ do {							\
 		   "i" (__FILE__),			\
 		   "i" (__LINE__), "i" (0),		\
 		   "i" (sizeof(struct bug_entry)));	\
+	unreachable();					\
 } while (0)
 
 #define __WARN_TAINT(taint)				\
Signature · 1 line
2.0.1