From 9d15323e24847d434a0d66e03a20e000e601e129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 4 Jun 2018 13:41:09 +0200 Subject: [PATCH 01/11] Add small tweaks to the code to fix compilation when ISC assertions are disabled While implementing the new unit testing framework cmocka, it was found that the BIND 9 code doesn't compile when assertions are disabled or replaced with any function (such as mock_assert() from cmocka unit testing framework) that's not directly recognized as assertion by the compiler. This made the compiler to complain about blocks of code that was recognized as unreachable before, but now it isn't. The changes in this commit include: * assigns default values to couple of local variables, * moves some return statements around INSIST assertions, * adds __builtin_unreachable(); annotations after some INSIST assertions, * fixes one broken assertion (= instead of ==) (cherry picked from commit fbd2e47f519ab1d6edbd4b9b50a1cebff31217e9) (cherry picked from commit b222783ae90533f2e50cc04e2408ef8d5a9bc869) --- bin/dig/dighost.c | 2 +- bin/named/client.c | 2 +- bin/named/server.c | 10 +++++----- bin/named/zoneconf.c | 2 +- config.h.in | 3 +++ configure | 32 ++++++++++++++++++++++++++++++++ configure.ac | 15 +++++++++++++++ lib/dns/dnstap.c | 1 + lib/dns/master.c | 5 +++-- lib/dns/rpz.c | 7 ++++--- lib/isc/include/isc/util.h | 6 ++++++ lib/isc/pk11.c | 1 + 12 files changed, 73 insertions(+), 13 deletions(-) diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index a3bfca726d..9a9e221a8e 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -2648,7 +2648,7 @@ setup_lookup(dig_lookup_t *lookup) { if (lookup->ecs_addr != NULL) { uint8_t addr[16]; - uint16_t family; + uint16_t family = 0; uint32_t plen; struct sockaddr *sa; struct sockaddr_in *sin; diff --git a/bin/named/client.c b/bin/named/client.c index 0f6e162477..7f1d614a25 100644 --- a/bin/named/client.c +++ b/bin/named/client.c @@ -1638,7 +1638,7 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message, isc_buffer_t buf; uint8_t addr[16]; uint32_t plen, addrl; - uint16_t family; + uint16_t family = 0; /* Add CLIENT-SUBNET option. */ diff --git a/bin/named/server.c b/bin/named/server.c index 7f87ccf042..5ef16a9fd5 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -2361,7 +2361,7 @@ catz_create_chg_task(dns_catz_entry_t *entry, dns_catz_zone_t *origin, catz_chgzone_event_t *event; isc_task_t *task; isc_result_t result; - isc_taskaction_t action; + isc_taskaction_t action = NULL; switch (type) { case DNS_EVENT_CATZADDZONE: @@ -3920,7 +3920,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, obj2 = cfg_tuple_get(obj, "response"); if (!cfg_obj_isvoid(obj2)) { const char *resp = cfg_obj_asstring(obj2); - isc_result_t r; + isc_result_t r = DNS_R_SERVFAIL; if (strcasecmp(resp, "drop") == 0) r = DNS_R_DROP; @@ -4524,7 +4524,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, obj2 = cfg_tuple_get(obj, "response"); if (!cfg_obj_isvoid(obj2)) { const char *resp = cfg_obj_asstring(obj2); - isc_result_t r; + isc_result_t r = DNS_R_SERVFAIL; if (strcasecmp(resp, "drop") == 0) r = DNS_R_DROP; @@ -4775,7 +4775,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, const char *empty_dbtype[4] = { "_builtin", "empty", NULL, NULL }; int empty_dbtypec = 4; - dns_zonestat_level_t statlevel; + dns_zonestat_level_t statlevel = dns_zonestat_none; name = dns_fixedname_initname(&fixed); @@ -12005,7 +12005,7 @@ newzone_parse(ns_server_t *server, char *command, dns_view_t **viewp, const char *viewname = NULL; dns_rdataclass_t rdclass; dns_view_t *view = NULL; - const char *bn; + const char *bn = NULL; REQUIRE(viewp != NULL && *viewp == NULL); REQUIRE(zoneobjp != NULL && *zoneobjp == NULL); diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index e237bdbedf..42773f62ce 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -796,7 +796,7 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, const dns_master_style_t *masterstyle = &dns_master_style_default; isc_stats_t *zoneqrystats; dns_stats_t *rcvquerystats; - dns_zonestat_level_t statlevel; + dns_zonestat_level_t statlevel = dns_zonestat_none; int seconds; dns_zone_t *mayberaw = (raw != NULL) ? raw : zone; isc_dscp_t dscp; diff --git a/config.h.in b/config.h.in index 442483f3b2..b71de76226 100644 --- a/config.h.in +++ b/config.h.in @@ -195,6 +195,9 @@ int sigwait(const unsigned int *set, int *sig); /* Define to 1 if the compiler supports __builtin_expect. */ #undef HAVE_BUILTIN_EXPECT +/* define if the compiler supports __builtin_unreachable(). */ +#undef HAVE_BUILTIN_UNREACHABLE + /* Define to 1 if you have the `chroot' function. */ #undef HAVE_CHROOT diff --git a/configure b/configure index 26b6040546..dc9924df16 100755 --- a/configure +++ b/configure @@ -21372,6 +21372,38 @@ fi ISC_ARCH_DIR=$arch +# +# Check for __builtin_unreachable +# +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking compiler support for __builtin_unreachable()" >&5 +$as_echo_n "checking compiler support for __builtin_unreachable()... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +__builtin_unreachable(); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_BUILTIN_UNREACHABLE 1" >>confdefs.h + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + # # Check for __builtin_expect # diff --git a/configure.ac b/configure.ac index 501969aba7..eb334f1bba 100644 --- a/configure.ac +++ b/configure.ac @@ -4273,6 +4273,21 @@ AC_SUBST(ISC_PLATFORM_USEMACASM) ISC_ARCH_DIR=$arch AC_SUBST(ISC_ARCH_DIR) +# +# Check for __builtin_unreachable +# +AC_MSG_CHECKING([compiler support for __builtin_unreachable()]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[]], + [[__builtin_unreachable();]] + )], + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_BUILTIN_UNREACHABLE], [1], [define if the compiler supports __builtin_unreachable().]) + ], + [AC_MSG_RESULT([no]) + ]) + # # Check for __builtin_expect # diff --git a/lib/dns/dnstap.c b/lib/dns/dnstap.c index ab3bd749d5..d10a14863f 100644 --- a/lib/dns/dnstap.c +++ b/lib/dns/dnstap.c @@ -634,6 +634,7 @@ dnstap_type(dns_dtmsgtype_t msgtype) { return (DNSTAP__MESSAGE__TYPE__TOOL_RESPONSE); default: INSIST(0); + ISC_UNREACHABLE(); } } diff --git a/lib/dns/master.c b/lib/dns/master.c index b9e0a31534..e653d2955f 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -548,8 +548,6 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx, lctx->format = format; switch (format) { - default: - INSIST(0); case dns_masterformat_text: lctx->openfile = openfile_text; lctx->load = load_text; @@ -562,6 +560,9 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx, lctx->openfile = openfile_map; lctx->load = load_map; break; + default: + INSIST(0); + ISC_UNREACHABLE(); } if (lex != NULL) { diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index f0993be086..cd4c95063a 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -550,8 +550,8 @@ adj_trigger_cnt(dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, const dns_rpz_cidr_key_t *tgt_ip, dns_rpz_prefix_t tgt_prefix, bool inc) { - dns_rpz_trigger_counter_t *cnt; - dns_rpz_zbits_t *have; + dns_rpz_trigger_counter_t *cnt = 0; + dns_rpz_zbits_t *have = 0; switch (rpz_type) { case DNS_RPZ_TYPE_CLIENT_IP: @@ -594,6 +594,7 @@ adj_trigger_cnt(dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, break; default: INSIST(0); + ISC_UNREACHABLE(); } if (inc) { @@ -2166,7 +2167,7 @@ dns_rpz_find_ip(dns_rpz_zones_t *rpzs, dns_rpz_type_t rpz_type, dns_rpz_addr_zbits_t tgt_set; dns_rpz_cidr_node_t *found; isc_result_t result; - dns_rpz_num_t rpz_num; + dns_rpz_num_t rpz_num = 0; dns_rpz_have_t have; int i; diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index 75a63c1400..1593a32793 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -203,6 +203,12 @@ */ #include +#ifdef HAVE_BUILTIN_UNREACHABLE +#define ISC_UNREACHABLE() __builtin_unreachable(); +#else +#define ISC_UNREACHABLE() +#endif + /* * Assertions */ diff --git a/lib/isc/pk11.c b/lib/isc/pk11.c index c5d2310e41..0d5b00939e 100644 --- a/lib/isc/pk11.c +++ b/lib/isc/pk11.c @@ -995,6 +995,7 @@ pk11_numbits(CK_BYTE_PTR data, unsigned int bytecnt) { break; } INSIST(0); + ISC_UNREACHABLE(); } CK_ATTRIBUTE * From 12a266211e7b7d51b3f9a5e8c72d13b9c9a99e66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 11 Oct 2018 11:57:57 +0200 Subject: [PATCH 02/11] Turn (int & flag) into (int & flag) != 0 when implicitly typed to bool (cherry picked from commit b2b43fd235b88b24bd68ca21ae6b9e37aad87440) (cherry picked from commit fcd1569e2bc0dbdbfcac78ffac87fc202fd6bd05) --- bin/named/query.c | 5 ++-- bin/named/server.c | 9 +++--- bin/named/xfrout.c | 2 +- lib/dns/adb.c | 7 ++--- lib/dns/client.c | 10 +++---- lib/dns/dispatch.c | 4 +-- lib/dns/dnssec.c | 12 ++++---- lib/dns/dst_api.c | 8 ++--- lib/dns/ecdb.c | 2 +- lib/dns/journal.c | 9 +++--- lib/dns/master.c | 2 +- lib/dns/masterdump.c | 6 ++-- lib/dns/message.c | 8 ++--- lib/dns/name.c | 11 +++---- lib/dns/nsec.c | 2 +- lib/dns/nsec3.c | 13 ++++----- lib/dns/openssl_link.c | 2 +- lib/dns/private.c | 6 ++-- lib/dns/rbtdb.c | 7 +++-- lib/dns/rdata/generic/keydata_65533.c | 8 +++-- lib/dns/rdata/generic/soa_6.c | 8 +++-- lib/dns/request.c | 6 ++-- lib/dns/resolver.c | 10 +++---- lib/dns/rpz.c | 4 +-- lib/dns/sdb.c | 2 +- lib/dns/sdlz.c | 3 +- lib/dns/update.c | 6 ++-- lib/dns/zone.c | 18 +++++++----- lib/irs/getaddrinfo.c | 2 +- lib/irs/getnameinfo.c | 2 +- lib/isc/httpd.c | 2 +- lib/isc/include/isc/radix.h | 2 -- lib/isc/lex.c | 6 ++-- lib/isc/log.c | 18 ++++++------ lib/isc/radix.c | 2 ++ lib/isc/task.c | 4 +-- lib/isc/tests/socket_test.c | 2 +- lib/isc/tests/task_test.c | 2 +- lib/isc/tm.c | 2 +- lib/isc/unix/socket.c | 32 +++++++++++--------- lib/isc/win32/fsaccess.c | 42 ++++++++++++++++++--------- lib/isc/win32/socket.c | 20 ++++++------- lib/isccfg/namedconf.c | 14 +++++---- lib/isccfg/parser.c | 30 ++++++++++--------- 44 files changed, 205 insertions(+), 167 deletions(-) diff --git a/bin/named/query.c b/bin/named/query.c index 1e57bbb5fe..6ebf9608a6 100644 --- a/bin/named/query.c +++ b/bin/named/query.c @@ -9559,7 +9559,7 @@ ns_query_start(ns_client_t *client) { * We don't need to set DNS_DBFIND_PENDINGOK when validation is * disabled as there will be no pending data. */ - if (message->flags & DNS_MESSAGEFLAG_CD || + if ((message->flags & DNS_MESSAGEFLAG_CD) != 0 || qtype == dns_rdatatype_rrsig) { client->query.dboptions |= DNS_DBFIND_PENDINGOK; @@ -9571,8 +9571,9 @@ ns_query_start(ns_client_t *client) { * Allow glue NS records to be added to the authority section * if the answer is secure. */ - if (message->flags & DNS_MESSAGEFLAG_CD) + if ((message->flags & DNS_MESSAGEFLAG_CD) != 0) { client->query.attributes &= ~NS_QUERYATTR_SECURE; + } /* * Set NS_CLIENTATTR_WANTAD if the client has set AD in the query. diff --git a/bin/named/server.c b/bin/named/server.c index 5ef16a9fd5..35af4dafdc 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -8358,7 +8358,8 @@ load_configuration(const char *filename, ns_server_t *server, cfg_map_get(options, "memstatistics", &obj) == ISC_R_SUCCESS) { ns_g_memstatistics = cfg_obj_asboolean(obj); } else { - ns_g_memstatistics = (isc_mem_debugging & ISC_MEM_DEBUGRECORD); + ns_g_memstatistics = + ((isc_mem_debugging & ISC_MEM_DEBUGRECORD) != 0); } obj = NULL; @@ -13442,8 +13443,8 @@ ns_server_zonestatus(ns_server_t *server, isc_lex_t *lex, /* Security */ secure = dns_db_issecure(db); - allow = (dns_zone_getkeyopts(zone) & DNS_ZONEKEY_ALLOW); - maintain = (dns_zone_getkeyopts(zone) & DNS_ZONEKEY_MAINTAIN); + allow = ((dns_zone_getkeyopts(zone) & DNS_ZONEKEY_ALLOW) != 0); + maintain = ((dns_zone_getkeyopts(zone) & DNS_ZONEKEY_MAINTAIN) != 0); /* Master files */ file = dns_zone_getfile(mayberaw); @@ -14030,7 +14031,7 @@ mkey_dumpzone(dns_view_t *view, isc_buffer_t **text) { snprintf(buf, sizeof(buf), "\n\talgorithm: %s", alg); CHECK(putstr(text, buf)); - revoked = (kd.flags & DNS_KEYFLAG_REVOKE); + revoked = ((kd.flags & DNS_KEYFLAG_REVOKE) != 0); snprintf(buf, sizeof(buf), "\n\tflags:%s%s%s", revoked ? " REVOKE" : "", ((kd.flags & DNS_KEYFLAG_KSK) != 0) diff --git a/bin/named/xfrout.c b/bin/named/xfrout.c index 86ab0c1b03..ea30052d3f 100644 --- a/bin/named/xfrout.c +++ b/bin/named/xfrout.c @@ -1281,7 +1281,7 @@ sendstream(xfrout_ctx_t *xfr) { isc_buffer_clear(&xfr->txlenbuf); isc_buffer_clear(&xfr->txbuf); - is_tcp = (xfr->client->attributes & NS_CLIENTATTR_TCP); + is_tcp = ((xfr->client->attributes & NS_CLIENTATTR_TCP) != 0); if (!is_tcp) { /* * In the UDP case, we put the response data directly into diff --git a/lib/dns/adb.c b/lib/dns/adb.c index 956f368889..b249aa19ca 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -2187,7 +2187,7 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find, dns_name_t *qname, bucket = DNS_ADB_INVALIDBUCKET; - if (find->options & DNS_ADBFIND_INET) { + if ((find->options & DNS_ADBFIND_INET) != 0) { namehook = ISC_LIST_HEAD(name->v4); while (namehook != NULL) { entry = namehook->entry; @@ -2227,7 +2227,7 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find, dns_name_t *qname, } } - if (find->options & DNS_ADBFIND_INET6) { + if ((find->options & DNS_ADBFIND_INET6) != 0) { namehook = ISC_LIST_HEAD(name->v6); while (namehook != NULL) { entry = namehook->entry; @@ -3710,8 +3710,7 @@ dbfind_name(dns_adbname_t *adbname, isc_stdtime_t now, dns_rdatatype_t rdtype) result = dns_view_find2(adb->view, &adbname->name, rdtype, now, NAME_GLUEOK(adbname) ? DNS_DBFIND_GLUEOK : 0, NAME_HINTOK(adbname), - (adbname->flags & NAME_STARTATZONE) != 0 ? - true : false, + ((adbname->flags & NAME_STARTATZONE) != 0), NULL, NULL, fname, &rdataset, NULL); /* XXXVIX this switch statement is too sparse to gen a jump table. */ diff --git a/lib/dns/client.c b/lib/dns/client.c index a6d0e2130b..e99ce92f61 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -1342,10 +1342,10 @@ dns_client_startresolve(dns_client_t *client, dns_name_t *name, mctx = client->mctx; rdataset = NULL; sigrdataset = NULL; - want_dnssec = !(options & DNS_CLIENTRESOPT_NODNSSEC); - want_validation = !(options & DNS_CLIENTRESOPT_NOVALIDATE); - want_cdflag = !(options & DNS_CLIENTRESOPT_NOCDFLAG); - want_tcp = (options & DNS_CLIENTRESOPT_TCP); + want_dnssec = ((options & DNS_CLIENTRESOPT_NODNSSEC) == 0); + want_validation = ((options & DNS_CLIENTRESOPT_NOVALIDATE) == 0); + want_cdflag = ((options & DNS_CLIENTRESOPT_NOCDFLAG) == 0); + want_tcp = ((options & DNS_CLIENTRESOPT_TCP) != 0); /* * Prepare some intermediate resources @@ -2854,7 +2854,7 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass, if (result != ISC_R_SUCCESS) return (result); - want_tcp = (options & DNS_CLIENTUPDOPT_TCP); + want_tcp = ((options & DNS_CLIENTUPDOPT_TCP) != 0); /* * Create a context and prepare some resources. diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index d1e4c16371..7266b6c822 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -1170,7 +1170,7 @@ udp_recv(isc_event_t *ev_in, dns_dispatch_t *disp, dispsocket_t *dispsock) { dispatch_log(disp, LVL(92), "got valid DNS message header, /QR %c, id %u", - ((flags & DNS_MESSAGEFLAG_QR) ? '1' : '0'), id); + (((flags & DNS_MESSAGEFLAG_QR) != 0) ? '1' : '0'), id); /* * Look at flags. If query, drop it. If response, @@ -1423,7 +1423,7 @@ tcp_recv(isc_task_t *task, isc_event_t *ev_in) { dispatch_log(disp, LVL(92), "got valid DNS message header, /QR %c, id %u", - ((flags & DNS_MESSAGEFLAG_QR) ? '1' : '0'), id); + (((flags & DNS_MESSAGEFLAG_QR) != 0) ? '1' : '0'), id); /* * Allocate an event to send to the query or response client, and diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c index 7d45e3abff..d12ae7e0ab 100644 --- a/lib/dns/dnssec.c +++ b/lib/dns/dnssec.c @@ -46,7 +46,7 @@ LIBDNS_EXTERNAL_DATA isc_stats_t *dns_dnssec_stats; -#define is_response(msg) (msg->flags & DNS_MESSAGEFLAG_QR) +#define is_response(msg) ((msg->flags & DNS_MESSAGEFLAG_QR) != 0) #define RETERR(x) do { \ result = (x); \ @@ -220,10 +220,12 @@ dns_dnssec_sign(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, * Is the key allowed to sign data? */ flags = dst_key_flags(key); - if (flags & DNS_KEYTYPE_NOAUTH) + if ((flags & DNS_KEYTYPE_NOAUTH) != 0) { return (DNS_R_KEYUNAUTHORIZED); - if ((flags & DNS_KEYFLAG_OWNERMASK) != DNS_KEYOWNER_ZONE) + } + if ((flags & DNS_KEYFLAG_OWNERMASK) != DNS_KEYOWNER_ZONE) { return (DNS_R_KEYUNAUTHORIZED); + } sig.mctx = mctx; sig.common.rdclass = set->rdclass; @@ -456,7 +458,7 @@ dns_dnssec_verify3(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, * Is the key allowed to sign data? */ flags = dst_key_flags(key); - if (flags & DNS_KEYTYPE_NOAUTH) { + if ((flags & DNS_KEYTYPE_NOAUTH) != 0) { inc_stat(dns_dnssecstats_fail); return (DNS_R_KEYUNAUTHORIZED); } @@ -1287,7 +1289,7 @@ dns_dnsseckey_create(isc_mem_t *mctx, dst_key_t **dstkey, dk->index = 0; /* KSK or ZSK? */ - dk->ksk = (dst_key_flags(dk->key) & DNS_KEYFLAG_KSK); + dk->ksk = ((dst_key_flags(dk->key) & DNS_KEYFLAG_KSK) != 0); /* Is this an old-style key? */ result = dst_key_getprivateformat(dk->key, &major, &minor); diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index 107891624b..e3c47a91cf 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -500,13 +500,13 @@ dst_key_tofile(const dst_key_t *key, int type, const char *directory) { if (key->func->tofile == NULL) return (DST_R_UNSUPPORTEDALG); - if (type & DST_TYPE_PUBLIC) { + if ((type & DST_TYPE_PUBLIC) != 0) { ret = write_public_key(key, type, directory); if (ret != ISC_R_SUCCESS) return (ret); } - if ((type & DST_TYPE_PRIVATE) && + if (((type & DST_TYPE_PRIVATE) != 0) && (key->key_flags & DNS_KEYFLAG_TYPEMASK) != DNS_KEYTYPE_NOKEY) return (key->func->tofile(key, directory)); else @@ -722,7 +722,7 @@ dst_key_todns(const dst_key_t *key, isc_buffer_t *target) { isc_buffer_putuint8(target, (uint8_t)key->key_proto); isc_buffer_putuint8(target, (uint8_t)key->key_alg); - if (key->key_flags & DNS_KEYFLAG_EXTENDED) { + if ((key->key_flags & DNS_KEYFLAG_EXTENDED) != 0) { if (isc_buffer_availablelength(target) < 2) return (ISC_R_NOSPACE); isc_buffer_putuint16(target, @@ -760,7 +760,7 @@ dst_key_fromdns(dns_name_t *name, dns_rdataclass_t rdclass, id = dst_region_computeid(&r, alg); rid = dst_region_computerid(&r, alg); - if (flags & DNS_KEYFLAG_EXTENDED) { + if ((flags & DNS_KEYFLAG_EXTENDED) != 0) { if (isc_buffer_remaininglength(source) < 2) return (DST_R_INVALIDPUBLICKEY); extflags = isc_buffer_getuint16(source); diff --git a/lib/dns/ecdb.c b/lib/dns/ecdb.c index cf24d73746..8c8e269f90 100644 --- a/lib/dns/ecdb.c +++ b/lib/dns/ecdb.c @@ -724,7 +724,7 @@ rdataset_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata) { raw += 2; #endif if (rdataset->type == dns_rdatatype_rrsig) { - if (*raw & DNS_RDATASLAB_OFFLINE) + if ((*raw & DNS_RDATASLAB_OFFLINE) != 0) flags |= DNS_RDATA_OFFLINE; length--; raw++; diff --git a/lib/dns/journal.c b/lib/dns/journal.c index bdbc459cbf..d39f5988ec 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -361,7 +361,7 @@ journal_header_decode(journal_rawheader_t *raw, journal_header_t *cooked) { journal_pos_decode(&raw->h.end, &cooked->end); cooked->index_size = decode_uint32(raw->h.index_size); cooked->sourceserial = decode_uint32(raw->h.sourceserial); - cooked->serialset = (raw->h.flags & JOURNAL_SERIALSET); + cooked->serialset = ((raw->h.flags & JOURNAL_SERIALSET) != 0); } static void @@ -375,8 +375,9 @@ journal_header_encode(journal_header_t *cooked, journal_rawheader_t *raw) { journal_pos_encode(&raw->h.end, &cooked->end); encode_uint32(cooked->index_size, raw->h.index_size); encode_uint32(cooked->sourceserial, raw->h.sourceserial); - if (cooked->serialset) + if (cooked->serialset) { flags |= JOURNAL_SERIALSET; + } raw->h.flags = flags; } @@ -699,8 +700,8 @@ dns_journal_open(isc_mem_t *mctx, const char *filename, unsigned int mode, char backup[1024]; bool writable, create; - create = (mode & DNS_JOURNAL_CREATE); - writable = (mode & (DNS_JOURNAL_WRITE|DNS_JOURNAL_CREATE)); + create = ((mode & DNS_JOURNAL_CREATE) != 0); + writable = ((mode & (DNS_JOURNAL_WRITE|DNS_JOURNAL_CREATE)) != 0); result = journal_open(mctx, filename, writable, create, journalp); if (result == ISC_R_NOTFOUND) { diff --git a/lib/dns/master.c b/lib/dns/master.c index e653d2955f..bd23f7975f 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -583,7 +583,7 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx, isc_lex_setcomments(lctx->lex, ISC_LEXCOMMENT_DNSMASTERFILE); } - lctx->ttl_known = (options & DNS_MASTER_NOTTL); + lctx->ttl_known = ((options & DNS_MASTER_NOTTL) != 0); lctx->ttl = 0; lctx->default_ttl_known = lctx->ttl_known; lctx->default_ttl = 0; diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 73dcec0bb5..c45edd5117 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -1022,7 +1022,7 @@ dump_rdatasets_text(isc_mem_t *mctx, dns_name_t *name, for (i = 0; i < n; i++) { dns_rdataset_t *rds = sorted[i]; - if (ctx->style.flags & DNS_STYLEFLAG_TRUST) { + if ((ctx->style.flags & DNS_STYLEFLAG_TRUST) != 0) { if ((ctx->style.flags & DNS_STYLEFLAG_INDENT) != 0 || (ctx->style.flags & DNS_STYLEFLAG_YAML) != 0) { @@ -1044,8 +1044,8 @@ dump_rdatasets_text(isc_mem_t *mctx, dns_name_t *name, if ((ctx->style.flags & DNS_STYLEFLAG_OMIT_OWNER) != 0) name = NULL; } - if (ctx->style.flags & DNS_STYLEFLAG_RESIGN && - rds->attributes & DNS_RDATASETATTR_RESIGN) { + if (((ctx->style.flags & DNS_STYLEFLAG_RESIGN) != 0) && + ((rds->attributes & DNS_RDATASETATTR_RESIGN) != 0)) { isc_buffer_t b; char buf[sizeof("YYYYMMDDHHMMSS")]; memset(buf, 0, sizeof(buf)); diff --git a/lib/dns/message.c b/lib/dns/message.c index ac637a2588..0225b6495f 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -1003,7 +1003,7 @@ getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, section = &msg->sections[DNS_SECTION_QUESTION]; - best_effort = (options & DNS_MESSAGEPARSE_BESTEFFORT); + best_effort = ((options & DNS_MESSAGEPARSE_BESTEFFORT) != 0); seen_problem = false; name = NULL; @@ -1235,8 +1235,8 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, bool preserve_order, best_effort, seen_problem; bool issigzero; - preserve_order = (options & DNS_MESSAGEPARSE_PRESERVEORDER); - best_effort = (options & DNS_MESSAGEPARSE_BESTEFFORT); + preserve_order = ((options & DNS_MESSAGEPARSE_PRESERVEORDER) != 0); + best_effort = ((options & DNS_MESSAGEPARSE_BESTEFFORT) != 0); seen_problem = false; section = &msg->sections[sectionid]; @@ -1672,7 +1672,7 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source, REQUIRE(msg->from_to_wire == DNS_MESSAGE_INTENTPARSE); seen_problem = false; - ignore_tc = (options & DNS_MESSAGEPARSE_IGNORETRUNCATION); + ignore_tc = ((options & DNS_MESSAGEPARSE_IGNORETRUNCATION) != 0); origsource = *source; diff --git a/lib/dns/name.c b/lib/dns/name.c index 66040fbaea..8e3caf9622 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -1114,7 +1114,7 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) || (target == NULL && ISC_BUFFER_VALID(name->buffer))); - downcase = (options & DNS_NAME_DOWNCASE); + downcase = ((options & DNS_NAME_DOWNCASE) != 0); if (target == NULL && name->buffer != NULL) { target = name->buffer; @@ -1409,7 +1409,7 @@ dns_name_totext2(const dns_name_t *name, unsigned int options, dns_name_totextfilter_t totext_filter_proc = NULL; isc_result_t result; #endif - bool omit_final_dot = (options & DNS_NAME_OMITFINALDOT); + bool omit_final_dot = ((options & DNS_NAME_OMITFINALDOT) != 0); /* * This function assumes the name is in proper uncompressed @@ -1823,7 +1823,7 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) || (target == NULL && ISC_BUFFER_VALID(name->buffer))); - downcase = (options & DNS_NAME_DOWNCASE); + downcase = ((options & DNS_NAME_DOWNCASE) != 0); if (target == NULL && name->buffer != NULL) { target = name->buffer; @@ -1907,9 +1907,10 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, /* * Ordinary 14-bit pointer. */ - if ((dctx->allowed & DNS_COMPRESS_GLOBAL14) == - 0) + if ((dctx->allowed & DNS_COMPRESS_GLOBAL14) == 0) + { return (DNS_R_DISALLOWED); + } new_current = c & 0x3F; state = fw_newcurrent; } else diff --git a/lib/dns/nsec.c b/lib/dns/nsec.c index d0f0705fe7..bca00547df 100644 --- a/lib/dns/nsec.c +++ b/lib/dns/nsec.c @@ -58,7 +58,7 @@ dns_nsec_isset(const unsigned char *array, unsigned int type) { shift = 7 - (type % 8); mask = 1 << shift; - return (byte & mask); + return ((byte & mask) != 0); } unsigned int diff --git a/lib/dns/nsec3.c b/lib/dns/nsec3.c index e1278935a5..a9d5cbada2 100644 --- a/lib/dns/nsec3.c +++ b/lib/dns/nsec3.c @@ -2093,13 +2093,12 @@ dns_nsec3_noexistnodata(dns_rdatatype_t type, dns_name_t* name, *exists = false; *data = false; if (optout != NULL) { - if ((nsec3.flags & DNS_NSEC3FLAG_OPTOUT) != 0) - (*logit)(arg, ISC_LOG_DEBUG(3), - "NSEC3 indicates optout"); - else - (*logit)(arg, ISC_LOG_DEBUG(3), - "NSEC3 indicates secure range"); - *optout = (nsec3.flags & DNS_NSEC3FLAG_OPTOUT); + *optout = ((nsec3.flags & DNS_NSEC3FLAG_OPTOUT) + != 0); + (*logit)(arg, ISC_LOG_DEBUG(3), + (*optout + ? "NSEC3 indicates optout" + : "NSEC3 indicates secure range")); } answer = ISC_R_SUCCESS; } diff --git a/lib/dns/openssl_link.c b/lib/dns/openssl_link.c index a30a2abb3a..b757e2258b 100644 --- a/lib/dns/openssl_link.c +++ b/lib/dns/openssl_link.c @@ -432,7 +432,7 @@ dst__openssl_toresult3(isc_logcategory_t *category, isc_log_write(dns_lctx, category, DNS_LOGMODULE_CRYPTO, ISC_LOG_INFO, "%s:%s:%d:%s", buf, file, line, - (flags & ERR_TXT_STRING) ? data : ""); + ((flags & ERR_TXT_STRING) != 0) ? data : ""); } done: diff --git a/lib/dns/private.c b/lib/dns/private.c index b694f8cd15..9651381d2e 100644 --- a/lib/dns/private.c +++ b/lib/dns/private.c @@ -312,9 +312,9 @@ dns_private_totext(dns_rdata_t *private, isc_buffer_t *buf) { CHECK(dns_rdata_tostruct(&rdata, &nsec3param, NULL)); - del = (nsec3param.flags & DNS_NSEC3FLAG_REMOVE); - init = (nsec3param.flags & DNS_NSEC3FLAG_INITIAL); - nonsec = (nsec3param.flags & DNS_NSEC3FLAG_NONSEC); + del = ((nsec3param.flags & DNS_NSEC3FLAG_REMOVE) != 0); + init = ((nsec3param.flags & DNS_NSEC3FLAG_INITIAL) != 0); + nonsec = ((nsec3param.flags & DNS_NSEC3FLAG_NONSEC) != 0); nsec3param.flags &= ~(DNS_NSEC3FLAG_CREATE| DNS_NSEC3FLAG_REMOVE| diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 08611399ac..0d82148800 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -5711,7 +5711,8 @@ createiterator(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp) rbtdbiter->common.methods = &dbiterator_methods; rbtdbiter->common.db = NULL; dns_db_attach(db, &rbtdbiter->common.db); - rbtdbiter->common.relative_names = (options & DNS_DB_RELATIVENAMES); + rbtdbiter->common.relative_names = + ((options & DNS_DB_RELATIVENAMES) != 0); rbtdbiter->common.magic = DNS_DBITERATOR_MAGIC; rbtdbiter->common.cleaning = false; rbtdbiter->paused = true; @@ -5721,8 +5722,8 @@ createiterator(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp) dns_fixedname_init(&rbtdbiter->origin); rbtdbiter->node = NULL; rbtdbiter->delcnt = 0; - rbtdbiter->nsec3only = (options & DNS_DB_NSEC3ONLY); - rbtdbiter->nonsec3 = (options & DNS_DB_NONSEC3); + rbtdbiter->nsec3only = ((options & DNS_DB_NSEC3ONLY) != 0); + rbtdbiter->nonsec3 = ((options & DNS_DB_NONSEC3) != 0); memset(rbtdbiter->deletions, 0, sizeof(rbtdbiter->deletions)); dns_rbtnodechain_init(&rbtdbiter->chain, db->mctx); dns_rbtnodechain_init(&rbtdbiter->nsec3chain, db->mctx); diff --git a/lib/dns/rdata/generic/keydata_65533.c b/lib/dns/rdata/generic/keydata_65533.c index 06b56c1e1a..30ba9676e7 100644 --- a/lib/dns/rdata/generic/keydata_65533.c +++ b/lib/dns/rdata/generic/keydata_65533.c @@ -129,12 +129,14 @@ totext_keydata(ARGS_TOTEXT) { RETERR(str_totext(buf, target)); RETERR(str_totext(" ", target)); if ((flags & DNS_KEYFLAG_KSK) != 0) { - if (flags & DNS_KEYFLAG_REVOKE) + if ((flags & DNS_KEYFLAG_REVOKE) != 0) { keyinfo = "revoked KSK"; - else + } else { keyinfo = "KSK"; - } else + } + } else { keyinfo = "ZSK"; + } /* protocol */ snprintf(buf, sizeof(buf), "%u", sr.base[0]); diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c index c21d64b35f..246a998993 100644 --- a/lib/dns/rdata/generic/soa_6.c +++ b/lib/dns/rdata/generic/soa_6.c @@ -92,9 +92,11 @@ totext_soa(ARGS_TOTEXT) { REQUIRE(rdata->length != 0); multiline = (tctx->flags & DNS_STYLEFLAG_MULTILINE); - comm = (multiline) ? - (tctx->flags & DNS_STYLEFLAG_RRCOMMENT) : - false; + if (multiline) { + comm = ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0); + } else { + comm = false; + } dns_name_init(&mname, NULL); dns_name_init(&rname, NULL); diff --git a/lib/dns/request.c b/lib/dns/request.c index a235387478..3f9855e30e 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -1045,8 +1045,8 @@ dns_request_createvia4(dns_requestmgr_t *requestmgr, dns_message_t *message, dns_tsigkey_attach(key, &request->tsigkey); use_tcp: - tcp = (options & DNS_REQUESTOPT_TCP); - share = (options & DNS_REQUESTOPT_SHARE); + tcp = ((options & DNS_REQUESTOPT_TCP) != 0); + share = ((options & DNS_REQUESTOPT_SHARE) != 0); result = get_dispatch(tcp, false, share, requestmgr, srcaddr, destaddr, dscp, &connected, &request->dispatch); @@ -1307,7 +1307,7 @@ bool dns_request_usedtcp(dns_request_t *request) { REQUIRE(VALID_REQUEST(request)); - return (request->flags & DNS_REQUEST_F_TCP); + return ((request->flags & DNS_REQUEST_F_TCP) != 0); } void diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 0abf4de8eb..d182d3375e 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -2126,7 +2126,7 @@ resquery_send(resquery_t *query) { bool cleanup_cctx = false; bool secure_domain; bool connecting = false; - bool tcp = (query->options & DNS_FETCHOPT_TCP); + bool tcp = ((query->options & DNS_FETCHOPT_TCP) != 0); dns_ednsopt_t ednsopts[DNS_EDNSOPTIONS]; unsigned ednsopt = 0; uint16_t hint = 0, udpsize = 0; /* No EDNS */ @@ -2214,7 +2214,7 @@ resquery_send(resquery_t *query) { else if (res->view->enablevalidation && ((fctx->qmessage->flags & DNS_MESSAGEFLAG_RD) != 0)) { - bool checknta = !(query->options & DNS_FETCHOPT_NONTA); + bool checknta = ((query->options & DNS_FETCHOPT_NONTA) == 0); result = issecuredomain(res->view, &fctx->name, fctx->type, isc_time_seconds(&query->start), checknta, &secure_domain); @@ -3096,7 +3096,7 @@ findname(fetchctx_t *fctx, dns_name_t *name, in_port_t port, isc_result_t result; res = fctx->res; - unshared = (fctx->options & DNS_FETCHOPT_UNSHARED); + unshared = ((fctx->options & DNS_FETCHOPT_UNSHARED) != 0); /* * If this name is a subdomain of the query domain, tell * the ADB to start looking using zone/hint data. This keeps us @@ -4846,7 +4846,7 @@ validated(isc_task_t *task, isc_event_t *event) { negative = (vevent->rdataset == NULL); - sentresponse = (fctx->options & DNS_FETCHOPT_NOVALIDATE); + sentresponse = ((fctx->options & DNS_FETCHOPT_NOVALIDATE) != 0); /* * If shutting down, ignore the results. Check to see if we're @@ -5441,7 +5441,7 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, dns_adbaddrinfo_t *addrinfo, /* * Cache or validate each cacheable rdataset. */ - fail = (fctx->res->options & DNS_RESOLVER_CHECKNAMESFAIL); + fail = ((fctx->res->options & DNS_RESOLVER_CHECKNAMESFAIL) != 0); for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL; rdataset = ISC_LIST_NEXT(rdataset, link)) diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index cd4c95063a..df95db05b3 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -550,8 +550,8 @@ adj_trigger_cnt(dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, const dns_rpz_cidr_key_t *tgt_ip, dns_rpz_prefix_t tgt_prefix, bool inc) { - dns_rpz_trigger_counter_t *cnt = 0; - dns_rpz_zbits_t *have = 0; + dns_rpz_trigger_counter_t *cnt = NULL; + dns_rpz_zbits_t *have = NULL; switch (rpz_type) { case DNS_RPZ_TYPE_CLIENT_IP: diff --git a/lib/dns/sdb.c b/lib/dns/sdb.c index cabda7fe78..013156ae95 100644 --- a/lib/dns/sdb.c +++ b/lib/dns/sdb.c @@ -1084,7 +1084,7 @@ createiterator(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp) sdbiter->common.methods = &dbiterator_methods; sdbiter->common.db = NULL; dns_db_attach(db, &sdbiter->common.db); - sdbiter->common.relative_names = (options & DNS_DB_RELATIVENAMES); + sdbiter->common.relative_names = ((options & DNS_DB_RELATIVENAMES) != 0); sdbiter->common.magic = DNS_DBITERATOR_MAGIC; ISC_LIST_INIT(sdbiter->nodelist); sdbiter->current = NULL; diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index 11c4c73716..2fbebb0fd8 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -818,7 +818,8 @@ createiterator(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp) sdlziter->common.methods = &dbiterator_methods; sdlziter->common.db = NULL; dns_db_attach(db, &sdlziter->common.db); - sdlziter->common.relative_names = (options & DNS_DB_RELATIVENAMES); + sdlziter->common.relative_names = + ((options & DNS_DB_RELATIVENAMES) != 0); sdlziter->common.magic = DNS_DBITERATOR_MAGIC; ISC_LIST_INIT(sdlziter->nodelist); sdlziter->current = NULL; diff --git a/lib/dns/update.c b/lib/dns/update.c index 1cc5f88673..7da8438c60 100644 --- a/lib/dns/update.c +++ b/lib/dns/update.c @@ -1429,9 +1429,11 @@ dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, * and one doesn't. */ state->check_ksk = - (dns_zone_getoptions(zone) & DNS_ZONEOPT_UPDATECHECKKSK); + ((dns_zone_getoptions(zone) & + DNS_ZONEOPT_UPDATECHECKKSK) != 0); state->keyset_kskonly = - (dns_zone_getoptions(zone) & DNS_ZONEOPT_DNSKEYKSKONLY); + ((dns_zone_getoptions(zone) & + DNS_ZONEOPT_DNSKEYKSKONLY) != 0); /* * Get the NSEC/NSEC3 TTL from the SOA MINIMUM field. diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 94a8c0ea12..766ad6b7c5 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -3426,27 +3426,28 @@ zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param) { strlcpy(flags, "NONE", sizeof(flags)); else { flags[0] = '\0'; - if (nsec3param->flags & DNS_NSEC3FLAG_REMOVE) + if ((nsec3param->flags & DNS_NSEC3FLAG_REMOVE) != 0) { strlcat(flags, "REMOVE", sizeof(flags)); - if (nsec3param->flags & DNS_NSEC3FLAG_INITIAL) { + } + if ((nsec3param->flags & DNS_NSEC3FLAG_INITIAL) != 0) { if (flags[0] == '\0') strlcpy(flags, "INITIAL", sizeof(flags)); else strlcat(flags, "|INITIAL", sizeof(flags)); } - if (nsec3param->flags & DNS_NSEC3FLAG_CREATE) { + if ((nsec3param->flags & DNS_NSEC3FLAG_CREATE) != 0) { if (flags[0] == '\0') strlcpy(flags, "CREATE", sizeof(flags)); else strlcat(flags, "|CREATE", sizeof(flags)); } - if (nsec3param->flags & DNS_NSEC3FLAG_NONSEC) { + if ((nsec3param->flags & DNS_NSEC3FLAG_NONSEC) != 0) { if (flags[0] == '\0') strlcpy(flags, "NONSEC", sizeof(flags)); else strlcat(flags, "|NONSEC", sizeof(flags)); } - if (nsec3param->flags & DNS_NSEC3FLAG_OPTOUT) { + if ((nsec3param->flags & DNS_NSEC3FLAG_OPTOUT) != 0) { if (flags[0] == '\0') strlcpy(flags, "OPTOUT", sizeof(flags)); else @@ -9500,13 +9501,14 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { RUNTIME_CHECK(result == ISC_R_SUCCESS); /* Skip ZSK's */ - if (!(dnskey.flags & DNS_KEYFLAG_KSK)) + if ((dnskey.flags & DNS_KEYFLAG_KSK) == 0) { continue; + } result = compute_tag(keyname, &dnskey, mctx, &keytag); RUNTIME_CHECK(result == ISC_R_SUCCESS); - revoked = (dnskey.flags & DNS_KEYFLAG_REVOKE); + revoked = ((dnskey.flags & DNS_KEYFLAG_REVOKE) != 0); if (matchkey(&kfetch->keydataset, &dnskeyrr)) { dns_rdata_reset(&keydatarr); @@ -11187,7 +11189,7 @@ notify_send(dns_notify_t *notify) { zone_iattach(notify->zone, &newnotify->zone); ISC_LIST_APPEND(newnotify->zone->notifies, newnotify, link); newnotify->dst = dst; - startup = (notify->flags & DNS_NOTIFY_STARTUP); + startup = ((notify->flags & DNS_NOTIFY_STARTUP) != 0); result = notify_send_queue(newnotify, startup); if (result != ISC_R_SUCCESS) goto cleanup; diff --git a/lib/irs/getaddrinfo.c b/lib/irs/getaddrinfo.c index 33a7fb5fd4..b6658bae70 100644 --- a/lib/irs/getaddrinfo.c +++ b/lib/irs/getaddrinfo.c @@ -728,7 +728,7 @@ process_answer(isc_task_t *task, isc_event_t *event) { goto done; } - wantcname = (resstate->head->ai_flags & AI_CANONNAME); + wantcname = ((resstate->head->ai_flags & AI_CANONNAME) != 0); /* Parse the response and construct the addrinfo chain */ for (name = ISC_LIST_HEAD(rev->answerlist); name != NULL; diff --git a/lib/irs/getnameinfo.c b/lib/irs/getnameinfo.c index 5069ba7a7f..f575426328 100644 --- a/lib/irs/getnameinfo.c +++ b/lib/irs/getnameinfo.c @@ -197,7 +197,7 @@ getnameinfo(const struct sockaddr *sa, IRS_GETNAMEINFO_SOCKLEN_T salen, default: INSIST(0); } - proto = (flags & NI_DGRAM) ? "udp" : "tcp"; + proto = ((flags & NI_DGRAM) != 0) ? "udp" : "tcp"; if (serv == NULL || servlen == 0U) { /* diff --git a/lib/isc/httpd.c b/lib/isc/httpd.c index 06e7a8b68b..ecd322a6f7 100644 --- a/lib/isc/httpd.c +++ b/lib/isc/httpd.c @@ -923,7 +923,7 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev) { } #ifdef HAVE_ZLIB - if (httpd->flags & HTTPD_ACCEPT_DEFLATE) { + if ((httpd->flags & HTTPD_ACCEPT_DEFLATE) != 0) { result = isc_httpd_compress(httpd); if (result == ISC_R_SUCCESS) { is_compressed = true; diff --git a/lib/isc/include/isc/radix.h b/lib/isc/include/isc/radix.h index 135552a627..c201d57369 100644 --- a/lib/isc/include/isc/radix.h +++ b/lib/isc/include/isc/radix.h @@ -61,8 +61,6 @@ typedef void (*isc_radix_processfunc_t)(isc_prefix_t *, void **); #define isc_prefix_tochar(prefix) ((char *)&(prefix)->add.sin) #define isc_prefix_touchar(prefix) ((u_char *)&(prefix)->add.sin) -#define BIT_TEST(f, b) ((f) & (b)) - /* * We need "first match" when we search the radix tree to preserve * compatibility with the existing ACL implementation. Radix trees diff --git a/lib/isc/lex.c b/lib/isc/lex.c index a8955bc78d..c9758872a6 100644 --- a/lib/isc/lex.c +++ b/lib/isc/lex.c @@ -650,10 +650,10 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { goto done; done = true; continue; - } else if (!(options & ISC_LEXOPT_CNUMBER) || + } else if ((options & ISC_LEXOPT_CNUMBER) == 0 || ((c != 'x' && c != 'X') || - (curr != &lex->data[1]) || - (lex->data[0] != '0'))) { + (curr != &lex->data[1]) || + (lex->data[0] != '0'))) { /* Above test supports hex numbers */ state = lexstate_string; } diff --git a/lib/isc/log.c b/lib/isc/log.c index 33875330a2..7bf567e07f 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -1633,16 +1633,16 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, } } - printtime = (channel->flags & ISC_LOG_PRINTTIME); + printtime = ((channel->flags & ISC_LOG_PRINTTIME) != 0); printtag = ((channel->flags & - (ISC_LOG_PRINTTAG|ISC_LOG_PRINTPREFIX)) - && lcfg->tag != NULL); - printcolon = ((channel->flags & ISC_LOG_PRINTTAG) - && lcfg->tag != NULL); - printcategory = (channel->flags & ISC_LOG_PRINTCATEGORY); - printmodule = (channel->flags & ISC_LOG_PRINTMODULE); - printlevel = (channel->flags & ISC_LOG_PRINTLEVEL); - buffered = (channel->flags & ISC_LOG_BUFFERED); + (ISC_LOG_PRINTTAG|ISC_LOG_PRINTPREFIX)) != 0 && + lcfg->tag != NULL); + printcolon = ((channel->flags & ISC_LOG_PRINTTAG) != 0 && + lcfg->tag != NULL); + printcategory = ((channel->flags & ISC_LOG_PRINTCATEGORY) != 0); + printmodule = ((channel->flags & ISC_LOG_PRINTMODULE) != 0); + printlevel = ((channel->flags & ISC_LOG_PRINTLEVEL) != 0); + buffered = ((channel->flags & ISC_LOG_BUFFERED) != 0); switch (channel->type) { case ISC_LOG_TOFILE: diff --git a/lib/isc/radix.c b/lib/isc/radix.c index 6299dfef41..3781861ce2 100644 --- a/lib/isc/radix.c +++ b/lib/isc/radix.c @@ -25,6 +25,8 @@ #include #include +#define BIT_TEST(f, b) (((f) & (b)) != 0) + static isc_result_t _new_prefix(isc_mem_t *mctx, isc_prefix_t **target, int family, void *dest, int bitlen); diff --git a/lib/isc/task.c b/lib/isc/task.c index f9f1eed64f..51fe39649c 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -1767,7 +1767,7 @@ isc__task_setprivilege(isc_task_t *task0, bool priv) { bool oldpriv; LOCK(&task->lock); - oldpriv = (task->flags & TASK_F_PRIVILEGED); + oldpriv = ((task->flags & TASK_F_PRIVILEGED) != 0); if (priv) task->flags |= TASK_F_PRIVILEGED; else @@ -1793,7 +1793,7 @@ isc__task_privilege(isc_task_t *task0) { bool priv; LOCK(&task->lock); - priv = (task->flags & TASK_F_PRIVILEGED); + priv = ((task->flags & TASK_F_PRIVILEGED) != 0); UNLOCK(&task->lock); return (priv); } diff --git a/lib/isc/tests/socket_test.c b/lib/isc/tests/socket_test.c index 3f3f2497e6..9c60ac522b 100644 --- a/lib/isc/tests/socket_test.c +++ b/lib/isc/tests/socket_test.c @@ -78,7 +78,7 @@ event_done(isc_task_t *task, isc_event_t *event) { } else { recv_dscp = false; } - recv_trunc = (dev->attributes & ISC_SOCKEVENTATTR_TRUNC); + recv_trunc = ((dev->attributes & ISC_SOCKEVENTATTR_TRUNC) != 0); isc_event_free(&event); } diff --git a/lib/isc/tests/task_test.c b/lib/isc/tests/task_test.c index c9912720a3..c4a92068c6 100644 --- a/lib/isc/tests/task_test.c +++ b/lib/isc/tests/task_test.c @@ -1013,7 +1013,7 @@ pg_event2(isc_task_t *task, isc_event_t *event) { } if (sender_match && type_match && tag_match) { - if (event->ev_attributes & ISC_EVENTATTR_NOPURGE) { + if ((event->ev_attributes & ISC_EVENTATTR_NOPURGE) != 0) { printf("event %p,%d,%p matched but was not purgeable\n", event->ev_sender, (int)event->ev_type, event->ev_tag); diff --git a/lib/isc/tm.c b/lib/isc/tm.c index c39039663d..338157ade5 100644 --- a/lib/isc/tm.c +++ b/lib/isc/tm.c @@ -61,7 +61,7 @@ */ #define ALT_E 0x01 #define ALT_O 0x02 -#define LEGAL_ALT(x) { if (alt_format & ~(x)) return (0); } +#define LEGAL_ALT(x) { if ((alt_format & ~(x)) != 0) return (0); } #ifndef TM_YEAR_BASE #define TM_YEAR_BASE 1900 diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 12ab492cf1..fa3259556e 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -1366,13 +1366,15 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { #ifdef ISC_NET_BSD44MSGHDR #ifdef MSG_TRUNC - if ((msg->msg_flags & MSG_TRUNC) == MSG_TRUNC) + if ((msg->msg_flags & MSG_TRUNC) != 0) { dev->attributes |= ISC_SOCKEVENTATTR_TRUNC; + } #endif #ifdef MSG_CTRUNC - if ((msg->msg_flags & MSG_CTRUNC) == MSG_CTRUNC) + if ((msg->msg_flags & MSG_CTRUNC) != 0) { dev->attributes |= ISC_SOCKEVENTATTR_CTRUNC; + } #endif #ifndef USE_CMSG @@ -3146,10 +3148,12 @@ isc__socket_fdwatchcreate(isc_socketmgr_t *manager0, int fd, int flags, #endif UNLOCK(&manager->lock); - if (flags & ISC_SOCKFDWATCH_READ) + if ((flags & ISC_SOCKFDWATCH_READ) != 0) { select_poke(sock->manager, sock->fd, SELECT_POKE_READ); - if (flags & ISC_SOCKFDWATCH_WRITE) + } + if ((flags & ISC_SOCKFDWATCH_WRITE) != 0) { select_poke(sock->manager, sock->fd, SELECT_POKE_WRITE); + } socket_log(sock, NULL, CREATION, isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_CREATED, "fdwatch-created"); @@ -3427,11 +3431,11 @@ send_recvdone_event(isc__socket_t *sock, isc_socketevent_t **dev) { if (ISC_LINK_LINKED(*dev, ev_link)) ISC_LIST_DEQUEUE(sock->recv_list, *dev, ev_link); - if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) - == ISC_SOCKEVENTATTR_ATTACHED) + if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) != 0) { isc_task_sendanddetach(&task, (isc_event_t **)dev); - else + } else { isc_task_send(task, (isc_event_t **)dev); + } } /* @@ -3451,11 +3455,11 @@ send_senddone_event(isc__socket_t *sock, isc_socketevent_t **dev) { if (ISC_LINK_LINKED(*dev, ev_link)) ISC_LIST_DEQUEUE(sock->send_list, *dev, ev_link); - if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) - == ISC_SOCKEVENTATTR_ATTACHED) + if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) != 0) { isc_task_sendanddetach(&task, (isc_event_t **)dev); - else + } else { isc_task_send(task, (isc_event_t **)dev); + } } /* @@ -6175,7 +6179,7 @@ isc__socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) { * its done event with status of "ISC_R_CANCELED". * o Reset any state needed. */ - if (((how & ISC_SOCKCANCEL_RECV) == ISC_SOCKCANCEL_RECV) + if (((how & ISC_SOCKCANCEL_RECV) != 0) && !ISC_LIST_EMPTY(sock->recv_list)) { isc_socketevent_t *dev; isc_socketevent_t *next; @@ -6195,7 +6199,7 @@ isc__socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) { } } - if (((how & ISC_SOCKCANCEL_SEND) == ISC_SOCKCANCEL_SEND) + if (((how & ISC_SOCKCANCEL_SEND) != 0) && !ISC_LIST_EMPTY(sock->send_list)) { isc_socketevent_t *dev; isc_socketevent_t *next; @@ -6215,7 +6219,7 @@ isc__socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) { } } - if (((how & ISC_SOCKCANCEL_ACCEPT) == ISC_SOCKCANCEL_ACCEPT) + if (((how & ISC_SOCKCANCEL_ACCEPT) != 0) && !ISC_LIST_EMPTY(sock->accept_list)) { isc_socket_newconnev_t *dev; isc_socket_newconnev_t *next; @@ -6244,7 +6248,7 @@ isc__socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) { } } - if (((how & ISC_SOCKCANCEL_CONNECT) == ISC_SOCKCANCEL_CONNECT) + if (((how & ISC_SOCKCANCEL_CONNECT) != 0) && !ISC_LIST_EMPTY(sock->connect_list)) { isc_socket_connev_t *dev; isc_socket_connev_t *next; diff --git a/lib/isc/win32/fsaccess.c b/lib/isc/win32/fsaccess.c index 164985da7b..e64d172a0c 100644 --- a/lib/isc/win32/fsaccess.c +++ b/lib/isc/win32/fsaccess.c @@ -189,23 +189,30 @@ NTFS_Access_Control(const char *filename, const char *user, int access, /* Owner check */ NTFSbits = 0; - if (caccess & ISC_FSACCESS_READ) + if ((caccess & ISC_FSACCESS_READ) != 0) { NTFSbits |= FILE_GENERIC_READ; - if (caccess & ISC_FSACCESS_WRITE) + } + if ((caccess & ISC_FSACCESS_WRITE) != 0) { NTFSbits |= FILE_GENERIC_WRITE; - if (caccess & ISC_FSACCESS_EXECUTE) + } + if ((caccess & ISC_FSACCESS_EXECUTE) != 0) { NTFSbits |= FILE_GENERIC_EXECUTE; + } /* For directories check the directory-specific bits */ if (isdir == true) { - if (caccess & ISC_FSACCESS_CREATECHILD) + if ((caccess & ISC_FSACCESS_CREATECHILD) != 0) { NTFSbits |= FILE_ADD_SUBDIRECTORY | FILE_ADD_FILE; - if (caccess & ISC_FSACCESS_DELETECHILD) + } + if ((caccess & ISC_FSACCESS_DELETECHILD) != 0) { NTFSbits |= FILE_DELETE_CHILD; - if (caccess & ISC_FSACCESS_LISTDIRECTORY) + } + if ((caccess & ISC_FSACCESS_LISTDIRECTORY) != 0) { NTFSbits |= FILE_LIST_DIRECTORY; - if (caccess & ISC_FSACCESS_ACCESSCHILD) + } + if ((caccess & ISC_FSACCESS_ACCESSCHILD) != 0) { NTFSbits |= FILE_TRAVERSE; + } } if (NTFSbits == (FILE_GENERIC_READ | FILE_GENERIC_WRITE @@ -238,23 +245,30 @@ NTFS_Access_Control(const char *filename, const char *user, int access, caccess = caccess >> STEP; NTFSbits = 0; - if (caccess & ISC_FSACCESS_READ) + if ((caccess & ISC_FSACCESS_READ) != 0) { NTFSbits |= FILE_GENERIC_READ; - if (caccess & ISC_FSACCESS_WRITE) + } + if ((caccess & ISC_FSACCESS_WRITE) != 0) { NTFSbits |= FILE_GENERIC_WRITE; - if (caccess & ISC_FSACCESS_EXECUTE) + } + if ((caccess & ISC_FSACCESS_EXECUTE) != 0) { NTFSbits |= FILE_GENERIC_EXECUTE; + } /* For directories check the directory-specific bits */ if (isdir == TRUE) { - if (caccess & ISC_FSACCESS_CREATECHILD) + if ((caccess & ISC_FSACCESS_CREATECHILD) != 0) { NTFSbits |= FILE_ADD_SUBDIRECTORY | FILE_ADD_FILE; - if (caccess & ISC_FSACCESS_DELETECHILD) + } + if ((caccess & ISC_FSACCESS_DELETECHILD) != 0) { NTFSbits |= FILE_DELETE_CHILD; - if (caccess & ISC_FSACCESS_LISTDIRECTORY) + } + if ((caccess & ISC_FSACCESS_LISTDIRECTORY) != 0) { NTFSbits |= FILE_LIST_DIRECTORY; - if (caccess & ISC_FSACCESS_ACCESSCHILD) + } + if ((caccess & ISC_FSACCESS_ACCESSCHILD) != 0) { NTFSbits |= FILE_TRAVERSE; + } } /* Add the ACE to the ACL */ if (!AddAccessAllowedAce(pacl, ACL_REVISION, NTFSbits, diff --git a/lib/isc/win32/socket.c b/lib/isc/win32/socket.c index 75b1c26780..0a8f55047a 100644 --- a/lib/isc/win32/socket.c +++ b/lib/isc/win32/socket.c @@ -1950,11 +1950,11 @@ send_recvdone_event(isc_socket_t *sock, isc_socketevent_t **dev) { if (ISC_LINK_LINKED(*dev, ev_link)) ISC_LIST_DEQUEUE(sock->recv_list, *dev, ev_link); - if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) - == ISC_SOCKEVENTATTR_ATTACHED) + if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) != 0) { isc_task_sendanddetach(&task, (isc_event_t **)dev); - else + } else { isc_task_send(task, (isc_event_t **)dev); + } CONSISTENT(sock); } @@ -1974,11 +1974,11 @@ send_senddone_event(isc_socket_t *sock, isc_socketevent_t **dev) { if (ISC_LINK_LINKED(*dev, ev_link)) ISC_LIST_DEQUEUE(sock->send_list, *dev, ev_link); - if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) - == ISC_SOCKEVENTATTR_ATTACHED) + if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) != 0) { isc_task_sendanddetach(&task, (isc_event_t **)dev); - else + } else { isc_task_send(task, (isc_event_t **)dev); + } CONSISTENT(sock); } @@ -3738,7 +3738,7 @@ isc__socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) { * o Reset any state needed. */ - if ((how & ISC_SOCKCANCEL_RECV) == ISC_SOCKCANCEL_RECV) { + if ((how & ISC_SOCKCANCEL_RECV) != 0) { isc_socketevent_t *dev; isc_socketevent_t *next; isc_task_t *current_task; @@ -3756,7 +3756,7 @@ isc__socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) { } how &= ~ISC_SOCKCANCEL_RECV; - if ((how & ISC_SOCKCANCEL_SEND) == ISC_SOCKCANCEL_SEND) { + if ((how & ISC_SOCKCANCEL_SEND) != 0) { isc_socketevent_t *dev; isc_socketevent_t *next; isc_task_t *current_task; @@ -3775,7 +3775,7 @@ isc__socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) { } how &= ~ISC_SOCKCANCEL_SEND; - if (((how & ISC_SOCKCANCEL_ACCEPT) == ISC_SOCKCANCEL_ACCEPT) + if (((how & ISC_SOCKCANCEL_ACCEPT) != 0) && !ISC_LIST_EMPTY(sock->accept_list)) { isc_socket_newconnev_t *dev; isc_socket_newconnev_t *next; @@ -3802,7 +3802,7 @@ isc__socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) { } how &= ~ISC_SOCKCANCEL_ACCEPT; - if (((how & ISC_SOCKCANCEL_CONNECT) == ISC_SOCKCANCEL_CONNECT) + if (((how & ISC_SOCKCANCEL_CONNECT) != 0) && !ISC_LIST_EMPTY(sock->connect_list)) { isc_socket_connev_t *dev; isc_socket_connev_t *next; diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index 1132841403..d27003ba74 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -3169,20 +3169,22 @@ doc_querysource(cfg_printer_t *pctx, const cfg_type_t *type) { const unsigned int *flagp = type->of; cfg_print_cstr(pctx, "( ( [ address ] ( "); - if (*flagp & CFG_ADDR_V4OK) + if ((*flagp & CFG_ADDR_V4OK) != 0) { cfg_print_cstr(pctx, ""); - else if (*flagp & CFG_ADDR_V6OK) + } else if ((*flagp & CFG_ADDR_V6OK) != 0) { cfg_print_cstr(pctx, ""); - else + } else { INSIST(0); + } cfg_print_cstr(pctx, " | * ) [ port ( | * ) ] ) | " "( [ [ address ] ( "); - if (*flagp & CFG_ADDR_V4OK) + if ((*flagp & CFG_ADDR_V4OK) != 0) { cfg_print_cstr(pctx, ""); - else if (*flagp & CFG_ADDR_V6OK) + } else if ((*flagp & CFG_ADDR_V6OK) != 0) { cfg_print_cstr(pctx, ""); - else + } else { INSIST(0); + } cfg_print_cstr(pctx, " | * ) ] port ( | * ) ) )" " [ dscp ]"); } diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index e08e257d2e..e1abed9d9a 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -1804,7 +1804,8 @@ cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) /* Single-valued clause */ if (result == ISC_R_NOTFOUND) { bool callback = - (clause->flags & CFG_CLAUSEFLAG_CALLBACK); + ((clause->flags & + CFG_CLAUSEFLAG_CALLBACK) != 0); CHECK(parse_symtab_elt(pctx, clause->name, clause->type, obj->value.map.symtab, @@ -2505,27 +2506,29 @@ static void cfg_doc_netaddr(cfg_printer_t *pctx, const cfg_type_t *type) { const unsigned int *flagp = type->of; int n = 0; - if (*flagp != CFG_ADDR_V4OK && *flagp != CFG_ADDR_V6OK) + if (*flagp != CFG_ADDR_V4OK && *flagp != CFG_ADDR_V6OK) { cfg_print_cstr(pctx, "( "); - if (*flagp & CFG_ADDR_V4OK) { + } + if ((*flagp & CFG_ADDR_V4OK) != 0) { cfg_print_cstr(pctx, ""); n++; } - if (*flagp & CFG_ADDR_V6OK) { + if ((*flagp & CFG_ADDR_V6OK) != 0) { if (n != 0) cfg_print_cstr(pctx, " | "); cfg_print_cstr(pctx, ""); n++; } - if (*flagp & CFG_ADDR_WILDOK) { + if ((*flagp & CFG_ADDR_WILDOK) != 0) { if (n != 0) cfg_print_cstr(pctx, " | "); cfg_print_cstr(pctx, "*"); n++; POST(n); } - if (*flagp != CFG_ADDR_V4OK && *flagp != CFG_ADDR_V6OK) + if (*flagp != CFG_ADDR_V4OK && *flagp != CFG_ADDR_V6OK) { cfg_print_cstr(pctx, " )"); + } } LIBISCCFG_EXTERNAL_DATA cfg_type_t cfg_type_netaddr = { @@ -2753,17 +2756,17 @@ cfg_doc_sockaddr(cfg_printer_t *pctx, const cfg_type_t *type) { REQUIRE(type != NULL); cfg_print_cstr(pctx, "( "); - if (*flagp & CFG_ADDR_V4OK) { + if ((*flagp & CFG_ADDR_V4OK) != 0) { cfg_print_cstr(pctx, ""); n++; } - if (*flagp & CFG_ADDR_V6OK) { + if ((*flagp & CFG_ADDR_V6OK) != 0) { if (n != 0) cfg_print_cstr(pctx, " | "); cfg_print_cstr(pctx, ""); n++; } - if (*flagp & CFG_ADDR_WILDOK) { + if ((*flagp & CFG_ADDR_WILDOK) != 0) { if (n != 0) cfg_print_cstr(pctx, " | "); cfg_print_cstr(pctx, "*"); @@ -2771,7 +2774,7 @@ cfg_doc_sockaddr(cfg_printer_t *pctx, const cfg_type_t *type) { POST(n); } cfg_print_cstr(pctx, " ) "); - if (*flagp & CFG_ADDR_WILDOK) { + if ((*flagp & CFG_ADDR_WILDOK) != 0) { cfg_print_cstr(pctx, "[ port ( | * ) ]"); } else { cfg_print_cstr(pctx, "[ port ]"); @@ -3012,12 +3015,13 @@ parser_complain(cfg_parser_t *pctx, bool is_warning, } /* Choose a preposition. */ - if (flags & CFG_LOG_NEAR) + if ((flags & CFG_LOG_NEAR) != 0) { prep = " near "; - else if (flags & CFG_LOG_BEFORE) + } else if ((flags & CFG_LOG_BEFORE) != 0) { prep = " before "; - else + } else { prep = " "; + } } else { tokenbuf[0] = '\0'; } From 7eb962ee145da9b6b3869c83cc7139db8b1523ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Sat, 13 Oct 2018 11:39:55 +0200 Subject: [PATCH 03/11] Add a GitLab CI job that runs with all assertions disabled (cherry picked from commit 461ffead1f45e0f5f8811d86c0d8452f25fc4ffc) (cherry picked from commit c5825eba40fd904cf76403ae6c67958a8a5765cb) --- .gitlab-ci.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 67e59ef619..95e606b557 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -307,3 +307,23 @@ install:debian:sid:amd64: <<: *install_test_job dependencies: - build:debian:sid:amd64 + +noassert:build:debian:sid:amd64: + variables: + CC: gcc + CFLAGS: "-Wall -Wextra -O2 -g -DISC_CHECK_NONE=1" + EXTRA_CONFIGURE: "--with-libidn2" + <<: *debian_sid_amd64_image + <<: *build_job + +noassert:unittest:debian:sid:amd64: + <<: *debian_sid_amd64_image + <<: *unit_test_job + dependencies: + - noassert:build:debian:sid:amd64 + +noassert:systemtest:debian:sid:amd64: + <<: *debian_sid_amd64_image + <<: *system_test_job + dependencies: + - noassert:build:debian:sid:amd64 From f1224b4af14d2ecc95dfb253a89a9f4a77a01bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Sat, 13 Oct 2018 11:52:08 +0200 Subject: [PATCH 04/11] When ISC assertions are disabled, still execute the condition to prevent unused variable warnings/errors from the compiler (cherry picked from commit a831e0f72df901ff046ab0e4b7c14debb5d0ddbc) (cherry picked from commit 3d834566f15ea2ffd6ab198826022e6983edfb38) --- lib/isc/include/isc/assertions.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/isc/include/isc/assertions.h b/lib/isc/include/isc/assertions.h index e5719d98d7..62e883d17b 100644 --- a/lib/isc/include/isc/assertions.h +++ b/lib/isc/include/isc/assertions.h @@ -80,7 +80,7 @@ isc_assertion_typetotext(isc_assertiontype_t type); isc_assertiontype_require, \ #cond), 0))) #else -#define ISC_REQUIRE(cond) ((void) 0) +#define ISC_REQUIRE(cond) ((void) ISC_LIKELY(cond)) #endif /* ISC_CHECK_REQUIRE */ #if ISC_CHECK_ENSURE != 0 @@ -90,7 +90,7 @@ isc_assertion_typetotext(isc_assertiontype_t type); isc_assertiontype_ensure, \ #cond), 0))) #else -#define ISC_ENSURE(cond) ((void) 0) +#define ISC_ENSURE(cond) ((void) ISC_LIKELY(cond)) #endif /* ISC_CHECK_ENSURE */ #if ISC_CHECK_INSIST != 0 @@ -100,7 +100,7 @@ isc_assertion_typetotext(isc_assertiontype_t type); isc_assertiontype_insist, \ #cond), 0))) #else -#define ISC_INSIST(cond) ((void) 0) +#define ISC_INSIST(cond) ((void) ISC_LIKELY(cond)) #endif /* ISC_CHECK_INSIST */ #if ISC_CHECK_INVARIANT != 0 @@ -110,7 +110,7 @@ isc_assertion_typetotext(isc_assertiontype_t type); isc_assertiontype_invariant, \ #cond), 0))) #else -#define ISC_INVARIANT(cond) ((void) 0) +#define ISC_INVARIANT(cond) ((void) ISC_LIKELY(cond)) #endif /* ISC_CHECK_INVARIANT */ ISC_LANG_ENDDECLS From c576cb2ff6126f1a65e6983ce1947d1cd37d2af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Sat, 13 Oct 2018 12:10:43 +0200 Subject: [PATCH 05/11] Don't assert on failed getrlimit call to allow called to handle this gracefully as it already does, just abort where we need to know the numbers (cherry picked from commit e2e138a801a7fa9d31ef24ea5e8b15af07d147cd) (cherry picked from commit 1e6329038b176e62c89ed03332206cd74db12d51) --- lib/isc/unix/resource.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/isc/unix/resource.c b/lib/isc/unix/resource.c index 6d5c5aae24..eaebf0256c 100644 --- a/lib/isc/unix/resource.c +++ b/lib/isc/unix/resource.c @@ -194,34 +194,38 @@ isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) { isc_result_t isc_resource_getlimit(isc_resource_t resource, isc_resourcevalue_t *value) { - int unixresult; int unixresource; struct rlimit rl; isc_result_t result; result = resource2rlim(resource, &unixresource); - if (result == ISC_R_SUCCESS) { - unixresult = getrlimit(unixresource, &rl); - INSIST(unixresult == 0); - *value = rl.rlim_max; + if (result != ISC_R_SUCCESS) { + return (result); } - return (result); + if (getrlimit(unixresource, &rl) != 0) { + return (isc__errno2result(errno)); + } + + *value = rl.rlim_max; + return (ISC_R_SUCCESS); } isc_result_t isc_resource_getcurlimit(isc_resource_t resource, isc_resourcevalue_t *value) { - int unixresult; int unixresource; struct rlimit rl; isc_result_t result; result = resource2rlim(resource, &unixresource); - if (result == ISC_R_SUCCESS) { - unixresult = getrlimit(unixresource, &rl); - INSIST(unixresult == 0); - *value = rl.rlim_cur; + if (result != ISC_R_SUCCESS) { + return (result); } - return (result); + if (getrlimit(unixresource, &rl) != 0) { + return (isc__errno2result(errno)); + } + + *value = rl.rlim_cur; + return (ISC_R_SUCCESS); } From d894b2da79687475d5cf90fbc37ce9f259a68c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 24 Oct 2018 16:28:21 +0200 Subject: [PATCH 06/11] Use larger buffers on snprintf buffer overflow false positives (cherry picked from commit 4eaf9275719f0512993376828ecf6df310c0f340) (cherry picked from commit 65536fb10bdda48c347a4a6bd6adbef9d172697f) --- lib/dns/rdata/generic/loc_29.c | 7 ++++--- lib/dns/rdata/in_1/dhcid_49.c | 11 +++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/dns/rdata/generic/loc_29.c b/lib/dns/rdata/generic/loc_29.c index 50c00ff9f7..7af1c18731 100644 --- a/lib/dns/rdata/generic/loc_29.c +++ b/lib/dns/rdata/generic/loc_29.c @@ -454,11 +454,12 @@ totext_loc(ARGS_TOTEXT) { bool east; bool below; isc_region_t sr; - char buf[sizeof("89 59 59.999 N 179 59 59.999 E " - "-42849672.95m 90000000m 90000000m 90000000m")]; char sbuf[sizeof("90000000m")]; char hbuf[sizeof("90000000m")]; char vbuf[sizeof("90000000m")]; + /* "89 59 59.999 N 179 59 59.999 E " */ + /* "-42849672.95m 90000000m 90000000m 90000000m"; */ + char buf[8*6 + 12*1 + 2*10 + sizeof(sbuf)+sizeof(hbuf)+sizeof(vbuf)]; unsigned char size, hp, vp; unsigned long poweroften[8] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000 }; @@ -550,7 +551,7 @@ totext_loc(ARGS_TOTEXT) { altitude -= 10000000; } - snprintf(buf, sizeof(buf), + snprintf(NULL, 0, "%d %d %d.%03d %s %d %d %d.%03d %s %s%lu.%02lum %s %s %s", d1, m1, s1, fs1, north ? "N" : "S", d2, m2, s2, fs2, east ? "E" : "W", diff --git a/lib/dns/rdata/in_1/dhcid_49.c b/lib/dns/rdata/in_1/dhcid_49.c index 90971b7827..9fce42d473 100644 --- a/lib/dns/rdata/in_1/dhcid_49.c +++ b/lib/dns/rdata/in_1/dhcid_49.c @@ -35,8 +35,8 @@ fromtext_in_dhcid(ARGS_FROMTEXT) { static inline isc_result_t totext_in_dhcid(ARGS_TOTEXT) { isc_region_t sr, sr2; - char buf[sizeof(" ; 64000 255 64000")]; - size_t n; + /* " ; 64000 255 64000" */ + char buf[5 + 3*5 + 1]; REQUIRE(rdata->type == dns_rdatatype_dhcid); REQUIRE(rdata->rdclass == dns_rdataclass_in); @@ -55,10 +55,9 @@ totext_in_dhcid(ARGS_TOTEXT) { if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) { RETERR(str_totext(/* ( */ " )", target)); if (rdata->length > 2) { - n = snprintf(buf, sizeof(buf), " ; %u %u %u", - sr2.base[0] * 256U + sr2.base[1], - sr2.base[2], rdata->length - 3U); - INSIST(n < sizeof(buf)); + snprintf(NULL, 0, " ; %u %u %u", + sr2.base[0] * 256U + sr2.base[1], + sr2.base[2], rdata->length - 3U); RETERR(str_totext(buf, target)); } } From 6aa63d934992bafacfd6ee2501c989684c3825af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 24 Oct 2018 16:28:55 +0200 Subject: [PATCH 07/11] Add extra return failure after INSIST(0) in default branch (cherry picked from commit 29c45200e7e344920ca6d2b9a2d00596d581edfe) (cherry picked from commit 2a261892561370412d30b3b15e453152cb6419f6) --- lib/dns/openssleddsa_link.c | 1 + lib/dns/rdata/generic/loc_29.c | 2 +- lib/dns/rdata/in_1/dhcid_49.c | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/dns/openssleddsa_link.c b/lib/dns/openssleddsa_link.c index b76fac918b..43f11e790a 100644 --- a/lib/dns/openssleddsa_link.c +++ b/lib/dns/openssleddsa_link.c @@ -477,6 +477,7 @@ openssleddsa_todns(const dst_key_t *key, isc_buffer_t *data) { default: INSIST(0); } + return (DST_R_OPENSSLFAILURE); } static isc_result_t diff --git a/lib/dns/rdata/generic/loc_29.c b/lib/dns/rdata/generic/loc_29.c index 7af1c18731..388742b836 100644 --- a/lib/dns/rdata/generic/loc_29.c +++ b/lib/dns/rdata/generic/loc_29.c @@ -551,7 +551,7 @@ totext_loc(ARGS_TOTEXT) { altitude -= 10000000; } - snprintf(NULL, 0, + snprintf(buf, sizeof(buf), "%d %d %d.%03d %s %d %d %d.%03d %s %s%lu.%02lum %s %s %s", d1, m1, s1, fs1, north ? "N" : "S", d2, m2, s2, fs2, east ? "E" : "W", diff --git a/lib/dns/rdata/in_1/dhcid_49.c b/lib/dns/rdata/in_1/dhcid_49.c index 9fce42d473..1f2c30d883 100644 --- a/lib/dns/rdata/in_1/dhcid_49.c +++ b/lib/dns/rdata/in_1/dhcid_49.c @@ -36,7 +36,7 @@ static inline isc_result_t totext_in_dhcid(ARGS_TOTEXT) { isc_region_t sr, sr2; /* " ; 64000 255 64000" */ - char buf[5 + 3*5 + 1]; + char buf[5 + 3*11 + 1]; REQUIRE(rdata->type == dns_rdatatype_dhcid); REQUIRE(rdata->rdclass == dns_rdataclass_in); @@ -55,7 +55,7 @@ totext_in_dhcid(ARGS_TOTEXT) { if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) { RETERR(str_totext(/* ( */ " )", target)); if (rdata->length > 2) { - snprintf(NULL, 0, " ; %u %u %u", + snprintf(buf, sizeof(buf), " ; %u %u %u", sr2.base[0] * 256U + sr2.base[1], sr2.base[2], rdata->length - 3U); RETERR(str_totext(buf, target)); From baa5811623e7b7021c8d83bfbb4818cadf31d5fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 24 Oct 2018 20:00:46 +0200 Subject: [PATCH 08/11] Modify the dbversion_test.c to detect disabled assertions (cherry picked from commit b992b5b811271f5447856cf40a0bbc41a9dc9723) (cherry picked from commit ce6ef5b50e173d378a15390495fdcb2d8877e396) --- lib/dns/tests/dbversion_test.c | 79 ++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 13 deletions(-) diff --git a/lib/dns/tests/dbversion_test.c b/lib/dns/tests/dbversion_test.c index 275fc9bf85..43aa1fe7e5 100644 --- a/lib/dns/tests/dbversion_test.c +++ b/lib/dns/tests/dbversion_test.c @@ -103,9 +103,13 @@ attachversion(isc_assertioncallback_t callback) { isc_assertion_setcallback(callback); dns_db_attachversion(db1, VERSION(callback), &v); - if (callback != NULL) + if (callback != NULL) { +#ifndef ISC_CHECK_NONE atf_tc_fail("dns_db_attachversion did not assert"); - +#else + atf_tc_pass(); +#endif + } ATF_REQUIRE_EQ(v, v1); dns_db_closeversion(db1, &v, false); ATF_REQUIRE_EQ(v, NULL); @@ -147,8 +151,13 @@ closeversion(isc_assertioncallback_t callback) { isc_assertion_setcallback(callback); dns_db_closeversion(db1, VERSIONP(callback), false); - if (callback != NULL) + if (callback != NULL) { +#ifndef ISC_CHECK_NONE atf_tc_fail("dns_db_closeversion did not assert"); +#else + atf_tc_pass(); +#endif + } ATF_REQUIRE_EQ(v1, NULL); close_db(); @@ -195,8 +204,13 @@ find(isc_assertioncallback_t callback) { result = dns_db_find(db1, dns_rootname, VERSION(callback), dns_rdatatype_soa, 0, 0, NULL, dns_fixedname_name(&fixed), &rdataset, NULL); - if (callback != NULL) + if (callback != NULL) { +#ifndef ISC_CHECK_NONE atf_tc_fail("dns_db_find did not assert"); +#else + atf_tc_pass(); +#endif + } ATF_REQUIRE_EQ(result, DNS_R_NXDOMAIN); close_db(); @@ -242,8 +256,13 @@ allrdatasets(isc_assertioncallback_t callback) { isc_assertion_setcallback(callback); result = dns_db_allrdatasets(db1, node, VERSION(callback), 0, &iterator); - if (callback != NULL) + if (callback != NULL) { +#ifndef ISC_CHECK_NONE atf_tc_fail("dns_db_allrdatasets did not assert"); +#else + atf_tc_pass(); +#endif + } ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); dns_rdatasetiter_destroy(&iterator); @@ -300,8 +319,13 @@ findrdataset(isc_assertioncallback_t callback) { isc_assertion_setcallback(callback); result = dns_db_findrdataset(db1, node, VERSION(callback), dns_rdatatype_soa, 0, 0, &rdataset, NULL); - if (callback != NULL) + if (callback != NULL) { +#ifndef ISC_CHECK_NONE atf_tc_fail("dns_db_findrdataset did not assert"); +#else + atf_tc_pass(); +#endif + } ATF_REQUIRE_EQ(result, ISC_R_NOTFOUND); dns_db_detachnode(db1, &node); @@ -355,8 +379,13 @@ deleterdataset(isc_assertioncallback_t callback) { isc_assertion_setcallback(callback); result = dns_db_deleterdataset(db1, node, VERSION(callback), dns_rdatatype_soa, 0); - if (callback != NULL) + if (callback != NULL) { +#ifndef ISC_CHECK_NONE atf_tc_fail("dns_db_deleterdataset did not assert"); +#else + atf_tc_pass(); +#endif + } ATF_REQUIRE_EQ(result, DNS_R_UNCHANGED); dns_db_detachnode(db1, &node); @@ -417,8 +446,13 @@ subtract(isc_assertioncallback_t callback) { isc_assertion_setcallback(callback); result = dns_db_subtractrdataset(db1, node, VERSION(callback), &rdataset, 0, NULL); - if (callback != NULL) + if (callback != NULL) { +#ifndef ISC_CHECK_NONE atf_tc_fail("dns_db_subtractrdataset did not assert"); +#else + atf_tc_pass(); +#endif + } ATF_REQUIRE_EQ(result, DNS_R_UNCHANGED); dns_db_detachnode(db1, &node); @@ -468,8 +502,13 @@ dump(isc_assertioncallback_t callback) { isc_assertion_setcallback(callback); result = dns_db_dump(db1, VERSION(callback), tempname); (void)unlink(tempname); - if (callback != NULL) + if (callback != NULL) { +#ifndef ISC_CHECK_NONE atf_tc_fail("dns_db_dump did not assert"); +#else + atf_tc_pass(); +#endif + } ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); close_db(); @@ -527,8 +566,13 @@ addrdataset(isc_assertioncallback_t callback) { isc_assertion_setcallback(callback); result = dns_db_addrdataset(db1, node, VERSION(callback), 0, &rdataset, 0, NULL); - if (callback != NULL) + if (callback != NULL) { +#ifndef ISC_CHECK_NONE atf_tc_fail("dns_db_adddataset did not assert"); +#else + atf_tc_pass(); +#endif + } ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); dns_db_detachnode(db1, &node); @@ -579,8 +623,13 @@ getnsec3parameters(isc_assertioncallback_t callback) { result = dns_db_getnsec3parameters(db1, VERSION(callback), &hash, &flags, &iterations, salt, &salt_length); - if (callback != NULL) + if (callback != NULL) { +#ifndef ISC_CHECK_NONE atf_tc_fail("dns_db_dump did not assert"); +#else + atf_tc_pass(); +#endif + } ATF_REQUIRE_EQ(result, ISC_R_NOTFOUND); close_db(); @@ -672,9 +721,13 @@ resigned(isc_assertioncallback_t callback) { isc_assertion_setcallback(callback); dns_db_resigned(db1, &added, VERSION(callback)); - if (callback != NULL) + if (callback != NULL) { +#ifndef ISC_CHECK_NONE atf_tc_fail("dns_db_resigned did not assert"); - +#else + atf_tc_pass(); +#endif + } dns_rdataset_disassociate(&added); close_db(); From 2f8b28efad6641b5d5c645d379f50fbc98230463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 7 Nov 2018 15:00:07 +0700 Subject: [PATCH 09/11] Hint the compiler with ISC_UNREACHABLE(); that code after INSIST(0); cannot be reached (cherry picked from commit 23fff6c569e656274cf1543ac36b014e25c906ed) (cherry picked from commit 4568669807031938f0004dd35243cb6199c8b973) --- bin/check/named-checkconf.c | 34 ++++++++---- bin/check/named-checkzone.c | 8 ++- bin/confgen/ddns-confgen.c | 6 +- bin/delv/delv.c | 1 + bin/dig/dighost.c | 1 + bin/named/client.c | 13 +++-- bin/named/config.c | 15 +++-- bin/named/logconf.c | 1 + bin/named/query.c | 3 + bin/named/server.c | 97 ++++++++++++++++++++------------ bin/named/xfrout.c | 2 +- bin/named/zoneconf.c | 101 ++++++++++++++++++++++------------ lib/bind9/check.c | 12 ++-- lib/dns/acl.c | 4 +- lib/dns/client.c | 2 + lib/dns/diff.c | 1 + lib/dns/dispatch.c | 4 +- lib/dns/dnstap.c | 1 + lib/dns/geoip.c | 4 ++ lib/dns/journal.c | 2 + lib/dns/masterdump.c | 3 +- lib/dns/message.c | 4 +- lib/dns/openssleddsa_link.c | 2 +- lib/dns/opensslrsa_link.c | 10 ++++ lib/dns/peer.c | 3 +- lib/dns/pkcs11rsa_link.c | 10 ++++ lib/dns/rbtdb.c | 4 ++ lib/dns/resolver.c | 1 + lib/dns/rpz.c | 13 ++--- lib/dns/rrl.c | 5 +- lib/dns/sdb.c | 2 +- lib/dns/sdlz.c | 2 +- lib/dns/ssu.c | 2 + lib/dns/tsec.c | 3 + lib/dns/update.c | 3 + lib/dns/validator.c | 4 +- lib/dns/xfrin.c | 3 +- lib/dns/zone.c | 6 +- lib/irs/getnameinfo.c | 1 + lib/isc/hmacmd5.c | 13 +---- lib/isc/md5.c | 11 +--- lib/isc/mem.c | 2 + lib/isc/netaddr.c | 1 + lib/isc/sockaddr.c | 2 + lib/isc/unix/interfaceiter.c | 2 +- lib/isc/unix/net.c | 1 + lib/isc/unix/socket.c | 4 +- lib/isc/win32/interfaceiter.c | 2 +- lib/isccc/sexpr.c | 1 + lib/isccfg/aclconf.c | 5 +- lib/isccfg/namedconf.c | 11 +++- lib/isccfg/parser.c | 6 +- 52 files changed, 298 insertions(+), 156 deletions(-) diff --git a/bin/check/named-checkconf.c b/bin/check/named-checkconf.c index 29ff8218b7..ff1c0d260a 100644 --- a/bin/check/named-checkconf.c +++ b/bin/check/named-checkconf.c @@ -265,8 +265,10 @@ configure_zone(const char *vclass, const char *view, } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { zone_options &= ~DNS_ZONEOPT_CHECKDUPRR; zone_options &= ~DNS_ZONEOPT_CHECKDUPRRFAIL; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } else { zone_options |= DNS_ZONEOPT_CHECKDUPRR; zone_options &= ~DNS_ZONEOPT_CHECKDUPRRFAIL; @@ -283,8 +285,10 @@ configure_zone(const char *vclass, const char *view, } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { zone_options &= ~DNS_ZONEOPT_CHECKMX; zone_options &= ~DNS_ZONEOPT_CHECKMXFAIL; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } else { zone_options |= DNS_ZONEOPT_CHECKMX; zone_options &= ~DNS_ZONEOPT_CHECKMXFAIL; @@ -310,8 +314,10 @@ configure_zone(const char *vclass, const char *view, } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { zone_options |= DNS_ZONEOPT_WARNMXCNAME; zone_options |= DNS_ZONEOPT_IGNOREMXCNAME; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } else { zone_options |= DNS_ZONEOPT_WARNMXCNAME; zone_options &= ~DNS_ZONEOPT_IGNOREMXCNAME; @@ -328,8 +334,10 @@ configure_zone(const char *vclass, const char *view, } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { zone_options |= DNS_ZONEOPT_WARNSRVCNAME; zone_options |= DNS_ZONEOPT_IGNORESRVCNAME; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } else { zone_options |= DNS_ZONEOPT_WARNSRVCNAME; zone_options &= ~DNS_ZONEOPT_IGNORESRVCNAME; @@ -349,8 +357,10 @@ configure_zone(const char *vclass, const char *view, zone_options |= DNS_ZONEOPT_CHECKSPF; } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { zone_options &= ~DNS_ZONEOPT_CHECKSPF; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } else { zone_options |= DNS_ZONEOPT_CHECKSPF; } @@ -366,8 +376,10 @@ configure_zone(const char *vclass, const char *view, } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { zone_options &= ~DNS_ZONEOPT_CHECKNAMES; zone_options &= ~DNS_ZONEOPT_CHECKNAMESFAIL; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } else { zone_options |= DNS_ZONEOPT_CHECKNAMES; zone_options |= DNS_ZONEOPT_CHECKNAMESFAIL; @@ -377,14 +389,16 @@ configure_zone(const char *vclass, const char *view, fmtobj = NULL; if (get_maps(maps, "masterfile-format", &fmtobj)) { const char *masterformatstr = cfg_obj_asstring(fmtobj); - if (strcasecmp(masterformatstr, "text") == 0) + if (strcasecmp(masterformatstr, "text") == 0) { masterformat = dns_masterformat_text; - else if (strcasecmp(masterformatstr, "raw") == 0) + } else if (strcasecmp(masterformatstr, "raw") == 0) { masterformat = dns_masterformat_raw; - else if (strcasecmp(masterformatstr, "map") == 0) + } else if (strcasecmp(masterformatstr, "map") == 0) { masterformat = dns_masterformat_map; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } obj = NULL; diff --git a/bin/check/named-checkzone.c b/bin/check/named-checkzone.c index 0f491fa03d..7640112907 100644 --- a/bin/check/named-checkzone.c +++ b/bin/check/named-checkzone.c @@ -141,12 +141,14 @@ main(int argc, char **argv) { #define PROGCMP(X) \ (strcasecmp(prog_name, X) == 0 || strcasecmp(prog_name, X ".exe") == 0) - if (PROGCMP("named-checkzone")) + if (PROGCMP("named-checkzone")) { progmode = progmode_check; - else if (PROGCMP("named-compilezone")) + } else if (PROGCMP("named-compilezone")) { progmode = progmode_compile; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } /* Compilation specific defaults */ if (progmode == progmode_compile) { diff --git a/bin/confgen/ddns-confgen.c b/bin/confgen/ddns-confgen.c index 5220ed6995..9e4f6176e6 100644 --- a/bin/confgen/ddns-confgen.c +++ b/bin/confgen/ddns-confgen.c @@ -130,10 +130,12 @@ main(int argc, char **argv) { if (PROGCMP("tsig-keygen")) { progmode = progmode_keygen; quiet = true; - } else if (PROGCMP("ddns-confgen")) + } else if (PROGCMP("ddns-confgen")) { progmode = progmode_confgen; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } isc_commandline_errprint = false; diff --git a/bin/delv/delv.c b/bin/delv/delv.c index d0b5515d4a..b42027250d 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -1236,6 +1236,7 @@ dash_option(char *option, char *next, bool *open_type_class) { /* NOTREACHED */ default: INSIST(0); + ISC_UNREACHABLE(); } if (strlen(option) > 1U) option = &option[1]; diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 9a9e221a8e..39abb9d0fd 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -2705,6 +2705,7 @@ setup_lookup(dig_lookup_t *lookup) { break; default: INSIST(0); + ISC_UNREACHABLE(); } isc_buffer_init(&b, ecsbuf, sizeof(ecsbuf)); diff --git a/bin/named/client.c b/bin/named/client.c index 7f1d614a25..9c9a90b6cb 100644 --- a/bin/named/client.c +++ b/bin/named/client.c @@ -617,6 +617,7 @@ exit_check(ns_client_t *client) { if (ns_g_clienttest && isc_mem_references(client->mctx) != 1) { isc_mem_stats(client->mctx, stderr); INSIST(0); + ISC_UNREACHABLE(); } /* @@ -1230,7 +1231,7 @@ client_send(ns_client_t *client) { break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } } else { respsize = isc_buffer_usedlength(&buffer); @@ -1256,7 +1257,7 @@ client_send(ns_client_t *client) { break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } } @@ -1664,6 +1665,7 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message, break; default: INSIST(0); + ISC_UNREACHABLE(); } isc_buffer_init(&buf, ecs, sizeof(ecs)); @@ -1851,6 +1853,7 @@ compute_cookie(ns_client_t *client, uint32_t when, uint32_t nonce, break; default: INSIST(0); + ISC_UNREACHABLE(); } isc_hmacsha1_update(&hmacsha1, cp, length); isc_hmacsha1_sign(&hmacsha1, digest, sizeof(digest)); @@ -1886,6 +1889,7 @@ compute_cookie(ns_client_t *client, uint32_t when, uint32_t nonce, break; default: INSIST(0); + ISC_UNREACHABLE(); } isc_hmacsha256_update(&hmacsha256, cp, length); isc_hmacsha256_sign(&hmacsha256, digest, sizeof(digest)); @@ -1895,6 +1899,7 @@ compute_cookie(ns_client_t *client, uint32_t when, uint32_t nonce, } default: INSIST(0); + ISC_UNREACHABLE(); } } @@ -2439,7 +2444,7 @@ client_request(isc_task_t *task, isc_event_t *event) { break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } } else { switch (isc_sockaddr_pf(&client->peeraddr)) { @@ -2453,7 +2458,7 @@ client_request(isc_task_t *task, isc_event_t *event) { break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } } diff --git a/bin/named/config.c b/bin/named/config.c index 2732a8fd79..7584efba94 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -423,18 +423,20 @@ ns_config_getzonetype(const cfg_obj_t *zonetypeobj) { const char *str; str = cfg_obj_asstring(zonetypeobj); - if (strcasecmp(str, "master") == 0) + if (strcasecmp(str, "master") == 0) { ztype = dns_zone_master; - else if (strcasecmp(str, "slave") == 0) + } else if (strcasecmp(str, "slave") == 0) { ztype = dns_zone_slave; - else if (strcasecmp(str, "stub") == 0) + } else if (strcasecmp(str, "stub") == 0) { ztype = dns_zone_stub; - else if (strcasecmp(str, "static-stub") == 0) + } else if (strcasecmp(str, "static-stub") == 0) { ztype = dns_zone_staticstub; - else if (strcasecmp(str, "redirect") == 0) + } else if (strcasecmp(str, "redirect") == 0) { ztype = dns_zone_redirect; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } return (ztype); } @@ -1008,6 +1010,7 @@ ns_config_getkeyalgorithm2(const char *str, dns_name_t **name, case hmacsha512: *name = dns_tsig_hmacsha512_name; break; default: INSIST(0); + ISC_UNREACHABLE(); } } if (typep != NULL) diff --git a/bin/named/logconf.c b/bin/named/logconf.c index e1cd762df4..5b3a14b0d7 100644 --- a/bin/named/logconf.c +++ b/bin/named/logconf.c @@ -157,6 +157,7 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) break; default: INSIST(0); + ISC_UNREACHABLE(); } type = ISC_LOG_TOFILE; diff --git a/bin/named/query.c b/bin/named/query.c index 6ebf9608a6..12c2e530a9 100644 --- a/bin/named/query.c +++ b/bin/named/query.c @@ -4471,6 +4471,7 @@ rpz_get_zbits(ns_client_t *client, break; default: INSIST(0); + ISC_UNREACHABLE(); break; } @@ -4695,6 +4696,7 @@ rpz_get_p_name(ns_client_t *client, dns_name_t *p_name, break; default: INSIST(0); + ISC_UNREACHABLE(); } /* @@ -6009,6 +6011,7 @@ setup_query_sortlist(ns_client_t *client) { break; default: INSIST(0); + ISC_UNREACHABLE(); break; } dns_message_setsortorder(client->message, order, order_arg); diff --git a/bin/named/server.c b/bin/named/server.c index 35af4dafdc..b85df51a98 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -1148,6 +1148,7 @@ get_view_querysource_dispatch(const cfg_obj_t **maps, int af, break; default: INSIST(0); + ISC_UNREACHABLE(); } sa = *(cfg_obj_assockaddr(obj)); @@ -1169,6 +1170,7 @@ get_view_querysource_dispatch(const cfg_obj_t **maps, int af, break; default: INSIST(0); + ISC_UNREACHABLE(); } if (result != ISC_R_SUCCESS) return (ISC_R_SUCCESS); @@ -1276,18 +1278,20 @@ configure_order(dns_order_t *order, const cfg_obj_t *ent) { obj = cfg_tuple_get(ent, "ordering"); INSIST(cfg_obj_isstring(obj)); str = cfg_obj_asstring(obj); - if (!strcasecmp(str, "fixed")) + if (!strcasecmp(str, "fixed")) { #if DNS_RDATASET_FIXED mode = DNS_RDATASETATTR_FIXEDORDER; #else mode = 0; #endif /* DNS_RDATASET_FIXED */ - else if (!strcasecmp(str, "random")) + } else if (!strcasecmp(str, "random")) { mode = DNS_RDATASETATTR_RANDOMIZE; - else if (!strcasecmp(str, "cyclic")) + } else if (!strcasecmp(str, "cyclic")) { mode = 0; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } /* * "*" should match everything including the root (BIND 8 compat). @@ -1401,14 +1405,16 @@ configure_peer(const cfg_obj_t *cpeer, isc_mem_t *mctx, dns_peer_t **peerp) { (void)cfg_map_get(cpeer, "transfer-format", &obj); if (obj != NULL) { str = cfg_obj_asstring(obj); - if (strcasecmp(str, "many-answers") == 0) + if (strcasecmp(str, "many-answers") == 0) { CHECK(dns_peer_settransferformat(peer, dns_many_answers)); - else if (strcasecmp(str, "one-answer") == 0) + } else if (strcasecmp(str, "one-answer") == 0) { CHECK(dns_peer_settransferformat(peer, dns_one_answer)); - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } obj = NULL; @@ -3561,8 +3567,10 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, view->checknames = false; } else if (strcasecmp(str, "ignore") == 0) { view->checknames = false; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } obj = NULL; result = ns_config_get(maps, "zero-no-soa-ttl-cache", &obj); @@ -3922,12 +3930,14 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, const char *resp = cfg_obj_asstring(obj2); isc_result_t r = DNS_R_SERVFAIL; - if (strcasecmp(resp, "drop") == 0) + if (strcasecmp(resp, "drop") == 0) { r = DNS_R_DROP; - else if (strcasecmp(resp, "fail") == 0) + } else if (strcasecmp(resp, "fail") == 0) { r = DNS_R_SERVFAIL; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } dns_resolver_setquotaresponse(view->resolver, dns_quotatype_server, r); @@ -4234,20 +4244,24 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, view->minimalresponses = dns_minimal_noauth; } else if (strcasecmp(str, "no-auth-recursive") == 0) { view->minimalresponses = dns_minimal_noauthrec; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } obj = NULL; result = ns_config_get(maps, "transfer-format", &obj); INSIST(result == ISC_R_SUCCESS); str = cfg_obj_asstring(obj); - if (strcasecmp(str, "many-answers") == 0) + if (strcasecmp(str, "many-answers") == 0) { view->transfer_format = dns_many_answers; - else if (strcasecmp(str, "one-answer") == 0) + } else if (strcasecmp(str, "one-answer") == 0) { view->transfer_format = dns_one_answer; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } obj = NULL; result = ns_config_get(maps, "trust-anchor-telemetry", &obj); @@ -4526,12 +4540,14 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, const char *resp = cfg_obj_asstring(obj2); isc_result_t r = DNS_R_SERVFAIL; - if (strcasecmp(resp, "drop") == 0) + if (strcasecmp(resp, "drop") == 0) { r = DNS_R_DROP; - else if (strcasecmp(resp, "fail") == 0) + } else if (strcasecmp(resp, "fail") == 0) { r = DNS_R_SERVFAIL; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } dns_resolver_setquotaresponse(view->resolver, dns_quotatype_zone, r); @@ -4548,10 +4564,12 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, view->v4_aaaa = dns_aaaa_ok; } else { const char *v4_aaaastr = cfg_obj_asstring(obj); - if (strcasecmp(v4_aaaastr, "break-dnssec") == 0) + if (strcasecmp(v4_aaaastr, "break-dnssec") == 0) { view->v4_aaaa = dns_aaaa_break_dnssec; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } obj = NULL; @@ -4564,10 +4582,12 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, view->v6_aaaa = dns_aaaa_ok; } else { const char *v6_aaaastr = cfg_obj_asstring(obj); - if (strcasecmp(v6_aaaastr, "break-dnssec") == 0) + if (strcasecmp(v6_aaaastr, "break-dnssec") == 0) { view->v6_aaaa = dns_aaaa_break_dnssec; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } CHECK(configure_view_acl(vconfig, config, ns_g_config, @@ -4813,14 +4833,16 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, statlevel = dns_zonestat_none; } else { const char *levelstr = cfg_obj_asstring(obj); - if (strcasecmp(levelstr, "full") == 0) + if (strcasecmp(levelstr, "full") == 0) { statlevel = dns_zonestat_full; - else if (strcasecmp(levelstr, "terse") == 0) + } else if (strcasecmp(levelstr, "terse") == 0) { statlevel = dns_zonestat_terse; - else if (strcasecmp(levelstr, "none") == 0) + } else if (strcasecmp(levelstr, "none") == 0) { statlevel = dns_zonestat_none; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } for (empty = empty_zones[empty_zone]; @@ -5139,16 +5161,18 @@ configure_forward(const cfg_obj_t *config, dns_view_t *view, dns_name_t *origin, "forwarding"); fwdpolicy = dns_fwdpolicy_none; } else { - if (forwardtype == NULL) + if (forwardtype == NULL) { fwdpolicy = dns_fwdpolicy_first; - else { + } else { const char *forwardstr = cfg_obj_asstring(forwardtype); - if (strcasecmp(forwardstr, "first") == 0) + if (strcasecmp(forwardstr, "first") == 0) { fwdpolicy = dns_fwdpolicy_first; - else if (strcasecmp(forwardstr, "only") == 0) + } else if (strcasecmp(forwardstr, "only") == 0) { fwdpolicy = dns_fwdpolicy_only; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } } @@ -8450,6 +8474,7 @@ load_configuration(const char *filename, ns_server_t *server, server->cookiealg = ns_cookiealg_aes; #else INSIST(0); + ISC_UNREACHABLE(); #endif } else if (strcasecmp(cfg_obj_asstring(obj), "sha1") == 0) { server->cookiealg = ns_cookiealg_sha1; @@ -8457,6 +8482,7 @@ load_configuration(const char *filename, ns_server_t *server, server->cookiealg = ns_cookiealg_sha256; } else { INSIST(0); + ISC_UNREACHABLE(); } obj = NULL; @@ -12016,12 +12042,14 @@ newzone_parse(ns_server_t *server, char *command, dns_view_t **viewp, isc_buffer_init(&argbuf, command, (unsigned int) strlen(command)); isc_buffer_add(&argbuf, strlen(command)); - if (strncasecmp(command, "add", 3) == 0) + if (strncasecmp(command, "add", 3) == 0) { bn = "addzone"; - else if (strncasecmp(command, "mod", 3) == 0) + } else if (strncasecmp(command, "mod", 3) == 0) { bn = "modzone"; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } /* * Convert the "addzone" or "modzone" to just "zone", for @@ -14208,6 +14236,7 @@ ns_server_mkeys(ns_server_t *server, isc_lex_t *lex, isc_buffer_t **text) { break; default: INSIST(0); + ISC_UNREACHABLE(); } if (viewtxt != NULL) diff --git a/bin/named/xfrout.c b/bin/named/xfrout.c index ea30052d3f..52027da19d 100644 --- a/bin/named/xfrout.c +++ b/bin/named/xfrout.c @@ -765,7 +765,7 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) { break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } ns_client_log(client, diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 42773f62ce..6ef4d0ae4f 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -122,7 +122,7 @@ configure_zone_acl(const cfg_obj_t *zconfig, const cfg_obj_t *vconfig, break; default: INSIST(0); - return (ISC_R_FAILURE); + ISC_UNREACHABLE(); } /* First check to see if ACL is defined within the zone */ @@ -228,12 +228,14 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone, unsigned int i, n; str = cfg_obj_asstring(mode); - if (strcasecmp(str, "grant") == 0) + if (strcasecmp(str, "grant") == 0) { grant = true; - else if (strcasecmp(str, "deny") == 0) + } else if (strcasecmp(str, "deny") == 0) { grant = false; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } str = cfg_obj_asstring(matchtype); CHECK(dns_ssu_mtypefromstring(str, &mtype)); @@ -753,6 +755,7 @@ checknames(dns_zonetype_t ztype, const cfg_obj_t **maps, case dns_zone_master: zone = "master"; break; default: INSIST(0); + ISC_UNREACHABLE(); } result = ns_checknames_get(maps, zone, objp); INSIST(result == ISC_R_SUCCESS && objp != NULL && *objp != NULL); @@ -920,14 +923,16 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, if (result == ISC_R_SUCCESS) { const char *masterformatstr = cfg_obj_asstring(obj); - if (strcasecmp(masterformatstr, "text") == 0) + if (strcasecmp(masterformatstr, "text") == 0) { masterformat = dns_masterformat_text; - else if (strcasecmp(masterformatstr, "raw") == 0) + } else if (strcasecmp(masterformatstr, "raw") == 0) { masterformat = dns_masterformat_raw; - else if (strcasecmp(masterformatstr, "map") == 0) + } else if (strcasecmp(masterformatstr, "map") == 0) { masterformat = dns_masterformat_map; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } obj = NULL; @@ -943,12 +948,14 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, return (ISC_R_FAILURE); } - if (strcasecmp(masterstylestr, "full") == 0) + if (strcasecmp(masterstylestr, "full") == 0) { masterstyle = &dns_master_style_full; - else if (strcasecmp(masterstylestr, "relative") == 0) + } else if (strcasecmp(masterstylestr, "relative") == 0) { masterstyle = &dns_master_style_default; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } obj = NULL; @@ -1034,16 +1041,18 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, dialup = dns_dialuptype_no; } else { const char *dialupstr = cfg_obj_asstring(obj); - if (strcasecmp(dialupstr, "notify") == 0) + if (strcasecmp(dialupstr, "notify") == 0) { dialup = dns_dialuptype_notify; - else if (strcasecmp(dialupstr, "notify-passive") == 0) + } else if (strcasecmp(dialupstr, "notify-passive") == 0) { dialup = dns_dialuptype_notifypassive; - else if (strcasecmp(dialupstr, "refresh") == 0) + } else if (strcasecmp(dialupstr, "refresh") == 0) { dialup = dns_dialuptype_refresh; - else if (strcasecmp(dialupstr, "passive") == 0) + } else if (strcasecmp(dialupstr, "passive") == 0) { dialup = dns_dialuptype_passive; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } if (raw != NULL) dns_zone_setdialup(raw, dialup); @@ -1059,14 +1068,16 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, statlevel = dns_zonestat_none; } else { const char *levelstr = cfg_obj_asstring(obj); - if (strcasecmp(levelstr, "full") == 0) + if (strcasecmp(levelstr, "full") == 0) { statlevel = dns_zonestat_full; - else if (strcasecmp(levelstr, "terse") == 0) + } else if (strcasecmp(levelstr, "terse") == 0) { statlevel = dns_zonestat_terse; - else if (strcasecmp(levelstr, "none") == 0) + } else if (strcasecmp(levelstr, "none") == 0) { statlevel = dns_zonestat_none; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } dns_zone_setstatlevel(zone, statlevel); @@ -1104,12 +1115,14 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, notifytype = dns_notifytype_no; } else { const char *notifystr = cfg_obj_asstring(obj); - if (strcasecmp(notifystr, "explicit") == 0) + if (strcasecmp(notifystr, "explicit") == 0) { notifytype = dns_notifytype_explicit; - else if (strcasecmp(notifystr, "master-only") == 0) + } else if (strcasecmp(notifystr, "master-only") == 0) { notifytype = dns_notifytype_masteronly; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } if (raw != NULL) dns_zone_setnotifytype(raw, dns_notifytype_no); @@ -1250,8 +1263,10 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, fail = check = true; } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { fail = check = false; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } if (raw != NULL) { dns_zone_setoption(raw, DNS_ZONEOPT_CHECKNAMES, check); @@ -1286,8 +1301,10 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, check = true; } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { check = false; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } dns_zone_setoption(zone, DNS_ZONEOPT_CHECKSPF, check); obj = NULL; @@ -1424,14 +1441,16 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, result = cfg_map_get(zoptions, "auto-dnssec", &obj); if (result == ISC_R_SUCCESS) { const char *arg = cfg_obj_asstring(obj); - if (strcasecmp(arg, "allow") == 0) + if (strcasecmp(arg, "allow") == 0) { allow = true; - else if (strcasecmp(arg, "maintain") == 0) + } else if (strcasecmp(arg, "maintain") == 0) { allow = maint = true; - else if (strcasecmp(arg, "off") == 0) + } else if (strcasecmp(arg, "off") == 0) { ; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } dns_zone_setkeyopt(zone, DNS_ZONEKEY_ALLOW, allow); dns_zone_setkeyopt(zone, DNS_ZONEKEY_MAINTAIN, maint); } @@ -1482,8 +1501,10 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, fail = check = true; } else if (strcasecmp(dupcheck, "ignore") == 0) { fail = check = false; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKDUPRR, check); dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKDUPRRFAIL, fail); @@ -1497,8 +1518,10 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, fail = check = true; } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { fail = check = false; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKMX, check); dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKMXFAIL, fail); @@ -1533,8 +1556,10 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, warn = ignore = false; } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { warn = ignore = true; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } dns_zone_setoption(mayberaw, DNS_ZONEOPT_WARNMXCNAME, warn); dns_zone_setoption(mayberaw, DNS_ZONEOPT_IGNOREMXCNAME, ignore); @@ -1548,8 +1573,10 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, warn = ignore = false; } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { warn = ignore = true; - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } dns_zone_setoption(mayberaw, DNS_ZONEOPT_WARNSRVCNAME, warn); dns_zone_setoption(mayberaw, DNS_ZONEOPT_IGNORESRVCNAME, ignore); @@ -1564,13 +1591,15 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, result = cfg_map_get(zoptions, "dnssec-update-mode", &obj); if (result == ISC_R_SUCCESS) { const char *arg = cfg_obj_asstring(obj); - if (strcasecmp(arg, "no-resign") == 0) + if (strcasecmp(arg, "no-resign") == 0) { dns_zone_setkeyopt(zone, DNS_ZONEKEY_NORESIGN, true); - else if (strcasecmp(arg, "maintain") == 0) + } else if (strcasecmp(arg, "maintain") == 0) { ; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } obj = NULL; diff --git a/lib/bind9/check.c b/lib/bind9/check.c index cfc1e489e3..dd79cc736f 100644 --- a/lib/bind9/check.c +++ b/lib/bind9/check.c @@ -1765,6 +1765,7 @@ check_update_policy(const cfg_obj_t *policy, isc_log_t *logctx) { break; default: INSIST(0); + ISC_UNREACHABLE(); } for (element2 = cfg_list_first(typelist); @@ -2020,6 +2021,7 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions, default: INSIST(0); + ISC_UNREACHABLE(); } } @@ -2416,14 +2418,16 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions, (void)cfg_map_get(zoptions, "masterfile-format", &obj); if (obj != NULL) { const char *masterformatstr = cfg_obj_asstring(obj); - if (strcasecmp(masterformatstr, "text") == 0) + if (strcasecmp(masterformatstr, "text") == 0) { masterformat = dns_masterformat_text; - else if (strcasecmp(masterformatstr, "raw") == 0) + } else if (strcasecmp(masterformatstr, "raw") == 0) { masterformat = dns_masterformat_raw; - else if (strcasecmp(masterformatstr, "map") == 0) + } else if (strcasecmp(masterformatstr, "map") == 0) { masterformat = dns_masterformat_map; - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } } if (masterformat == dns_masterformat_map) { diff --git a/lib/dns/acl.c b/lib/dns/acl.c index c1108e8d20..e8911946b9 100644 --- a/lib/dns/acl.c +++ b/lib/dns/acl.c @@ -494,8 +494,8 @@ dns_aclelement_match2(const isc_netaddr_t *reqaddr, &e->geoip_elem)); #endif default: - /* Should be impossible. */ INSIST(0); + ISC_UNREACHABLE(); } result = dns_acl_match2(reqaddr, reqsigner, ecs, ecslen, scope, @@ -673,7 +673,7 @@ dns_acl_isinsecure(const dns_acl_t *a) { default: INSIST(0); - return (true); + ISC_UNREACHABLE(); } } diff --git a/lib/dns/client.c b/lib/dns/client.c index e99ce92f61..c5b9884086 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -275,6 +275,7 @@ getudpdispatch(int family, dns_dispatchmgr_t *dispatchmgr, break; default: INSIST(0); + ISC_UNREACHABLE(); } attrmask = 0; attrmask |= DNS_DISPATCHATTR_UDP; @@ -3183,6 +3184,7 @@ dns_client_updaterec(dns_client_updateop_t op, dns_name_t *owner, break; default: INSIST(0); + ISC_UNREACHABLE(); } rdatalist->type = rdata->type; diff --git a/lib/dns/diff.c b/lib/dns/diff.c index 0550452524..2777b24c2c 100644 --- a/lib/dns/diff.c +++ b/lib/dns/diff.c @@ -380,6 +380,7 @@ diff_apply(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver, break; default: INSIST(0); + ISC_UNREACHABLE(); } if (result == ISC_R_SUCCESS) { diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 7266b6c822..408beda367 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -917,7 +917,7 @@ free_buffer(dns_dispatch_t *disp, void *buf, unsigned int len) { break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } } @@ -1587,7 +1587,7 @@ startrecv(dns_dispatch_t *disp, dispsocket_t *dispsock) { break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } return (ISC_R_SUCCESS); diff --git a/lib/dns/dnstap.c b/lib/dns/dnstap.c index d10a14863f..0c29d0ba78 100644 --- a/lib/dns/dnstap.c +++ b/lib/dns/dnstap.c @@ -886,6 +886,7 @@ dns_dt_open(const char *filename, dns_dtmode_t mode, isc_mem_t *mctx, return (ISC_R_NOTIMPLEMENTED); default: INSIST(0); + ISC_UNREACHABLE(); } isc_mem_attach(mctx, &handle->mctx); diff --git a/lib/dns/geoip.c b/lib/dns/geoip.c index ec20baa958..ea19bbe900 100644 --- a/lib/dns/geoip.c +++ b/lib/dns/geoip.c @@ -306,6 +306,7 @@ country_lookup(GeoIP *db, dns_geoip_subtype_t subtype, break; default: INSIST(0); + ISC_UNREACHABLE(); } if (text == NULL) @@ -373,6 +374,7 @@ city_string(GeoIPRecord *record, dns_geoip_subtype_t subtype, int *maxlen) { return (deconst); default: INSIST(0); + ISC_UNREACHABLE(); } } @@ -467,6 +469,7 @@ static char * region_string(GeoIPRegion *region, dns_geoip_subtype_t subtype, in return (deconst); default: INSIST(0); + ISC_UNREACHABLE(); } } @@ -861,6 +864,7 @@ dns_geoip_match(const isc_netaddr_t *reqaddr, uint8_t *scope, default: INSIST(0); + ISC_UNREACHABLE(); } return (false); diff --git a/lib/dns/journal.c b/lib/dns/journal.c index d39f5988ec..bea961f41e 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -751,6 +751,7 @@ ixfr_order(const void *av, const void *bv) { break; default: INSIST(0); + ISC_UNREACHABLE(); } switch (b->op) { @@ -764,6 +765,7 @@ ixfr_order(const void *av, const void *bv) { break; default: INSIST(0); + ISC_UNREACHABLE(); } r = bop - aop; diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index c45edd5117..c544c0a683 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -1490,7 +1490,7 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } result = totext_ctx_init(style, &dctx->tctx); @@ -1618,6 +1618,7 @@ writeheader(dns_dumpctx_t *dctx) { break; default: INSIST(0); + ISC_UNREACHABLE(); } isc_mem_put(dctx->mctx, buffer.base, buffer.length); diff --git a/lib/dns/message.c b/lib/dns/message.c index 0225b6495f..c621f62683 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -915,8 +915,8 @@ getname(dns_name_t *name, isc_buffer_t *source, dns_message_t *msg, } } - INSIST(0); /* Cannot get here... */ - return (ISC_R_UNEXPECTED); + INSIST(0); + ISC_UNREACHABLE(); } static isc_result_t diff --git a/lib/dns/openssleddsa_link.c b/lib/dns/openssleddsa_link.c index 43f11e790a..fb529201c1 100644 --- a/lib/dns/openssleddsa_link.c +++ b/lib/dns/openssleddsa_link.c @@ -476,8 +476,8 @@ openssleddsa_todns(const dst_key_t *key, isc_buffer_t *data) { return (result); default: INSIST(0); + ISC_UNREACHABLE(); } - return (DST_R_OPENSSLFAILURE); } static isc_result_t diff --git a/lib/dns/opensslrsa_link.c b/lib/dns/opensslrsa_link.c index c03fd72388..ec35f50dd2 100644 --- a/lib/dns/opensslrsa_link.c +++ b/lib/dns/opensslrsa_link.c @@ -298,6 +298,7 @@ opensslrsa_createctx(dst_key_t *key, dst_context_t *dctx) { break; default: INSIST(0); + ISC_UNREACHABLE(); } #if USE_EVP @@ -327,6 +328,7 @@ opensslrsa_createctx(dst_key_t *key, dst_context_t *dctx) { #endif default: INSIST(0); + ISC_UNREACHABLE(); } if (!EVP_DigestInit_ex(evp_md_ctx, type, NULL)) { @@ -389,6 +391,7 @@ opensslrsa_createctx(dst_key_t *key, dst_context_t *dctx) { break; default: INSIST(0); + ISC_UNREACHABLE(); } #endif @@ -474,6 +477,7 @@ opensslrsa_destroyctx(dst_context_t *dctx) { break; default: INSIST(0); + ISC_UNREACHABLE(); } #endif } @@ -538,6 +542,7 @@ opensslrsa_adddata(dst_context_t *dctx, const isc_region_t *data) { break; default: INSIST(0); + ISC_UNREACHABLE(); } #endif return (ISC_R_SUCCESS); @@ -659,6 +664,7 @@ opensslrsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { break; default: INSIST(0); + ISC_UNREACHABLE(); } #if OPENSSL_VERSION_NUMBER < 0x00908000L @@ -692,6 +698,7 @@ opensslrsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { default: INSIST(0); + ISC_UNREACHABLE(); } #else INSIST(type != 0); @@ -821,6 +828,7 @@ opensslrsa_verify2(dst_context_t *dctx, int maxbits, const isc_region_t *sig) { break; default: INSIST(0); + ISC_UNREACHABLE(); } if (sig->length != (unsigned int) RSA_size(rsa)) @@ -874,6 +882,7 @@ opensslrsa_verify2(dst_context_t *dctx, int maxbits, const isc_region_t *sig) { default: INSIST(0); + ISC_UNREACHABLE(); } #else INSIST(type != 0); @@ -1022,6 +1031,7 @@ opensslrsa_generate(dst_key_t *key, int exp, void (*callback)(int)) { break; default: INSIST(0); + ISC_UNREACHABLE(); } if (rsa == NULL || e == NULL || cb == NULL) diff --git a/lib/dns/peer.c b/lib/dns/peer.c index 3a781d2041..93ea98e940 100644 --- a/lib/dns/peer.c +++ b/lib/dns/peer.c @@ -206,10 +206,11 @@ dns_peer_new(isc_mem_t *mem, isc_netaddr_t *addr, dns_peer_t **peerptr) { prefixlen = 32; break; case AF_INET6: - prefixlen = 128; + prefixlen = 128; break; default: INSIST(0); + ISC_UNREACHABLE(); } return (dns_peer_newprefix(mem, addr, prefixlen, peerptr)); diff --git a/lib/dns/pkcs11rsa_link.c b/lib/dns/pkcs11rsa_link.c index eb782c85bd..dce62042e8 100644 --- a/lib/dns/pkcs11rsa_link.c +++ b/lib/dns/pkcs11rsa_link.c @@ -120,6 +120,7 @@ pkcs11rsa_createctx_sign(dst_key_t *key, dst_context_t *dctx) { break; default: INSIST(0); + ISC_UNREACHABLE(); } rsa = key->keydata.pkey; @@ -257,6 +258,7 @@ pkcs11rsa_createctx_sign(dst_key_t *key, dst_context_t *dctx) { break; default: INSIST(0); + ISC_UNREACHABLE(); } PK11_RET(pkcs_C_SignInit, @@ -356,6 +358,7 @@ pkcs11rsa_createctx_verify(dst_key_t *key, unsigned int maxbits, break; default: INSIST(0); + ISC_UNREACHABLE(); } rsa = key->keydata.pkey; @@ -425,6 +428,7 @@ pkcs11rsa_createctx_verify(dst_key_t *key, unsigned int maxbits, break; default: INSIST(0); + ISC_UNREACHABLE(); } PK11_RET(pkcs_C_VerifyInit, @@ -631,6 +635,7 @@ pkcs11rsa_createctx(dst_key_t *key, dst_context_t *dctx) { break; default: INSIST(0); + ISC_UNREACHABLE(); } switch (key->key_alg) { @@ -651,6 +656,7 @@ pkcs11rsa_createctx(dst_key_t *key, dst_context_t *dctx) { break; default: INSIST(0); + ISC_UNREACHABLE(); } pk11_ctx = (pk11_context_t *) isc_mem_get(dctx->mctx, @@ -787,6 +793,7 @@ pkcs11rsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { break; default: INSIST(0); + ISC_UNREACHABLE(); } switch (key->key_alg) { @@ -815,6 +822,7 @@ pkcs11rsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { break; default: INSIST(0); + ISC_UNREACHABLE(); } dgstlen = derlen + hashlen; INSIST(dgstlen <= sizeof(digest)); @@ -1039,6 +1047,7 @@ pkcs11rsa_verify(dst_context_t *dctx, const isc_region_t *sig) { break; default: INSIST(0); + ISC_UNREACHABLE(); } dgstlen = derlen + hashlen; INSIST(dgstlen <= sizeof(digest)); @@ -1230,6 +1239,7 @@ pkcs11rsa_generate(dst_key_t *key, int exp, void (*callback)(int)) { break; default: INSIST(0); + ISC_UNREACHABLE(); } pk11_ctx = (pk11_context_t *) isc_mem_get(key->mctx, diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 0d82148800..ff43c15973 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -9773,6 +9773,7 @@ rdataset_getadditional(dns_rdataset_t *rdataset, dns_rdatasetadditional_t type, break; default: INSIST(0); + ISC_UNREACHABLE(); } if (acarray == NULL) { @@ -9832,6 +9833,7 @@ acache_callback(dns_acacheentry_t *entry, void **arg) { break; default: INSIST(0); + ISC_UNREACHABLE(); } count = cbarg->count; @@ -9966,6 +9968,7 @@ rdataset_setadditional(dns_rdataset_t *rdataset, dns_rdatasetadditional_t type, break; default: INSIST(0); + ISC_UNREACHABLE(); } if (acarray[count].entry != NULL) { @@ -10048,6 +10051,7 @@ rdataset_putadditional(dns_acache_t *acache, dns_rdataset_t *rdataset, break; default: INSIST(0); + ISC_UNREACHABLE(); } if (acarray == NULL) { diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index d182d3375e..86847d080f 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -6365,6 +6365,7 @@ is_answertarget_allowed(fetchctx_t *fctx, dns_name_t *qname, dns_name_t *rname, break; default: INSIST(0); + ISC_UNREACHABLE(); } if (chainingp != NULL) diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index df95db05b3..df9eb76a9a 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -247,9 +247,8 @@ dns_rpz_policy2str(dns_rpz_policy_t policy) { str = "MISS"; break; default: - str = ""; - POST(str); INSIST(0); + ISC_UNREACHABLE(); } return (str); } @@ -316,7 +315,7 @@ make_addr_set(dns_rpz_addr_zbits_t *tgt_set, dns_rpz_zbits_t zbits, break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } } @@ -335,7 +334,7 @@ make_nm_set(dns_rpz_nm_zbits_t *tgt_set, break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } } @@ -2195,7 +2194,7 @@ dns_rpz_find_ip(dns_rpz_zones_t *rpzs, dns_rpz_type_t rpz_type, break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } } else if (netaddr->family == AF_INET6) { dns_rpz_cidr_key_t src_ip6; @@ -2221,7 +2220,7 @@ dns_rpz_find_ip(dns_rpz_zones_t *rpzs, dns_rpz_type_t rpz_type, break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } } else { return (DNS_RPZ_INVALID_NUM); @@ -2258,7 +2257,7 @@ dns_rpz_find_ip(dns_rpz_zones_t *rpzs, dns_rpz_type_t rpz_type, break; default: INSIST(0); - break; + ISC_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 cb7e7b6a7b..0e51910e36 100644 --- a/lib/dns/rrl.c +++ b/lib/dns/rrl.c @@ -465,8 +465,8 @@ get_rate(dns_rrl_t *rrl, dns_rrl_rtype_t rtype) { return (&rrl->all_per_second); default: INSIST(0); + ISC_UNREACHABLE(); } - return (NULL); } static int @@ -823,7 +823,7 @@ make_log_buf(dns_rrl_t *rrl, dns_rrl_entry_t *e, break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } switch (e->key.s.rtype) { @@ -852,6 +852,7 @@ make_log_buf(dns_rrl_t *rrl, dns_rrl_entry_t *e, break; default: INSIST(0); + ISC_UNREACHABLE(); } if (plural) diff --git a/lib/dns/sdb.c b/lib/dns/sdb.c index 013156ae95..3b12666cf1 100644 --- a/lib/dns/sdb.c +++ b/lib/dns/sdb.c @@ -1049,7 +1049,7 @@ expirenode(dns_db_t *db, dns_dbnode_t *node, isc_stdtime_t now) { UNUSED(node); UNUSED(now); INSIST(0); - return (ISC_R_UNEXPECTED); + ISC_UNREACHABLE(); } static void diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index 2fbebb0fd8..7c311329ef 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -776,7 +776,7 @@ expirenode(dns_db_t *db, dns_dbnode_t *node, isc_stdtime_t now) { UNUSED(node); UNUSED(now); INSIST(0); - return (ISC_R_UNEXPECTED); + ISC_UNREACHABLE(); } static void diff --git a/lib/dns/ssu.c b/lib/dns/ssu.c index 71ded66bbc..4f9c0bf05e 100644 --- a/lib/dns/ssu.c +++ b/lib/dns/ssu.c @@ -289,6 +289,7 @@ reverse_from_address(dns_name_t *tcpself, isc_netaddr_t *tcpaddr) { break; default: INSIST(0); + ISC_UNREACHABLE(); } isc_buffer_init(&b, buf, strlen(buf)); isc_buffer_add(&b, strlen(buf)); @@ -331,6 +332,7 @@ stf_from_address(dns_name_t *stfself, isc_netaddr_t *tcpaddr) { break; default: INSIST(0); + ISC_UNREACHABLE(); } isc_buffer_init(&b, buf, strlen(buf)); isc_buffer_add(&b, strlen(buf)); diff --git a/lib/dns/tsec.c b/lib/dns/tsec.c index c5eca0e095..9d8ead44fa 100644 --- a/lib/dns/tsec.c +++ b/lib/dns/tsec.c @@ -100,6 +100,7 @@ dns_tsec_create(isc_mem_t *mctx, dns_tsectype_t type, dst_key_t *key, break; default: INSIST(0); + ISC_UNREACHABLE(); } tsec->magic = DNS_TSEC_MAGIC; @@ -125,6 +126,7 @@ dns_tsec_destroy(dns_tsec_t **tsecp) { break; default: INSIST(0); + ISC_UNREACHABLE(); } tsec->magic = 0; @@ -154,5 +156,6 @@ dns_tsec_getkey(dns_tsec_t *tsec, void *keyp) { break; default: INSIST(0); + ISC_UNREACHABLE(); } } diff --git a/lib/dns/update.c b/lib/dns/update.c index 7da8438c60..47cc4cf4ef 100644 --- a/lib/dns/update.c +++ b/lib/dns/update.c @@ -1808,6 +1808,7 @@ dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, sigs++; } else { INSIST(0); + ISC_UNREACHABLE(); } ISC_LIST_UNLINK(state->nsec_mindiff.tuples, t, link); ISC_LIST_APPEND(state->work.tuples, t, link); @@ -1981,6 +1982,7 @@ dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, sigs++; } else { INSIST(0); + ISC_UNREACHABLE(); } ISC_LIST_UNLINK(state->nsec_mindiff.tuples, t, link); ISC_LIST_APPEND(state->work.tuples, t, link); @@ -2007,6 +2009,7 @@ dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, break; default: INSIST(0); + ISC_UNREACHABLE(); } failure: diff --git a/lib/dns/validator.c b/lib/dns/validator.c index 9ae11a2330..085fcbdbf3 100644 --- a/lib/dns/validator.c +++ b/lib/dns/validator.c @@ -3703,10 +3703,8 @@ validator_start(isc_task_t *task, isc_event_t *event) { val->attributes |= VALATTR_NEEDNODATA; result = nsecvalidate(val, false); } else { - /* - * This shouldn't happen. - */ INSIST(0); + ISC_UNREACHABLE(); } if (result != DNS_R_WAIT) { diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index d39ca26f6d..ccc9aed16c 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -623,7 +623,7 @@ xfr_rr(dns_xfrin_ctx_t *xfr, dns_name_t *name, uint32_t ttl, /* FALLTHROUGH */ default: INSIST(0); - break; + ISC_UNREACHABLE(); } result = ISC_R_SUCCESS; failure: @@ -651,6 +651,7 @@ dns_xfrin_create(dns_zone_t *zone, dns_rdatatype_t xfrtype, break; default: INSIST(0); + ISC_UNREACHABLE(); } return(dns_xfrin_create3(zone, xfrtype, masteraddr, &sourceaddr, diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 766ad6b7c5..439afeda0c 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -8958,6 +8958,7 @@ normalize_key(dns_rdata_t *rr, dns_rdata_t *target, break; default: INSIST(0); + ISC_UNREACHABLE(); } return (ISC_R_SUCCESS); } @@ -15779,7 +15780,8 @@ got_transfer_quota(isc_task_t *task, isc_event_t *event) { break; default: INSIST(0); - }; + ISC_UNREACHABLE(); + } UNLOCK_ZONE(zone); INSIST(isc_sockaddr_pf(&masteraddr) == isc_sockaddr_pf(&sourceaddr)); result = dns_xfrin_create3(zone, xfrtype, &masteraddr, &sourceaddr, @@ -17248,6 +17250,7 @@ dns_zone_setdialup(dns_zone_t *zone, dns_dialuptype_t dialup) { break; default: INSIST(0); + ISC_UNREACHABLE(); } UNLOCK_ZONE(zone); } @@ -17323,6 +17326,7 @@ dns_zonemgr_getcount(dns_zonemgr_t *zmgr, int state) { break; default: INSIST(0); + ISC_UNREACHABLE(); } RWUNLOCK(&zmgr->rwlock, isc_rwlocktype_read); diff --git a/lib/irs/getnameinfo.c b/lib/irs/getnameinfo.c index f575426328..343a65e8ab 100644 --- a/lib/irs/getnameinfo.c +++ b/lib/irs/getnameinfo.c @@ -196,6 +196,7 @@ getnameinfo(const struct sockaddr *sa, IRS_GETNAMEINFO_SOCKLEN_T salen, default: INSIST(0); + ISC_UNREACHABLE(); } proto = ((flags & NI_DGRAM) != 0) ? "udp" : "tcp"; diff --git a/lib/isc/hmacmd5.c b/lib/isc/hmacmd5.c index 0aa270d8f2..0423762ca4 100644 --- a/lib/isc/hmacmd5.c +++ b/lib/isc/hmacmd5.c @@ -408,16 +408,5 @@ isc_hmacmd5_check(int testing) { } #else /* !PK11_MD5_DISABLE */ -#ifdef WIN32 -/* Make the Visual Studio linker happy */ -#include - -void isc_hmacmd5_init() { INSIST(0); } -void isc_hmacmd5_invalidate() { INSIST(0); } -void isc_hmacmd5_sign() { INSIST(0); } -void isc_hmacmd5_update() { INSIST(0); } -void isc_hmacmd5_verify() { INSIST(0); } -void isc_hmacmd5_verify2() { INSIST(0); } -void isc_hmacmd5_check() { INSIST(0); } -#endif +EMPTY_TRANSLATION_UNIT #endif /* PK11_MD5_DISABLE */ diff --git a/lib/isc/md5.c b/lib/isc/md5.c index 25c71a207a..920aed5f58 100644 --- a/lib/isc/md5.c +++ b/lib/isc/md5.c @@ -382,14 +382,5 @@ isc_md5_check(bool testing) { } #else /* !PK11_MD5_DISABLE */ -#ifdef WIN32 -/* Make the Visual Studio linker happy */ -#include - -void isc_md5_final() { INSIST(0); } -void isc_md5_init() { INSIST(0); } -void isc_md5_invalidate() { INSIST(0); } -void isc_md5_update() { INSIST(0); } -void isc_md5_check() { INSIST(0); } -#endif +EMPTY_TRANSLATION_UNIT #endif /* PK11_MD5_DISABLE */ diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 3fec79585a..41383ed7ef 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -489,6 +489,7 @@ delete_trace_entry(isc__mem_t *mctx, const void *ptr, size_t size, * screwed. */ INSIST(dl != NULL); + ISC_UNREACHABLE(); } #endif /* ISC_MEM_TRACKLINES */ @@ -2316,6 +2317,7 @@ isc_mem_checkdestroyed(FILE *file) { } #endif INSIST(0); + ISC_UNREACHABLE(); } UNLOCK(&contextslock); } diff --git a/lib/isc/netaddr.c b/lib/isc/netaddr.c index 81851a015b..29f19baa6d 100644 --- a/lib/isc/netaddr.c +++ b/lib/isc/netaddr.c @@ -350,6 +350,7 @@ isc_netaddr_fromsockaddr(isc_netaddr_t *t, const isc_sockaddr_t *s) { #endif default: INSIST(0); + ISC_UNREACHABLE(); } } diff --git a/lib/isc/sockaddr.c b/lib/isc/sockaddr.c index 6a97e69c46..c2c599e1a6 100644 --- a/lib/isc/sockaddr.c +++ b/lib/isc/sockaddr.c @@ -293,6 +293,7 @@ isc_sockaddr_anyofpf(isc_sockaddr_t *sockaddr, int pf) { break; default: INSIST(0); + ISC_UNREACHABLE(); } } @@ -384,6 +385,7 @@ isc_sockaddr_fromnetaddr(isc_sockaddr_t *sockaddr, const isc_netaddr_t *na, break; default: INSIST(0); + ISC_UNREACHABLE(); } ISC_LINK_INIT(sockaddr, link); } diff --git a/lib/isc/unix/interfaceiter.c b/lib/isc/unix/interfaceiter.c index 4df4d34703..deafe4ed98 100644 --- a/lib/isc/unix/interfaceiter.c +++ b/lib/isc/unix/interfaceiter.c @@ -131,7 +131,7 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src, break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } } diff --git a/lib/isc/unix/net.c b/lib/isc/unix/net.c index efe17bd23a..05d8f162f5 100644 --- a/lib/isc/unix/net.c +++ b/lib/isc/unix/net.c @@ -564,6 +564,7 @@ cmsgsend(int s, int level, int type, struct addrinfo *res) { #endif default: INSIST(0); + ISC_UNREACHABLE(); } if (sendmsg(s, &msg, 0) < 0) { diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index fa3259556e..d5861c4e38 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -1996,6 +1996,7 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) { case isc_sockettype_fdwatch: default: INSIST(0); + ISC_UNREACHABLE(); } if (sock->type == isc_sockettype_udp) { @@ -2625,7 +2626,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, * sockets. */ INSIST(0); - break; + ISC_UNREACHABLE(); } } else { sock->fd = dup(dup_socket->fd); @@ -2967,6 +2968,7 @@ socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type, break; default: INSIST(0); + ISC_UNREACHABLE(); } sock->pf = pf; diff --git a/lib/isc/win32/interfaceiter.c b/lib/isc/win32/interfaceiter.c index 1bbd0f89fe..3fd2a9c13d 100644 --- a/lib/isc/win32/interfaceiter.c +++ b/lib/isc/win32/interfaceiter.c @@ -97,7 +97,7 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src) { break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } } diff --git a/lib/isccc/sexpr.c b/lib/isccc/sexpr.c index 68dbe446c7..bb9565b2fd 100644 --- a/lib/isccc/sexpr.c +++ b/lib/isccc/sexpr.c @@ -202,6 +202,7 @@ isccc_sexpr_print(isccc_sexpr_t *sexpr, FILE *stream) { break; default: INSIST(0); + ISC_UNREACHABLE(); } } diff --git a/lib/isccfg/aclconf.c b/lib/isccfg/aclconf.c index 3fa813eb93..e653c8b281 100644 --- a/lib/isccfg/aclconf.c +++ b/lib/isccfg/aclconf.c @@ -401,6 +401,7 @@ get_subtype(const cfg_obj_t *obj, isc_log_t *lctx, return (subtype); default: INSIST(0); + ISC_UNREACHABLE(); } } @@ -595,8 +596,10 @@ parse_geoip_element(const cfg_obj_t *obj, isc_log_t *lctx, } else if (strcasecmp(stype, "netspeed") == 0) { subtype = dns_geoip_netspeed_id; de.geoip_elem.as_int = atoi(search); - } else + } else { INSIST(0); + ISC_UNREACHABLE(); + } de.geoip_elem.subtype = get_subtype(obj, lctx, subtype, dbname); diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index d27003ba74..fbc62cc06d 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -3082,12 +3082,14 @@ parse_querysource(cfg_parser_t *pctx, const cfg_type_t *type, unsigned int have_dscp = 0; const unsigned int *flagp = type->of; - if ((*flagp & CFG_ADDR_V4OK) != 0) + if ((*flagp & CFG_ADDR_V4OK) != 0) { isc_netaddr_any(&netaddr); - else if ((*flagp & CFG_ADDR_V6OK) != 0) + } else if ((*flagp & CFG_ADDR_V6OK) != 0) { isc_netaddr_any6(&netaddr); - else + } else { INSIST(0); + ISC_UNREACHABLE(); + } for (;;) { CHECK(cfg_peektoken(pctx, 0)); @@ -3175,6 +3177,7 @@ doc_querysource(cfg_printer_t *pctx, const cfg_type_t *type) { cfg_print_cstr(pctx, ""); } else { INSIST(0); + ISC_UNREACHABLE(); } cfg_print_cstr(pctx, " | * ) [ port ( | * ) ] ) | " "( [ [ address ] ( "); @@ -3184,6 +3187,7 @@ doc_querysource(cfg_printer_t *pctx, const cfg_type_t *type) { cfg_print_cstr(pctx, ""); } else { INSIST(0); + ISC_UNREACHABLE(); } cfg_print_cstr(pctx, " | * ) ] port ( | * ) ) )" " [ dscp ]"); @@ -3994,6 +3998,7 @@ cfg_print_zonegrammar(const unsigned int zonetype, break; default: INSIST(0); + ISC_UNREACHABLE(); } for (clause = clauses; clause->name != NULL; clause++) { diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index e1abed9d9a..3ec30884df 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -369,7 +369,7 @@ cfg_tuple_get(const cfg_obj_t *tupleobj, const char* name) { return (tupleobj->value.tuple[i]); } INSIST(0); - return (NULL); + ISC_UNREACHABLE(); } isc_result_t @@ -1990,6 +1990,7 @@ cfg_print_mapbody(cfg_printer_t *pctx, const cfg_obj_t *obj) { ; /* do nothing */ } else { INSIST(0); + ISC_UNREACHABLE(); } } } @@ -2305,6 +2306,7 @@ token_addr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na) { return (ISC_R_SUCCESS); } else { INSIST(0); + ISC_UNREACHABLE(); } } else { if ((flags & (CFG_ADDR_V4OK | CFG_ADDR_V4PREFIXOK)) != 0) { @@ -2583,7 +2585,7 @@ cfg_parse_netprefix(cfg_parser_t *pctx, const cfg_type_t *type, break; default: INSIST(0); - break; + ISC_UNREACHABLE(); } CHECK(cfg_peektoken(pctx, 0)); if (pctx->token.type == isc_tokentype_special && From c5b54803cd3396ca0f4eb01b023c1f6df589397d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 8 Nov 2018 12:19:00 +0700 Subject: [PATCH 10/11] Remove dummy ISLOCKED macro (cherry picked from commit 68ca9877921892968c718865363e9115ba5095bf) (cherry picked from commit 5ad72603a81e454c29a6088eb2cf18b7c03a2e9c) --- lib/isc/include/isc/util.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index 1593a32793..b954880831 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -106,7 +106,6 @@ ISC_MSG_UNLOCKED, "UNLOCKED"), \ (lp), __FILE__, __LINE__)); \ } while (0) -#define ISLOCKED(lp) (1) #define DESTROYLOCK(lp) \ RUNTIME_CHECK(isc_mutex_destroy((lp)) == ISC_R_SUCCESS) From 29601a6e7e793456531c58f9162899b2e5a73712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 8 Nov 2018 19:53:05 +0700 Subject: [PATCH 11/11] Disable Ed448 algorithm, the implementation in BIND 9 is incomplete and broken (cherry picked from commit 03c7bb9ab3f66fe92edeb2c27052c34f869f7421) --- configure | 6 +++--- configure.ac | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configure b/configure index dc9924df16..062347791a 100755 --- a/configure +++ b/configure @@ -17134,9 +17134,9 @@ int main() { _ACEOF if ac_fn_c_try_run "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - have_ed448="yes" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: broken" >&5 +$as_echo "broken" >&6; } + have_ed448="no" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } diff --git a/configure.ac b/configure.ac index eb334f1bba..d8e2b300be 100644 --- a/configure.ac +++ b/configure.ac @@ -1894,9 +1894,9 @@ int main() { return (0); } ], - [AC_MSG_RESULT(yes) - have_ed448="yes"], - [AC_MSG_RESULT(no) + [AC_MSG_RESULT([broken]) + have_ed448="no"], + [AC_MSG_RESULT([no]) have_ed448="no"], [AC_MSG_RESULT(using --with-eddsa)]) case $with_eddsa in