]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
kernel: provide panicky version of __unreachable
authorkevans <kevans@FreeBSD.org>
Wed, 13 May 2020 18:07:37 +0000 (18:07 +0000)
committerkevans <kevans@FreeBSD.org>
Wed, 13 May 2020 18:07:37 +0000 (18:07 +0000)
commita185748c6dc02986c19910ab60738fe37afcbb03
tree482bc9b1d4468d4fe52b090605655632d3b00b8e
parent61a651cd8666c8ba2e360ce82f4d9043a0535596
kernel: provide panicky version of __unreachable

__builtin_unreachable doesn't raise any compile-time warnings/errors on its
own, so problems with its usage can't be easily detected. While it would be
nice for this situation to change and compilers to at least add a warning
for trivial cases where local state means the instruction can't be reached,
this isn't the case at the moment and likely will not happen.

This commit adds an __assert_unreachable, whose intent is incredibly clear:
it asserts that this instruction is unreachable. On INVARIANTS builds, it's
a panic(), and on non-INVARIANTS it expands to  __unreachable().

Existing users of __unreachable() are converted to __assert_unreachable,
to improve debuggability if this assumption is violated.

Reviewed by: mjg
Differential Revision: https://reviews.freebsd.org/D23793
sys/ddb/db_expr.c
sys/dev/amdtemp/amdtemp.c
sys/dev/nvdimm/nvdimm.c
sys/dev/ow/ow.c
sys/net/mppcc.c
sys/sys/systm.h
sys/vm/vm_radix.c