2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

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.
This commit is contained in:
Ondřej Surý
2021-10-11 12:50:17 +02:00
committed by Ondřej Surý
parent fe7ce629f4
commit 584f0d7a7e
91 changed files with 246 additions and 439 deletions

View File

@@ -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));