Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/common/lib/libc/misc Fix kUBSan build with GCC7



details:   https://anonhg.NetBSD.org/src/rev/5bd3c7b6e487
branches:  trunk
changeset: 996931:5bd3c7b6e487
user:      kamil <kamil%NetBSD.org@localhost>
date:      Wed Feb 13 17:17:02 2019 +0000

description:
Fix kUBSan build with GCC7

Add missing __unreachable() and FALLTHROUGH keywords.

Reported by <Akul Pillai>

diffstat:

 common/lib/libc/misc/ubsan.c |  22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diffs (106 lines):

diff -r 0e64abc655eb -r 5bd3c7b6e487 common/lib/libc/misc/ubsan.c
--- a/common/lib/libc/misc/ubsan.c      Wed Feb 13 16:06:28 2019 +0000
+++ b/common/lib/libc/misc/ubsan.c      Wed Feb 13 17:17:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ubsan.c,v 1.4 2019/02/04 22:07:41 mrg Exp $    */
+/*     $NetBSD: ubsan.c,v 1.5 2019/02/13 17:17:02 kamil Exp $  */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -38,9 +38,9 @@
 
 #include <sys/cdefs.h>
 #if defined(_KERNEL)
-__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.4 2019/02/04 22:07:41 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.5 2019/02/13 17:17:02 kamil Exp $");
 #else
-__RCSID("$NetBSD: ubsan.c,v 1.4 2019/02/04 22:07:41 mrg Exp $");
+__RCSID("$NetBSD: ubsan.c,v 1.5 2019/02/13 17:17:02 kamil Exp $");
 #endif
 
 #if defined(_KERNEL)
@@ -110,7 +110,7 @@
 
 #define NUMBER_SIGNED_BIT      1U
 
-#if __SIZEOF_INT128__
+#ifdef __SIZEOF_INT128__
 typedef __int128 longest;
 typedef unsigned __int128 ulongest;
 #else
@@ -1192,6 +1192,7 @@
        }
        if (isFatal || ISSET(ubsan_flags, UBSAN_ABORT)) {
                abort();
+               __unreachable();
                /* NOTREACHED */
        }
 #endif
@@ -1291,6 +1292,7 @@
        switch (zDeserializeTypeWidth(pType)) {
        default:
                ASSERT(0 && "Invalid codepath");
+               __unreachable();
                /* NOTREACHED */
 #ifdef __SIZEOF_INT128__
        case WIDTH_128:
@@ -1298,8 +1300,11 @@
                break;
 #endif
        case WIDTH_64:
+               /* FALLTHROUGH */
        case WIDTH_32:
+               /* FALLTHROUGH */
        case WIDTH_16:
+               /* FALLTHROUGH */
        case WIDTH_8:
                snprintf(pBuffer, zBUfferLength, "%" PRId64, STATIC_CAST(int64_t, L));
                break;
@@ -1318,6 +1323,7 @@
        switch (zDeserializeTypeWidth(pType)) {
        default:
                ASSERT(0 && "Invalid codepath");
+               __unreachable();
                /* NOTREACHED */
 #ifdef __SIZEOF_INT128__
        case WIDTH_128:
@@ -1325,8 +1331,11 @@
                break;
 #endif
        case WIDTH_64:
+               /* FALLTHROUGH */
        case WIDTH_32:
+               /* FALLTHROUGH */
        case WIDTH_16:
+               /* FALLTHROUGH */
        case WIDTH_8:
                snprintf(pBuffer, zBUfferLength, "%" PRIu64, STATIC_CAST(uint64_t, L));
                break;
@@ -1358,7 +1367,9 @@
        switch (zDeserializeTypeWidth(pType)) {
 #ifdef __HAVE_LONG_DOUBLE
        case WIDTH_128:
+               /* FALLTHROUGH */
        case WIDTH_96:
+               /* FALLTHROUGH */
        case WIDTH_80:
                memcpy(&LD, pNumber, sizeof(long double));
                snprintf(pBuffer, zBUfferLength, "%Lg", LD);
@@ -1512,7 +1523,9 @@
                /* NOTREACHED */
 #ifdef __HAVE_LONG_DOUBLE
        case WIDTH_128:
+               /* FALLTHROUGH */
        case WIDTH_96:
+               /* FALLTHROUGH */
        case WIDTH_80:
                DeserializeFloatOverPointer(pBuffer, zBUfferLength, pType, REINTERPRET_CAST(unsigned long *, ulNumber));
                break;
@@ -1524,6 +1537,7 @@
                }
                /* FALLTHROUGH */
        case WIDTH_32:
+               /* FALLTHROUGH */
        case WIDTH_16:
                DeserializeFloatInlined(pBuffer, zBUfferLength, pType, ulNumber);
                break;



Home | Main Index | Thread Index | Old Index