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 - use __unreachable() and move 'break's...
details: https://anonhg.NetBSD.org/src/rev/6d76af687069
branches: trunk
changeset: 448535:6d76af687069
user: mrg <mrg%NetBSD.org@localhost>
date: Mon Feb 04 22:07:41 2019 +0000
description:
- use __unreachable() and move 'break's around to increase consistency
and correctness
ok kamil@
diffstat:
common/lib/libc/misc/ubsan.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diffs (99 lines):
diff -r 020f7834f2ab -r 6d76af687069 common/lib/libc/misc/ubsan.c
--- a/common/lib/libc/misc/ubsan.c Mon Feb 04 22:00:51 2019 +0000
+++ b/common/lib/libc/misc/ubsan.c Mon Feb 04 22:07:41 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ubsan.c,v 1.3 2018/08/03 16:31:04 kamil Exp $ */
+/* $NetBSD: ubsan.c,v 1.4 2019/02/04 22:07:41 mrg 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.3 2018/08/03 16:31:04 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.4 2019/02/04 22:07:41 mrg Exp $");
#else
-__RCSID("$NetBSD: ubsan.c,v 1.3 2018/08/03 16:31:04 kamil Exp $");
+__RCSID("$NetBSD: ubsan.c,v 1.4 2019/02/04 22:07:41 mrg Exp $");
#endif
#if defined(_KERNEL)
@@ -1236,6 +1236,7 @@
break;
default:
Report(true, "UBSan: Unknown variable type %#04" PRIx16 "\n", pType->mTypeKind);
+ __unreachable();
/* NOTREACHED */
}
@@ -1418,15 +1419,17 @@
switch (zNumberWidth) {
default:
Report(true, "UBSan: Unexpected %zu-Bit Type in %s\n", zNumberWidth, szLocation);
+ __unreachable();
/* NOTREACHED */
case WIDTH_128:
#ifdef __SIZEOF_INT128__
memcpy(&L, REINTERPRET_CAST(longest *, ulNumber), sizeof(longest));
+ break;
#else
Report(true, "UBSan: Unexpected 128-Bit Type in %s\n", szLocation);
+ __unreachable();
/* NOTREACHED */
#endif
- break;
case WIDTH_64:
if (sizeof(ulNumber) * CHAR_BIT < WIDTH_64) {
L = *REINTERPRET_CAST(int64_t *, ulNumber);
@@ -1460,6 +1463,7 @@
switch (zNumberWidth) {
default:
Report(true, "UBSan: Unexpected %zu-Bit Type in %s\n", zNumberWidth, szLocation);
+ __unreachable();
/* NOTREACHED */
case WIDTH_128:
#ifdef __SIZEOF_INT128__
@@ -1467,6 +1471,7 @@
break;
#else
Report(true, "UBSan: Unexpected 128-Bit Type in %s\n", szLocation);
+ __unreachable();
/* NOTREACHED */
#endif
case WIDTH_64:
@@ -1503,6 +1508,7 @@
switch (zNumberWidth) {
default:
Report(true, "UBSan: Unexpected %zu-Bit Type in %s\n", zNumberWidth, szLocation);
+ __unreachable();
/* NOTREACHED */
#ifdef __HAVE_LONG_DOUBLE
case WIDTH_128:
@@ -1516,6 +1522,7 @@
DeserializeFloatOverPointer(pBuffer, zBUfferLength, pType, REINTERPRET_CAST(unsigned long *, ulNumber));
break;
}
+ /* FALLTHROUGH */
case WIDTH_32:
case WIDTH_16:
DeserializeFloatInlined(pBuffer, zBUfferLength, pType, ulNumber);
@@ -1546,15 +1553,16 @@
case KIND_FLOAT:
#ifdef _KERNEL
Report(true, "UBSan: Unexpected Float Type in %s\n", szLocation);
+ __unreachable();
/* NOTREACHED */
#else
DeserializeNumberFloat(szLocation, pBuffer, zBUfferLength, pType, ulNumber);
+ break;
#endif
- break;
case KIND_UNKNOWN:
Report(true, "UBSan: Unknown Type in %s\n", szLocation);
+ __unreachable();
/* NOTREACHED */
- break;
}
}
Home |
Main Index |
Thread Index |
Old Index