diff mbox

target-ppc: Fix compiler warning

Message ID 1403025508-19171-1-git-send-email-sw@weilnetz.de
State Accepted
Headers show

Commit Message

Stefan Weil June 17, 2014, 5:18 p.m. UTC
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.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 target-ppc/dfp_helper.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Alexander Graf June 17, 2014, 7:40 p.m. UTC | #1
On 17.06.14 19:18, Stefan Weil wrote:
> 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.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>

Reviewed-by: Alexander Graf <agraf@suse.de>

Please take it via -trivial.


Alex
Michael Tokarev June 21, 2014, 12:39 p.m. UTC | #2
17.06.2014 21:18, Stefan Weil wrote:
> gcc reports a warning which is usually wrong:
[]
> Using g_assert_not_reached better documents the intention and does not
> have these problems.

Applied to -trivial, thanks!

/mjt
diff mbox

Patch

diff --git a/target-ppc/dfp_helper.c b/target-ppc/dfp_helper.c
index 773803a..49820bf 100644
--- a/target-ppc/dfp_helper.c
+++ b/target-ppc/dfp_helper.c
@@ -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)                              \