From: Ondřej Surý Date: Mon, 11 Oct 2021 10:50:17 +0000 (+0200) Subject: Simplify way we tag unreachable code with only ISC_UNREACHABLE() X-Git-Tag: v9.19.0~48^2~3 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=584f0d7a7e89f4681b78dee157f7a2807812023a;p=thirdparty%2Fbind9.git Simplify way we tag unreachable code with only ISC_UNREACHABLE() Previously, the unreachable code paths would have to be tagged with: INSIST(0); ISC_UNREACHABLE(); There was also older parts of the code that used comment annotation: /* NOTREACHED */ Unify the handling of unreachable code paths to just use: UNREACHABLE(); The UNREACHABLE() macro now asserts when reached and also uses __builtin_unreachable(); when such builtin is available in the compiler. --- diff --git a/bin/check/named-checkconf.c b/bin/check/named-checkconf.c index 0594ed157e3..06fd59cb8d2 100644 --- a/bin/check/named-checkconf.c +++ b/bin/check/named-checkconf.c @@ -306,8 +306,7 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig, zone_options &= ~DNS_ZONEOPT_CHECKDUPRR; zone_options &= ~DNS_ZONEOPT_CHECKDUPRRFAIL; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } else { zone_options |= DNS_ZONEOPT_CHECKDUPRR; @@ -326,8 +325,7 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig, zone_options &= ~DNS_ZONEOPT_CHECKMX; zone_options &= ~DNS_ZONEOPT_CHECKMXFAIL; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } else { zone_options |= DNS_ZONEOPT_CHECKMX; @@ -357,8 +355,7 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig, zone_options |= DNS_ZONEOPT_WARNMXCNAME; zone_options |= DNS_ZONEOPT_IGNOREMXCNAME; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } else { zone_options |= DNS_ZONEOPT_WARNMXCNAME; @@ -377,8 +374,7 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig, zone_options |= DNS_ZONEOPT_WARNSRVCNAME; zone_options |= DNS_ZONEOPT_IGNORESRVCNAME; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } else { zone_options |= DNS_ZONEOPT_WARNSRVCNAME; @@ -401,8 +397,7 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig, } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { zone_options &= ~DNS_ZONEOPT_CHECKSPF; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } else { zone_options |= DNS_ZONEOPT_CHECKSPF; @@ -420,8 +415,7 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig, zone_options &= ~DNS_ZONEOPT_CHECKNAMES; zone_options &= ~DNS_ZONEOPT_CHECKNAMESFAIL; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } else { zone_options |= DNS_ZONEOPT_CHECKNAMES; @@ -437,8 +431,7 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig, } else if (strcasecmp(masterformatstr, "raw") == 0) { masterformat = dns_masterformat_raw; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/bin/check/named-checkzone.c b/bin/check/named-checkzone.c index 80cdfb55d38..ffee5bcd776 100644 --- a/bin/check/named-checkzone.c +++ b/bin/check/named-checkzone.c @@ -147,8 +147,7 @@ main(int argc, char **argv) { } else if (PROGCMP("named-compilezone")) { progmode = progmode_compile; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } /* Compilation specific defaults */ diff --git a/bin/confgen/tsig-keygen.c b/bin/confgen/tsig-keygen.c index a0d0764112f..b34d099faa7 100644 --- a/bin/confgen/tsig-keygen.c +++ b/bin/confgen/tsig-keygen.c @@ -121,8 +121,7 @@ main(int argc, char **argv) { } else if (PROGCMP("ddns-confgen")) { progmode = progmode_confgen; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc_commandline_errprint = false; diff --git a/bin/delv/delv.c b/bin/delv/delv.c index be77cb1f538..360b9839797 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -1325,7 +1325,7 @@ dash_option(char *option, char *next, bool *open_type_class) { case 'h': usage(); exit(0); - /* NOTREACHED */ + UNREACHABLE(); case 'i': no_sigs = true; root_validation = false; @@ -1336,10 +1336,9 @@ dash_option(char *option, char *next, bool *open_type_class) { case 'v': printf("delv %s\n", PACKAGE_VERSION); exit(0); - /* NOTREACHED */ + UNREACHABLE(); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (strlen(option) > 1U) { option = &option[1]; @@ -1477,7 +1476,7 @@ dash_option(char *option, char *next, bool *open_type_class) { fprintf(stderr, "Invalid option: -%s\n", option); usage(); } - /* NOTREACHED */ + UNREACHABLE(); return (false); } diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 4421df9d5db..7a7c648d8ec 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -2115,7 +2115,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, have_ipv6 = false; } else { fatal("can't find IPv4 networking"); - /* NOTREACHED */ + UNREACHABLE(); return (false); } break; @@ -2125,7 +2125,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, have_ipv4 = false; } else { fatal("can't find IPv6 networking"); - /* NOTREACHED */ + UNREACHABLE(); return (false); } break; @@ -2377,7 +2377,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, fprintf(stderr, "Invalid option: -%s\n", option); usage(); } - /* NOTREACHED */ + UNREACHABLE(); return (false); } diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index fa813901c7d..7b68d252ee5 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -2468,8 +2468,7 @@ setup_lookup(dig_lookup_t *lookup) { memmove(addr, &sin6->sin6_addr, addrl); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc_buffer_init(&b, ecsbuf, sizeof(ecsbuf)); diff --git a/bin/dnssec/dnssec-keyfromlabel.c b/bin/dnssec/dnssec-keyfromlabel.c index 233e12bc113..eca8f86b81c 100644 --- a/bin/dnssec/dnssec-keyfromlabel.c +++ b/bin/dnssec/dnssec-keyfromlabel.c @@ -616,7 +616,7 @@ main(int argc, char **argv) { dns_secalg_format(alg, algstr, sizeof(algstr)); fatal("failed to get key %s/%s: %s", namestr, algstr, isc_result_totext(ret)); - /* NOTREACHED */ + UNREACHABLE(); exit(-1); } diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 207c861a5d5..2cceda3fce0 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -461,7 +461,7 @@ expecttofindkey(dns_name_t *name) { dns_name_format(name, namestr, sizeof(namestr)); fatal("failure looking for '%s DNSKEY' in database: %s", namestr, isc_result_totext(result)); - /* NOTREACHED */ + UNREACHABLE(); return (false); /* removes a warning */ } diff --git a/bin/dnssec/dnssectool.c b/bin/dnssec/dnssectool.c index 38e21c7b764..c0d5d997911 100644 --- a/bin/dnssec/dnssectool.c +++ b/bin/dnssec/dnssectool.c @@ -217,7 +217,7 @@ time_units(isc_stdtime_t offset, char *suffix, const char *str) { default: fatal("time value %s is invalid", str); } - /* NOTREACHED */ + UNREACHABLE(); break; case 'W': case 'w': @@ -235,7 +235,7 @@ time_units(isc_stdtime_t offset, char *suffix, const char *str) { default: fatal("time value %s is invalid", str); } - /* NOTREACHED */ + UNREACHABLE(); return (0); /* silence compiler warning */ } diff --git a/bin/named/config.c b/bin/named/config.c index e11163834d5..7c6ad5dc8b8 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -453,8 +453,7 @@ named_config_getzonetype(const cfg_obj_t *zonetypeobj) { } else if (strcasecmp(str, "redirect") == 0) { ztype = dns_zone_redirect; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } return (ztype); } @@ -1066,8 +1065,7 @@ named_config_getkeyalgorithm2(const char *str, const dns_name_t **name, *name = dns_tsig_hmacsha512_name; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } if (typep != NULL) { diff --git a/bin/named/logconf.c b/bin/named/logconf.c index af3b4045d91..5fd0904f43f 100644 --- a/bin/named/logconf.c +++ b/bin/named/logconf.c @@ -161,8 +161,7 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) { maxoffset = 0x7fffffffffffffffULL; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } type = ISC_LOG_TOFILE; diff --git a/bin/named/main.c b/bin/named/main.c index e7ed4936127..bb4c08bb1ba 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -728,8 +728,7 @@ parse_port(char *arg) { named_g_httpport = port; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/bin/named/server.c b/bin/named/server.c index 19590f64496..831955fef1e 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -866,8 +866,7 @@ ta_fromconfig(const cfg_obj_t *key, bool *initialp, const char **namestrp, break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } return (ISC_R_SUCCESS); @@ -1273,8 +1272,7 @@ get_view_querysource_dispatch(const cfg_obj_t **maps, int af, INSIST(result == ISC_R_SUCCESS); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } sa = *(cfg_obj_assockaddr(obj)); @@ -1296,8 +1294,7 @@ get_view_querysource_dispatch(const cfg_obj_t **maps, int af, result = isc_net_probeipv6(); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (result != ISC_R_SUCCESS) { return (ISC_R_SUCCESS); @@ -1401,8 +1398,7 @@ configure_order(dns_order_t *order, const cfg_obj_t *ent) { } else if (!strcasecmp(str, "none")) { mode = DNS_RDATASETATTR_NONE; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } /* @@ -1558,8 +1554,7 @@ configure_peer(const cfg_obj_t *cpeer, isc_mem_t *mctx, dns_peer_t **peerp) { } else if (strcasecmp(str, "one-answer") == 0) { CHECK(dns_peer_settransferformat(peer, dns_one_answer)); } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -2933,7 +2928,7 @@ catz_create_chg_task(dns_catz_entry_t *entry, dns_catz_zone_t *origin, break; default: REQUIRE(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } event = (catz_chgzone_event_t *)isc_event_allocate( @@ -4329,8 +4324,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config, } else if (strcasecmp(str, "ignore") == 0) { view->checknames = false; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } obj = NULL; @@ -4784,8 +4778,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config, } else if (strcasecmp(resp, "fail") == 0) { r = DNS_R_SERVFAIL; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } dns_resolver_setquotaresponse(view->resolver, @@ -5184,8 +5177,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config, } else if (strcasecmp(str, "no-auth-recursive") == 0) { view->minimalresponses = dns_minimal_noauthrec; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -5198,8 +5190,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config, } else if (strcasecmp(str, "one-answer") == 0) { view->transfer_format = dns_one_answer; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } obj = NULL; @@ -5511,8 +5502,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config, } else if (strcasecmp(resp, "fail") == 0) { r = DNS_R_SERVFAIL; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } dns_resolver_setquotaresponse(view->resolver, @@ -5739,8 +5729,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config, } else if (strcasecmp(levelstr, "none") == 0) { statlevel = dns_zonestat_none; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -6281,8 +6270,7 @@ configure_forward(const cfg_obj_t *config, dns_view_t *view, } else if (strcasecmp(forwardstr, "only") == 0) { fwdpolicy = dns_fwdpolicy_only; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } } @@ -9575,8 +9563,7 @@ load_configuration(const char *filename, named_server_t *server, } else if (strcasecmp(cfg_obj_asstring(obj), "aes") == 0) { server->sctx->cookiealg = ns_cookiealg_aes; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } obj = NULL; @@ -13654,8 +13641,7 @@ newzone_parse(named_server_t *server, char *command, dns_view_t **viewp, } else if (strncasecmp(command, "mod", 3) == 0) { bn = "modzone"; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } /* @@ -16350,8 +16336,7 @@ named_server_mkeys(named_server_t *server, isc_lex_t *lex, CHECK(mkey_destroy(server, view, text)); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (viewtxt != NULL) { diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 55f2f358543..9a363b30c31 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -133,8 +133,7 @@ configure_zone_acl(const cfg_obj_t *zconfig, const cfg_obj_t *vconfig, aclname = "allow-update-forwarding"; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } /* First check to see if ACL is defined within the zone */ @@ -246,8 +245,7 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone, } else if (strcasecmp(str, "deny") == 0) { grant = false; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } str = cfg_obj_asstring(matchtype); @@ -759,8 +757,7 @@ checknames(dns_zonetype_t ztype, const cfg_obj_t **maps, result = named_checknames_get(maps, primary_synonyms, objp); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } INSIST(result == ISC_R_SUCCESS && objp != NULL && *objp != NULL); @@ -1041,8 +1038,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } else if (strcasecmp(masterformatstr, "raw") == 0) { masterformat = dns_masterformat_raw; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -1065,8 +1061,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } else if (strcasecmp(masterstylestr, "relative") == 0) { masterstyle = &dns_master_style_default; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -1159,8 +1154,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } else if (strcasecmp(dialupstr, "passive") == 0) { dialup = dns_dialuptype_passive; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } if (raw != NULL) { @@ -1186,8 +1180,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } else if (strcasecmp(levelstr, "none") == 0) { statlevel = dns_zonestat_none; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } dns_zone_setstatlevel(zone, statlevel); @@ -1266,8 +1259,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, { notifytype = dns_notifytype_masteronly; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } notifytype = process_notifytype(notifytype, ztype, zname, @@ -1460,8 +1452,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { fail = check = false; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (raw != NULL) { dns_zone_setoption(raw, DNS_ZONEOPT_CHECKNAMES, check); @@ -1495,8 +1486,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { check = false; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } dns_zone_setoption(zone, DNS_ZONEOPT_CHECKSPF, check); @@ -1696,8 +1686,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } else if (strcasecmp(arg, "off") == 0) { /* Default */ } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } dns_zone_setkeyopt(zone, DNS_ZONEKEY_ALLOW, allow); dns_zone_setkeyopt(zone, DNS_ZONEKEY_CREATE, false); @@ -1756,8 +1745,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } else if (strcasecmp(dupcheck, "ignore") == 0) { fail = check = false; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKDUPRR, check); dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKDUPRRFAIL, fail); @@ -1773,8 +1761,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { fail = check = false; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKMX, check); dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKMXFAIL, fail); @@ -1796,8 +1783,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { warn = ignore = true; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } dns_zone_setoption(mayberaw, DNS_ZONEOPT_WARNMXCNAME, warn); dns_zone_setoption(mayberaw, DNS_ZONEOPT_IGNOREMXCNAME, ignore); @@ -1813,8 +1799,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { warn = ignore = true; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } dns_zone_setoption(mayberaw, DNS_ZONEOPT_WARNSRVCNAME, warn); dns_zone_setoption(mayberaw, DNS_ZONEOPT_IGNORESRVCNAME, @@ -1837,8 +1822,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } else if (strcasecmp(arg, "maintain") == 0) { /* Default */ } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index 178120d90d8..4c43e39ba00 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -592,8 +592,7 @@ rndc_startconnect(isc_sockaddr_t *addr) { */ fatal("UNIX domain sockets not currently supported"); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } atomic_fetch_add_relaxed(&connects, 1); diff --git a/bin/tests/system/rpz/dnsrps.c b/bin/tests/system/rpz/dnsrps.c index dfbe76147f8..4f8890873df 100644 --- a/bin/tests/system/rpz/dnsrps.c +++ b/bin/tests/system/rpz/dnsrps.c @@ -83,8 +83,7 @@ main(int argc, char **argv) { #ifdef USE_DNSRPS printf("%s\n", librpz->dnsrpzd_path); #else /* ifdef USE_DNSRPS */ - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); #endif /* ifdef USE_DNSRPS */ return (0); @@ -134,8 +133,7 @@ main(int argc, char **argv) { librpz->client_detach(&client); printf("%u\n", serial); #else /* ifdef USE_DNSRPS */ - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); #endif /* ifdef USE_DNSRPS */ return (0); diff --git a/bin/tests/test_client.c b/bin/tests/test_client.c index 5ba259087ec..bd5e543b6d5 100644 --- a/bin/tests/test_client.c +++ b/bin/tests/test_client.c @@ -432,8 +432,7 @@ run(void) { } break; #endif default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } waitforsignal(); diff --git a/bin/tests/test_server.c b/bin/tests/test_server.c index affa92614e5..a5b88339637 100644 --- a/bin/tests/test_server.c +++ b/bin/tests/test_server.c @@ -302,8 +302,7 @@ run(void) { } break; #endif default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } REQUIRE(result == ISC_R_SUCCESS); diff --git a/bin/tests/wire_test.c b/bin/tests/wire_test.c index 3944e3b00b9..9f50981f046 100644 --- a/bin/tests/wire_test.c +++ b/bin/tests/wire_test.c @@ -58,7 +58,7 @@ fromhex(char c) { fprintf(stderr, "bad input format: %02x\n", c); exit(3); - /* NOTREACHED */ + UNREACHABLE(); } static void diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index a8dd85da38c..af395826b93 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -1698,7 +1698,7 @@ dash_option(const char *option, char *next, struct query *query, bool global, have_ipv6 = false; } else { fatal("can't find IPv4 networking"); - /* NOTREACHED */ + UNREACHABLE(); return (false); } break; @@ -1709,7 +1709,7 @@ dash_option(const char *option, char *next, struct query *query, bool global, have_ipv4 = false; } else { fatal("can't find IPv6 networking"); - /* NOTREACHED */ + UNREACHABLE(); return (false); } break; @@ -1817,7 +1817,7 @@ dash_option(const char *option, char *next, struct query *query, bool global, fprintf(stderr, "Invalid option: -%s\n", option); usage(); } - /* NOTREACHED */ + UNREACHABLE(); return (false); } diff --git a/cocci/unreachable.spatch b/cocci/unreachable.spatch index 0cc368a5164..100f1a0abe1 100644 --- a/cocci/unreachable.spatch +++ b/cocci/unreachable.spatch @@ -1,6 +1,13 @@ @@ @@ - INSIST(0); -+ ISC_UNREACHABLE(); - ... when != ISC_UNREACHABLE(); +- INSIST(0); ++ UNREACHABLE(); + ... when != UNREACHABLE(); + +@@ +@@ + +- INSIST(0); +- ISC_UNREACHABLE(); ++ UNREACHABLE(); diff --git a/contrib/dlz/modules/wildcard/dlz_wildcard_dynamic.c b/contrib/dlz/modules/wildcard/dlz_wildcard_dynamic.c index 9edcffe9ce1..3cb3ee1106d 100644 --- a/contrib/dlz/modules/wildcard/dlz_wildcard_dynamic.c +++ b/contrib/dlz/modules/wildcard/dlz_wildcard_dynamic.c @@ -699,7 +699,7 @@ fnmatch(const char *pattern, const char *string, int flags) { break; } } - /* NOTREACHED */ + UNREACHABLE(); } static int diff --git a/doc/dev/style.md b/doc/dev/style.md index 3a71b859958..7551211c024 100644 --- a/doc/dev/style.md +++ b/doc/dev/style.md @@ -142,12 +142,10 @@ Good: static char * c /* Description of 'c'. */ -The following lint and lint-like comments should be used where appropriate: +The following macros should be used where appropriate: - /* ARGSUSED */ FALLTHROUGH; - /* NOTREACHED */ - /* VARARGS */ + UNREACHABLE(); #### Header files diff --git a/lib/bind9/check.c b/lib/bind9/check.c index 556bfb6faf8..5ced085ac4c 100644 --- a/lib/bind9/check.c +++ b/lib/bind9/check.c @@ -2654,8 +2654,7 @@ check_update_policy(const cfg_obj_t *policy, isc_log_t *logctx) { } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } for (element2 = cfg_list_first(typelist); element2 != NULL; @@ -3054,8 +3053,7 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions, break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/lib/dns/acl.c b/lib/dns/acl.c index 1dfbf33675c..f38ce3b64bd 100644 --- a/lib/dns/acl.c +++ b/lib/dns/acl.c @@ -464,8 +464,7 @@ dns_aclelement_match(const isc_netaddr_t *reqaddr, const dns_name_t *reqsigner, return (dns_geoip_match(reqaddr, env->geoip, &e->geoip_elem)); #endif /* if defined(HAVE_GEOIP2) */ default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } result = dns_acl_match(reqaddr, reqsigner, inner, env, &indirectmatch, @@ -658,8 +657,7 @@ dns_acl_isinsecure(const dns_acl_t *a) { return (true); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/lib/dns/diff.c b/lib/dns/diff.c index 9c2a2516f73..f5f7cef11c9 100644 --- a/lib/dns/diff.c +++ b/lib/dns/diff.c @@ -372,8 +372,7 @@ diff_apply(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver, bool warn) { &ardataset); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (result == ISC_R_SUCCESS) { diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 0fcac79d3c9..c7e683b9316 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -1543,8 +1543,7 @@ dispatch_getnext(dns_dispatch_t *disp, dns_dispentry_t *resp, int32_t timeout) { break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -1710,8 +1709,7 @@ startrecv(isc_nmhandle_t *handle, dns_dispatch_t *disp, dns_dispentry_t *resp) { break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -1838,8 +1836,7 @@ dns_dispatch_connect(dns_dispentry_t *resp) { break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } break; diff --git a/lib/dns/dnsrps.c b/lib/dns/dnsrps.c index 9ff55b27a43..30b7052b3ed 100644 --- a/lib/dns/dnsrps.c +++ b/lib/dns/dnsrps.c @@ -311,8 +311,7 @@ dns_dnsrps_2policy(librpz_policy_t rps_policy) { case LIBRPZ_POLICY_GIVEN: case LIBRPZ_POLICY_DISABLED: default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/lib/dns/dnstap.c b/lib/dns/dnstap.c index 44e5f6e160e..e013ec27fab 100644 --- a/lib/dns/dnstap.c +++ b/lib/dns/dnstap.c @@ -635,8 +635,7 @@ dnstap_type(dns_dtmsgtype_t msgtype) { case DNS_DTTYPE_UR: return (DNSTAP__MESSAGE__TYPE__UPDATE_RESPONSE); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -985,8 +984,7 @@ dns_dt_open(const char *filename, dns_dtmode_t mode, isc_mem_t *mctx, result = ISC_R_NOTIMPLEMENTED; goto cleanup; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc_mem_attach(mctx, &handle->mctx); diff --git a/lib/dns/ds.c b/lib/dns/ds.c index 7b39d853001..22f158bd71e 100644 --- a/lib/dns/ds.c +++ b/lib/dns/ds.c @@ -63,8 +63,7 @@ dns_ds_fromkeyrdata(const dns_name_t *owner, dns_rdata_t *key, break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } name = dns_fixedname_initname(&fname); diff --git a/lib/dns/ecs.c b/lib/dns/ecs.c index ae88c4713e1..8dbf720f64e 100644 --- a/lib/dns/ecs.c +++ b/lib/dns/ecs.c @@ -66,8 +66,7 @@ dns_ecs_equals(const dns_ecs_t *ecs1, const dns_ecs_t *ecs2) { addr2 = (const unsigned char *)&ecs2->addr.type.in6; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } /* diff --git a/lib/dns/hmac_link.c b/lib/dns/hmac_link.c index 244e1f15774..5764a0ff072 100644 --- a/lib/dns/hmac_link.c +++ b/lib/dns/hmac_link.c @@ -370,8 +370,7 @@ hmac__get_tag_key(const isc_md_type_t *type) { } else if (type == ISC_MD_SHA512) { return (TAG_HMACSHA512_KEY); } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -390,8 +389,7 @@ hmac__get_tag_bits(const isc_md_type_t *type) { } else if (type == ISC_MD_SHA512) { return (TAG_HMACSHA512_BITS); } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -443,8 +441,7 @@ hmac__to_dst_alg(const isc_md_type_t *type) { } else if (type == ISC_MD_SHA512) { return (DST_ALG_HMACSHA512); } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/lib/dns/journal.c b/lib/dns/journal.c index 89ac28c4f92..d9aee371c6c 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -825,8 +825,7 @@ ixfr_order(const void *av, const void *bv) { aop = 0; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } switch (b->op) { @@ -839,8 +838,7 @@ ixfr_order(const void *av, const void *bv) { bop = 0; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } r = bop - aop; diff --git a/lib/dns/keymgr.c b/lib/dns/keymgr.c index 6bc11dbb62c..660b8cd26f1 100644 --- a/lib/dns/keymgr.c +++ b/lib/dns/keymgr.c @@ -1366,8 +1366,7 @@ keymgr_transition_time(dns_dnsseckey_t *key, int type, } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); break; } diff --git a/lib/dns/master.c b/lib/dns/master.c index 020e4a1b8d3..a9cfe4d4fa5 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -540,8 +540,7 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx, unsigned int options, lctx->load = load_raw; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (lex != NULL) { diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index ae2e815c866..e2743de8065 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -1580,8 +1580,7 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, dctx->dumpsets = dump_rdatasets_raw; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } result = totext_ctx_init(style, NULL, &dctx->tctx); @@ -1701,8 +1700,7 @@ writeheader(dns_dumpctx_t *dctx) { break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc_mem_put(dctx->mctx, buffer.base, buffer.length); diff --git a/lib/dns/message.c b/lib/dns/message.c index 04a33452262..31d92a96ca7 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -883,8 +883,7 @@ getname(dns_name_t *name, isc_buffer_t *source, dns_message_t *msg, } } - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } static isc_result_t diff --git a/lib/dns/name.c b/lib/dns/name.c index 2a8f9a5d771..d9d55eb4f15 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -1475,7 +1475,7 @@ dns_name_totext2(const dns_name_t *name, unsigned int options, } else { FATAL_ERROR(__FILE__, __LINE__, "Unexpected label type %02x", count); - /* NOTREACHED */ + UNREACHABLE(); } /* @@ -1599,7 +1599,7 @@ dns_name_tofilenametext(const dns_name_t *name, bool omit_final_dot, } else { FATAL_ERROR(__FILE__, __LINE__, "Unexpected label type %02x", count); - /* NOTREACHED */ + UNREACHABLE(); } /* diff --git a/lib/dns/opensslecdsa_link.c b/lib/dns/opensslecdsa_link.c index f1cb63eb0ef..519e88b7e7a 100644 --- a/lib/dns/opensslecdsa_link.c +++ b/lib/dns/opensslecdsa_link.c @@ -1153,8 +1153,7 @@ dst__key_to_eckey(dst_key_t *key, EC_KEY **eckey) { group_nid = NID_secp384r1; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } *eckey = EC_KEY_new_by_curve_name(group_nid); diff --git a/lib/dns/opensslrsa_link.c b/lib/dns/opensslrsa_link.c index 2e39bf69e21..be1998e3819 100644 --- a/lib/dns/opensslrsa_link.c +++ b/lib/dns/opensslrsa_link.c @@ -83,8 +83,7 @@ opensslrsa_createctx(dst_key_t *key, dst_context_t *dctx) { } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } evp_md_ctx = EVP_MD_CTX_create(); @@ -104,8 +103,7 @@ opensslrsa_createctx(dst_key_t *key, dst_context_t *dctx) { type = EVP_sha512(); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (!EVP_DigestInit_ex(evp_md_ctx, type, NULL)) { @@ -426,8 +424,7 @@ opensslrsa_generate(dst_key_t *key, int exp, void (*callback)(int)) { } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (exp == 0) { diff --git a/lib/dns/peer.c b/lib/dns/peer.c index 2ada8416558..bac2624e09f 100644 --- a/lib/dns/peer.c +++ b/lib/dns/peer.c @@ -251,8 +251,7 @@ dns_peer_new(isc_mem_t *mem, const isc_netaddr_t *addr, dns_peer_t **peerptr) { prefixlen = 128; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } return (dns_peer_newprefix(mem, addr, prefixlen, peerptr)); diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c index 9ebe4e50f26..fd6fb1f4277 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -1805,8 +1805,7 @@ nexttable: } /* We haven't found any matching node, this should not be possible. */ - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } static inline void diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 8757fbd5ab0..79c65ae9cea 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -4440,7 +4440,7 @@ zone_findzonecut(dns_db_t *db, const dns_name_t *name, unsigned int options, FATAL_ERROR(__FILE__, __LINE__, "zone_findzonecut() called!"); - /* NOTREACHED */ + UNREACHABLE(); return (ISC_R_NOTIMPLEMENTED); } @@ -7606,8 +7606,7 @@ nodecount(dns_db_t *db, dns_dbtree_t tree) { count = dns_rbt_nodecount(rbtdb->nsec3); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } RWUNLOCK(&rbtdb->tree_lock, isc_rwlocktype_read); diff --git a/lib/dns/rdata/generic/amtrelay_260.c b/lib/dns/rdata/generic/amtrelay_260.c index 020cfcf06d8..54e08ba6629 100644 --- a/lib/dns/rdata/generic/amtrelay_260.c +++ b/lib/dns/rdata/generic/amtrelay_260.c @@ -116,8 +116,7 @@ fromtext_amtrelay(ARGS_FROMTEXT) { return (dns_name_fromtext(&name, &buffer, origin, options, target)); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -178,8 +177,7 @@ totext_amtrelay(ARGS_TOTEXT) { return (dns_name_totext(&name, false, target)); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/generic/loc_29.c b/lib/dns/rdata/generic/loc_29.c index 4c203a4de32..d6632e61494 100644 --- a/lib/dns/rdata/generic/loc_29.c +++ b/lib/dns/rdata/generic/loc_29.c @@ -272,8 +272,7 @@ loc_getlatitude(isc_lex_t *lexer, unsigned long *latitude) { *latitude = 0x80000000 - (d1 * 3600 + m1 * 60) * 1000 - s1; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } return (ISC_R_SUCCESS); @@ -294,8 +293,7 @@ loc_getlongitude(isc_lex_t *lexer, unsigned long *longitude) { *longitude = 0x80000000 - (d2 * 3600 + m2 * 60) * 1000 - s2; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } return (ISC_R_SUCCESS); diff --git a/lib/dns/rdata/in_1/svcb_64.c b/lib/dns/rdata/in_1/svcb_64.c index b2b8657b970..848505269be 100644 --- a/lib/dns/rdata/in_1/svcb_64.c +++ b/lib/dns/rdata/in_1/svcb_64.c @@ -322,8 +322,7 @@ svc_fromtext(isc_textregion_t *region, isc_buffer_t *target) { RETERR(svcsortkeylist(target, used)); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } len = isc_buffer_usedlength(target) - @@ -732,8 +731,7 @@ generic_totext_in_svcb(ARGS_TOTEXT) { } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } return (ISC_R_SUCCESS); diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 5865b8a4d64..4d910a640e9 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -2323,8 +2323,7 @@ addr2buf(void *buf, const size_t bufsize, const isc_sockaddr_t *sockaddr) { memmove(buf, &netaddr.type.in6, 16); return (16); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } return (0); } @@ -7088,8 +7087,7 @@ is_answertarget_allowed(fetchctx_t *fctx, dns_name_t *qname, dns_name_t *rname, RUNTIME_CHECK(result == ISC_R_SUCCESS); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (chainingp != NULL) { diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index 0f316308dda..d03330dca0c 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -280,8 +280,7 @@ dns_rpz_policy2str(dns_rpz_policy_t policy) { str = "DNS64"; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } return (str); } @@ -345,8 +344,7 @@ make_addr_set(dns_rpz_addr_zbits_t *tgt_set, dns_rpz_zbits_t zbits, tgt_set->nsip = zbits; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -363,8 +361,7 @@ make_nm_set(dns_rpz_nm_zbits_t *tgt_set, dns_rpz_num_t rpz_num, tgt_set->ns = DNS_RPZ_ZBIT(rpz_num); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -619,8 +616,7 @@ adj_trigger_cnt(dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (inc) { @@ -2658,8 +2654,7 @@ dns_rpz_find_ip(dns_rpz_zones_t *rpzs, dns_rpz_type_t rpz_type, rpz_num = zbit_to_num(found->set.nsip & tgt_set.nsip); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } result = ip2name(&found->ip, found->prefix, dns_rootname, ip_name); RWUNLOCK(&rpzs->search_lock, isc_rwlocktype_read); diff --git a/lib/dns/rrl.c b/lib/dns/rrl.c index 142b47fd1d1..9d3c8f6fa34 100644 --- a/lib/dns/rrl.c +++ b/lib/dns/rrl.c @@ -482,8 +482,7 @@ get_rate(dns_rrl_t *rrl, dns_rrl_rtype_t rtype) { case DNS_RRL_RTYPE_ALL: return (&rrl->all_per_second); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -852,8 +851,7 @@ make_log_buf(dns_rrl_t *rrl, dns_rrl_entry_t *e, const char *str1, ADD_LOG_CSTR(&lb, "slip "); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } switch (e->key.s.rtype) { @@ -881,8 +879,7 @@ make_log_buf(dns_rrl_t *rrl, dns_rrl_entry_t *e, const char *str1, ADD_LOG_CSTR(&lb, "all "); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (plural) { diff --git a/lib/dns/sdb.c b/lib/dns/sdb.c index 54e9b48018b..2608c294c22 100644 --- a/lib/dns/sdb.c +++ b/lib/dns/sdb.c @@ -1069,8 +1069,7 @@ expirenode(dns_db_t *db, dns_dbnode_t *node, isc_stdtime_t now) { UNUSED(db); UNUSED(node); UNUSED(now); - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } static void diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index ba50846794d..9b2af6d0ed9 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -736,8 +736,7 @@ expirenode(dns_db_t *db, dns_dbnode_t *node, isc_stdtime_t now) { UNUSED(db); UNUSED(node); UNUSED(now); - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } static void diff --git a/lib/dns/ssu.c b/lib/dns/ssu.c index a254c610f4a..92db924469f 100644 --- a/lib/dns/ssu.c +++ b/lib/dns/ssu.c @@ -227,8 +227,7 @@ reverse_from_address(dns_name_t *tcpself, const isc_netaddr_t *tcpaddr) { RUNTIME_CHECK(result < sizeof(buf)); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc_buffer_init(&b, buf, strlen(buf)); isc_buffer_add(&b, strlen(buf)); @@ -269,8 +268,7 @@ stf_from_address(dns_name_t *stfself, const isc_netaddr_t *tcpaddr) { RUNTIME_CHECK(result < sizeof(buf)); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc_buffer_init(&b, buf, strlen(buf)); isc_buffer_add(&b, strlen(buf)); diff --git a/lib/dns/tests/dnstest.c b/lib/dns/tests/dnstest.c index 47ff71644d9..e3da9d47856 100644 --- a/lib/dns/tests/dnstest.c +++ b/lib/dns/tests/dnstest.c @@ -372,7 +372,7 @@ fromhex(char c) { printf("bad input format: %02x\n", c); exit(3); - /* NOTREACHED */ + UNREACHABLE(); } /* diff --git a/lib/dns/tests/geoip_test.c b/lib/dns/tests/geoip_test.c index 2523c7b8f0c..abe64f9e4e5 100644 --- a/lib/dns/tests/geoip_test.c +++ b/lib/dns/tests/geoip_test.c @@ -120,8 +120,7 @@ entry_exists(dns_geoip_subtype_t subtype, const char *addr) { } else if (inet_pton(AF_INET, addr, &in4) == 1) { isc_netaddr_fromin(&na, &in4); } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } db = geoip2_database(&geoip, fix_subtype(&geoip, subtype)); diff --git a/lib/dns/transport.c b/lib/dns/transport.c index 7937f2d2104..e7fbb70ac3c 100644 --- a/lib/dns/transport.c +++ b/lib/dns/transport.c @@ -327,8 +327,7 @@ dns_transport_get_prefer_server_ciphers(const dns_transport_t *transport, return (true); } - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); return false; } diff --git a/lib/dns/tsec.c b/lib/dns/tsec.c index 6127cf34e9b..fcb761348bc 100644 --- a/lib/dns/tsec.c +++ b/lib/dns/tsec.c @@ -91,8 +91,7 @@ dns_tsec_create(isc_mem_t *mctx, dns_tsectype_t type, dst_key_t *key, tsec->ukey.key = key; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } tsec->magic = DNS_TSEC_MAGIC; @@ -118,8 +117,7 @@ dns_tsec_destroy(dns_tsec_t **tsecp) { dst_key_free(&tsec->ukey.key); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } tsec->magic = 0; @@ -146,7 +144,6 @@ dns_tsec_getkey(dns_tsec_t *tsec, void *keyp) { *(dst_key_t **)keyp = tsec->ukey.key; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/lib/dns/update.c b/lib/dns/update.c index 610643b8071..9241b1cad65 100644 --- a/lib/dns/update.c +++ b/lib/dns/update.c @@ -1970,8 +1970,7 @@ next_state: state->keyset_kskonly)); sigs++; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } ISC_LIST_UNLINK(state->nsec_mindiff.tuples, t, link); ISC_LIST_APPEND(state->work.tuples, t, link); @@ -2145,8 +2144,7 @@ next_state: state->keyset_kskonly)); sigs++; } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } ISC_LIST_UNLINK(state->nsec_mindiff.tuples, t, link); ISC_LIST_APPEND(state->work.tuples, t, link); @@ -2173,8 +2171,7 @@ next_state: INSIST(ISC_LIST_EMPTY(state->nsec_mindiff.tuples)); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } failure: @@ -2234,8 +2231,7 @@ dns__update_soaserial(uint32_t serial, dns_updatemethod_t method) { } return (serial); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -2266,8 +2262,7 @@ dns_update_soaserial(uint32_t serial, dns_updatemethod_t method, } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (used != NULL) { diff --git a/lib/dns/validator.c b/lib/dns/validator.c index 5014e500fb1..64f876f807e 100644 --- a/lib/dns/validator.c +++ b/lib/dns/validator.c @@ -3085,8 +3085,7 @@ validator_start(isc_task_t *task, isc_event_t *event) { result = validate_nx(val, false); } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (result != DNS_R_WAIT) { diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 2136cb7fc5e..5df10d3dede 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -682,8 +682,7 @@ redo: FAIL(DNS_R_EXTRADATA); FALLTHROUGH; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } result = ISC_R_SUCCESS; failure: @@ -1029,8 +1028,7 @@ xfrin_start(dns_xfrin_ctx_t *xfr) { connect_xfr, 30000, 0, tlsctx); } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } return (ISC_R_SUCCESS); diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 58f17334700..646bfd1f5da 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -10135,8 +10135,7 @@ normalize_key(dns_rdata_t *rr, dns_rdata_t *target, unsigned char *data, &dnskey, &buf); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } return (ISC_R_SUCCESS); } @@ -18176,8 +18175,7 @@ got_transfer_quota(isc_task_t *task, isc_event_t *event) { } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } UNLOCK_ZONE(zone); INSIST(isc_sockaddr_pf(&primaryaddr) == isc_sockaddr_pf(&sourceaddr)); @@ -19952,8 +19950,7 @@ dns_zone_setdialup(dns_zone_t *zone, dns_dialuptype_t dialup) { DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NOREFRESH); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } UNLOCK_ZONE(zone); } @@ -20035,8 +20032,7 @@ dns_zonemgr_getcount(dns_zonemgr_t *zmgr, int state) { } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } RWUNLOCK(&zmgr->rwlock, isc_rwlocktype_read); diff --git a/lib/isc/app.c b/lib/isc/app.c index d5bf097e99b..d02371c9500 100644 --- a/lib/isc/app.c +++ b/lib/isc/app.c @@ -245,8 +245,7 @@ isc_app_ctxrun(isc_appctx_t *ctx) { true); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } } else { diff --git a/lib/isc/assertions.c b/lib/isc/assertions.c index 5470d81715a..8b954cf475e 100644 --- a/lib/isc/assertions.c +++ b/lib/isc/assertions.c @@ -48,7 +48,6 @@ isc_assertion_failed(const char *file, int line, isc_assertiontype_t type, const char *cond) { isc_assertion_failed_cb(file, line, type, cond); abort(); - /* NOTREACHED */ } /*% Set callback. */ diff --git a/lib/isc/include/isc/assertions.h b/lib/isc/include/isc/assertions.h index 7045179cbaf..d5dbced8534 100644 --- a/lib/isc/include/isc/assertions.h +++ b/lib/isc/include/isc/assertions.h @@ -66,4 +66,9 @@ isc_assertion_typetotext(isc_assertiontype_t type); isc_assertiontype_invariant, #cond), \ 0))) +#define ISC_UNREACHABLE() \ + (isc_assertion_failed(__FILE__, __LINE__, isc_assertiontype_insist, \ + "unreachable"), \ + __builtin_unreachable()) + ISC_LANG_ENDDECLS diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index d0cd0197d38..63d3af340c4 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -218,12 +218,6 @@ * Performance */ -#ifdef HAVE_BUILTIN_UNREACHABLE -#define ISC_UNREACHABLE() __builtin_unreachable(); -#else /* ifdef HAVE_BUILTIN_UNREACHABLE */ -#define ISC_UNREACHABLE() -#endif /* ifdef HAVE_BUILTIN_UNREACHABLE */ - /* GCC defines __SANITIZE_ADDRESS__, so reuse the macro for clang */ #if __has_feature(address_sanitizer) #define __SANITIZE_ADDRESS__ 1 @@ -278,6 +272,8 @@ mock_assert(const int result, const char *const expression, ((!(expression)) \ ? (mock_assert(0, #expression, __FILE__, __LINE__), abort()) \ : (void)0) +#define UNREACHABLE() \ + (mock_assert(0, "unreachable", __FILE__, __LINE__), abort()) #define _assert_true(c, e, f, l) \ ((c) ? (void)0 : (_assert_true(0, e, f, l), abort())) #define _assert_int_equal(a, b, f, l) \ @@ -300,6 +296,8 @@ mock_assert(const int result, const char *const expression, /*% Invariant Assertion */ #define INVARIANT(e) ISC_INVARIANT(e) +#define UNREACHABLE() ISC_UNREACHABLE() + #endif /* UNIT_TESTING */ /* diff --git a/lib/isc/interfaceiter.c b/lib/isc/interfaceiter.c index 54b13eba65b..abb16f4b6da 100644 --- a/lib/isc/interfaceiter.c +++ b/lib/isc/interfaceiter.c @@ -125,8 +125,7 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src, } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/lib/isc/log.c b/lib/isc/log.c index f41c39237dd..95c3e6b05d6 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -707,8 +707,7 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name, break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } ISC_LIST_PREPEND(lcfg->channels, channel, link); diff --git a/lib/isc/mem.c b/lib/isc/mem.c index f21954b65af..ea6d4cc95e5 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -319,8 +319,7 @@ delete_trace_entry(isc_mem_t *mctx, const void *ptr, size_t size, * If we get here, we didn't find the item on the list. We're * screwed. */ - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); unlock: MCTXUNLOCK(mctx); } @@ -1436,8 +1435,7 @@ isc__mem_checkdestroyed(void) { print_contexts(file); } #endif /* if ISC_MEM_TRACKLINES */ - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } UNLOCK(&contextslock); } diff --git a/lib/isc/net.c b/lib/isc/net.c index 9a720837607..5525762d93a 100644 --- a/lib/isc/net.c +++ b/lib/isc/net.c @@ -506,8 +506,7 @@ cmsgsend(int s, int level, int type, struct addrinfo *res) { break; #endif /* ifdef IPV6_TCLASS */ default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (sendmsg(s, &msg, 0) < 0) { diff --git a/lib/isc/netaddr.c b/lib/isc/netaddr.c index 9ccf12e74b6..940fbf0370c 100644 --- a/lib/isc/netaddr.c +++ b/lib/isc/netaddr.c @@ -352,8 +352,7 @@ isc_netaddr_fromsockaddr(isc_netaddr_t *t, const isc_sockaddr_t *s) { t->zone = 0; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/lib/isc/netmgr/http.c b/lib/isc/netmgr/http.c index 0d06c1b9020..d09ad5b8c7a 100644 --- a/lib/isc/netmgr/http.c +++ b/lib/isc/netmgr/http.c @@ -2107,8 +2107,7 @@ server_on_request_recv(nghttp2_session *ngsession, INSIST(socket->h2.content_length > 0); isc_buffer_usedregion(&socket->h2.rbuf, &data); } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } server_call_cb(socket, session, ISC_R_SUCCESS, &data); @@ -2671,8 +2670,7 @@ isc__nm_http_stoplistening(isc_nmsocket_t *sock) { if (!atomic_compare_exchange_strong(&sock->closing, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (!isc__nm_in_netthread()) { diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 4216b5c24b1..122e5e84a20 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -521,8 +521,7 @@ isc__netmgr_destroy(isc_nm_t **netmgrp) { #ifdef NETMGR_TRACE if (isc_refcount_current(&mgr->references) > 1) { isc__nm_dump_active(mgr); - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } #endif @@ -720,8 +719,7 @@ process_all_queues(isc__networker_t *worker) { reschedule = true; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -793,8 +791,7 @@ isc__nm_async_task(isc__networker_t *worker, isc__netievent_t *ev0) { case ISC_R_SUCCESS: return; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -922,8 +919,7 @@ process_netievent(isc__networker_t *worker, isc__netievent_t *ievent) { NETIEVENT_CASE(resume); NETIEVENT_CASE_NOMORE(pause); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } return (true); } @@ -1074,8 +1070,7 @@ isc__nm_enqueue_ievent(isc__networker_t *worker, isc__netievent_t *event) { } else { switch (event->type) { case netievent_prio: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); break; case netievent_privilegedtask: type = NETIEVENT_PRIVILEGED; @@ -1462,8 +1457,7 @@ isc___nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr, isc_nmsocket_type type, */ break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } break; case isc_nm_tcpsocket: @@ -1482,8 +1476,7 @@ isc___nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr, isc_nmsocket_type type, sock->statsindex = tcp6statsindex; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } break; default: @@ -1921,8 +1914,7 @@ isc__nm_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result, bool async) { isc__nm_tlsdns_failed_read_cb(sock, result, async); return; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -2142,8 +2134,7 @@ isc__nm_alloc_cb(uv_handle_t *handle, size_t size, uv_buf_t *buf) { buf->len = ISC_NETMGR_TCP_RECVBUF_SIZE; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } REQUIRE(buf->len <= ISC_NETMGR_RECVBUF_SIZE); @@ -2182,8 +2173,7 @@ isc__nm_start_reading(isc_nmsocket_t *sock) { UV_RUNTIME_CHECK(uv_read_start, r); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } atomic_store(&sock->reading, true); } @@ -2208,8 +2198,7 @@ isc__nm_stop_reading(isc_nmsocket_t *sock) { UV_RUNTIME_CHECK(uv_read_stop, r); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } atomic_store(&sock->reading, false); } @@ -2234,8 +2223,7 @@ processbuffer(isc_nmsocket_t *sock) { case isc_nm_tlsdnssocket: return (isc__nm_tlsdns_processbuffer(sock)); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -2514,8 +2502,7 @@ isc_nm_send(isc_nmhandle_t *handle, isc_region_t *region, isc_nm_cb_t cb, break; #endif default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -2545,8 +2532,7 @@ isc_nm_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg) { break; #endif default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -2573,8 +2559,7 @@ isc_nm_cancelread(isc_nmhandle_t *handle) { break; #endif default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -2594,8 +2579,7 @@ isc_nm_pauseread(isc_nmhandle_t *handle) { break; #endif default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -2615,8 +2599,7 @@ isc_nm_resumeread(isc_nmhandle_t *handle) { break; #endif default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -2646,8 +2629,7 @@ isc_nm_stoplistening(isc_nmsocket_t *sock) { break; #endif default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -2828,7 +2810,7 @@ isc__nmsocket_reset(isc_nmsocket_t *sock) { break; default: INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); break; } @@ -2870,8 +2852,7 @@ isc__nmsocket_shutdown(isc_nmsocket_t *sock) { case isc_nm_tlsdnslistener: return; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -3348,8 +3329,7 @@ isc__nm_set_network_buffers(isc_nm_t *nm, uv_handle_t *handle) { atomic_load_relaxed(&nm->send_udp_buffer_size); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (recv_buffer_size > 0) { @@ -3457,8 +3437,7 @@ isc_nm_bad_request(isc_nmhandle_t *handle) { case isc_nm_tlssocket: #endif /* HAVE_LIBNGHTTP2 */ default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); break; } } @@ -3481,8 +3460,7 @@ isc_nm_xfr_allowed(isc_nmhandle_t *handle) { return (false); } - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); return (false); } @@ -3526,7 +3504,7 @@ isc_nm_set_maxage(isc_nmhandle_t *handle, const uint32_t ttl) { #endif /* HAVE_LIBNGHTTP2 */ default: INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); break; } } @@ -3602,8 +3580,7 @@ nmsocket_type_totext(isc_nmsocket_type type) { case isc_nm_httpsocket: return ("isc_nm_httpsocket"); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index 85edea5df6b..9fc80c4d20f 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -647,8 +647,7 @@ isc__nm_tcp_stoplistening(isc_nmsocket_t *sock) { if (!atomic_compare_exchange_strong(&sock->closing, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (!isc__nm_in_netthread()) { @@ -1158,8 +1157,7 @@ tcp_stop_cb(uv_handle_t *handle) { if (!atomic_compare_exchange_strong(&sock->closed, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc__nm_incstats(sock, STATID_CLOSE); @@ -1177,8 +1175,7 @@ tcp_close_sock(isc_nmsocket_t *sock) { if (!atomic_compare_exchange_strong(&sock->closed, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc__nm_incstats(sock, STATID_CLOSE); diff --git a/lib/isc/netmgr/tcpdns.c b/lib/isc/netmgr/tcpdns.c index a0d7961ff80..53c2f30ff2b 100644 --- a/lib/isc/netmgr/tcpdns.c +++ b/lib/isc/netmgr/tcpdns.c @@ -613,8 +613,7 @@ isc__nm_tcpdns_stoplistening(isc_nmsocket_t *sock) { if (!atomic_compare_exchange_strong(&sock->closing, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (!isc__nm_in_netthread()) { @@ -1210,8 +1209,7 @@ tcpdns_stop_cb(uv_handle_t *handle) { if (!atomic_compare_exchange_strong(&sock->closed, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc__nm_incstats(sock, STATID_CLOSE); @@ -1229,8 +1227,7 @@ tcpdns_close_sock(isc_nmsocket_t *sock) { if (!atomic_compare_exchange_strong(&sock->closed, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc__nm_incstats(sock, STATID_CLOSE); diff --git a/lib/isc/netmgr/tlsdns.c b/lib/isc/netmgr/tlsdns.c index 1347666232d..4864fcc477b 100644 --- a/lib/isc/netmgr/tlsdns.c +++ b/lib/isc/netmgr/tlsdns.c @@ -685,8 +685,7 @@ isc__nm_tlsdns_stoplistening(isc_nmsocket_t *sock) { if (!atomic_compare_exchange_strong(&sock->closing, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (!isc__nm_in_netthread()) { @@ -760,8 +759,7 @@ isc__nm_async_tlsdnsshutdown(isc__networker_t *worker, isc__netievent_t *ev0) { tls_shutdown(sock); return; case 0: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); case SSL_ERROR_ZERO_RETURN: tls_error(sock, ISC_R_EOF); break; @@ -1737,8 +1735,7 @@ tlsdns_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) { case SSL_ERROR_WANT_READ: break; case 0: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); default: return (ISC_R_TLSERROR); } @@ -1764,8 +1761,7 @@ tlsdns_stop_cb(uv_handle_t *handle) { if (!atomic_compare_exchange_strong(&sock->closed, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc__nm_incstats(sock, STATID_CLOSE); @@ -1788,8 +1784,7 @@ tlsdns_close_sock(isc_nmsocket_t *sock) { if (!atomic_compare_exchange_strong(&sock->closed, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc__nm_incstats(sock, STATID_CLOSE); diff --git a/lib/isc/netmgr/tlsstream.c b/lib/isc/netmgr/tlsstream.c index 6df651f2048..252b52da9f5 100644 --- a/lib/isc/netmgr/tlsstream.c +++ b/lib/isc/netmgr/tlsstream.c @@ -856,8 +856,7 @@ isc__nm_tls_stoplistening(isc_nmsocket_t *sock) { if (!atomic_compare_exchange_strong(&sock->closing, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } atomic_store(&sock->listening, false); diff --git a/lib/isc/netmgr/udp.c b/lib/isc/netmgr/udp.c index 1067f015331..3a43cd3b84d 100644 --- a/lib/isc/netmgr/udp.c +++ b/lib/isc/netmgr/udp.c @@ -516,8 +516,7 @@ isc__nm_udp_stoplistening(isc_nmsocket_t *sock) { if (!atomic_compare_exchange_strong(&sock->closing, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } if (!isc__nm_in_netthread()) { @@ -1175,8 +1174,7 @@ udp_stop_cb(uv_handle_t *handle) { if (!atomic_compare_exchange_strong(&sock->closed, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc__nm_incstats(sock, STATID_CLOSE); @@ -1197,8 +1195,7 @@ udp_close_cb(uv_handle_t *handle) { if (!atomic_compare_exchange_strong(&sock->closed, &(bool){ false }, true)) { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc__nm_incstats(sock, STATID_CLOSE); diff --git a/lib/isc/rwlock.c b/lib/isc/rwlock.c index 4c11feb5181..c76ea74dda3 100644 --- a/lib/isc/rwlock.c +++ b/lib/isc/rwlock.c @@ -62,8 +62,7 @@ isc_rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) { } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } return (ISC_R_SUCCESS); } @@ -94,8 +93,7 @@ isc_rwlock_trylock(isc_rwlock_t *rwl, isc_rwlocktype_t type) { case EAGAIN: return (ISC_R_LOCKBUSY); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/lib/isc/siphash.c b/lib/isc/siphash.c index 0f83ef5f2e6..1a863ff8e1d 100644 --- a/lib/isc/siphash.c +++ b/lib/isc/siphash.c @@ -142,8 +142,7 @@ isc_siphash24(const uint8_t *k, const uint8_t *in, const size_t inlen, case 0: break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } v3 ^= b; @@ -208,8 +207,7 @@ isc_halfsiphash24(const uint8_t *k, const uint8_t *in, const size_t inlen, case 0: break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } v3 ^= b; diff --git a/lib/isc/sockaddr.c b/lib/isc/sockaddr.c index e2f363ef1bc..85b3d284394 100644 --- a/lib/isc/sockaddr.c +++ b/lib/isc/sockaddr.c @@ -295,8 +295,7 @@ isc_sockaddr_anyofpf(isc_sockaddr_t *sockaddr, int pf) { isc_sockaddr_any6(sockaddr); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -366,8 +365,7 @@ isc_sockaddr_fromnetaddr(isc_sockaddr_t *sockaddr, const isc_netaddr_t *na, sockaddr->type.sin6.sin6_port = htons(port); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } ISC_LINK_INIT(sockaddr, link); } diff --git a/lib/isc/timer.c b/lib/isc/timer.c index 720f972260b..f833000601f 100644 --- a/lib/isc/timer.c +++ b/lib/isc/timer.c @@ -118,7 +118,7 @@ schedule(isc_timer_t *timer, isc_time_t *now, bool signal_ok) { break; default: INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } /* @@ -426,7 +426,7 @@ dispatch(isc_timermgr_t *manager, isc_time_t *now) { break; default: INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } timer->index = 0; diff --git a/lib/isc/tls.c b/lib/isc/tls.c index a726d94aeb3..b71cdd6aade 100644 --- a/lib/isc/tls.c +++ b/lib/isc/tls.c @@ -511,8 +511,7 @@ get_tls_version_disable_bit(const isc_tls_protocol_version_t tls_ver) { #endif break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); break; }; diff --git a/lib/isc/url.c b/lib/isc/url.c index 8758496e5b0..7f618743410 100644 --- a/lib/isc/url.c +++ b/lib/isc/url.c @@ -596,8 +596,7 @@ isc_url_parse(const char *buf, size_t buflen, bool is_connect, break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } /* Nothing's changed; soldier on */ diff --git a/lib/isccc/sexpr.c b/lib/isccc/sexpr.c index c703710c46e..62c80c46ed4 100644 --- a/lib/isccc/sexpr.c +++ b/lib/isccc/sexpr.c @@ -211,8 +211,7 @@ isccc_sexpr_print(isccc_sexpr_t *sexpr, FILE *stream) { } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/lib/isccfg/aclconf.c b/lib/isccfg/aclconf.c index d03dc40fe32..716ffe6cee0 100644 --- a/lib/isccfg/aclconf.c +++ b/lib/isccfg/aclconf.c @@ -399,8 +399,7 @@ get_subtype(const cfg_obj_t *obj, isc_log_t *lctx, dns_geoip_subtype_t subtype, } return (subtype); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index 36e20cd1b28..203e066926c 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -3172,8 +3172,7 @@ parse_querysource(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { } else if ((*flagp & CFG_ADDR_V6OK) != 0) { isc_netaddr_any6(&netaddr); } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } for (;;) { @@ -3258,8 +3257,7 @@ doc_querysource(cfg_printer_t *pctx, const cfg_type_t *type) { } else if ((*flagp & CFG_ADDR_V6OK) != 0) { cfg_print_cstr(pctx, ""); } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } cfg_print_cstr(pctx, " | * ) [ port ( | * ) ] ) | " "( [ [ address ] ( "); @@ -3268,8 +3266,7 @@ doc_querysource(cfg_printer_t *pctx, const cfg_type_t *type) { } else if ((*flagp & CFG_ADDR_V6OK) != 0) { cfg_print_cstr(pctx, ""); } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } cfg_print_cstr(pctx, " | * ) ] port ( | * ) ) )" " [ dscp ]"); @@ -3893,8 +3890,7 @@ cfg_print_zonegrammar(const unsigned int zonetype, unsigned int flags, /* no zone type is specified for these */ break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } for (clause = clauses; clause->name != NULL; clause++) { diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 1b4e164725a..eeea6e77904 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -423,8 +423,7 @@ cfg_tuple_get(const cfg_obj_t *tupleobj, const char *name) { return (tupleobj->value.tuple[i]); } } - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc_result_t @@ -2679,8 +2678,7 @@ cfg_print_mapbody(cfg_printer_t *pctx, const cfg_obj_t *obj) { } else if (result == ISC_R_NOTFOUND) { /* do nothing */ } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } } @@ -3015,8 +3013,7 @@ token_addr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na) { isc_netaddr_any6(na); return (ISC_R_SUCCESS); } else { - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } else { if ((flags & (CFG_ADDR_V4OK | CFG_ADDR_V4PREFIXOK)) != 0) { @@ -3294,8 +3291,7 @@ cfg_parse_netprefix(cfg_parser_t *pctx, const cfg_type_t *type, addrlen = 128; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } expectprefix = (result == ISC_R_IPV4PREFIX); CHECK(cfg_peektoken(pctx, 0)); diff --git a/lib/ns/client.c b/lib/ns/client.c index b0fa0c40e99..27fdffb15fb 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -678,8 +678,7 @@ renderend: ISC_MIN((int)respsize / 16, 256)); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } else { #ifdef HAVE_DNSTAP @@ -708,8 +707,7 @@ renderend: ISC_MIN((int)respsize / 16, 256)); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -1072,8 +1070,7 @@ no_nsid: memmove(addr, &client->ecs.addr.type, addrl); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc_buffer_init(&buf, ecs, sizeof(ecs)); @@ -1193,8 +1190,7 @@ compute_cookie(ns_client_t *client, uint32_t when, uint32_t nonce, inputlen = 32; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } isc_siphash24(secret, input, inputlen, digest); @@ -1235,8 +1231,7 @@ compute_cookie(ns_client_t *client, uint32_t when, uint32_t nonce, digest); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } for (i = 0; i < 8; i++) { digest[i] ^= digest[i + 8]; @@ -1246,8 +1241,7 @@ compute_cookie(ns_client_t *client, uint32_t when, uint32_t nonce, } default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } @@ -1871,8 +1865,7 @@ ns__client_request(isc_nmhandle_t *handle, isc_result_t eresult, ISC_MIN((int)reqsize / 16, 18)); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } else { switch (isc_sockaddr_pf(&client->peeraddr)) { @@ -1885,8 +1878,7 @@ ns__client_request(isc_nmhandle_t *handle, isc_result_t eresult, ISC_MIN((int)reqsize / 16, 18)); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/lib/ns/query.c b/lib/ns/query.c index 9a661c6d0a2..253baa42d5d 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -2731,8 +2731,7 @@ rpz_get_zbits(ns_client_t *client, dns_rdatatype_t ip_type, } break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } /* @@ -2969,8 +2968,7 @@ rpz_get_p_name(ns_client_t *client, dns_name_t *p_name, dns_rpz_zone_t *rpz, suffix = &rpz->nsip; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } /* @@ -3404,8 +3402,7 @@ dnsrps_rewrite_ip(ns_client_t *client, const isc_netaddr_t *netaddr, recursed = true; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } do { @@ -3455,8 +3452,7 @@ dnsrps_rewrite_name(ns_client_t *client, dns_name_t *trig_name, bool recursed, trig = LIBRPZ_TRIG_NSDNAME; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } dns_name_toregion(trig_name, &r); @@ -7306,8 +7302,7 @@ query_checkrpz(query_ctx_t *qctx, isc_result_t result) { qctx->want_restart = true; return (ISC_R_COMPLETE); default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } /* @@ -9202,8 +9197,7 @@ query_nodata(query_ctx_t *qctx, isc_result_t res) { dns64_ttl(qctx->db, qctx->version); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } SAVE(qctx->client->query.dns64_aaaa, qctx->rdataset); @@ -11602,8 +11596,7 @@ query_setup_sortlist(query_ctx_t *qctx) { case NS_SORTLISTTYPE_NONE: break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } } diff --git a/lib/ns/tests/nstest.c b/lib/ns/tests/nstest.c index 690af2c64be..8158a15aee7 100644 --- a/lib/ns/tests/nstest.c +++ b/lib/ns/tests/nstest.c @@ -919,7 +919,7 @@ fromhex(char c) { printf("bad input format: %02x\n", c); exit(3); - /* NOTREACHED */ + UNREACHABLE(); } isc_result_t diff --git a/lib/ns/tests/query_test.c b/lib/ns/tests/query_test.c index e1b05c61c10..9c8005fa5f9 100644 --- a/lib/ns/tests/query_test.c +++ b/lib/ns/tests/query_test.c @@ -433,8 +433,7 @@ run_start_test(const ns__query_start_test_params_t *test) { test->id.description, test->id.lineno); break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } /* diff --git a/lib/ns/xfrout.c b/lib/ns/xfrout.c index c763db873ed..04388d522cc 100644 --- a/lib/ns/xfrout.c +++ b/lib/ns/xfrout.c @@ -758,8 +758,7 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) { mnemonic = "IXFR"; break; default: - INSIST(0); - ISC_UNREACHABLE(); + UNREACHABLE(); } ns_client_log(client, DNS_LOGCATEGORY_XFER_OUT, NS_LOGMODULE_XFER_OUT,