From fc500b96eb4f3e5fde618634230eee85adad5a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 28 Mar 2022 12:59:43 +0200 Subject: [PATCH] Consistenly use UNREACHABLE() instead of ISC_UNREACHABLE() In couple places, we have missed INSIST(0) or ISC_UNREACHABLE() replacement on some branches with UNREACHABLE(). Replace all ISC_UNREACHABLE() or INSIST(0) calls with UNREACHABLE(). --- bin/tests/test_client.c | 2 +- bin/tests/test_server.c | 2 +- cocci/unreachable.spatch | 6 ++++++ lib/dns/rpz.c | 4 ++-- lib/isc/netmgr/netmgr.c | 4 +--- lib/isc/rwlock.c | 2 +- lib/ns/query.c | 2 +- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/bin/tests/test_client.c b/bin/tests/test_client.c index bd5e543b6d..ee62a6dfb9 100644 --- a/bin/tests/test_client.c +++ b/bin/tests/test_client.c @@ -232,7 +232,7 @@ parse_options(int argc, char **argv) { break; default: - INSIST(0); + UNREACHABLE(); } } diff --git a/bin/tests/test_server.c b/bin/tests/test_server.c index a5b8833963..19b0638309 100644 --- a/bin/tests/test_server.c +++ b/bin/tests/test_server.c @@ -152,7 +152,7 @@ parse_options(int argc, char **argv) { break; default: - INSIST(0); + UNREACHABLE(); } } diff --git a/cocci/unreachable.spatch b/cocci/unreachable.spatch index 100f1a0abe..84c0c344bb 100644 --- a/cocci/unreachable.spatch +++ b/cocci/unreachable.spatch @@ -11,3 +11,9 @@ - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); + +@@ +@@ + +- UNREACHABLE(); + UNREACHABLE(); diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index 7f9f7eb924..92eda66b9f 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -2604,7 +2604,7 @@ dns_rpz_find_ip(dns_rpz_zones_t *rpzs, dns_rpz_type_t rpz_type, zbits &= have.nsipv4; break; default: - INSIST(0); + UNREACHABLE(); break; } } else if (netaddr->family == AF_INET6) { @@ -2630,7 +2630,7 @@ dns_rpz_find_ip(dns_rpz_zones_t *rpzs, dns_rpz_type_t rpz_type, zbits &= have.nsipv6; break; default: - INSIST(0); + UNREACHABLE(); break; } } else { diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index e8c2c71b6a..dd7147a55e 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -2285,7 +2285,7 @@ isc__nm_process_sock_buffer(isc_nmsocket_t *sock) { } break; default: - INSIST(0); + UNREACHABLE(); } } } @@ -2818,7 +2818,6 @@ isc__nmsocket_reset(isc_nmsocket_t *sock) { REQUIRE(sock->parent == NULL); break; default: - INSIST(0); UNREACHABLE(); break; } @@ -3544,7 +3543,6 @@ isc_nm_set_maxage(isc_nmhandle_t *handle, const uint32_t ttl) { case isc_nm_tlssocket: #endif /* HAVE_LIBNGHTTP2 */ default: - INSIST(0); UNREACHABLE(); break; } diff --git a/lib/isc/rwlock.c b/lib/isc/rwlock.c index c76ea74dda..2691a44de4 100644 --- a/lib/isc/rwlock.c +++ b/lib/isc/rwlock.c @@ -82,7 +82,7 @@ isc_rwlock_trylock(isc_rwlock_t *rwl, isc_rwlocktype_t type) { } break; default: - INSIST(0); + UNREACHABLE(); } switch (ret) { diff --git a/lib/ns/query.c b/lib/ns/query.c index 739f1b6688..4740e7225d 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -293,7 +293,7 @@ get_hooktab(query_ctx_t *qctx) { result = _res; \ goto cleanup; \ default: \ - INSIST(0); \ + UNREACHABLE(); \ } \ } \ } while (false)