Skip to contentSkip to conversation

target-ppc: Fix compiler warning

PATCH Applied Stefan Weil 3 participants 3 messages Jun 17, 2014 – Jun 21, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-ppc: Fix compiler warning

gcc reports a warning which is usually wrong:

target-ppc/dfp_helper.c: In function ‘dfp_get_digit’:
target-ppc/dfp_helper.c:417:1: warning:
control reaches end of non-void function [-Wreturn-type]

The compiler shows the warning if assert is not marked with the noreturn attribute or if the code is compiled with -DNDEBUG.

Using g_assert_not_reached better documents the intention and does not have these problems.

---
 target-ppc/dfp_helper.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
target-ppc/dfp_helper.c +1 -2
index 773803a..49820bf 100644
@@ -411,9 +411,8 @@ static inline int dfp_get_digit(decNumber *dn, int n)
         return (dn->lsu[unit] / 10) % 10;
     case 2:
         return dn->lsu[unit] / 100;
-    default:
-        assert(0);
     }
+    g_assert_not_reached();
 }
 
 #define DFP_HELPER_TAB(op, dnop, postprocs, size)                              \
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Stefan Weil

gcc reports a warning which is usually wrong:

target-ppc/dfp_helper.c: In function ‘dfp_get_digit’:
target-ppc/dfp_helper.c:417:1: warning:
control reaches end of non-void function [-Wreturn-type]

Quoted 7 lines

The compiler shows the warning if assert is not marked with the noreturn attribute or if the code is compiled with -DNDEBUG.

Using g_assert_not_reached better documents the intention and does not have these problems.

Please take it via -trivial.

Alex

#2 lore raw
In reply to Stefan Weil
Quoted 1 line · Stefan Weil

gcc reports a warning which is usually wrong:

[]

Quoted 2 lines

Using g_assert_not_reached better documents the intention and does not have these problems.

Applied to -trivial, thanks!

/mjt