From: Evan Hunt Date: Fri, 13 Jun 2025 05:17:33 +0000 (-0700) Subject: switch to RETERR where it wasn't being used X-Git-Tag: v9.21.16~3^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b33b7fc77d906f5e3ddd0933111a8a1ab9a9380;p=thirdparty%2Fbind9.git switch to RETERR where it wasn't being used replace all instances of the pattern: result = if (result != ISC_R_SUCCESS) { return result; } with: RETERR(); --- diff --git a/bin/check/named-checkconf.c b/bin/check/named-checkconf.c index caac86ee256..ee304a9b204 100644 --- a/bin/check/named-checkconf.c +++ b/bin/check/named-checkconf.c @@ -108,7 +108,6 @@ get_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj) { static isc_result_t configure_hint(const char *zfile, const char *zclass) { - isc_result_t result; dns_db_t *db = NULL; dns_rdataclass_t rdclass; isc_textregion_t r; @@ -119,15 +118,8 @@ configure_hint(const char *zfile, const char *zclass) { r.base = UNCONST(zclass); r.length = strlen(zclass); - result = dns_rdataclass_fromtext(&rdclass, &r); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = dns_rootns_create(isc_g_mctx, rdclass, zfile, &db); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdataclass_fromtext(&rdclass, &r)); + RETERR(dns_rootns_create(isc_g_mctx, rdclass, zfile, &db)); dns_db_detach(&db); return ISC_R_SUCCESS; diff --git a/bin/delv/delv.c b/bin/delv/delv.c index eba04e85b12..7915c4f8089 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -1757,15 +1757,8 @@ reverse_octets(const char *in, char **p, char *end) { char *dot = strchr(in, '.'); int len; if (dot != NULL) { - isc_result_t result; - result = reverse_octets(dot + 1, p, end); - if (result != ISC_R_SUCCESS) { - return result; - } - result = append_str(".", 1, p, end); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(reverse_octets(dot + 1, p, end)); + RETERR(append_str(".", 1, p, end)); len = (int)(dot - in); } else { len = strlen(in); @@ -1776,7 +1769,6 @@ reverse_octets(const char *in, char **p, char *end) { static isc_result_t get_reverse(char *reverse, size_t len, char *value, bool strict) { int r; - isc_result_t result; isc_netaddr_t addr; addr.family = AF_INET6; @@ -1787,10 +1779,7 @@ get_reverse(char *reverse, size_t len, char *value, bool strict) { dns_name_t *name; name = dns_fixedname_initname(&fname); - result = dns_byaddr_createptrname(&addr, name); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_byaddr_createptrname(&addr, name)); dns_name_format(name, reverse, (unsigned int)len); return ISC_R_SUCCESS; } else { @@ -1807,14 +1796,8 @@ get_reverse(char *reverse, size_t len, char *value, bool strict) { if (strict && inet_pton(AF_INET, value, &addr.type.in) != 1) { return DNS_R_BADDOTTEDQUAD; } - result = reverse_octets(value, &p, end); - if (result != ISC_R_SUCCESS) { - return result; - } - result = append_str(".in-addr.arpa.", 15, &p, end); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(reverse_octets(value, &p, end)); + RETERR(append_str(".in-addr.arpa.", 15, &p, end)); return ISC_R_SUCCESS; } } diff --git a/bin/dig/dig.c b/bin/dig/dig.c index b1d12ec2b60..ecb722b78e5 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -503,10 +503,7 @@ say_message(dns_rdata_t *rdata, dig_query_t *query, isc_buffer_t *buf) { unsigned int styleflags = 0; if (query->lookup->trace || query->lookup->ns_search_only) { - result = dns_rdatatype_totext(rdata->type, buf); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdatatype_totext(rdata->type, buf)); ADD_STRING(buf, " "); } @@ -583,14 +580,8 @@ dns64prefix_answer(dns_message_t *msg, isc_buffer_t *buf) { count = 10; } for (i = 0; i < count; i++) { - result = isc_netaddr_totext(&prefix[i].addr, buf); - if (result != ISC_R_SUCCESS) { - return result; - } - result = isc_buffer_printf(buf, "/%u\n", prefix[i].prefixlen); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_netaddr_totext(&prefix[i].addr, buf)); + RETERR(isc_buffer_printf(buf, "/%u\n", prefix[i].prefixlen)); } return ISC_R_SUCCESS; diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 81d1cc552bd..1eeb11e4329 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -291,15 +291,8 @@ reverse_octets(const char *in, char **p, char *end) { const char *dot = strchr(in, '.'); size_t len; if (dot != NULL) { - isc_result_t result; - result = reverse_octets(dot + 1, p, end); - if (result != ISC_R_SUCCESS) { - return result; - } - result = append(".", 1, p, end); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(reverse_octets(dot + 1, p, end)); + RETERR(append(".", 1, p, end)); len = (int)(dot - in); } else { len = (int)strlen(in); @@ -310,7 +303,6 @@ reverse_octets(const char *in, char **p, char *end) { isc_result_t get_reverse(char *reverse, size_t len, char *value, bool strict) { int r; - isc_result_t result; isc_netaddr_t addr; addr.family = AF_INET6; @@ -321,10 +313,7 @@ get_reverse(char *reverse, size_t len, char *value, bool strict) { dns_name_t *name; name = dns_fixedname_initname(&fname); - result = dns_byaddr_createptrname(&addr, name); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_byaddr_createptrname(&addr, name)); dns_name_format(name, reverse, (unsigned int)len); return ISC_R_SUCCESS; } else { @@ -341,15 +330,9 @@ get_reverse(char *reverse, size_t len, char *value, bool strict) { if (strict && inet_pton(AF_INET, value, &addr.type.in) != 1) { return DNS_R_BADDOTTEDQUAD; } - result = reverse_octets(value, &p, end); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(reverse_octets(value, &p, end)); /* Append .in-addr.arpa. and a terminating NUL. */ - result = append(".in-addr.arpa.", 15, &p, end); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(append(".in-addr.arpa.", 15, &p, end)); return ISC_R_SUCCESS; } } diff --git a/bin/dig/host.c b/bin/dig/host.c index df38b0f24aa..4156aec9a80 100644 --- a/bin/dig/host.c +++ b/bin/dig/host.c @@ -208,7 +208,6 @@ printsection(dns_message_t *msg, dns_section_t sectionid, const char *section_name, bool headers, dig_query_t *query) { dns_name_t *print_name; isc_buffer_t target; - isc_result_t result; isc_region_t r; dns_name_t empty_name; char tbuf[4096] = { 0 }; @@ -245,12 +244,9 @@ printsection(dns_message_t *msg, dns_section_t sectionid, continue; } if (!short_form) { - result = dns_rdataset_totext(rdataset, - print_name, false, - no_rdata, &target); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdataset_totext(rdataset, print_name, + false, no_rdata, + &target)); #ifdef USEINITALWS if (first) { print_name = &empty_name; @@ -305,7 +301,6 @@ static isc_result_t printrdata(dns_message_t *msg, dns_rdataset_t *rdataset, const dns_name_t *owner, const char *set_name, bool headers) { isc_buffer_t target; - isc_result_t result; isc_region_t r; char tbuf[4096]; @@ -316,10 +311,7 @@ printrdata(dns_message_t *msg, dns_rdataset_t *rdataset, isc_buffer_init(&target, tbuf, sizeof(tbuf)); - result = dns_rdataset_totext(rdataset, owner, false, false, &target); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdataset_totext(rdataset, owner, false, false, &target)); isc_buffer_usedregion(&target, &r); printf("%.*s", (int)r.length, (char *)r.base); @@ -501,50 +493,35 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg, if (!ISC_LIST_EMPTY(msg->sections[DNS_SECTION_QUESTION]) && !short_form) { printf("\n"); - result = printsection(msg, DNS_SECTION_QUESTION, "QUESTION", - true, query); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(printsection(msg, DNS_SECTION_QUESTION, "QUESTION", true, + query)); } if (!ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ANSWER])) { if (!short_form) { printf("\n"); } - result = printsection(msg, DNS_SECTION_ANSWER, "ANSWER", - !short_form, query); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(printsection(msg, DNS_SECTION_ANSWER, "ANSWER", + !short_form, query)); } if (!ISC_LIST_EMPTY(msg->sections[DNS_SECTION_AUTHORITY]) && !short_form) { printf("\n"); - result = printsection(msg, DNS_SECTION_AUTHORITY, "AUTHORITY", - true, query); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(printsection(msg, DNS_SECTION_AUTHORITY, "AUTHORITY", + true, query)); } if (!ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ADDITIONAL]) && !short_form) { printf("\n"); - result = printsection(msg, DNS_SECTION_ADDITIONAL, "ADDITIONAL", - true, query); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(printsection(msg, DNS_SECTION_ADDITIONAL, "ADDITIONAL", + true, query)); } if ((tsig != NULL) && !short_form) { printf("\n"); - result = printrdata(msg, tsig, tsigname, "PSEUDOSECTION TSIG", - true); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(printrdata(msg, tsig, tsigname, "PSEUDOSECTION TSIG", + true)); } if (!short_form) { printf("\n"); diff --git a/bin/dnssec/dnssec-ksr.c b/bin/dnssec/dnssec-ksr.c index 7240da42786..efba16f4518 100644 --- a/bin/dnssec/dnssec-ksr.c +++ b/bin/dnssec/dnssec-ksr.c @@ -967,10 +967,7 @@ parse_dnskey(isc_lex_t *lex, char *owner, isc_buffer_t *buf, dns_ttl_t *ttl) { dname = dns_fixedname_initname(&dfname); isc_buffer_init(&b, owner, strlen(owner)); isc_buffer_add(&b, strlen(owner)); - result = dns_name_fromtext(dname, &b, dns_rootname, 0); - if (result != ISC_R_SUCCESS) { - goto cleanup; - } + CHECK(dns_name_fromtext(dname, &b, dns_rootname, 0)); if (dns_name_compare(dname, name) != 0) { result = DNS_R_BADOWNERNAME; goto cleanup; diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 43a295ca2a8..4502d00720f 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -1377,10 +1377,7 @@ setsoaserial(uint32_t serial, dns_updatemethod_t method) { uint32_t old_serial, new_serial = 0; dns_updatemethod_t used = dns_updatemethod_none; - result = dns_db_getoriginnode(gdb, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_getoriginnode(gdb, &node)); dns_rdataset_init(&rdataset); diff --git a/bin/named/builtin.c b/bin/named/builtin.c index 814ad911bd4..80e3c5a7fe5 100644 --- a/bin/named/builtin.c +++ b/bin/named/builtin.c @@ -166,10 +166,7 @@ putrr(bdbnode_t *node, const char *type, dns_ttl_t ttl, const char *data) { origin = &node->bdb->common.origin; isc_constregion_t r = { .base = type, .length = strlen(type) }; - result = dns_rdatatype_fromtext(&typeval, (isc_textregion_t *)&r); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdatatype_fromtext(&typeval, (isc_textregion_t *)&r)); isc_lex_create(mctx, 64, &lex); @@ -177,10 +174,7 @@ putrr(bdbnode_t *node, const char *type, dns_ttl_t ttl, const char *data) { isc_buffer_constinit(&b, data, datalen); isc_buffer_add(&b, datalen); - result = isc_lex_openbuffer(lex, &b); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_lex_openbuffer(lex, &b)); isc_buffer_allocate(mctx, &rb, DNS_RDATA_MAXLENGTH); result = dns_rdata_fromtext(NULL, node->bdb->common.rdclass, typeval, @@ -535,7 +529,6 @@ hostname_lookup(bdbnode_t *node) { static isc_result_t authors_lookup(bdbnode_t *node) { - isc_result_t result; const char **p = NULL; static const char *authors[] = { "Mark Andrews", "Curtis Blackburn", @@ -559,10 +552,7 @@ authors_lookup(bdbnode_t *node) { } for (p = authors; *p != NULL; p++) { - result = puttxt(node, *p); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(puttxt(node, *p)); } return ISC_R_SUCCESS; } @@ -591,14 +581,10 @@ empty_lookup(bdbnode_t *node) { static isc_result_t ipv4only_lookup(bdbnode_t *node) { - isc_result_t result; unsigned char data[2][4] = { { 192, 0, 0, 170 }, { 192, 0, 0, 171 } }; for (int i = 0; i < 2; i++) { - result = putrdata(node, dns_rdatatype_a, 3600, data[i], 4); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(putrdata(node, dns_rdatatype_a, 3600, data[i], 4)); } return ISC_R_SUCCESS; } @@ -846,10 +832,7 @@ findnode(dns_db_t *db, const dns_name_t *name, bool create, dns_name_getlabelsequence(name, 0, labels, &relname); name = &relname; - result = createnode(bdb, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(createnode(bdb, &node)); result = builtin_lookup(bdb, name, node); if (result != ISC_R_SUCCESS && (!isorigin || result != ISC_R_NOTFOUND)) @@ -1212,11 +1195,8 @@ isc_result_t named_builtin_init(void) { isc_result_t result; - result = dns_db_register("_builtin", create, &builtin, isc_g_mctx, - &builtin.dbimp); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_register("_builtin", create, &builtin, isc_g_mctx, + &builtin.dbimp)); result = dns_db_register("_dns64", create, &dns64, isc_g_mctx, &dns64.dbimp); diff --git a/bin/named/config.c b/bin/named/config.c index 31683d005ca..c953f4c45a9 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -248,17 +248,13 @@ named_config_getzonetype(const cfg_obj_t *zonetypeobj) { isc_result_t named_config_getremotesdef(const cfg_obj_t *cctx, const char *list, const char *name, const cfg_obj_t **ret) { - isc_result_t result; const cfg_obj_t *obj = NULL; REQUIRE(cctx != NULL); REQUIRE(name != NULL); REQUIRE(ret != NULL && *ret == NULL); - result = cfg_map_get(cctx, list, &obj); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(cfg_map_get(cctx, list, &obj)); CFG_LIST_FOREACH(obj, elt) { obj = cfg_listelt_value(elt); if (strcasecmp(cfg_obj_asstring(cfg_tuple_get(obj, "name")), @@ -697,7 +693,6 @@ named_config_getkeyalgorithm(const char *str, unsigned int *typep, int i; size_t len = 0; uint16_t bits; - isc_result_t result; for (i = 0; algorithms[i].str != NULL; i++) { len = strlen(algorithms[i].str); @@ -712,10 +707,7 @@ named_config_getkeyalgorithm(const char *str, unsigned int *typep, return ISC_R_NOTFOUND; } if (str[len] == '-') { - result = isc_parse_uint16(&bits, str + len + 1, 10); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_parse_uint16(&bits, str + len + 1, 10)); if (bits > algorithms[i].size) { return ISC_R_RANGE; } diff --git a/bin/named/control.c b/bin/named/control.c index 8f20933f021..8750f4c7f2e 100644 --- a/bin/named/control.c +++ b/bin/named/control.c @@ -37,15 +37,11 @@ static isc_result_t getcommand(isc_lex_t *lex, char **cmdp) { - isc_result_t result; isc_token_t token; REQUIRE(cmdp != NULL && *cmdp == NULL); - result = isc_lex_gettoken(lex, ISC_LEXOPT_EOF, &token); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_lex_gettoken(lex, ISC_LEXOPT_EOF, &token)); isc_lex_ungettoken(lex, &token); @@ -89,13 +85,7 @@ named_control_docommand(isccc_sexpr_t *message, bool readonly, return ISC_R_FAILURE; } - result = isccc_cc_lookupstring(data, "type", &cmdline); - if (result != ISC_R_SUCCESS) { - /* - * We have no idea what this is. - */ - return result; - } + RETERR(isccc_cc_lookupstring(data, "type", &cmdline)); isc_lex_create(isc_g_mctx, strlen(cmdline), &lex); diff --git a/bin/named/server.c b/bin/named/server.c index 7aeeec2b87f..b6ca56d9a45 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -928,10 +928,7 @@ process_key(const cfg_obj_t *key, dns_keytable_t *secroots, isc_buffer_constinit(&b, namestr, strlen(namestr)); isc_buffer_add(&b, strlen(namestr)); keyname = dns_fixedname_initname(&fkeyname); - result = dns_name_fromtext(keyname, &b, dns_rootname, 0); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromtext(keyname, &b, dns_rootname, 0)); break; case DST_R_UNSUPPORTEDALG: case DST_R_BADKEYTYPE: @@ -1290,20 +1287,12 @@ configure_order(dns_order_t *order, const cfg_obj_t *ent) { dns_orderopt_t mode = dns_order_none; const char *str; isc_buffer_t b; - isc_result_t result; bool addroot; - result = named_config_getclass(cfg_tuple_get(ent, "class"), - dns_rdataclass_any, &rdclass); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = named_config_gettype(cfg_tuple_get(ent, "type"), - dns_rdatatype_any, &rdtype); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(named_config_getclass(cfg_tuple_get(ent, "class"), + dns_rdataclass_any, &rdclass)); + RETERR(named_config_gettype(cfg_tuple_get(ent, "type"), + dns_rdatatype_any, &rdtype)); obj = cfg_tuple_get(ent, "name"); if (cfg_obj_isstring(obj)) { @@ -1315,11 +1304,8 @@ configure_order(dns_order_t *order, const cfg_obj_t *ent) { isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); dns_fixedname_init(&fixed); - result = dns_name_fromtext(dns_fixedname_name(&fixed), &b, dns_rootname, - 0); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromtext(dns_fixedname_name(&fixed), &b, dns_rootname, + 0)); obj = cfg_tuple_get(ent, "ordering"); INSIST(cfg_obj_isstring(obj)); @@ -1354,19 +1340,14 @@ configure_order(dns_order_t *order, const cfg_obj_t *ent) { static isc_result_t configure_peer(const cfg_obj_t *cpeer, isc_mem_t *mctx, dns_peer_t **peerp) { isc_netaddr_t na; - dns_peer_t *peer; - const cfg_obj_t *obj; - const char *str; - isc_result_t result; + dns_peer_t *peer = NULL; + const cfg_obj_t *obj = NULL; + isc_result_t result = ISC_R_SUCCESS; unsigned int prefixlen; cfg_obj_asnetprefix(cfg_map_getname(cpeer), &na, &prefixlen); - peer = NULL; - result = dns_peer_newprefix(mctx, &na, prefixlen, &peer); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_peer_newprefix(mctx, &na, prefixlen, &peer)); obj = NULL; (void)cfg_map_get(cpeer, "bogus", &obj); @@ -1500,7 +1481,7 @@ configure_peer(const cfg_obj_t *cpeer, isc_mem_t *mctx, dns_peer_t **peerp) { obj = NULL; (void)cfg_map_get(cpeer, "transfer-format", &obj); if (obj != NULL) { - str = cfg_obj_asstring(obj); + const char *str = cfg_obj_asstring(obj); if (strcasecmp(str, "many-answers") == 0) { CHECK(dns_peer_settransferformat(peer, dns_many_answers)); @@ -1792,12 +1773,9 @@ static isc_result_t dlzconfigure_callback(dns_view_t *view, dns_dlzdb_t *dlzdb, dns_zone_t *zone) { dns_name_t *origin = dns_zone_getorigin(zone); dns_rdataclass_t zclass = view->rdclass; - isc_result_t result; - result = dns_zonemgr_managezone(named_g_server->zonemgr, zone); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_zonemgr_managezone(named_g_server->zonemgr, zone)); + dns_zone_setstats(zone, named_g_server->zonestats); return named_zone_configure_writeable_dlz(dlzdb, zone, zclass, origin); @@ -1978,10 +1956,8 @@ configure_rpz_zone(dns_view_t *view, const cfg_listelt_t *element, } str = cfg_obj_asstring(cfg_tuple_get(rpz_obj, "zone name")); - result = configure_rpz_name(view, rpz_obj, &zone->origin, str, "zone"); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(configure_rpz_name(view, rpz_obj, &zone->origin, str, "zone")); + if (dns_name_equal(&zone->origin, dns_rootname)) { cfg_obj_log(rpz_obj, DNS_RPZ_ERROR_LEVEL, "invalid zone name '%s'", str); @@ -2001,47 +1977,20 @@ configure_rpz_zone(dns_view_t *view, const cfg_listelt_t *element, *old_rpz_okp = false; } - result = configure_rpz_name2(view, rpz_obj, &zone->client_ip, - DNS_RPZ_CLIENT_IP_ZONE, &zone->origin); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = configure_rpz_name2(view, rpz_obj, &zone->ip, DNS_RPZ_IP_ZONE, - &zone->origin); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = configure_rpz_name2(view, rpz_obj, &zone->nsdname, - DNS_RPZ_NSDNAME_ZONE, &zone->origin); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = configure_rpz_name2(view, rpz_obj, &zone->nsip, - DNS_RPZ_NSIP_ZONE, &zone->origin); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = configure_rpz_name(view, rpz_obj, &zone->passthru, - DNS_RPZ_PASSTHRU_NAME, "name"); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = configure_rpz_name(view, rpz_obj, &zone->drop, - DNS_RPZ_DROP_NAME, "name"); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = configure_rpz_name(view, rpz_obj, &zone->tcp_only, - DNS_RPZ_TCP_ONLY_NAME, "name"); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(configure_rpz_name2(view, rpz_obj, &zone->client_ip, + DNS_RPZ_CLIENT_IP_ZONE, &zone->origin)); + RETERR(configure_rpz_name2(view, rpz_obj, &zone->ip, DNS_RPZ_IP_ZONE, + &zone->origin)); + RETERR(configure_rpz_name2(view, rpz_obj, &zone->nsdname, + DNS_RPZ_NSDNAME_ZONE, &zone->origin)); + RETERR(configure_rpz_name2(view, rpz_obj, &zone->nsip, + DNS_RPZ_NSIP_ZONE, &zone->origin)); + RETERR(configure_rpz_name(view, rpz_obj, &zone->passthru, + DNS_RPZ_PASSTHRU_NAME, "name")); + RETERR(configure_rpz_name(view, rpz_obj, &zone->drop, DNS_RPZ_DROP_NAME, + "name")); + RETERR(configure_rpz_name(view, rpz_obj, &zone->tcp_only, + DNS_RPZ_TCP_ONLY_NAME, "name")); obj = cfg_tuple_get(rpz_obj, "policy"); if (cfg_obj_isvoid(obj)) { @@ -2052,11 +2001,8 @@ configure_rpz_zone(dns_view_t *view, const cfg_listelt_t *element, INSIST(zone->policy != DNS_RPZ_POLICY_ERROR); if (zone->policy == DNS_RPZ_POLICY_CNAME) { str = cfg_obj_asstring(cfg_tuple_get(obj, "cname")); - result = configure_rpz_name(view, rpz_obj, &zone->cname, - str, "cname"); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(configure_rpz_name(view, rpz_obj, &zone->cname, + str, "cname")); } } if (*old_rpz_okp && (zone->policy != old->policy || @@ -2104,7 +2050,7 @@ configure_rpz(dns_view_t *view, dns_view_t *pview, const cfg_obj_t *rpz_obj, const dns_rpz_zones_t *old = NULL; bool pview_must_detach = false; const dns_rpz_zone_t *old_zone = NULL; - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; *old_rpz_okp = false; @@ -2127,10 +2073,7 @@ configure_rpz(dns_view_t *view, dns_view_t *pview, const cfg_obj_t *rpz_obj, } nsdname_on = nsdname_enabled ? DNS_RPZ_ALL_ZBITS : 0; - result = dns_rpz_new_zones(view, &view->rpzs, first_time); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rpz_new_zones(view, &view->rpzs, first_time)); zones = view->rpzs; @@ -2635,11 +2578,10 @@ static void catz_changeview(dns_catz_entry_t *entry, void *arg1, void *arg2) { dns_view_t *pview = arg1; dns_view_t *view = arg2; - dns_zone_t *zone = NULL; + isc_result_t result = dns_view_findzone( pview, dns_catz_entry_getname(entry), DNS_ZTFIND_EXACT, &zone); - if (result != ISC_R_SUCCESS) { return; } @@ -2940,10 +2882,7 @@ configure_rrl(dns_view_t *view, const cfg_obj_t *config, const cfg_obj_t *map, min_entries = 1; } } - result = dns_rrl_init(&rrl, view, min_entries); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rrl_init(&rrl, view, min_entries)); i = ISC_MAX(20000, min_entries); obj = NULL; @@ -5706,7 +5645,7 @@ configure_forward(const cfg_obj_t *config, dns_view_t *view, const cfg_obj_t *faddresses = NULL; dns_fwdpolicy_t fwdpolicy = dns_fwdpolicy_none; dns_forwarderlist_t fwdlist; - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; in_port_t port; in_port_t tls_port; const char *tls = NULL; @@ -5740,11 +5679,8 @@ configure_forward(const cfg_obj_t *config, dns_view_t *view, if (cfg_obj_isstring(tlspobj)) { tls = cfg_obj_asstring(tlspobj); if (tls != NULL) { - result = validate_tls(config, view, tlspobj, - tls, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(validate_tls(config, view, tlspobj, tls, + NULL)); } } } @@ -5820,8 +5756,6 @@ configure_forward(const cfg_obj_t *config, dns_view_t *view, dns_view_sfd_add(view, origin); } - result = ISC_R_SUCCESS; - cleanup: ISC_LIST_FOREACH(fwdlist, fwd, link) { @@ -5881,20 +5815,12 @@ cleanup: static isc_result_t find_view(const cfg_obj_t *vconfig, dns_viewlist_t *viewlist, dns_view_t **viewp) { - isc_result_t result; const char *viewname = NULL; dns_rdataclass_t viewclass; dns_view_t *view = NULL; - result = get_viewinfo(vconfig, &viewname, &viewclass); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = dns_viewlist_find(viewlist, viewname, viewclass, &view); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(get_viewinfo(vconfig, &viewname, &viewclass)); + RETERR(dns_viewlist_find(viewlist, viewname, viewclass, &view)); *viewp = view; return ISC_R_SUCCESS; @@ -5915,10 +5841,7 @@ create_view(const cfg_obj_t *vconfig, dns_viewlist_t *viewlist, dns_rdataclass_t viewclass; dns_view_t *view = NULL; - result = get_viewinfo(vconfig, &viewname, &viewclass); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(get_viewinfo(vconfig, &viewname, &viewclass)); result = dns_viewlist_find(viewlist, viewname, viewclass, &view); if (result == ISC_R_SUCCESS) { @@ -6886,11 +6809,8 @@ generate_session_key(const char *filename, const char *keynamestr, ISC_LOG_INFO, "generating session key for dynamic DNS"); /* generate key */ - result = dst_key_generate(keyname, alg, bits, 1, 0, DNS_KEYPROTO_ANY, - dns_rdataclass_in, NULL, mctx, &key, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_key_generate(keyname, alg, bits, 1, 0, DNS_KEYPROTO_ANY, + dns_rdataclass_in, NULL, mctx, &key, NULL)); /* * Dump the key to the buffer for later use. @@ -6974,10 +6894,7 @@ configure_session_key(const cfg_obj_t **maps, named_server_t *server, isc_buffer_constinit(&buffer, keynamestr, strlen(keynamestr)); isc_buffer_add(&buffer, strlen(keynamestr)); keyname = dns_fixedname_initname(&fname); - result = dns_name_fromtext(keyname, &buffer, dns_rootname, 0); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromtext(keyname, &buffer, dns_rootname, 0)); obj = NULL; result = named_config_get(maps, "session-keyalg", &obj); @@ -7665,10 +7582,7 @@ configure_views(cfg_obj_t *config, const cfg_obj_t *bindkeys, cfg_obj_t *vconfig = cfg_listelt_value(element); dns_view_t *view = NULL; - result = find_view(vconfig, viewlist, &view); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(find_view(vconfig, viewlist, &view)); result = configure_view(view, viewlist, config, vconfig, cachelist, &server->cachelist, kasplist, @@ -7695,10 +7609,7 @@ configure_views(cfg_obj_t *config, const cfg_obj_t *bindkeys, */ if (explicitviews == false) { dns_view_t *view = NULL; - result = find_view(NULL, viewlist, &view); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(find_view(NULL, viewlist, &view)); result = configure_view(view, viewlist, config, NULL, cachelist, &server->cachelist, kasplist, bindkeys, isc_g_mctx, aclctx, tlsctx_client_cache, @@ -7745,10 +7656,7 @@ configure_keystores(const cfg_obj_t *config, dns_keystorelist_t *keystorelist) { /* * Create the built-in key store ("key-directory"). */ - result = cfg_keystore_fromconfig(NULL, isc_g_mctx, keystorelist, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(cfg_keystore_fromconfig(NULL, isc_g_mctx, keystorelist, NULL)); /* * Create the DNSSEC key stores. @@ -7758,11 +7666,8 @@ configure_keystores(const cfg_obj_t *config, dns_keystorelist_t *keystorelist) { CFG_LIST_FOREACH(keystores, element) { cfg_obj_t *kconfig = cfg_listelt_value(element); - result = cfg_keystore_fromconfig(kconfig, isc_g_mctx, - keystorelist, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(cfg_keystore_fromconfig(kconfig, isc_g_mctx, + keystorelist, NULL)); } return result; @@ -7788,13 +7693,9 @@ configure_kasplist(const cfg_obj_t *config, dns_kasplist_t *kasplist, cfg_obj_t *kconfig = cfg_listelt_value(element); dns_kasp_t *kasp = NULL; - result = cfg_kasp_fromconfig(kconfig, default_kasp, kaspopts, - isc_g_mctx, keystorelist, kasplist, - &kasp); - if (result != ISC_R_SUCCESS) { - return result; - } - + RETERR(cfg_kasp_fromconfig(kconfig, default_kasp, kaspopts, + isc_g_mctx, keystorelist, kasplist, + &kasp)); INSIST(kasp != NULL); dns_kasp_freeze(kasp); @@ -10091,7 +9992,7 @@ cleanup: isc_result_t named_server_retransfercommand(named_server_t *server, isc_lex_t *lex, isc_buffer_t *text) { - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; const char *arg = NULL; dns_zone_t *zone = NULL; dns_zone_t *raw = NULL; @@ -10109,10 +10010,8 @@ named_server_retransfercommand(named_server_t *server, isc_lex_t *lex, arg = next_token(lex, text); } - result = zone_from_args(server, lex, arg, &zone, NULL, text, false); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(zone_from_args(server, lex, arg, &zone, NULL, text, false)); + if (zone == NULL) { return ISC_R_UNEXPECTEDEND; } @@ -10154,17 +10053,15 @@ named_server_retransfercommand(named_server_t *server, isc_lex_t *lex, isc_result_t named_server_reloadcommand(named_server_t *server, isc_lex_t *lex, isc_buffer_t *text) { - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; dns_zone_t *zone = NULL; dns_zonetype_t type; const char *msg = NULL; REQUIRE(text != NULL); - result = zone_from_args(server, lex, NULL, &zone, NULL, text, true); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(zone_from_args(server, lex, NULL, &zone, NULL, text, true)); + if (zone == NULL) { result = reload(server); switch (result) { @@ -10317,16 +10214,13 @@ cleanup: isc_result_t named_server_notifycommand(named_server_t *server, isc_lex_t *lex, isc_buffer_t *text) { - isc_result_t result; dns_zone_t *zone = NULL; const char msg[] = "zone notify queued"; REQUIRE(text != NULL); - result = zone_from_args(server, lex, NULL, &zone, NULL, text, true); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(zone_from_args(server, lex, NULL, &zone, NULL, text, true)); + if (zone == NULL) { return ISC_R_UNEXPECTEDEND; } @@ -10345,7 +10239,6 @@ named_server_notifycommand(named_server_t *server, isc_lex_t *lex, isc_result_t named_server_refreshcommand(named_server_t *server, isc_lex_t *lex, isc_buffer_t *text) { - isc_result_t result; dns_zone_t *zone = NULL, *raw = NULL; const char msg1[] = "zone refresh queued"; const char msg2[] = "not a secondary, mirror, or stub zone"; @@ -10353,10 +10246,8 @@ named_server_refreshcommand(named_server_t *server, isc_lex_t *lex, REQUIRE(text != NULL); - result = zone_from_args(server, lex, NULL, &zone, NULL, text, true); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(zone_from_args(server, lex, NULL, &zone, NULL, text, true)); + if (zone == NULL) { return ISC_R_UNEXPECTEDEND; } @@ -10431,15 +10322,12 @@ listenlist_fromconfig(const cfg_obj_t *listenlist, const cfg_obj_t *config, cfg_aclconfctx_t *aclctx, isc_mem_t *mctx, uint16_t family, isc_tlsctx_cache_t *tlsctx_cache, ns_listenlist_t **target) { - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; ns_listenlist_t *dlist = NULL; REQUIRE(target != NULL && *target == NULL); - result = ns_listenlist_create(mctx, &dlist); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(ns_listenlist_create(mctx, &dlist)); CFG_LIST_FOREACH(listenlist, element) { ns_listenelt_t *delt = NULL; @@ -10490,7 +10378,7 @@ listenelt_fromconfig(const cfg_obj_t *listener, const cfg_obj_t *config, cfg_aclconfctx_t *aclctx, isc_mem_t *mctx, uint16_t family, isc_tlsctx_cache_t *tlsctx_cache, ns_listenelt_t **target) { - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; const cfg_obj_t *ltup = NULL; const cfg_obj_t *tlsobj = NULL, *httpobj = NULL; const cfg_obj_t *portobj = NULL; @@ -10653,41 +10541,29 @@ listenelt_fromconfig(const cfg_obj_t *listener, const cfg_obj_t *config, if (named_g_httpsport != 0) { port = named_g_httpsport; } else { - result = named_config_getport( - config, "https-port", &port); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(named_config_getport( + config, "https-port", &port)); } } else if (http && !do_tls) { if (named_g_httpport != 0) { port = named_g_httpport; } else { - result = named_config_getport( - config, "http-port", &port); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(named_config_getport(config, "http-port", + &port)); } } else if (do_tls) { if (named_g_tlsport != 0) { port = named_g_tlsport; } else { - result = named_config_getport( - config, "tls-port", &port); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(named_config_getport(config, "tls-port", + &port)); } } else { if (named_g_port != 0) { port = named_g_port; } else { - result = named_config_getport(config, "port", - &port); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(named_config_getport(config, "port", + &port)); } } } else { @@ -11562,11 +11438,11 @@ named_server_flushcache(named_server_t *server, isc_lex_t *lex) { isc_result_t named_server_flushnode(named_server_t *server, isc_lex_t *lex, bool tree) { - char *ptr, *viewname; + char *ptr = NULL, *viewname = NULL; char target[DNS_NAME_FORMATSIZE]; bool flushed; bool found; - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; isc_buffer_t b; dns_fixedname_t fixed; dns_name_t *name = NULL; @@ -11587,10 +11463,7 @@ named_server_flushnode(named_server_t *server, isc_lex_t *lex, bool tree) { isc_buffer_constinit(&b, target, strlen(target)); isc_buffer_add(&b, strlen(target)); name = dns_fixedname_initname(&fixed); - result = dns_name_fromtext(name, &b, dns_rootname, 0); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromtext(name, &b, dns_rootname, 0)); /* Look for the view name. */ viewname = next_token(lex, NULL); @@ -11834,11 +11707,11 @@ cleanup: */ isc_result_t named_server_rekey(named_server_t *server, isc_lex_t *lex, isc_buffer_t *text) { - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; dns_zone_t *zone = NULL; dns_zonetype_t type; bool fullsign = false; - char *ptr; + char *ptr = NULL; REQUIRE(text != NULL); @@ -11853,10 +11726,8 @@ named_server_rekey(named_server_t *server, isc_lex_t *lex, isc_buffer_t *text) { REQUIRE(text != NULL); - result = zone_from_args(server, lex, NULL, &zone, NULL, text, false); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(zone_from_args(server, lex, NULL, &zone, NULL, text, false)); + if (zone == NULL) { return ISC_R_UNEXPECTEDEND; /* XXX: or do all zones? */ } @@ -11912,7 +11783,7 @@ synczone(dns_zone_t *zone, void *uap) { isc_result_t named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t *text) { - isc_result_t result, tresult; + isc_result_t result = ISC_R_SUCCESS, tresult; dns_zone_t *zone = NULL; char classstr[DNS_RDATACLASS_FORMATSIZE]; char zonename[DNS_NAME_FORMATSIZE]; @@ -11933,10 +11804,7 @@ named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t *text) { REQUIRE(text != NULL); - result = zone_from_args(server, lex, arg, &zone, NULL, text, false); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(zone_from_args(server, lex, arg, &zone, NULL, text, false)); if (zone == NULL) { isc_loopmgr_pause(); @@ -11989,7 +11857,7 @@ named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t *text) { isc_result_t named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex, isc_buffer_t *text) { - isc_result_t result, tresult; + isc_result_t result = ISC_R_SUCCESS; dns_zone_t *mayberaw = NULL, *raw = NULL; dns_zonetype_t type; char classstr[DNS_RDATACLASS_FORMATSIZE]; @@ -12000,26 +11868,24 @@ named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex, REQUIRE(text != NULL); - result = zone_from_args(server, lex, NULL, &mayberaw, NULL, text, true); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(zone_from_args(server, lex, NULL, &mayberaw, NULL, text, true)); + if (mayberaw == NULL) { + isc_result_t tresult = ISC_R_SUCCESS; isc_loopmgr_pause(); - tresult = ISC_R_SUCCESS; ISC_LIST_FOREACH(server->viewlist, view, link) { - result = dns_view_freezezones(view, freeze); - if (result != ISC_R_SUCCESS && tresult == ISC_R_SUCCESS) + tresult = dns_view_freezezones(view, freeze); + if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS) { - tresult = result; + result = tresult; } } isc_loopmgr_resume(); isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER, ISC_LOG_INFO, "%s all zones: %s", freeze ? "freezing" : "thawing", - isc_result_totext(tresult)); - return tresult; + isc_result_totext(result)); + return result; } dns_zone_getraw(mayberaw, &raw); if (raw != NULL) { diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index f557ec75142..bd29d8fab53 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -71,7 +71,6 @@ configure_zone_acl(const cfg_obj_t *zconfig, const cfg_obj_t *vconfig, cfg_aclconfctx_t *aclctx, dns_zone_t *zone, void (*setzacl)(dns_zone_t *, dns_acl_t *), void (*clearzacl)(dns_zone_t *)) { - isc_result_t result; const cfg_obj_t *maps[6] = { 0 }; const cfg_obj_t *aclobj = NULL; int i = 0; @@ -169,11 +168,7 @@ configure_zone_acl(const cfg_obj_t *zconfig, const cfg_obj_t *vconfig, } parse_acl: - result = cfg_acl_fromconfig(aclobj, config, aclctx, isc_g_mctx, 0, - &acl); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(cfg_acl_fromconfig(aclobj, config, aclctx, isc_g_mctx, 0, &acl)); (*setzacl)(zone, acl); /* Set the view default now */ @@ -558,12 +553,9 @@ configure_staticstub(const cfg_obj_t *zconfig, const cfg_obj_t *tconfig, isc_region_t region; /* Create the DB beforehand */ - result = dns_db_create(mctx, dbtype, dns_zone_getorigin(zone), - dns_dbtype_stub, dns_zone_getclass(zone), 0, - NULL, &db); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_create(mctx, dbtype, dns_zone_getorigin(zone), + dns_dbtype_stub, dns_zone_getclass(zone), 0, NULL, + &db)); dns_rdataset_init(&rdataset); @@ -694,8 +686,6 @@ zonetype_fromconfig(const cfg_obj_t *zmap, const cfg_obj_t *tmap) { static isc_result_t strtoargvsub(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp, unsigned int n) { - isc_result_t result; - /* Discard leading whitespace. */ while (*s == ' ' || *s == '\t') { s++; @@ -714,10 +704,7 @@ strtoargvsub(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp, *p++ = '\0'; } - result = strtoargvsub(mctx, p, argcp, argvp, n + 1); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(strtoargvsub(mctx, p, argcp, argvp, n + 1)); (*argvp)[n] = s; } return ISC_R_SUCCESS; @@ -1917,10 +1904,7 @@ named_zone_configure_writeable_dlz(dns_dlzdb_t *dlzdatabase, dns_zone_t *zone, isc_result_t result; dns_zone_settype(zone, dns_zone_dlz); - result = dns_sdlz_setdb(dlzdatabase, rdclass, name, &db); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_sdlz_setdb(dlzdatabase, rdclass, name, &db)); result = dns_zone_dlzpostload(zone, db); dns_db_detach(&db); return result; diff --git a/bin/plugins/synthrecord.c b/bin/plugins/synthrecord.c index 3fdd7633f60..8dc3e257b12 100644 --- a/bin/plugins/synthrecord.c +++ b/bin/plugins/synthrecord.c @@ -62,7 +62,6 @@ synthrecord_reverseanswer(synthrecord_t *inst, isc_netaddr_t *na, isc_buffer_t addrb; char addrbdata[DNS_NAME_FORMATSIZE]; isc_region_t addrr; - isc_result_t result; REQUIRE(DNS_NAME_VALID(synthname)); REQUIRE(na->family == AF_INET || na->family == AF_INET6); @@ -71,10 +70,7 @@ synthrecord_reverseanswer(synthrecord_t *inst, isc_netaddr_t *na, isc_buffer_copyregion(&b, &inst->prefix); isc_buffer_init(&addrb, addrbdata, sizeof(addrbdata)); - result = isc_netaddr_totext(na, &addrb); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_netaddr_totext(na, &addrb)); /* * IDN compatibility, as an IPv6 begining or ending with `::` will be @@ -468,11 +464,8 @@ synthrecord_initorigin(synthrecord_t *inst, const cfg_obj_t *synthrecordcfg, dns_name_init(&inst->origin); if (result == ISC_R_SUCCESS) { originstr = cfg_obj_asstring(obj); - result = dns_name_fromstring(&inst->origin, originstr, NULL, 0, - inst->mctx); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromstring(&inst->origin, originstr, NULL, 0, + inst->mctx)); if (!dns_name_isabsolute(&inst->origin)) { isc_log_write(NS_LOGCATEGORY_GENERAL, @@ -517,11 +510,8 @@ synthrecord_parseallowsynth(synthrecord_t *inst, const cfg_obj_t *cfg, return result; } - result = cfg_acl_fromconfig(obj, cfg, aclctx, inst->mctx, 0, - &inst->allowedsynth); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(cfg_acl_fromconfig(obj, cfg, aclctx, inst->mctx, 0, + &inst->allowedsynth)); for (unsigned int i = 0; i < inst->allowedsynth->length; i++) { switch (inst->allowedsynth->elements[i].type) { diff --git a/bin/tests/system/dlzexternal/driver/driver.c b/bin/tests/system/dlzexternal/driver/driver.c index 47ab393e736..34a64c8c8a3 100644 --- a/bin/tests/system/dlzexternal/driver/driver.c +++ b/bin/tests/system/dlzexternal/driver/driver.c @@ -502,10 +502,7 @@ dlz_lookup(const char *zone, const char *name, void *dbdata, loginfo("dlz_example: lookup connection from %s", buf); found = true; - result = state->putrr(lookup, "TXT", 0, buf); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(state->putrr(lookup, "TXT", 0, buf)); } if (strcmp(name, "too-long") == 0 || @@ -516,10 +513,7 @@ dlz_lookup(const char *zone, const char *name, void *dbdata, } buf[i] = '\0'; found = true; - result = state->putrr(lookup, "TXT", 0, buf); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(state->putrr(lookup, "TXT", 0, buf)); } /* Tests for DLZ redirection zones */ @@ -545,12 +539,9 @@ dlz_lookup(const char *zone, const char *name, void *dbdata, for (i = 0; i < MAX_RECORDS; i++) { if (strcasecmp(state->current[i].name, full_name) == 0) { found = true; - result = state->putrr(lookup, state->current[i].type, - state->current[i].ttl, - state->current[i].data); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(state->putrr(lookup, state->current[i].type, + state->current[i].ttl, + state->current[i].data)); } } @@ -616,17 +607,13 @@ dlz_allnodes(const char *zone, void *dbdata, dns_sdlzallnodes_t *allnodes) { } for (i = 0; i < MAX_RECORDS; i++) { - isc_result_t result; if (strlen(state->current[i].name) == 0U) { continue; } - result = state->putnamedrr(allnodes, state->current[i].name, - state->current[i].type, - state->current[i].ttl, - state->current[i].data); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(state->putnamedrr(allnodes, state->current[i].name, + state->current[i].type, + state->current[i].ttl, + state->current[i].data)); } return ISC_R_SUCCESS; diff --git a/bin/tools/named-makejournal.c b/bin/tools/named-makejournal.c index 3cdbd34df69..52cea705170 100644 --- a/bin/tools/named-makejournal.c +++ b/bin/tools/named-makejournal.c @@ -45,20 +45,11 @@ static isc_result_t loadzone(dns_db_t **db, const char *origin, const char *filename) { isc_result_t result; dns_fixedname_t fixed; - dns_name_t *name = NULL; + dns_name_t *name = dns_fixedname_initname(&fixed); - name = dns_fixedname_initname(&fixed); - - result = dns_name_fromstring(name, origin, dns_rootname, 0, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, name, - dns_dbtype_zone, dns_rdataclass_in, 0, NULL, db); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromstring(name, origin, dns_rootname, 0, NULL)); + RETERR(dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone, + dns_rdataclass_in, 0, NULL, db)); result = dns_db_load(*db, filename, dns_masterformat_text, 0); if (result == DNS_R_SEENINCLUDE) { diff --git a/lib/dns/acl.c b/lib/dns/acl.c index d0a65a62d1e..9c9faa35354 100644 --- a/lib/dns/acl.c +++ b/lib/dns/acl.c @@ -271,7 +271,6 @@ dns_acl_match_port_transport(const isc_netaddr_t *reqaddr, */ isc_result_t dns_acl_merge(dns_acl_t *dest, dns_acl_t *source, bool pos) { - isc_result_t result; unsigned int nelem, i; int max_node = 0, nodes; @@ -345,10 +344,7 @@ dns_acl_merge(dns_acl_t *dest, dns_acl_t *source, bool pos) { * node_count value is set correctly afterward. */ nodes = max_node + dns_acl_node_count(dest); - result = dns_iptable_merge(dest->iptable, source->iptable, pos); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_iptable_merge(dest->iptable, source->iptable, pos)); if (nodes > dns_acl_node_count(dest)) { dns_acl_node_count(dest) = nodes; } diff --git a/lib/dns/adb.c b/lib/dns/adb.c index af36a8f878a..467caa26627 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -2351,12 +2351,7 @@ print_find_list(FILE *f, dns_adbname_t *name) { static isc_result_t putstr(isc_buffer_t *b, const char *str) { - isc_result_t result; - - result = isc_buffer_reserve(b, strlen(str)); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_buffer_reserve(b, strlen(str))); isc_buffer_putstr(b, str); return ISC_R_SUCCESS; diff --git a/lib/dns/cache.c b/lib/dns/cache.c index f93f7255106..e9c904eda00 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -323,15 +323,11 @@ dns_cache_getservestalerefresh(dns_cache_t *cache) { isc_result_t dns_cache_flush(dns_cache_t *cache) { - dns_db_t *db = NULL, *olddb; - isc_mem_t *tmctx = NULL, *oldtmctx; - isc_mem_t *hmctx = NULL, *oldhmctx; - isc_result_t result; + dns_db_t *db = NULL, *olddb = NULL; + isc_mem_t *tmctx = NULL, *oldtmctx = NULL; + isc_mem_t *hmctx = NULL, *oldhmctx = NULL; - result = cache_create_db(cache, &db, &tmctx, &hmctx); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(cache_create_db(cache, &db, &tmctx, &hmctx)); LOCK(&cache->lock); isc_mem_clearwater(cache->tmctx); @@ -353,16 +349,13 @@ dns_cache_flush(dns_cache_t *cache) { static isc_result_t clearnode(dns_db_t *db, dns_dbnode_t *node) { - isc_result_t result; dns_rdatasetiter_t *iter = NULL; - result = dns_db_allrdatasets(db, node, NULL, DNS_DB_STALEOK, - (isc_stdtime_t)0, &iter); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_allrdatasets(db, node, NULL, DNS_DB_STALEOK, + (isc_stdtime_t)0, &iter)); DNS_RDATASETITER_FOREACH(iter) { + isc_result_t result; dns_rdataset_t rdataset = DNS_RDATASET_INIT; dns_rdatasetiter_current(iter, &rdataset); @@ -375,7 +368,7 @@ clearnode(dns_db_t *db, dns_dbnode_t *node) { } dns_rdatasetiter_destroy(&iter); - return result; + return ISC_R_SUCCESS; } static isc_result_t diff --git a/lib/dns/catz.c b/lib/dns/catz.c index fb7b284dcb5..44f2757c290 100644 --- a/lib/dns/catz.c +++ b/lib/dns/catz.c @@ -1200,18 +1200,12 @@ catz_process_coo(dns_catz_zone_t *catz, dns_label_t *mhash, return ISC_R_FAILURE; } - result = dns_rdataset_first(value); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdataset_first(value)); dns_rdata_init(&rdata); dns_rdataset_current(value, &rdata); - result = dns_rdata_tostruct(&rdata, &ptr, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_tostruct(&rdata, &ptr, NULL)); if (dns_name_countlabels(&ptr.ptr) == 0) { CHECK(ISC_R_FAILURE); @@ -1253,18 +1247,12 @@ catz_process_zones_entry(dns_catz_zone_t *catz, dns_rdataset_t *value, return ISC_R_FAILURE; } - result = dns_rdataset_first(value); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdataset_first(value)); dns_rdata_init(&rdata); dns_rdataset_current(value, &rdata); - result = dns_rdata_tostruct(&rdata, &ptr, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_tostruct(&rdata, &ptr, NULL)); result = isc_ht_find(catz->entries, mhash->base, mhash->length, (void **)&entry); @@ -1314,18 +1302,12 @@ catz_process_version(dns_catz_zone_t *catz, dns_rdataset_t *value) { return ISC_R_FAILURE; } - result = dns_rdataset_first(value); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdataset_first(value)); dns_rdata_init(&rdata); dns_rdataset_current(value, &rdata); - result = dns_rdata_tostruct(&rdata, &rdatatxt, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_tostruct(&rdata, &rdatatxt, NULL)); CHECK(dns_rdata_txt_first(&rdatatxt)); @@ -1559,10 +1541,7 @@ catz_process_apl(dns_catz_zone_t *catz, isc_buffer_t **aclbp, RUNTIME_CHECK(result == ISC_R_SUCCESS); dns_rdata_init(&rdata); dns_rdataset_current(value, &rdata); - result = dns_rdata_tostruct(&rdata, &rdata_apl, catz->catzs->mctx); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_tostruct(&rdata, &rdata_apl, catz->catzs->mctx)); isc_buffer_allocate(catz->catzs->mctx, &aclb, 16); for (result = dns_rdata_apl_first(&rdata_apl); result == ISC_R_SUCCESS; result = dns_rdata_apl_next(&rdata_apl)) @@ -1802,10 +1781,7 @@ dns__catz_update_process(dns_catz_zone_t *catz, const dns_name_t *src_name, nrres = dns_name_fullcompare(src_name, &catz->name, &order, &nlabels); if (nrres == dns_namereln_equal) { if (rdataset->type == dns_rdatatype_soa) { - result = dns_rdataset_first(rdataset); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdataset_first(rdataset)); dns_rdataset_current(rdataset, &rdata); result = dns_rdata_tostruct(&rdata, &soa, NULL); diff --git a/lib/dns/db.c b/lib/dns/db.c index 2ab84644c9f..80f505d02bb 100644 --- a/lib/dns/db.c +++ b/lib/dns/db.c @@ -317,10 +317,7 @@ dns_db_load(dns_db_t *db, const char *filename, dns_masterformat_t format, } dns_rdatacallbacks_init(&callbacks); - result = dns_db_beginload(db, &callbacks); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_beginload(db, &callbacks)); result = dns_master_loadfile(filename, &db->origin, &db->origin, db->rdclass, options, 0, &callbacks, NULL, NULL, db->mctx, format, 0); @@ -697,10 +694,7 @@ dns_db_getsoaserial(dns_db_t *db, dns_dbversion_t *ver, uint32_t *serialp) { REQUIRE(dns_db_iszone(db) || dns_db_isstub(db)); - result = dns_db_findnode(db, dns_db_origin(db), false, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_findnode(db, dns_db_origin(db), false, &node)); dns_rdataset_init(&rdataset); result = dns_db_findrdataset(db, node, ver, dns_rdatatype_soa, 0, diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 3927ef1162d..67a27894d5f 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -1328,10 +1328,7 @@ dispatch_createudp(dns_dispatchmgr_t *mgr, const isc_sockaddr_t *localaddr, */ isc_sockaddr_anyofpf(&sa_any, isc_sockaddr_pf(localaddr)); if (!isc_sockaddr_eqaddr(&sa_any, localaddr)) { - result = isc_nm_checkaddr(localaddr, isc_socktype_udp); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_nm_checkaddr(localaddr, isc_socktype_udp)); } dispatch_allocate(mgr, isc_socktype_udp, tid, &disp); @@ -1978,15 +1975,9 @@ tcp_dispatch_connect(dns_dispatch_t *disp, dns_dispentry_t *resp) { } if (transport_type == DNS_TRANSPORT_TLS) { - isc_result_t result; - - result = dns_transport_get_tlsctx( - resp->transport, &resp->peer, resp->tlsctx_cache, - resp->mctx, &tlsctx, &sess_cache); - - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_transport_get_tlsctx(resp->transport, &resp->peer, + resp->tlsctx_cache, resp->mctx, + &tlsctx, &sess_cache)); INSIST(tlsctx != NULL); } diff --git a/lib/dns/dns64.c b/lib/dns/dns64.c index f13c06ec12f..92c43999989 100644 --- a/lib/dns/dns64.c +++ b/lib/dns/dns64.c @@ -131,7 +131,6 @@ dns_dns64_aaaafroma(const dns_dns64_t *dns64, const isc_netaddr_t *reqaddr, const dns_name_t *reqsigner, dns_aclenv_t *env, unsigned int flags, unsigned char *a, unsigned char *aaaa) { unsigned int nbytes, i; - isc_result_t result; int match; if ((dns64->flags & DNS_DNS64_RECURSIVE_ONLY) != 0 && @@ -147,11 +146,8 @@ dns_dns64_aaaafroma(const dns_dns64_t *dns64, const isc_netaddr_t *reqaddr, } if (dns64->clients != NULL && reqaddr != NULL) { - result = dns_acl_match(reqaddr, reqsigner, dns64->clients, env, - &match, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_acl_match(reqaddr, reqsigner, dns64->clients, env, + &match, NULL)); if (match <= 0) { return DNS_R_DISALLOWED; } @@ -163,11 +159,8 @@ dns_dns64_aaaafroma(const dns_dns64_t *dns64, const isc_netaddr_t *reqaddr, memmove(&ina.s_addr, a, 4); isc_netaddr_fromin(&netaddr, &ina); - result = dns_acl_match(&netaddr, NULL, dns64->mapped, env, - &match, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_acl_match(&netaddr, NULL, dns64->mapped, env, &match, + NULL)); if (match <= 0) { return DNS_R_DISALLOWED; } diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c index 703366511de..f079dcc472a 100644 --- a/lib/dns/dnssec.c +++ b/lib/dns/dnssec.c @@ -145,17 +145,13 @@ static isc_result_t digest_sig(dst_context_t *ctx, bool downcase, dns_rdata_t *sigrdata, dns_rdata_rrsig_t *rrsig) { isc_region_t r; - isc_result_t ret; dns_fixedname_t fname; dns_rdata_toregion(sigrdata, &r); INSIST(r.length >= 19); r.length = 18; - ret = dst_context_adddata(ctx, &r); - if (ret != ISC_R_SUCCESS) { - return ret; - } + RETERR(dst_context_adddata(ctx, &r)); if (downcase) { dns_fixedname_init(&fname); @@ -225,10 +221,7 @@ dns_dnssec_sign(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, sig.timesigned = *inception; sig.timeexpire = *expire; sig.keyid = dst_key_id(key); - ret = dst_key_sigsize(key, &sigsize); - if (ret != ISC_R_SUCCESS) { - return ret; - } + RETERR(dst_key_sigsize(key, &sigsize)); sig.siglen = sigsize; /* * The actual contents of sig.signature are not important yet, since @@ -368,10 +361,7 @@ dns_dnssec_verify(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, REQUIRE(mctx != NULL); REQUIRE(sigrdata != NULL && sigrdata->type == dns_rdatatype_rrsig); - ret = dns_rdata_tostruct(sigrdata, &sig, NULL); - if (ret != ISC_R_SUCCESS) { - return ret; - } + RETERR(dns_rdata_tostruct(sigrdata, &sig, NULL)); if (set->type != sig.covered) { return DNS_R_SIGINVALID; @@ -1701,15 +1691,11 @@ cleanup: isc_result_t dns_dnssec_make_dnskey(dst_key_t *key, unsigned char *buf, int bufsize, dns_rdata_t *target) { - isc_result_t result; isc_buffer_t b; isc_region_t r; isc_buffer_init(&b, buf, bufsize); - result = dst_key_todns(key, &b); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_key_todns(key, &b)); dns_rdata_reset(target); isc_buffer_usedregion(&b, &r); @@ -1851,16 +1837,12 @@ static isc_result_t delete_cds(dns_dnsseckey_t *key, dns_rdata_t *keyrdata, const char *keystr, dns_rdataset_t *cds, unsigned int digesttype, dns_diff_t *diff, isc_mem_t *mctx) { - isc_result_t r; unsigned char dsbuf[DNS_DS_BUFFERSIZE]; dns_rdata_t cdsrdata = DNS_RDATA_INIT; dns_name_t *origin = dst_key_name(key->key); - r = dns_ds_buildrdata(origin, keyrdata, digesttype, dsbuf, - sizeof(dsbuf), &cdsrdata); - if (r != ISC_R_SUCCESS) { - return r; - } + RETERR(dns_ds_buildrdata(origin, keyrdata, digesttype, dsbuf, + sizeof(dsbuf), &cdsrdata)); cdsrdata.type = dns_rdatatype_cds; if (exists(cds, &cdsrdata)) { diff --git a/lib/dns/ds.c b/lib/dns/ds.c index 773a880127a..e8c71a80c72 100644 --- a/lib/dns/ds.c +++ b/lib/dns/ds.c @@ -186,10 +186,7 @@ dns_ds_buildrdata(dns_name_t *owner, dns_rdata_t *key, dns_rdata_ds_t ds; isc_buffer_t b; - result = dns_ds_fromkeyrdata(owner, key, digest_type, digest, len, &ds); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_ds_fromkeyrdata(owner, key, digest_type, digest, len, &ds)); memset(buffer, 0, DNS_DS_BUFFERSIZE); isc_buffer_init(&b, buffer, DNS_DS_BUFFERSIZE); diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index 3f9743e3b2d..4b79f487aed 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -675,7 +675,6 @@ dst_key_fromdns(const dns_name_t *name, dns_rdataclass_t rdclass, dst_key_t *key = NULL; dns_keytag_t id, rid; isc_region_t r; - isc_result_t result; isc_buffer_remainingregion(source, &r); @@ -697,11 +696,8 @@ dst_key_fromdns(const dns_name_t *name, dns_rdataclass_t rdclass, flags |= (extflags << 16); } - result = frombuffer(name, alg, flags, proto, rdclass, source, mctx, - &key); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(frombuffer(name, alg, flags, proto, rdclass, source, mctx, + &key)); key->key_id = id; key->key_rid = rid; @@ -716,11 +712,8 @@ dst_key_frombuffer(const dns_name_t *name, unsigned int alg, unsigned int flags, dst_key_t *key = NULL; isc_result_t result; - result = frombuffer(name, alg, flags, protocol, rdclass, source, mctx, - &key); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(frombuffer(name, alg, flags, protocol, rdclass, source, mctx, + &key)); result = computeid(key); if (result != ISC_R_SUCCESS) { @@ -1900,17 +1893,10 @@ write_key_state(const dst_key_t *key, int type, const char *directory) { * Make the filename. */ isc_buffer_init(&fileb, filename, sizeof(filename)); - result = dst_key_buildfilename(key, DST_TYPE_STATE, directory, &fileb); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_key_buildfilename(key, DST_TYPE_STATE, directory, &fileb)); isc_buffer_init(&tmpb, tmpname, sizeof(tmpname)); - result = dst_key_buildfilename(key, DST_TYPE_TEMPLATE, directory, - &tmpb); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_key_buildfilename(key, DST_TYPE_TEMPLATE, directory, &tmpb)); mode_t mode = issymmetric(key) ? S_IRUSR | S_IWUSR : S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; @@ -1993,10 +1979,7 @@ write_public_key(const dst_key_t *key, int type, const char *directory) { isc_buffer_init(&textb, text_array, sizeof(text_array)); isc_buffer_init(&classb, class_array, sizeof(class_array)); - result = dst_key_todns(key, &keyb); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_key_todns(key, &keyb)); isc_buffer_usedregion(&keyb, &r); dns_rdata_fromregion(&rdata, key->key_class, dns_rdatatype_dnskey, &r); @@ -2015,17 +1998,10 @@ write_public_key(const dst_key_t *key, int type, const char *directory) { * Make the filename. */ isc_buffer_init(&fileb, filename, sizeof(filename)); - result = dst_key_buildfilename(key, DST_TYPE_PUBLIC, directory, &fileb); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_key_buildfilename(key, DST_TYPE_PUBLIC, directory, &fileb)); isc_buffer_init(&tmpb, tmpname, sizeof(tmpname)); - result = dst_key_buildfilename(key, DST_TYPE_TEMPLATE, directory, - &tmpb); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_key_buildfilename(key, DST_TYPE_TEMPLATE, directory, &tmpb)); /* Create temporary public key file. */ mode_t mode = issymmetric(key) ? S_IRUSR | S_IWUSR @@ -2096,7 +2072,6 @@ static isc_result_t buildfilename(dns_name_t *name, dns_keytag_t id, unsigned int alg, unsigned int type, const char *directory, isc_buffer_t *out) { const char *suffix = ""; - isc_result_t result; REQUIRE(out != NULL); REQUIRE(alg != 0 && alg != DST_ALG_PRIVATEOID && @@ -2127,10 +2102,7 @@ buildfilename(dns_name_t *name, dns_keytag_t id, unsigned int alg, return ISC_R_NOSPACE; } isc_buffer_putstr(out, "K"); - result = dns_name_tofilenametext(name, false, out); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_tofilenametext(name, false, out)); return isc_buffer_printf(out, "+%03d+%05d%s", alg, id, suffix); } diff --git a/lib/dns/dst_parse.c b/lib/dns/dst_parse.c index 0310f3be797..8622a3b1294 100644 --- a/lib/dns/dst_parse.c +++ b/lib/dns/dst_parse.c @@ -619,11 +619,7 @@ dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv, } isc_buffer_init(&fileb, filename, sizeof(filename)); - result = dst_key_buildfilename(key, DST_TYPE_PRIVATE, directory, - &fileb); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_key_buildfilename(key, DST_TYPE_PRIVATE, directory, &fileb)); result = isc_file_mode(filename, &mode); if (result == ISC_R_SUCCESS && mode != (S_IRUSR | S_IWUSR)) { @@ -640,11 +636,7 @@ dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv, } isc_buffer_init(&tmpb, tmpname, sizeof(tmpname)); - result = dst_key_buildfilename(key, DST_TYPE_TEMPLATE, directory, - &tmpb); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_key_buildfilename(key, DST_TYPE_TEMPLATE, directory, &tmpb)); fp = dst_key_open(tmpname, S_IRUSR | S_IWUSR); if (fp == NULL) { diff --git a/lib/dns/hmac_link.c b/lib/dns/hmac_link.c index c84ce8efc17..1a9a1631911 100644 --- a/lib/dns/hmac_link.c +++ b/lib/dns/hmac_link.c @@ -456,18 +456,15 @@ static isc_result_t hmac_parse(const isc_md_type_t *type, dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) { dst_private_t priv; - isc_result_t result, tresult; + isc_result_t result = ISC_R_SUCCESS, tresult; isc_buffer_t b; isc_mem_t *mctx = key->mctx; unsigned int i; UNUSED(pub); /* read private key file */ - result = dst__privstruct_parse(key, hmac__to_dst_alg(type), lexer, mctx, - &priv); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst__privstruct_parse(key, hmac__to_dst_alg(type), lexer, mctx, + &priv)); if (key->external) { result = DST_R_EXTERNALKEY; diff --git a/lib/dns/iptable.c b/lib/dns/iptable.c index c405ce54cd1..3b2884dded3 100644 --- a/lib/dns/iptable.c +++ b/lib/dns/iptable.c @@ -90,17 +90,12 @@ dns_iptable_addprefix(dns_iptable_t *tab, const isc_netaddr_t *addr, */ isc_result_t dns_iptable_merge(dns_iptable_t *tab, dns_iptable_t *source, bool pos) { - isc_result_t result; isc_radix_node_t *node, *new_node; int i, max_node = 0; RADIX_WALK(source->radix->head, node) { new_node = NULL; - result = isc_radix_insert(tab->radix, &new_node, node, NULL); - - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_radix_insert(tab->radix, &new_node, node, NULL)); /* * If we're negating a nested ACL, then we should diff --git a/lib/dns/journal.c b/lib/dns/journal.c index 9c969a4a0af..46dff831bd7 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -460,17 +460,12 @@ journal_fsync(dns_journal_t *j) { */ static isc_result_t journal_read_xhdr(dns_journal_t *j, journal_xhdr_t *xhdr) { - isc_result_t result; - j->it.cpos.offset = j->offset; switch (j->xhdr_version) { case XHDR_VERSION1: { journal_rawxhdr_ver1_t raw; - result = journal_read(j, &raw, sizeof(raw)); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(journal_read(j, &raw, sizeof(raw))); xhdr->size = decode_uint32(raw.size); xhdr->count = 0; xhdr->serial0 = decode_uint32(raw.serial0); @@ -481,10 +476,7 @@ journal_read_xhdr(dns_journal_t *j, journal_xhdr_t *xhdr) { case XHDR_VERSION2: { journal_rawxhdr_t raw; - result = journal_read(j, &raw, sizeof(raw)); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(journal_read(j, &raw, sizeof(raw))); xhdr->size = decode_uint32(raw.size); xhdr->count = decode_uint32(raw.count); xhdr->serial0 = decode_uint32(raw.serial0); @@ -524,12 +516,8 @@ journal_write_xhdr(dns_journal_t *j, uint32_t size, uint32_t count, static isc_result_t journal_read_rrhdr(dns_journal_t *j, journal_rrhdr_t *rrhdr) { journal_rawrrhdr_t raw; - isc_result_t result; - result = journal_read(j, &raw, sizeof(raw)); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(journal_read(j, &raw, sizeof(raw))); rrhdr->size = decode_uint32(raw.size); return ISC_R_SUCCESS; } @@ -929,10 +917,7 @@ journal_next(dns_journal_t *j, journal_pos_t *pos) { REQUIRE(DNS_JOURNAL_VALID(j)); - result = journal_seek(j, pos->offset); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(journal_seek(j, pos->offset)); if (pos->serial == j->header.end.serial) { return ISC_R_NOMORE; @@ -942,10 +927,7 @@ journal_next(dns_journal_t *j, journal_pos_t *pos) { * Read the header of the current transaction. * This will return ISC_R_NOMORE if we are at EOF. */ - result = journal_read_xhdr(j, &xhdr); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(journal_read_xhdr(j, &xhdr)); if (j->header_ver1) { CHECK(maybe_fixup_xhdr(j, &xhdr, pos->serial, pos->offset)); @@ -1096,7 +1078,6 @@ index_invalidate(dns_journal_t *j, uint32_t serial) { */ static isc_result_t journal_find(dns_journal_t *j, uint32_t serial, journal_pos_t *pos) { - isc_result_t result; journal_pos_t current_pos; REQUIRE(DNS_JOURNAL_VALID(j)); @@ -1119,10 +1100,7 @@ journal_find(dns_journal_t *j, uint32_t serial, journal_pos_t *pos) { if (DNS_SERIAL_GT(current_pos.serial, serial)) { return ISC_R_NOTFOUND; } - result = journal_next(j, ¤t_pos); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(journal_next(j, ¤t_pos)); } *pos = current_pos; return ISC_R_SUCCESS; @@ -2111,10 +2089,7 @@ get_name_diff(dns_db_t *db, dns_dbversion_t *ver, isc_stdtime_t now, dns_rdatasetiter_t *rdsiter = NULL; dns_difftuple_t *tuple = NULL; - result = dns_dbiterator_current(dbit, &node, name); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_dbiterator_current(dbit, &node, name)); result = dns_db_allrdatasets(db, node, ver, 0, now, &rdsiter); if (result != ISC_R_SUCCESS) { @@ -2250,10 +2225,7 @@ diff_namespace(dns_db_t *dba, dns_dbversion_t *dbvera, dns_db_t *dbb, dns_fixedname_init(&fixname[0]); dns_fixedname_init(&fixname[1]); - result = dns_db_createiterator(db[0], options, &dbit[0]); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_createiterator(db[0], options, &dbit[0])); result = dns_db_createiterator(db[1], options, &dbit[1]); if (result != ISC_R_SUCCESS) { goto cleanup_iterator; @@ -2363,11 +2335,8 @@ dns_db_diffx(dns_diff_t *diff, dns_db_t *dba, dns_dbversion_t *dbvera, dns_journal_t *journal = NULL; if (filename != NULL) { - result = dns_journal_open(diff->mctx, filename, - DNS_JOURNAL_CREATE, &journal); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_journal_open(diff->mctx, filename, + DNS_JOURNAL_CREATE, &journal)); } CHECK(diff_namespace(dba, dbvera, dbb, dbverb, DNS_DB_NONSEC3, diff)); diff --git a/lib/dns/keystore.c b/lib/dns/keystore.c index ff05486f16d..a08846e37e5 100644 --- a/lib/dns/keystore.c +++ b/lib/dns/keystore.c @@ -134,7 +134,6 @@ buildpkcs11label(const char *uri, const dns_name_t *zname, const char *policy, bool ksk = ((flags & DNS_KEYFLAG_KSK) != 0); char timebuf[18]; isc_time_t now = isc_time_now(); - isc_result_t result; dns_fixedname_t fname; dns_name_t *pname = dns_fixedname_initname(&fname); @@ -146,10 +145,7 @@ buildpkcs11label(const char *uri, const dns_name_t *zname, const char *policy, isc_buffer_putstr(buf, uri); isc_buffer_putstr(buf, ";object="); /* zone name */ - result = dns_name_tofilenametext(zname, false, buf); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_tofilenametext(zname, false, buf)); /* * policy name * @@ -161,14 +157,8 @@ buildpkcs11label(const char *uri, const dns_name_t *zname, const char *policy, return ISC_R_NOSPACE; } isc_buffer_putstr(buf, "-"); - result = dns_name_fromstring(pname, policy, dns_rootname, 0, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } - result = dns_name_tofilenametext(pname, false, buf); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromstring(pname, policy, dns_rootname, 0, NULL)); + RETERR(dns_name_tofilenametext(pname, false, buf)); /* key type + current time */ isc_time_formatshorttimestamp(&now, timebuf, sizeof(timebuf)); return isc_buffer_printf(buf, "-%s-%s", ksk ? "ksk" : "zsk", timebuf); diff --git a/lib/dns/keytable.c b/lib/dns/keytable.c index 67523178ea5..1c04b951320 100644 --- a/lib/dns/keytable.c +++ b/lib/dns/keytable.c @@ -558,12 +558,7 @@ dns_keytable_issecuredomain(dns_keytable_t *keytable, const dns_name_t *name, static isc_result_t putstr(isc_buffer_t *b, const char *str) { - isc_result_t result; - - result = isc_buffer_reserve(b, strlen(str)); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_buffer_reserve(b, strlen(str))); isc_buffer_putstr(b, str); return ISC_R_SUCCESS; diff --git a/lib/dns/master.c b/lib/dns/master.c index f42c0c1ec18..d6fe9dfe76b 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -2204,17 +2204,12 @@ cleanup: static isc_result_t read_and_check(bool do_read, isc_buffer_t *buffer, size_t len, FILE *f, uint32_t *totallen) { - isc_result_t result; - REQUIRE(totallen != NULL); if (do_read) { INSIST(isc_buffer_availablelength(buffer) >= len); - result = isc_stdio_read(isc_buffer_used(buffer), 1, len, f, - NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_stdio_read(isc_buffer_used(buffer), 1, len, f, + NULL)); isc_buffer_add(buffer, (unsigned int)len); if (*totallen < len) { return ISC_R_RANGE; @@ -2336,10 +2331,7 @@ load_raw(dns_loadctx_t *lctx) { dctx = DNS_DECOMPRESS_NEVER; if (lctx->first) { - result = load_header(lctx); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(load_header(lctx)); } ISC_LIST_INIT(head); diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index ca5704204bd..f80c40232ac 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -645,11 +645,8 @@ rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name, INDENT_TO(ttl_column); if ((ctx->style.flags & DNS_STYLEFLAG_TTL_UNITS) != 0) { length = target->used; - result = dns_ttl_totext(rdataset->ttl, false, - false, target); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_ttl_totext(rdataset->ttl, false, + false, target)); column += target->used - length; } else { length = snprintf(ttlbuf, sizeof(ttlbuf), "%u", @@ -1740,17 +1737,13 @@ dns_master_dumptostreamasync(isc_mem_t *mctx, dns_db_t *db, isc_loop_t *loop, dns_dumpdonefunc_t done, void *done_arg, dns_dumpctx_t **dctxp) { dns_dumpctx_t *dctx = NULL; - isc_result_t result; REQUIRE(loop != NULL); REQUIRE(f != NULL); REQUIRE(done != NULL); - result = dumpctx_create(mctx, db, version, style, f, &dctx, - dns_masterformat_text, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dumpctx_create(mctx, db, version, style, f, &dctx, + dns_masterformat_text, NULL)); dctx->done = done; dctx->done_arg = done_arg; @@ -1768,11 +1761,8 @@ dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, dns_dumpctx_t *dctx = NULL; isc_result_t result; - result = dumpctx_create(mctx, db, version, style, f, &dctx, format, - header); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dumpctx_create(mctx, db, version, style, f, &dctx, format, + header)); result = dumptostream(dctx); INSIST(result != DNS_R_CONTINUE); @@ -1871,10 +1861,7 @@ dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, char *tempname; dns_dumpctx_t *dctx = NULL; - result = opentmp(mctx, filename, &tempname, &f); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(opentmp(mctx, filename, &tempname, &f)); CHECK(dumpctx_create(mctx, db, version, style, f, &dctx, format, header)); diff --git a/lib/dns/message.c b/lib/dns/message.c index bd68f18a6fa..f1701c98c20 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -295,15 +295,13 @@ msgblock_free(isc_mem_t *mctx, dns_msgblock_t *block, * "current" buffer. (which is always the last on the list, for our * uses) */ -static isc_result_t +static void newbuffer(dns_message_t *msg, unsigned int size) { - isc_buffer_t *dynbuf; + isc_buffer_t *dynbuf = NULL; - dynbuf = NULL; isc_buffer_allocate(msg->mctx, &dynbuf, size); ISC_LIST_APPEND(msg->scratchpad, dynbuf, link); - return ISC_R_SUCCESS; } static isc_buffer_t * @@ -849,11 +847,7 @@ getname(dns_name_t *name, isc_buffer_t *source, dns_message_t *msg, if (result == ISC_R_NOSPACE) { tries++; - result = newbuffer(msg, SCRATCHPAD_SIZE); - if (result != ISC_R_SUCCESS) { - return result; - } - + newbuffer(msg, SCRATCHPAD_SIZE); scratch = currentbuffer(msg); dns_name_reset(name); } else { @@ -906,10 +900,7 @@ getrdata(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t dctx, trysize *= 2; } tries++; - result = newbuffer(msg, trysize); - if (result != ISC_R_SUCCESS) { - return result; - } + newbuffer(msg, trysize); scratch = currentbuffer(msg); } else { @@ -2217,10 +2208,7 @@ dns_message_renderend(dns_message_t *msg) { if (msg->tsigkey != NULL) { dns_message_renderrelease(msg, msg->sig_reserved); msg->sig_reserved = 0; - result = dns_tsig_sign(msg); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_tsig_sign(msg)); count = 0; result = renderset(msg->tsig, msg->tsigname, msg->id, msg->cctx, msg->buffer, msg->reserved, 0, &count); @@ -2236,10 +2224,7 @@ dns_message_renderend(dns_message_t *msg) { if (msg->sig0key != NULL) { dns_message_renderrelease(msg, msg->sig_reserved); msg->sig_reserved = 0; - result = dns_dnssec_signmessage(msg, msg->sig0key); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_dnssec_signmessage(msg, msg->sig0key)); count = 0; /* * Note: dns_rootname is used here, not msg->sig0name, since @@ -2648,10 +2633,7 @@ dns_message_setopt(dns_message_t *msg) { REQUIRE(msg->from_to_wire == DNS_MESSAGE_INTENTRENDER); REQUIRE(msg->state == DNS_SECTION_ANY); - result = buildopt(msg, &opt); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(buildopt(msg, &opt)); msgresetopt(msg); @@ -2766,7 +2748,6 @@ dns_message_setquerytsig(dns_message_t *msg, isc_buffer_t *querytsig) { isc_result_t dns_message_getquerytsig(dns_message_t *msg, isc_mem_t *mctx, isc_buffer_t **querytsig) { - isc_result_t result; dns_rdata_t rdata = DNS_RDATA_INIT; isc_region_t r; @@ -2778,10 +2759,7 @@ dns_message_getquerytsig(dns_message_t *msg, isc_mem_t *mctx, return ISC_R_SUCCESS; } - result = dns_rdataset_first(msg->tsig); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdataset_first(msg->tsig)); dns_rdataset_current(msg->tsig, &rdata); dns_rdata_toregion(&rdata, &r); @@ -2917,10 +2895,7 @@ dns_message_signer(dns_message_t *msg, dns_name_t *signer) { INSIST(result == ISC_R_SUCCESS); dns_rdataset_current(msg->sig0, &rdata); - result = dns_rdata_tostruct(&rdata, &sig, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_tostruct(&rdata, &sig, NULL)); if (msg->verified_sig && msg->sig0status == dns_rcode_noerror) { result = ISC_R_SUCCESS; @@ -3111,10 +3086,7 @@ dns_message_checksig(dns_message_t *msg, dns_view_t *view) { return ISC_R_UNEXPECTEDEND; } - result = dns_rdata_tostruct(&sigrdata, &sig, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_tostruct(&sigrdata, &sig, NULL)); dns_rdataset_init(&keyset); if (view == NULL) { @@ -4168,11 +4140,8 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section, switch (optcode) { case DNS_OPT_LLQ: if (optlen == 18U) { - result = render_llq(&optbuf, msg, style, - target); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(render_llq(&optbuf, msg, style, + target)); ADD_STRING(target, "\n"); continue; } @@ -4225,11 +4194,8 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section, snprintf(buf, sizeof(buf), " %u", secs); ADD_STRING(target, buf); ADD_STRING(target, " ("); - result = dns_ttl_totext(secs, true, - true, target); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_ttl_totext(secs, true, true, + target)); ADD_STRING(target, ")\n"); continue; } @@ -4479,7 +4445,7 @@ isc_result_t dns_message_headertotext(dns_message_t *msg, const dns_master_style_t *style, dns_messagetextflag_t flags, isc_buffer_t *target) { char buf[sizeof("1234567890")]; - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; REQUIRE(DNS_MESSAGE_VALID(msg)); REQUIRE(target != NULL); @@ -4495,10 +4461,7 @@ dns_message_headertotext(dns_message_t *msg, const dns_master_style_t *style, ADD_STRING(target, "\n"); INDENT(style); ADD_STRING(target, "status: "); - result = dns_rcode_totext(msg->rcode, target); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rcode_totext(msg->rcode, target)); ADD_STRING(target, "\n"); INDENT(style); ADD_STRING(target, "id: "); @@ -4581,10 +4544,7 @@ dns_message_headertotext(dns_message_t *msg, const dns_master_style_t *style, ADD_STRING(target, ";; ->>HEADER<<- opcode: "); ADD_STRING(target, opcodetext[msg->opcode]); ADD_STRING(target, ", status: "); - result = dns_rcode_totext(msg->rcode, target); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rcode_totext(msg->rcode, target)); ADD_STRING(target, ", id: "); snprintf(buf, sizeof(buf), "%6u", msg->id); ADD_STRING(target, buf); @@ -4659,55 +4619,24 @@ cleanup: isc_result_t dns_message_totext(dns_message_t *msg, const dns_master_style_t *style, dns_messagetextflag_t flags, isc_buffer_t *target) { - isc_result_t result; - REQUIRE(DNS_MESSAGE_VALID(msg)); REQUIRE(target != NULL); - result = dns_message_headertotext(msg, style, flags, target); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = dns_message_pseudosectiontotext(msg, DNS_PSEUDOSECTION_OPT, - style, flags, target); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = dns_message_sectiontotext(msg, DNS_SECTION_QUESTION, style, - flags, target); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = dns_message_sectiontotext(msg, DNS_SECTION_ANSWER, style, - flags, target); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = dns_message_sectiontotext(msg, DNS_SECTION_AUTHORITY, style, - flags, target); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = dns_message_sectiontotext(msg, DNS_SECTION_ADDITIONAL, style, - flags, target); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = dns_message_pseudosectiontotext(msg, DNS_PSEUDOSECTION_TSIG, - style, flags, target); - if (result != ISC_R_SUCCESS) { - return result; - } - - result = dns_message_pseudosectiontotext(msg, DNS_PSEUDOSECTION_SIG0, - style, flags, target); - return result; + RETERR(dns_message_headertotext(msg, style, flags, target)); + RETERR(dns_message_pseudosectiontotext(msg, DNS_PSEUDOSECTION_OPT, + style, flags, target)); + RETERR(dns_message_sectiontotext(msg, DNS_SECTION_QUESTION, style, + flags, target)); + RETERR(dns_message_sectiontotext(msg, DNS_SECTION_ANSWER, style, flags, + target)); + RETERR(dns_message_sectiontotext(msg, DNS_SECTION_AUTHORITY, style, + flags, target)); + RETERR(dns_message_sectiontotext(msg, DNS_SECTION_ADDITIONAL, style, + flags, target)); + RETERR(dns_message_pseudosectiontotext(msg, DNS_PSEUDOSECTION_TSIG, + style, flags, target)); + return dns_message_pseudosectiontotext(msg, DNS_PSEUDOSECTION_SIG0, + style, flags, target); } isc_region_t * diff --git a/lib/dns/name.c b/lib/dns/name.c index 9613d7e3b42..c9b3709c1e6 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -1707,7 +1707,6 @@ dns_name_dynamic(const dns_name_t *name) { isc_result_t dns_name_print(const dns_name_t *name, FILE *stream) { - isc_result_t result; isc_buffer_t b; isc_region_t r; char t[1024]; @@ -1719,10 +1718,7 @@ dns_name_print(const dns_name_t *name, FILE *stream) { REQUIRE(DNS_NAME_VALID(name)); isc_buffer_init(&b, t, sizeof(t)); - result = dns_name_totext(name, 0, &b); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_totext(name, 0, &b)); isc_buffer_usedregion(&b, &r); fprintf(stream, "%.*s", (int)r.length, (char *)r.base); @@ -1774,7 +1770,6 @@ dns_name_format(const dns_name_t *name, char *cp, unsigned int size) { */ isc_result_t dns_name_tostring(const dns_name_t *name, char **target, isc_mem_t *mctx) { - isc_result_t result; isc_buffer_t buf; isc_region_t reg; char *p, txt[DNS_NAME_FORMATSIZE]; @@ -1783,10 +1778,7 @@ dns_name_tostring(const dns_name_t *name, char **target, isc_mem_t *mctx) { REQUIRE(target != NULL && *target == NULL); isc_buffer_init(&buf, txt, sizeof(txt)); - result = dns_name_totext(name, 0, &buf); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_totext(name, 0, &buf)); isc_buffer_usedregion(&buf, ®); p = isc_mem_allocate(mctx, reg.length + 1); @@ -1801,7 +1793,6 @@ isc_result_t dns_name_fromstring(dns_name_t *target, const char *src, const dns_name_t *origin, unsigned int options, isc_mem_t *mctx) { - isc_result_t result; isc_buffer_t buf; dns_fixedname_t fn; dns_name_t *name; @@ -1816,15 +1807,13 @@ dns_name_fromstring(dns_name_t *target, const char *src, name = dns_fixedname_initname(&fn); } - result = dns_name_fromtext(name, &buf, origin, options); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromtext(name, &buf, origin, options)); if (name != target) { dns_name_dup(name, mctx, target); } - return result; + + return ISC_R_SUCCESS; } void diff --git a/lib/dns/ncache.c b/lib/dns/ncache.c index 34363211053..54e72928fba 100644 --- a/lib/dns/ncache.c +++ b/lib/dns/ncache.c @@ -68,7 +68,6 @@ copy_rdataset(dns_rdataset_t *rdataset, isc_buffer_t *buffer) { isc_buffer_putuint16(buffer, (uint16_t)count); DNS_RDATASET_FOREACH(rdataset) { - isc_result_t result; dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdataset_current(rdataset, &rdata); @@ -85,10 +84,7 @@ copy_rdataset(dns_rdataset_t *rdataset, isc_buffer_t *buffer) { /* * Copy the rdata to the buffer. */ - result = isc_buffer_copyregion(buffer, &r); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_buffer_copyregion(buffer, &r)); } return ISC_R_SUCCESS; @@ -142,8 +138,6 @@ dns_ncache_add(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node, isc_buffer_init(&buffer, data, sizeof(data)); MSG_SECTION_FOREACH(message, DNS_SECTION_AUTHORITY, name) { - result = ISC_R_SUCCESS; - if (name->attributes.ncache) { ISC_LIST_FOREACH(name->list, rdataset, link) { if (!rdataset->attributes.ncache) { @@ -169,11 +163,8 @@ dns_ncache_add(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node, * Copy the owner name to the buffer. */ dns_name_toregion(name, &r); - result = isc_buffer_copyregion(&buffer, - &r); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_buffer_copyregion(&buffer, + &r)); /* * Copy the type to the buffer. */ @@ -189,11 +180,8 @@ dns_ncache_add(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node, /* * Copy the rdataset into the buffer. */ - result = copy_rdataset(rdataset, - &buffer); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(copy_rdataset(rdataset, + &buffer)); if (next >= DNS_NCACHE_RDATA) { return ISC_R_NOSPACE; diff --git a/lib/dns/nsec.c b/lib/dns/nsec.c index 1ebc6e8995a..145ada6b171 100644 --- a/lib/dns/nsec.c +++ b/lib/dns/nsec.c @@ -95,7 +95,6 @@ isc_result_t dns_nsec_buildrdata(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node, const dns_name_t *target, unsigned char *buffer, dns_rdata_t *rdata) { - isc_result_t result; isc_region_t r; unsigned int i; unsigned char *nsec_bits, *bm; @@ -118,10 +117,7 @@ dns_nsec_buildrdata(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node, dns_nsec_setbit(bm, dns_rdatatype_nsec, 1); max_type = dns_rdatatype_nsec; rdsiter = NULL; - result = dns_db_allrdatasets(db, node, version, 0, 0, &rdsiter); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_allrdatasets(db, node, version, 0, 0, &rdsiter)); DNS_RDATASETITER_FOREACH(rdsiter) { dns_rdataset_t rdataset = DNS_RDATASET_INIT; dns_rdatasetiter_current(rdsiter, &rdataset); @@ -243,10 +239,7 @@ dns_nsec_nseconly(dns_db_t *db, dns_dbversion_t *version, dns_diff_t *diff, dns_rdataset_init(&rdataset); - result = dns_db_getoriginnode(db, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_getoriginnode(db, &node)); result = dns_db_findrdataset(db, node, version, dns_rdatatype_dnskey, 0, 0, &rdataset, NULL); @@ -419,10 +412,7 @@ dns_nsec_noexistnodata(dns_rdatatype_t type, const dns_name_t *name, return DNS_R_DNAME; } - result = dns_rdata_tostruct(&rdata, &nsec, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_tostruct(&rdata, &nsec, NULL)); relation = dns_name_fullcompare(&nsec.next, name, &order, &nlabels); if (order == 0) { dns_rdata_freestruct(&nsec); diff --git a/lib/dns/nsec3.c b/lib/dns/nsec3.c index 164b5f69005..ff53e90be91 100644 --- a/lib/dns/nsec3.c +++ b/lib/dns/nsec3.c @@ -53,7 +53,6 @@ dns_nsec3_buildrdata(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node, size_t salt_length, const unsigned char *nexthash, size_t hash_length, unsigned char *buffer, dns_rdata_t *rdata) { - isc_result_t result; isc_region_t r; unsigned int i; bool found; @@ -108,10 +107,7 @@ dns_nsec3_buildrdata(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node, goto collapse_bitmap; } rdsiter = NULL; - result = dns_db_allrdatasets(db, node, version, 0, 0, &rdsiter); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_allrdatasets(db, node, version, 0, 0, &rdsiter)); found = found_ns = need_rrsig = false; DNS_RDATASETITER_FOREACH(rdsiter) { dns_rdataset_t rdataset = DNS_RDATASET_INIT; @@ -883,10 +879,7 @@ dns_nsec3_addnsec3s(dns_db_t *db, dns_dbversion_t *version, /* * Find the NSEC3 parameters for this zone. */ - result = dns_db_getoriginnode(db, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_getoriginnode(db, &node)); result = dns_db_findrdataset(db, node, version, dns_rdatatype_nsec3param, 0, 0, &rdataset, @@ -1016,7 +1009,6 @@ cleanup: isc_result_t dns_nsec3param_salttotext(dns_rdata_nsec3param_t *nsec3param, char *dst, size_t dstlen) { - isc_result_t result; isc_region_t r; isc_buffer_t b; @@ -1035,10 +1027,7 @@ dns_nsec3param_salttotext(dns_rdata_nsec3param_t *nsec3param, char *dst, r.length = nsec3param->salt_length; isc_buffer_init(&b, dst, (unsigned int)dstlen); - result = isc_hex_totext(&r, 2, "", &b); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_hex_totext(&r, 2, "", &b)); if (isc_buffer_availablelength(&b) < 1) { return ISC_R_NOSPACE; @@ -1064,10 +1053,7 @@ dns_nsec3param_deletechains(dns_db_t *db, dns_dbversion_t *ver, dns_name_init(&next); dns_rdataset_init(&rdataset); - result = dns_db_getoriginnode(db, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_getoriginnode(db, &node)); /* * Cause all NSEC3 chains to be deleted. @@ -1180,10 +1166,7 @@ dns_nsec3_addnsec3sx(dns_db_t *db, dns_dbversion_t *version, /* * Find the NSEC3 parameters for this zone. */ - result = dns_db_getoriginnode(db, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_getoriginnode(db, &node)); result = dns_db_findrdataset(db, node, version, type, 0, 0, &prdataset, NULL); @@ -1588,10 +1571,7 @@ dns_nsec3_delnsec3sx(dns_db_t *db, dns_dbversion_t *version, /* * Find the NSEC3 parameters for this zone. */ - result = dns_db_getoriginnode(db, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_getoriginnode(db, &node)); result = dns_db_findrdataset(db, node, version, dns_rdatatype_nsec3param, 0, 0, &rdataset, @@ -1693,10 +1673,7 @@ dns_nsec3_activex(dns_db_t *db, dns_dbversion_t *version, bool complete, dns_rdataset_init(&rdataset); - result = dns_db_getoriginnode(db, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_getoriginnode(db, &node)); result = dns_db_findrdataset(db, node, version, dns_rdatatype_nsec3param, 0, 0, &rdataset, @@ -1819,10 +1796,7 @@ dns_nsec3_noexistnodata(dns_rdatatype_t type, const dns_name_t *name, dns_rdataset_current(nsec3set, &rdata); - result = dns_rdata_tostruct(&rdata, &nsec3, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_tostruct(&rdata, &nsec3, NULL)); (*logit)(arg, ISC_LOG_DEBUG(3), "looking for relevant NSEC3"); @@ -1884,10 +1858,7 @@ dns_nsec3_noexistnodata(dns_rdatatype_t type, const dns_name_t *name, dns_name_getlabel(nsec3name, 0, &hashlabel); isc_region_consume(&hashlabel, 1); isc_buffer_init(&buffer, owner, sizeof(owner)); - result = isc_base32hex_decoderegion(&hashlabel, &buffer); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_base32hex_decoderegion(&hashlabel, &buffer)); /* * The hash lengths should match. If not ignore the record. diff --git a/lib/dns/nta.c b/lib/dns/nta.c index a026c752f1c..e2a20faf8b2 100644 --- a/lib/dns/nta.c +++ b/lib/dns/nta.c @@ -453,12 +453,7 @@ done: static isc_result_t putstr(isc_buffer_t *b, const char *str) { - isc_result_t result; - - result = isc_buffer_reserve(b, strlen(str)); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_buffer_reserve(b, strlen(str))); isc_buffer_putstr(b, str); return ISC_R_SUCCESS; diff --git a/lib/dns/opensslecdsa_link.c b/lib/dns/opensslecdsa_link.c index b2f2f2ea7cc..6fd0cca8420 100644 --- a/lib/dns/opensslecdsa_link.c +++ b/lib/dns/opensslecdsa_link.c @@ -916,22 +916,18 @@ cleanup: static isc_result_t opensslecdsa_generate(dst_key_t *key, int unused, void (*callback)(int)) { - isc_result_t ret; EVP_PKEY *pkey = NULL; REQUIRE(opensslecdsa_valid_key_alg(key->key_alg)); UNUSED(unused); UNUSED(callback); - ret = opensslecdsa_generate_pkey(key->key_alg, key->label, &pkey); - if (ret != ISC_R_SUCCESS) { - return ret; - } + RETERR(opensslecdsa_generate_pkey(key->key_alg, key->label, &pkey)); key->key_size = EVP_PKEY_bits(pkey); key->keydata.pkeypair.priv = pkey; key->keydata.pkeypair.pub = pkey; - return ret; + return ISC_R_SUCCESS; } static isc_result_t diff --git a/lib/dns/openssleddsa_link.c b/lib/dns/openssleddsa_link.c index ea164be6f96..b51e40a0581 100644 --- a/lib/dns/openssleddsa_link.c +++ b/lib/dns/openssleddsa_link.c @@ -330,7 +330,6 @@ openssleddsa_todns(const dst_key_t *key, isc_buffer_t *data) { static isc_result_t openssleddsa_fromdns(dst_key_t *key, isc_buffer_t *data) { const eddsa_alginfo_t *alginfo = openssleddsa_alg_info(key->key_alg); - isc_result_t ret; isc_region_t r; size_t len; EVP_PKEY *pkey = NULL; @@ -343,10 +342,7 @@ openssleddsa_fromdns(dst_key_t *key, isc_buffer_t *data) { } len = r.length; - ret = raw_key_to_ossl(alginfo, 0, r.base, &len, &pkey); - if (ret != ISC_R_SUCCESS) { - return ret; - } + RETERR(raw_key_to_ossl(alginfo, 0, r.base, &len, &pkey)); isc_buffer_forward(data, len); key->keydata.pkeypair.pub = pkey; diff --git a/lib/dns/peer.c b/lib/dns/peer.c index 194f55b0040..c5771703ec5 100644 --- a/lib/dns/peer.c +++ b/lib/dns/peer.c @@ -485,11 +485,8 @@ dns_peer_setkeybycharp(dns_peer_t *peer, const char *keyval) { dns_fixedname_init(&fname); isc_buffer_constinit(&b, keyval, strlen(keyval)); isc_buffer_add(&b, strlen(keyval)); - result = dns_name_fromtext(dns_fixedname_name(&fname), &b, dns_rootname, - 0); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromtext(dns_fixedname_name(&fname), &b, dns_rootname, + 0)); name = isc_mem_get(peer->mem, sizeof(dns_name_t)); diff --git a/lib/dns/qpcache.c b/lib/dns/qpcache.c index 5ef3d1be630..725d51fe9c5 100644 --- a/lib/dns/qpcache.c +++ b/lib/dns/qpcache.c @@ -1508,11 +1508,8 @@ find_coveringnsec(qpc_search_t *search, const dns_name_t *name, * Lookup the predecessor in the normal namespace. */ node = NULL; - result = dns_qp_getname(search->qpdb->tree, predecessor, - DNS_DBNAMESPACE_NORMAL, (void **)&node, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_qp_getname(search->qpdb->tree, predecessor, + DNS_DBNAMESPACE_NORMAL, (void **)&node, NULL)); dns_name_copy(&node->name, fname); nlock = &search->qpdb->buckets[node->locknum].lock; diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index ed7d0ad1467..5ad80cebc95 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -1252,33 +1252,23 @@ dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass, static isc_result_t unknown_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, isc_buffer_t *target) { - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; char buf[sizeof("65535")]; isc_region_t sr; strlcpy(buf, "\\# ", sizeof(buf)); - result = str_totext(buf, target); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(str_totext(buf, target)); dns_rdata_toregion(rdata, &sr); INSIST(sr.length < 65536); snprintf(buf, sizeof(buf), "%u", sr.length); - result = str_totext(buf, target); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(str_totext(buf, target)); if (sr.length != 0U) { if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) { - result = str_totext(" ( ", target); + RETERR(str_totext(" ( ", target)); } else { - result = str_totext(" ", target); - } - - if (result != ISC_R_SUCCESS) { - return result; + RETERR(str_totext(" ", target)); } if (tctx->width == 0) { /* No splitting */ diff --git a/lib/dns/rdata/generic/lp_107.c b/lib/dns/rdata/generic/lp_107.c index 1351ab420f2..f2fe025af82 100644 --- a/lib/dns/rdata/generic/lp_107.c +++ b/lib/dns/rdata/generic/lp_107.c @@ -187,7 +187,6 @@ static isc_result_t additionaldata_lp(ARGS_ADDLDATA) { dns_name_t name; isc_region_t region; - isc_result_t result; REQUIRE(rdata->type == dns_rdatatype_lp); @@ -198,10 +197,7 @@ additionaldata_lp(ARGS_ADDLDATA) { isc_region_consume(®ion, 2); dns_name_fromregion(&name, ®ion); - result = (add)(arg, &name, dns_rdatatype_l32, NULL DNS__DB_FILELINE); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR((add)(arg, &name, dns_rdatatype_l32, NULL DNS__DB_FILELINE)); return (add)(arg, &name, dns_rdatatype_l64, NULL DNS__DB_FILELINE); } diff --git a/lib/dns/rdata/generic/minfo_14.c b/lib/dns/rdata/generic/minfo_14.c index 2eb8036d9fe..96b738251ef 100644 --- a/lib/dns/rdata/generic/minfo_14.c +++ b/lib/dns/rdata/generic/minfo_14.c @@ -255,17 +255,13 @@ static isc_result_t digest_minfo(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - isc_result_t result; REQUIRE(rdata->type == dns_rdatatype_minfo); dns_rdata_toregion(rdata, &r); dns_name_init(&name); dns_name_fromregion(&name, &r); - result = dns_name_digest(&name, digest, arg); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_digest(&name, digest, arg)); isc_region_consume(&r, name_length(&name)); dns_name_init(&name); dns_name_fromregion(&name, &r); diff --git a/lib/dns/rdata/generic/mx_15.c b/lib/dns/rdata/generic/mx_15.c index 25cbfe92247..474fae44096 100644 --- a/lib/dns/rdata/generic/mx_15.c +++ b/lib/dns/rdata/generic/mx_15.c @@ -282,10 +282,7 @@ additionaldata_mx(ARGS_ADDLDATA) { return ISC_R_SUCCESS; } - result = (add)(arg, &name, dns_rdatatype_a, NULL DNS__DB_FILELINE); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR((add)(arg, &name, dns_rdatatype_a, NULL DNS__DB_FILELINE)); dns_fixedname_init(&fixed); result = dns_name_concatenate(&port25, &name, diff --git a/lib/dns/rdata/generic/naptr_35.c b/lib/dns/rdata/generic/naptr_35.c index fcc11a5b849..158dea6f887 100644 --- a/lib/dns/rdata/generic/naptr_35.c +++ b/lib/dns/rdata/generic/naptr_35.c @@ -626,7 +626,6 @@ static isc_result_t digest_naptr(ARGS_DIGEST) { isc_region_t r1, r2; unsigned int length, n; - isc_result_t result; dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_naptr); @@ -666,10 +665,7 @@ digest_naptr(ARGS_DIGEST) { * Digest the RR up to the replacement name. */ r1.length = length; - result = (digest)(arg, &r1); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR((digest)(arg, &r1)); /* * Replacement. diff --git a/lib/dns/rdata/generic/nxt_30.c b/lib/dns/rdata/generic/nxt_30.c index 95bd1e8de8a..1eec28ffd88 100644 --- a/lib/dns/rdata/generic/nxt_30.c +++ b/lib/dns/rdata/generic/nxt_30.c @@ -290,17 +290,13 @@ static isc_result_t digest_nxt(ARGS_DIGEST) { isc_region_t r; dns_name_t name; - isc_result_t result; REQUIRE(rdata->type == dns_rdatatype_nxt); dns_rdata_toregion(rdata, &r); dns_name_init(&name); dns_name_fromregion(&name, &r); - result = dns_name_digest(&name, digest, arg); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_digest(&name, digest, arg)); isc_region_consume(&r, name_length(&name)); return (digest)(arg, &r); diff --git a/lib/dns/rdata/generic/rt_21.c b/lib/dns/rdata/generic/rt_21.c index 1138fb75250..8323f9233c9 100644 --- a/lib/dns/rdata/generic/rt_21.c +++ b/lib/dns/rdata/generic/rt_21.c @@ -239,7 +239,6 @@ static isc_result_t additionaldata_rt(ARGS_ADDLDATA) { dns_name_t name; isc_region_t region; - isc_result_t result; REQUIRE(rdata->type == dns_rdatatype_rt); @@ -250,21 +249,14 @@ additionaldata_rt(ARGS_ADDLDATA) { isc_region_consume(®ion, 2); dns_name_fromregion(&name, ®ion); - result = (add)(arg, &name, dns_rdatatype_x25, NULL DNS__DB_FILELINE); - if (result != ISC_R_SUCCESS) { - return result; - } - result = (add)(arg, &name, dns_rdatatype_isdn, NULL DNS__DB_FILELINE); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR((add)(arg, &name, dns_rdatatype_x25, NULL DNS__DB_FILELINE)); + RETERR((add)(arg, &name, dns_rdatatype_isdn, NULL DNS__DB_FILELINE)); return (add)(arg, &name, dns_rdatatype_a, NULL DNS__DB_FILELINE); } static isc_result_t digest_rt(ARGS_DIGEST) { isc_region_t r1, r2; - isc_result_t result; dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_rt); @@ -273,10 +265,7 @@ digest_rt(ARGS_DIGEST) { r2 = r1; isc_region_consume(&r2, 2); r1.length = 2; - result = (digest)(arg, &r1); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR((digest)(arg, &r1)); dns_name_init(&name); dns_name_fromregion(&name, &r2); return dns_name_digest(&name, digest, arg); diff --git a/lib/dns/rdata/generic/txt_16.c b/lib/dns/rdata/generic/txt_16.c index b61ee8889cd..d4e9878aba6 100644 --- a/lib/dns/rdata/generic/txt_16.c +++ b/lib/dns/rdata/generic/txt_16.c @@ -71,17 +71,12 @@ generic_totext_txt(ARGS_TOTEXT) { static isc_result_t generic_fromwire_txt(ARGS_FROMWIRE) { - isc_result_t result; - UNUSED(type); UNUSED(dctx); UNUSED(rdclass); do { - result = txt_fromwire(source, target); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(txt_fromwire(source, target)); } while (!buffer_empty(source)); return ISC_R_SUCCESS; } diff --git a/lib/dns/rdata/in_1/a6_38.c b/lib/dns/rdata/in_1/a6_38.c index e6c14ed74b0..99f9e3cb9ae 100644 --- a/lib/dns/rdata/in_1/a6_38.c +++ b/lib/dns/rdata/in_1/a6_38.c @@ -415,7 +415,6 @@ static isc_result_t digest_in_a6(ARGS_DIGEST) { isc_region_t r1, r2; unsigned char prefixlen, octets; - isc_result_t result; dns_name_t name; REQUIRE(rdata->type == dns_rdatatype_a6); @@ -427,10 +426,7 @@ digest_in_a6(ARGS_DIGEST) { octets = 1 + 16 - prefixlen / 8; r1.length = octets; - result = (digest)(arg, &r1); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR((digest)(arg, &r1)); if (prefixlen == 0) { return ISC_R_SUCCESS; } diff --git a/lib/dns/rdata/in_1/px_26.c b/lib/dns/rdata/in_1/px_26.c index 46e82202d4d..cfc24d5d3ca 100644 --- a/lib/dns/rdata/in_1/px_26.c +++ b/lib/dns/rdata/in_1/px_26.c @@ -309,7 +309,6 @@ static isc_result_t digest_in_px(ARGS_DIGEST) { isc_region_t r1, r2; dns_name_t name; - isc_result_t result; REQUIRE(rdata->type == dns_rdatatype_px); REQUIRE(rdata->rdclass == dns_rdataclass_in); @@ -318,16 +317,10 @@ digest_in_px(ARGS_DIGEST) { r2 = r1; isc_region_consume(&r2, 2); r1.length = 2; - result = (digest)(arg, &r1); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR((digest)(arg, &r1)); dns_name_init(&name); dns_name_fromregion(&name, &r2); - result = dns_name_digest(&name, digest, arg); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_digest(&name, digest, arg)); isc_region_consume(&r2, name_length(&name)); dns_name_init(&name); dns_name_fromregion(&name, &r2); diff --git a/lib/dns/rdata/in_1/srv_33.c b/lib/dns/rdata/in_1/srv_33.c index c0b2cf86e3f..755a8751800 100644 --- a/lib/dns/rdata/in_1/srv_33.c +++ b/lib/dns/rdata/in_1/srv_33.c @@ -328,10 +328,7 @@ additionaldata_in_srv(ARGS_ADDLDATA) { return ISC_R_SUCCESS; } - result = (add)(arg, &name, dns_rdatatype_a, NULL DNS__DB_FILELINE); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR((add)(arg, &name, dns_rdatatype_a, NULL DNS__DB_FILELINE)); dns_fixedname_init(&fixed); snprintf(buf, sizeof(buf), "_%u._tcp", port); diff --git a/lib/dns/rdataset.c b/lib/dns/rdataset.c index 593b09771e5..c418bed890b 100644 --- a/lib/dns/rdataset.c +++ b/lib/dns/rdataset.c @@ -447,13 +447,9 @@ dns_rdataset_additionaldata(dns_rdataset_t *rdataset, } DNS_RDATASET_FOREACH(rdataset) { - isc_result_t result; dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdataset_current(rdataset, &rdata); - result = dns_rdata_additionaldata(&rdata, owner_name, add, arg); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_additionaldata(&rdata, owner_name, add, arg)); } return ISC_R_SUCCESS; diff --git a/lib/dns/request.c b/lib/dns/request.c index 00556da402d..46148c2bb0e 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -748,8 +748,6 @@ dns_request_cancel(dns_request_t *request) { isc_result_t dns_request_getresponse(dns_request_t *request, dns_message_t *message, unsigned int options) { - isc_result_t result; - REQUIRE(VALID_REQUEST(request)); REQUIRE(request->tid == isc_tid()); REQUIRE(request->answer != NULL); @@ -757,18 +755,12 @@ dns_request_getresponse(dns_request_t *request, dns_message_t *message, req_log(ISC_LOG_DEBUG(3), "%s: request %p", __func__, request); dns_message_setquerytsig(message, request->tsig); - result = dns_message_settsigkey(message, request->tsigkey); - if (result != ISC_R_SUCCESS) { - return result; - } - result = dns_message_parse(message, request->answer, options); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_settsigkey(message, request->tsigkey)); + RETERR(dns_message_parse(message, request->answer, options)); if (request->tsigkey != NULL) { - result = dns_tsig_verify(request->answer, message, NULL, NULL); + RETERR(dns_tsig_verify(request->answer, message, NULL, NULL)); } - return result; + return ISC_R_SUCCESS; } isc_buffer_t * diff --git a/lib/dns/resconf.c b/lib/dns/resconf.c index 9a31ddeb286..e53666c70cb 100644 --- a/lib/dns/resconf.c +++ b/lib/dns/resconf.c @@ -281,7 +281,6 @@ static isc_result_t resconf_parsenameserver(irs_resconf_t *conf, FILE *fp) { char word[RESCONFMAXLINELEN]; int cp; - isc_result_t result; cp = getword(fp, word, sizeof(word)); if (cp == EOF || strlen(word) == 0U) { @@ -298,10 +297,7 @@ resconf_parsenameserver(irs_resconf_t *conf, FILE *fp) { return ISC_R_SUCCESS; } - result = add_server(conf->mctx, word, &conf->nameservers); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(add_server(conf->mctx, word, &conf->nameservers)); conf->numns++; return ISC_R_SUCCESS; @@ -370,7 +366,6 @@ static isc_result_t resconf_parsesearch(irs_resconf_t *conf, FILE *fp) { int delim; char word[RESCONFMAXLINELEN]; - isc_result_t result; if (conf->domainname != NULL) { /* @@ -389,10 +384,7 @@ resconf_parsesearch(irs_resconf_t *conf, FILE *fp) { return ISC_R_UNEXPECTEDEND; /* Nothing else on line. */ } do { - result = add_search(conf, word); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(add_search(conf, word)); if (delim == '\n') { break; diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 2d171650549..018d76e739b 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -6174,7 +6174,7 @@ rctx_cache_insecure(respctx_t *rctx, dns_message_t *message, dns_name_t *name, static isc_result_t rctx_cachename(respctx_t *rctx, dns_message_t *message, dns_name_t *name) { - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; fetchctx_t *fctx = rctx->fctx; resquery_t *query = rctx->query; dns_resolver_t *res = fctx->res; @@ -6198,10 +6198,7 @@ rctx_cachename(respctx_t *rctx, dns_message_t *message, dns_name_t *name) { /* * Find or create the cache node. */ - result = dns_db_findnode(fctx->cache, name, true, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_findnode(fctx->cache, name, true, &node)); /* * Cache or validate each cacheable rdataset. @@ -6239,9 +6236,7 @@ rctx_cachename(respctx_t *rctx, dns_message_t *message, dns_name_t *name) { result = rctx_cache_insecure(rctx, message, name, node, rdataset, sigrdataset); } - if (result != ISC_R_SUCCESS) { - goto cleanup; - } + CHECK(result); } /* diff --git a/lib/dns/rootns.c b/lib/dns/rootns.c index f672ea5d54e..f5eadd98396 100644 --- a/lib/dns/rootns.c +++ b/lib/dns/rootns.c @@ -101,7 +101,6 @@ static struct upcoming { static isc_result_t in_rootns(dns_rdataset_t *rootns, dns_name_t *name) { - isc_result_t result; dns_rdata_ns_t ns; if (!dns_rdataset_isassociated(rootns)) { @@ -111,10 +110,7 @@ in_rootns(dns_rdataset_t *rootns, dns_name_t *name) { DNS_RDATASET_FOREACH(rootns) { dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdataset_current(rootns, &rdata); - result = dns_rdata_tostruct(&rdata, &ns, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_tostruct(&rdata, &ns, NULL)); if (dns_name_compare(name, &ns.name) == 0) { return ISC_R_SUCCESS; } diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index 6004190b943..e0e9bbd6d46 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -1480,7 +1480,6 @@ dns_rpz_new_zones(dns_view_t *view, dns_rpz_zones_t **rpzsp, bool first_time) { isc_result_t dns_rpz_new_zone(dns_rpz_zones_t *rpzs, dns_rpz_zone_t **rpzp) { - isc_result_t result; dns_rpz_zone_t *rpz = NULL; REQUIRE(DNS_RPZ_ZONES_VALID(rpzs)); @@ -1490,10 +1489,7 @@ dns_rpz_new_zone(dns_rpz_zones_t *rpzs, dns_rpz_zone_t **rpzp) { return ISC_R_NOSPACE; } - result = dns__rpz_shuttingdown(rpzs); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns__rpz_shuttingdown(rpzs)); rpz = isc_mem_get(rpzs->mctx, sizeof(*rpz)); *rpz = (dns_rpz_zone_t){ diff --git a/lib/dns/rriterator.c b/lib/dns/rriterator.c index 2adf531cb3e..3e468cbe5fa 100644 --- a/lib/dns/rriterator.c +++ b/lib/dns/rriterator.c @@ -37,17 +37,13 @@ isc_result_t dns_rriterator_init(dns_rriterator_t *it, dns_db_t *db, dns_dbversion_t *ver, isc_stdtime_t now) { - isc_result_t result; it->magic = RRITERATOR_MAGIC; it->db = db; it->dbit = NULL; it->ver = ver; it->now = now; it->node = NULL; - result = dns_db_createiterator(it->db, 0, &it->dbit); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_createiterator(it->db, 0, &it->dbit)); it->rdatasetit = NULL; dns_rdata_init(&it->rdata); dns_rdataset_init(&it->rdataset); diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index 1393bc909ac..96adec1e396 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -492,30 +492,18 @@ getnodedata(dns_db_t *db, const dns_name_t *name, bool create, dns_name_countlabels(&sdlz->common.origin); dns_name_init(&relname); dns_name_getlabelsequence(name, 0, labels, &relname); - result = dns_name_totext(&relname, DNS_NAME_OMITFINALDOT, &b); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_totext(&relname, DNS_NAME_OMITFINALDOT, &b)); } else { - result = dns_name_totext(name, DNS_NAME_OMITFINALDOT, &b); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_totext(name, DNS_NAME_OMITFINALDOT, &b)); } isc_buffer_putuint8(&b, 0); isc_buffer_init(&b2, zonestr, sizeof(zonestr)); - result = dns_name_totext(&sdlz->common.origin, DNS_NAME_OMITFINALDOT, - &b2); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_totext(&sdlz->common.origin, DNS_NAME_OMITFINALDOT, + &b2)); isc_buffer_putuint8(&b2, 0); - result = createnode(sdlz, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(createnode(sdlz, &node)); isorigin = dns_name_equal(name, &sdlz->common.origin); @@ -687,11 +675,8 @@ createiterator(dns_db_t *db, unsigned int options, } isc_buffer_init(&b, zonestr, sizeof(zonestr)); - result = dns_name_totext(&sdlz->common.origin, DNS_NAME_OMITFINALDOT, - &b); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_totext(&sdlz->common.origin, DNS_NAME_OMITFINALDOT, + &b)); isc_buffer_putuint8(&b, 0); sdlziter = isc_mem_get(sdlz->common.mctx, sizeof(sdlz_dbiterator_t)); @@ -1336,19 +1321,13 @@ dns_sdlzallowzonexfr(void *driverarg, void *dbdata, isc_mem_t *mctx, /* Convert DNS name to ascii text */ isc_buffer_init(&b, namestr, sizeof(namestr)); - result = dns_name_totext(name, DNS_NAME_OMITFINALDOT, &b); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_totext(name, DNS_NAME_OMITFINALDOT, &b)); isc_buffer_putuint8(&b, 0); /* convert client address to ascii text */ isc_buffer_init(&b2, clientstr, sizeof(clientstr)); isc_netaddr_fromsockaddr(&netaddr, clientaddr); - result = isc_netaddr_totext(&netaddr, &b2); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_netaddr_totext(&netaddr, &b2)); isc_buffer_putuint8(&b2, 0); /* make sure strings are always lowercase */ @@ -1455,10 +1434,7 @@ dns_sdlzfindzone(void *driverarg, void *dbdata, isc_mem_t *mctx, /* Convert DNS name to ascii text */ isc_buffer_init(&b, namestr, sizeof(namestr)); - result = dns_name_totext(name, DNS_NAME_OMITFINALDOT, &b); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_totext(name, DNS_NAME_OMITFINALDOT, &b)); isc_buffer_putuint8(&b, 0); /* make sure strings are always lowercase */ @@ -1599,10 +1575,7 @@ dns_sdlz_putrr(dns_sdlzlookup_t *lookup, const char *type, dns_ttl_t ttl, r.base = type; r.length = strlen(type); - result = dns_rdatatype_fromtext(&typeval, (void *)&r); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdatatype_fromtext(&typeval, (void *)&r)); rdatalist = ISC_LIST_HEAD(lookup->lists); while (rdatalist != NULL) { @@ -1702,7 +1675,6 @@ dns_sdlz_putnamedrr(dns_sdlzallnodes_t *allnodes, const char *name, dns_sdlznode_t *sdlznode; isc_mem_t *mctx = sdlz->common.mctx; isc_buffer_t b; - isc_result_t result; newname = dns_fixedname_initname(&fnewname); @@ -1714,10 +1686,7 @@ dns_sdlz_putnamedrr(dns_sdlzallnodes_t *allnodes, const char *name, isc_buffer_constinit(&b, name, strlen(name)); isc_buffer_add(&b, strlen(name)); - result = dns_name_fromtext(newname, &b, origin, 0); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromtext(newname, &b, origin, 0)); if (allnodes->common.relative_names) { /* All names are relative to the root */ @@ -1728,10 +1697,7 @@ dns_sdlz_putnamedrr(dns_sdlzallnodes_t *allnodes, const char *name, sdlznode = ISC_LIST_HEAD(allnodes->nodelist); if (sdlznode == NULL || !dns_name_equal(&sdlznode->name, newname)) { sdlznode = NULL; - result = createnode(sdlz, &sdlznode); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(createnode(sdlz, &sdlznode)); dns_name_dup(newname, mctx, &sdlznode->name); ISC_LIST_PREPEND(allnodes->nodelist, sdlznode, link); if (allnodes->origin == NULL && diff --git a/lib/dns/skr.c b/lib/dns/skr.c index 34a259963d0..fd57d4bcf3e 100644 --- a/lib/dns/skr.c +++ b/lib/dns/skr.c @@ -142,8 +142,6 @@ skrbundle_addtuple(dns_skrbundle_t *bundle, dns_difftuple_t **tuple) { isc_result_t dns_skrbundle_getsig(dns_skrbundle_t *bundle, dst_key_t *key, dns_rdatatype_t covering_type, dns_rdata_t *sigrdata) { - isc_result_t result = ISC_R_SUCCESS; - REQUIRE(DNS_SKRBUNDLE_VALID(bundle)); REQUIRE(DNS_DIFF_VALID(&bundle->diff)); @@ -155,10 +153,7 @@ dns_skrbundle_getsig(dns_skrbundle_t *bundle, dst_key_t *key, } INSIST(tuple->rdata.type == dns_rdatatype_rrsig); - result = dns_rdata_tostruct(&tuple->rdata, &rrsig, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_tostruct(&tuple->rdata, &rrsig, NULL)); /* * Check if covering type matches, and if the signature is diff --git a/lib/dns/time.c b/lib/dns/time.c index ae23ce0a991..ec49f522e0a 100644 --- a/lib/dns/time.c +++ b/lib/dns/time.c @@ -204,11 +204,8 @@ dns_time64_fromtext(const char *source, int64_t *target) { isc_result_t dns_time32_fromtext(const char *source, uint32_t *target) { int64_t value64; - isc_result_t result; - result = dns_time64_fromtext(source, &value64); - if (result != ISC_R_SUCCESS) { - return result; - } + + RETERR(dns_time64_fromtext(source, &value64)); *target = (uint32_t)value64; return ISC_R_SUCCESS; diff --git a/lib/dns/tkey.c b/lib/dns/tkey.c index 4618f5ff585..c3b1154fdad 100644 --- a/lib/dns/tkey.c +++ b/lib/dns/tkey.c @@ -574,10 +574,7 @@ find_tkey(dns_message_t *msg, dns_name_t **name, dns_rdata_t *rdata, result = dns_message_findtype(cur, dns_rdatatype_tkey, 0, &tkeyset); if (result == ISC_R_SUCCESS) { - result = dns_rdataset_first(tkeyset); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdataset_first(tkeyset)); dns_rdataset_current(tkeyset, rdata); *name = cur; diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c index 88b9d18213b..03bcc37a4c1 100644 --- a/lib/dns/tsig.c +++ b/lib/dns/tsig.c @@ -350,38 +350,26 @@ restore_key(dns_tsigkeyring_t *ring, isc_stdtime_t now, FILE *fp) { name = dns_fixedname_initname(&fname); isc_buffer_init(&b, namestr, strlen(namestr)); isc_buffer_add(&b, strlen(namestr)); - result = dns_name_fromtext(name, &b, dns_rootname, 0); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromtext(name, &b, dns_rootname, 0)); creator = dns_fixedname_initname(&fcreator); isc_buffer_init(&b, creatorstr, strlen(creatorstr)); isc_buffer_add(&b, strlen(creatorstr)); - result = dns_name_fromtext(creator, &b, dns_rootname, 0); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromtext(creator, &b, dns_rootname, 0)); algorithm = dns_fixedname_initname(&falgorithm); isc_buffer_init(&b, algorithmstr, strlen(algorithmstr)); isc_buffer_add(&b, strlen(algorithmstr)); - result = dns_name_fromtext(algorithm, &b, dns_rootname, 0); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromtext(algorithm, &b, dns_rootname, 0)); dstalg = dns__tsig_algfromname(algorithm); if (dstalg == DST_ALG_UNKNOWN) { return DNS_R_BADALG; } - result = dst_key_restore(name, dstalg, DNS_KEYOWNER_ENTITY, - DNS_KEYPROTO_DNSSEC, dns_rdataclass_in, - ring->mctx, keystr, &dstkey); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_key_restore(name, dstalg, DNS_KEYOWNER_ENTITY, + DNS_KEYPROTO_DNSSEC, dns_rdataclass_in, + ring->mctx, keystr, &dstkey)); result = dns_tsigkey_createfromkey(name, dstalg, dstkey, true, true, creator, inception, expire, @@ -483,13 +471,10 @@ dns_tsigkey_create(const dns_name_t *name, dst_algorithm_t algorithm, isc_buffer_init(&b, secret, length); isc_buffer_add(&b, length); - result = dst_key_frombuffer( + RETERR(dst_key_frombuffer( name, algorithm, DNS_KEYOWNER_ENTITY, DNS_KEYPROTO_DNSSEC, dns_rdataclass_in, &b, - mctx, &dstkey); - if (result != ISC_R_SUCCESS) { - return result; - } + mctx, &dstkey)); } } else if (length > 0) { return DNS_R_BADALG; @@ -609,11 +594,8 @@ dns_tsig_sign(dns_message_t *msg) { * has validated at this point. This is why we include a * MAC length > 0 in the reply. */ - result = dst_context_create(key->key, mctx, - DNS_LOGCATEGORY_DNSSEC, true, &ctx); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_context_create(key->key, mctx, + DNS_LOGCATEGORY_DNSSEC, true, &ctx)); /* * If this is a response, and if there was a TSIG in @@ -880,26 +862,14 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg, */ keyname = msg->tsigname; - result = dns_rdataset_first(msg->tsig); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdataset_first(msg->tsig)); dns_rdataset_current(msg->tsig, &rdata); - result = dns_rdata_tostruct(&rdata, &tsig, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_tostruct(&rdata, &tsig, NULL)); dns_rdata_reset(&rdata); if (response) { - result = dns_rdataset_first(msg->querytsig); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdataset_first(msg->querytsig)); dns_rdataset_current(msg->querytsig, &rdata); - result = dns_rdata_tostruct(&rdata, &querytsig, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_tostruct(&rdata, &querytsig, NULL)); } /* @@ -940,11 +910,8 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg, if (result != ISC_R_SUCCESS) { msg->tsigstatus = dns_tsigerror_badkey; alg = dns__tsig_algfromname(&tsig.algorithm); - result = dns_tsigkey_create(keyname, alg, NULL, 0, mctx, - &msg->tsigkey); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_tsigkey_create(keyname, alg, NULL, 0, mctx, + &msg->tsigkey)); if (alg == DST_ALG_UNKNOWN) { dns_name_clone(&tsig.algorithm, &msg->tsigkey->algname); @@ -962,10 +929,7 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg, * Check digest length. */ alg = dst_key_alg(key); - result = dst_key_sigsize(key, &siglen); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_key_sigsize(key, &siglen)); if (dns__tsig_algvalid(alg)) { if (tsig.siglen > siglen) { tsig_log(msg->tsigkey, 2, "signature length too big"); @@ -986,11 +950,8 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg, sig_r.base = tsig.signature; sig_r.length = tsig.siglen; - result = dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC, - false, &ctx); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC, + false, &ctx)); if (response) { isc_buffer_init(&databuf, data, sizeof(data)); @@ -1220,15 +1181,9 @@ tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) { /* * Extract and parse the previous TSIG */ - result = dns_rdataset_first(msg->querytsig); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdataset_first(msg->querytsig)); dns_rdataset_current(msg->querytsig, &rdata); - result = dns_rdata_tostruct(&rdata, &querytsig, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdata_tostruct(&rdata, &querytsig, NULL)); dns_rdata_reset(&rdata); /* diff --git a/lib/dns/update.c b/lib/dns/update.c index b741a75c905..1927df5ab57 100644 --- a/lib/dns/update.c +++ b/lib/dns/update.c @@ -204,17 +204,13 @@ typedef struct { */ static isc_result_t foreach_node_rr_action(void *data, dns_rdataset_t *rdataset) { - isc_result_t result; foreach_node_rr_ctx_t *ctx = data; DNS_RDATASET_FOREACH(rdataset) { rr_t rr = { 0, DNS_RDATA_INIT }; dns_rdataset_current(rdataset, &rr.rdata); rr.ttl = rdataset->ttl; - result = (*ctx->rr_action)(ctx->rr_action_data, &rr); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR((*ctx->rr_action)(ctx->rr_action_data, &rr)); } return ISC_R_SUCCESS; diff --git a/lib/dns/validator.c b/lib/dns/validator.c index 555e65d6a9e..0c7122c7f32 100644 --- a/lib/dns/validator.c +++ b/lib/dns/validator.c @@ -1180,13 +1180,10 @@ seek_dnskey(dns_validator_t *val) { * we had a key with trust level "answer" and * a DS record for the zone has now been added. */ - result = create_validator( + RETERR(create_validator( val, &siginfo->signer, dns_rdatatype_dnskey, &val->frdataset, &val->fsigrdataset, - validator_callback_dnskey, "seek_dnskey"); - if (result != ISC_R_SUCCESS) { - return result; - } + validator_callback_dnskey, "seek_dnskey")); return DNS_R_WAIT; } else if (val->frdataset.trust < dns_trust_secure) { /* @@ -1223,12 +1220,8 @@ seek_dnskey(dns_validator_t *val) { /* * We don't know anything about this key. */ - result = create_fetch(val, &siginfo->signer, - dns_rdatatype_dnskey, - fetch_callback_dnskey, "seek_dnskey"); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(create_fetch(val, &siginfo->signer, dns_rdatatype_dnskey, + fetch_callback_dnskey, "seek_dnskey")); return DNS_R_WAIT; case DNS_R_NCACHENXDOMAIN: @@ -1908,11 +1901,8 @@ check_signer(dns_validator_t *val, dns_rdata_t *keyrdata, uint16_t keyid, dst_key_t *dstkey = NULL; dns_rdataset_t rdataset = DNS_RDATASET_INIT; - result = dns_dnssec_keyfromrdata(val->name, keyrdata, val->view->mctx, - &dstkey); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_dnssec_keyfromrdata(val->name, keyrdata, val->view->mctx, + &dstkey)); dns_rdataset_clone(val->sigrdataset, &rdataset); DNS_RDATASET_FOREACH(&rdataset) { @@ -2365,7 +2355,7 @@ static isc_result_t val_rdataset_first(dns_validator_t *val, dns_name_t **namep, dns_rdataset_t **rdatasetp) { dns_message_t *message = val->message; - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; REQUIRE(rdatasetp != NULL); REQUIRE(namep != NULL); @@ -2378,10 +2368,7 @@ val_rdataset_first(dns_validator_t *val, dns_name_t **namep, } if (message != NULL) { - result = dns_message_firstname(message, DNS_SECTION_AUTHORITY); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_firstname(message, DNS_SECTION_AUTHORITY)); dns_message_currentname(message, DNS_SECTION_AUTHORITY, namep); *rdatasetp = ISC_LIST_HEAD((*namep)->list); INSIST(*rdatasetp != NULL); @@ -2391,6 +2378,7 @@ val_rdataset_first(dns_validator_t *val, dns_name_t **namep, dns_ncache_current(val->rdataset, *namep, *rdatasetp); } } + return result; } @@ -2745,8 +2733,6 @@ findnsec3proofs(dns_validator_t *val) { static isc_result_t validate_neg_rrset(dns_validator_t *val, dns_name_t *name, dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset) { - isc_result_t result; - /* * If a signed zone is missing the zone key, bad * things could happen. A query for data in the zone @@ -2763,10 +2749,7 @@ validate_neg_rrset(dns_validator_t *val, dns_name_t *name, { dns_rdata_t nsec = DNS_RDATA_INIT; - result = dns_rdataset_first(rdataset); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_rdataset_first(rdataset)); dns_rdataset_current(rdataset, &nsec); if (dns_nsec_typepresent(&nsec, dns_rdatatype_soa)) { return DNS_R_CONTINUE; @@ -2774,12 +2757,9 @@ validate_neg_rrset(dns_validator_t *val, dns_name_t *name, } val->nxset = rdataset; - result = create_validator(val, name, rdataset->type, rdataset, - sigrdataset, validator_callback_nsec, - "validate_neg_rrset"); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(create_validator(val, name, rdataset->type, rdataset, + sigrdataset, validator_callback_nsec, + "validate_neg_rrset")); val->authcount++; return DNS_R_WAIT; @@ -2984,10 +2964,7 @@ validate_nx(dns_validator_t *val, bool resume) { if (FOUNDNOQNAME(val) && FOUNDCLOSEST(val) && ((NEEDNODATA(val) && !FOUNDNODATA(val)) || NEEDNOWILDCARD(val))) { - result = checkwildcard(val, dns_rdatatype_nsec, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(checkwildcard(val, dns_rdatatype_nsec, NULL)); } if ((NEEDNODATA(val) && (FOUNDNODATA(val) || FOUNDOPTOUT(val))) || @@ -3664,7 +3641,6 @@ dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type, isc_counter_t *nvalidations, isc_counter_t *nfails, isc_counter_t *qc, isc_counter_t *gqc, fetchctx_t *parent, dns_edectx_t *edectx, dns_validator_t **validatorp) { - isc_result_t result = ISC_R_FAILURE; dns_validator_t *val = NULL; dns_keytable_t *kt = NULL; @@ -3674,10 +3650,7 @@ dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type, REQUIRE(validatorp != NULL && *validatorp == NULL); REQUIRE(edectx != NULL); - result = dns_view_getsecroots(view, &kt); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_view_getsecroots(view, &kt)); val = isc_mem_get(view->mctx, sizeof(*val)); *val = (dns_validator_t){ diff --git a/lib/dns/view.c b/lib/dns/view.c index bca4c3a7ab7..a640e875acc 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -537,12 +537,8 @@ dns_view_createresolver(dns_view_t *view, unsigned int options, REQUIRE(view->resolver == NULL); REQUIRE(view->dispatchmgr != NULL); - result = dns_resolver_create(view, options, tlsctx_cache, dispatchv4, - dispatchv6, &view->resolver); - if (result != ISC_R_SUCCESS) { - return result; - } - + RETERR(dns_resolver_create(view, options, tlsctx_cache, dispatchv4, + dispatchv6, &view->resolver)); isc_mem_create("ADB", &mctx); dns_adb_create(mctx, view, &view->adb); isc_mem_detach(&mctx); @@ -1353,15 +1349,9 @@ dns_view_getpeertsig(dns_view_t *view, const isc_netaddr_t *peeraddr, dns_name_t *keyname = NULL; dns_peer_t *peer = NULL; - result = dns_peerlist_peerbyaddr(view->peers, peeraddr, &peer); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_peerlist_peerbyaddr(view->peers, peeraddr, &peer)); - result = dns_peer_getkey(peer, &keyname); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_peer_getkey(peer, &keyname)); result = dns_view_gettsig(view, keyname, keyp); return (result == ISC_R_NOTFOUND) ? ISC_R_FAILURE : result; @@ -1378,7 +1368,6 @@ dns_view_checksig(dns_view_t *view, isc_buffer_t *source, dns_message_t *msg) { isc_result_t dns_view_flushcache(dns_view_t *view, bool fixuponly) { - isc_result_t result; dns_adb_t *adb = NULL; REQUIRE(DNS_VIEW_VALID(view)); @@ -1387,10 +1376,7 @@ dns_view_flushcache(dns_view_t *view, bool fixuponly) { return ISC_R_SUCCESS; } if (!fixuponly) { - result = dns_cache_flush(view->cache); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_cache_flush(view->cache)); } dns_db_detach(&view->cachedb); dns_cache_attachdb(view->cache, &view->cachedb); diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 27f20e88918..aab34c0f5ff 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -1526,24 +1526,16 @@ request_type(dns_xfrin_t *xfr) { static isc_result_t add_opt(dns_message_t *message, uint16_t udpsize, bool reqnsid, bool reqexpire) { - isc_result_t result; - dns_message_ednsinit(message, 0, udpsize, 0, 0); /* Set EDNS options if applicable. */ if (reqnsid) { dns_ednsopt_t option = { .code = DNS_OPT_NSID }; - result = dns_message_ednsaddopt(message, &option); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_ednsaddopt(message, &option)); } if (reqexpire) { dns_ednsopt_t option = { .code = DNS_OPT_EXPIRE }; - result = dns_message_ednsaddopt(message, &option); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_ednsaddopt(message, &option)); } return dns_message_setopt(message); diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 26e08945014..3b52aaaf2f4 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -4540,16 +4540,11 @@ cleanup: static isc_result_t delete_keydata(dns_db_t *db, dns_dbversion_t *ver, dns_diff_t *diff, dns_name_t *name, dns_rdataset_t *rdataset) { - isc_result_t uresult; - DNS_RDATASET_FOREACH(rdataset) { dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdataset_current(rdataset, &rdata); - uresult = update_one_rr(db, ver, diff, DNS_DIFFOP_DEL, name, 0, - &rdata); - if (uresult != ISC_R_SUCCESS) { - return uresult; - } + RETERR(update_one_rr(db, ver, diff, DNS_DIFFOP_DEL, name, 0, + &rdata)); } return ISC_R_SUCCESS; @@ -6930,11 +6925,8 @@ offline(dns_db_t *db, dns_dbversion_t *ver, dns__zonediff_t *zonediff, if ((rdata->flags & DNS_RDATA_OFFLINE) != 0) { return ISC_R_SUCCESS; } - result = update_one_rr(db, ver, zonediff->diff, DNS_DIFFOP_DELRESIGN, - name, ttl, rdata); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(update_one_rr(db, ver, zonediff->diff, DNS_DIFFOP_DELRESIGN, + name, ttl, rdata)); rdata->flags |= DNS_RDATA_OFFLINE; result = update_one_rr(db, ver, zonediff->diff, DNS_DIFFOP_ADDRESIGN, name, ttl, rdata); @@ -12786,24 +12778,16 @@ create_query(dns_zone_t *zone, dns_rdatatype_t rdtype, dns_name_t *name, static isc_result_t add_opt(dns_message_t *message, uint16_t udpsize, bool reqnsid, bool reqexpire) { - isc_result_t result; - dns_message_ednsinit(message, 0, udpsize, 0, 0); /* Set EDNS options if applicable. */ if (reqnsid) { dns_ednsopt_t option = { .code = DNS_OPT_NSID }; - result = dns_message_ednsaddopt(message, &option); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_ednsaddopt(message, &option)); } if (reqexpire) { dns_ednsopt_t option = { .code = DNS_OPT_EXPIRE }; - result = dns_message_ednsaddopt(message, &option); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_ednsaddopt(message, &option)); } return dns_message_setopt(message); @@ -17143,10 +17127,7 @@ zone_replacedb(dns_zone_t *zone, dns_db_t *db, bool dump) { return result; } - result = check_nsec3param(zone, db); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(check_nsec3param(zone, db)); ver = NULL; dns_db_currentversion(db, &ver); @@ -20128,15 +20109,11 @@ checkds_destroy(dns_checkds_t *checkds, bool locked) { static isc_result_t make_dnskey(dst_key_t *key, unsigned char *buf, int bufsize, dns_rdata_t *target) { - isc_result_t result; isc_buffer_t b; isc_region_t r; isc_buffer_init(&b, buf, bufsize); - result = dst_key_todns(key, &b); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dst_key_todns(key, &b)); dns_rdata_reset(target); isc_buffer_usedregion(&b, &r); @@ -22190,10 +22167,7 @@ dns_zone_nscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version, REQUIRE(DNS_ZONE_VALID(zone)); REQUIRE(errors != NULL); - result = dns_db_getoriginnode(db, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_getoriginnode(db, &node)); result = zone_count_ns_rr(zone, db, node, version, NULL, errors, false); dns_db_detachnode(&node); return result; @@ -22212,10 +22186,7 @@ dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) { REQUIRE(DNS_ZONE_VALID(zone)); - result = dns_db_getoriginnode(db, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_getoriginnode(db, &node)); dns_rdataset_init(&cds); dns_rdataset_init(&dnskey); diff --git a/lib/dns/zoneverify.c b/lib/dns/zoneverify.c index 95695c01eb2..5cde1aa4f08 100644 --- a/lib/dns/zoneverify.c +++ b/lib/dns/zoneverify.c @@ -704,10 +704,7 @@ verifynsec3(const vctx_t *vctx, const dns_name_t *name, return result; } - result = isoptout(vctx, &nsec3param, &optout); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isoptout(vctx, &nsec3param, &optout)); dns_fixedname_init(&fixed); result = dns_nsec3_hashname( @@ -772,23 +769,18 @@ verifynsec3s(const vctx_t *vctx, const dns_name_t *name, dns_rdataset_t *nsec3paramset, bool delegation, bool empty, const unsigned char types[8192], unsigned int maxtype, isc_result_t *vresult) { - isc_result_t result = ISC_R_NOMORE; - DNS_RDATASET_FOREACH(nsec3paramset) { dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdataset_current(nsec3paramset, &rdata); - result = verifynsec3(vctx, name, &rdata, delegation, empty, - types, maxtype, vresult); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(verifynsec3(vctx, name, &rdata, delegation, empty, types, + maxtype, vresult)); if (*vresult != ISC_R_SUCCESS) { break; } } - return result; + return ISC_R_SUCCESS; } static isc_result_t @@ -970,19 +962,13 @@ verifynode(vctx_t *vctx, const dns_name_t *name, dns_dbnode_t *node, *vresult = ISC_R_SUCCESS; if (nsecset != NULL && dns_rdataset_isassociated(nsecset)) { - result = verifynsec(vctx, name, node, nextname, &tvresult); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(verifynsec(vctx, name, node, nextname, &tvresult)); *vresult = tvresult; } if (nsec3paramset != NULL && dns_rdataset_isassociated(nsec3paramset)) { - result = verifynsec3s(vctx, name, nsec3paramset, delegation, - false, types, maxtype, &tvresult); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(verifynsec3s(vctx, name, nsec3paramset, delegation, + false, types, maxtype, &tvresult)); if (*vresult == ISC_R_SUCCESS) { *vresult = tvresult; } @@ -1217,7 +1203,7 @@ verifyemptynodes(const vctx_t *vctx, const dns_name_t *name, int order; unsigned int labels, nlabels, i; dns_name_t suffix; - isc_result_t result, tvresult = ISC_R_UNSET; + isc_result_t tvresult = ISC_R_UNSET; *vresult = ISC_R_SUCCESS; @@ -1238,12 +1224,9 @@ verifyemptynodes(const vctx_t *vctx, const dns_name_t *name, if (nsec3paramset != NULL && dns_rdataset_isassociated(nsec3paramset)) { - result = verifynsec3s( - vctx, &suffix, nsec3paramset, - isdelegation, true, NULL, 0, &tvresult); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(verifynsec3s(vctx, &suffix, + nsec3paramset, isdelegation, + true, NULL, 0, &tvresult)); if (*vresult == ISC_R_SUCCESS) { *vresult = tvresult; } diff --git a/lib/isc/commandline.c b/lib/isc/commandline.c index fdbcbb46e3a..513f85a92dc 100644 --- a/lib/isc/commandline.c +++ b/lib/isc/commandline.c @@ -211,8 +211,6 @@ isc_commandline_parse(int argc, char *const *argv, const char *options) { isc_result_t isc_commandline_strtoargv(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp, unsigned int n) { - isc_result_t result; - restart: /* Discard leading whitespace. */ while (*s == ' ' || *s == '\t') { @@ -256,11 +254,7 @@ restart: *p++ = '\0'; } - result = isc_commandline_strtoargv(mctx, p, argcp, argvp, - n + 1); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_commandline_strtoargv(mctx, p, argcp, argvp, n + 1)); (*argvp)[n] = s; } diff --git a/lib/isc/file.c b/lib/isc/file.c index fe027ae24c0..fbf0b80fb1f 100644 --- a/lib/isc/file.c +++ b/lib/isc/file.c @@ -576,15 +576,13 @@ dir_current(char *dirname, size_t length) { isc_result_t isc_file_absolutepath(const char *filename, char *path, size_t pathlen) { - isc_result_t result; - result = dir_current(path, pathlen); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dir_current(path, pathlen)); + if (strlen(path) + strlen(filename) + 1 > pathlen) { return ISC_R_NOSPACE; } strlcat(path, filename, pathlen); + return ISC_R_SUCCESS; } @@ -697,7 +695,6 @@ isc_file_sanitize(const char *dir, const char *base, const char *ext, unsigned int digestlen; char hash[ISC_MAX_MD_SIZE * 2 + 1]; size_t l = 0; - isc_result_t err; REQUIRE(base != NULL); REQUIRE(path != NULL); @@ -724,16 +721,10 @@ isc_file_sanitize(const char *dir, const char *base, const char *ext, } /* Check whether the full-length SHA256 hash filename exists */ - err = isc_md(ISC_MD_SHA256, (const unsigned char *)base, strlen(base), - digest, &digestlen); - if (err != ISC_R_SUCCESS) { - return err; - } + RETERR(isc_md(ISC_MD_SHA256, (const unsigned char *)base, strlen(base), + digest, &digestlen)); - err = digest2hex(digest, digestlen, hash, sizeof(hash)); - if (err != ISC_R_SUCCESS) { - return err; - } + RETERR(digest2hex(digest, digestlen, hash, sizeof(hash))); snprintf(buf, sizeof(buf), "%s%s%s%s%s", dir != NULL ? dir : "", dir != NULL ? "/" : "", hash, ext != NULL ? "." : "", diff --git a/lib/isc/getaddresses.c b/lib/isc/getaddresses.c index e77ef7a085e..ff9922d066e 100644 --- a/lib/isc/getaddresses.c +++ b/lib/isc/getaddresses.c @@ -81,14 +81,8 @@ isc_getaddresses(const char *hostname, in_port_t port, isc_sockaddr_t *addrs, } if (d != NULL) { - isc_result_t iresult; - - iresult = isc_netscope_pton(AF_INET6, d + 1, - &in6, &zone); - - if (iresult != ISC_R_SUCCESS) { - return iresult; - } + RETERR(isc_netscope_pton(AF_INET6, d + 1, &in6, + &zone)); } isc_netaddr_fromin6(&na, &in6); diff --git a/lib/isc/httpd.c b/lib/isc/httpd.c index 7cf51567e50..13b3d55a633 100644 --- a/lib/isc/httpd.c +++ b/lib/isc/httpd.c @@ -361,7 +361,6 @@ process_request(isc_httpd_t *httpd, size_t last_len) { size_t path_len = 0; struct phr_header headers[HTTP_HEADERS_NUM]; size_t num_headers; - isc_result_t result; num_headers = ARRAY_SIZE(headers); @@ -401,10 +400,7 @@ process_request(isc_httpd_t *httpd, size_t last_len) { /* * Parse the URL */ - result = isc_url_parse(path, path_len, 0, &httpd->up); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_url_parse(path, path_len, 0, &httpd->up)); httpd->path = path; /* diff --git a/lib/isc/include/isc/buffer.h b/lib/isc/include/isc/buffer.h index 75754bf08e5..3987fef8247 100644 --- a/lib/isc/include/isc/buffer.h +++ b/lib/isc/include/isc/buffer.h @@ -1190,16 +1190,11 @@ isc_buffer_dup(isc_mem_t *mctx, isc_buffer_t **restrict dstp, static inline isc_result_t isc_buffer_copyregion(isc_buffer_t *restrict b, const isc_region_t *restrict r) { - isc_result_t result; - REQUIRE(ISC_BUFFER_VALID(b)); REQUIRE(r != NULL); if (b->mctx) { - result = isc_buffer_reserve(b, r->length); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_buffer_reserve(b, r->length)); } if (r->length > isc_buffer_availablelength(b)) { @@ -1216,9 +1211,8 @@ isc_buffer_copyregion(isc_buffer_t *restrict b, static inline isc_result_t isc_buffer_printf(isc_buffer_t *restrict b, const char *restrict format, ...) { - va_list ap; - int n; - isc_result_t result; + va_list ap; + int n; REQUIRE(ISC_BUFFER_VALID(b)); @@ -1231,10 +1225,7 @@ isc_buffer_printf(isc_buffer_t *restrict b, const char *restrict format, ...) { } if (b->mctx) { - result = isc_buffer_reserve(b, n + 1); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_buffer_reserve(b, n + 1)); } if (isc_buffer_availablelength(b) < (unsigned int)n + 1) { diff --git a/lib/isc/lex.c b/lib/isc/lex.c index e38947cbdd5..588ffa6bf1e 100644 --- a/lib/isc/lex.c +++ b/lib/isc/lex.c @@ -200,7 +200,6 @@ new_source(isc_lex_t *lex, bool is_file, bool need_close, void *input, isc_result_t isc_lex_openfile(isc_lex_t *lex, const char *filename) { - isc_result_t result; FILE *stream = NULL; /* @@ -209,10 +208,7 @@ isc_lex_openfile(isc_lex_t *lex, const char *filename) { REQUIRE(VALID_LEX(lex)); - result = isc_stdio_open(filename, "r", &stream); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_stdio_open(filename, "r", &stream)); new_source(lex, true, true, stream, filename); return ISC_R_SUCCESS; diff --git a/lib/isc/log.c b/lib/isc/log.c index ad984c00688..5893eb4a862 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -796,14 +796,7 @@ greatest_version(isc_logfile_t *file, int versions, int *greatestp) { bnamelen = strlen(bname); isc_dir_init(&dir); - result = isc_dir_open(&dir, dirname); - - /* - * Return if the directory open failed. - */ - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_dir_open(&dir, dirname)); while (isc_dir_read(&dir) == ISC_R_SUCCESS) { if (dir.entry.length > bnamelen && @@ -943,14 +936,7 @@ remove_old_tsversions(isc_logfile_t *file, int versions) { bnamelen = strlen(bname); isc_dir_init(&dir); - result = isc_dir_open(&dir, dirname); - - /* - * Return if the directory open failed. - */ - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_dir_open(&dir, dirname)); last = last_to_keep(versions, &dir, bname, bnamelen); @@ -1023,10 +1009,7 @@ roll_increment(isc_logfile_t *file) { * Get the largest existing version and remove any * version greater than the permitted version. */ - result = greatest_version(file, file->versions, &greatest); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(greatest_version(file, file->versions, &greatest)); /* * Increment if greatest is not the actual maximum value. diff --git a/lib/isc/netmgr/udp.c b/lib/isc/netmgr/udp.c index bb3cb67045a..7922683bdc9 100644 --- a/lib/isc/netmgr/udp.c +++ b/lib/isc/netmgr/udp.c @@ -281,18 +281,14 @@ isc_nm_listenudp(uint32_t workers, isc_sockaddr_t *iface, isc_nm_recv_cb_t cb, #ifdef USE_ROUTE_SOCKET static isc_result_t route_socket(uv_os_sock_t *fdp) { - isc_result_t result; uv_os_sock_t fd = -1; #ifdef USE_NETLINK struct sockaddr_nl sa; int r; #endif - result = isc__nm_socket(ROUTE_SOCKET_PF, SOCK_RAW, - ROUTE_SOCKET_PROTOCOL, &fd); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc__nm_socket(ROUTE_SOCKET_PF, SOCK_RAW, ROUTE_SOCKET_PROTOCOL, + &fd)); #ifdef USE_NETLINK sa.nl_family = PF_NETLINK; @@ -361,10 +357,7 @@ isc_nm_routeconnect(isc_nm_cb_t cb, void *cbarg) { return ISC_R_SHUTTINGDOWN; } - result = route_socket(&fd); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(route_socket(&fd)); sock = isc_mempool_get(worker->nmsocket_pool); isc__nmsocket_init(sock, worker, isc_nm_udpsocket, NULL, NULL); diff --git a/lib/isc/parseint.c b/lib/isc/parseint.c index 001fe9d4166..d9887aef1df 100644 --- a/lib/isc/parseint.c +++ b/lib/isc/parseint.c @@ -51,11 +51,8 @@ isc_parse_uint32(uint32_t *uip, const char *string, int base) { isc_result_t isc_parse_uint16(uint16_t *uip, const char *string, int base) { uint32_t val; - isc_result_t result; - result = isc_parse_uint32(&val, string, base); - if (result != ISC_R_SUCCESS) { - return result; - } + + RETERR(isc_parse_uint32(&val, string, base)); if (val > 0xFFFF) { return ISC_R_RANGE; } @@ -66,11 +63,8 @@ isc_parse_uint16(uint16_t *uip, const char *string, int base) { isc_result_t isc_parse_uint8(uint8_t *uip, const char *string, int base) { uint32_t val; - isc_result_t result; - result = isc_parse_uint32(&val, string, base); - if (result != ISC_R_SUCCESS) { - return result; - } + + RETERR(isc_parse_uint32(&val, string, base)); if (val > 0xFF) { return ISC_R_RANGE; } diff --git a/lib/isc/proxy2.c b/lib/isc/proxy2.c index 7837b655280..5c9644097ad 100644 --- a/lib/isc/proxy2.c +++ b/lib/isc/proxy2.c @@ -673,7 +673,6 @@ isc_proxy2_handler_addresses(const isc_proxy2_handler_t *restrict handler, int *restrict psocktype, isc_sockaddr_t *restrict psrc_addr, isc_sockaddr_t *restrict pdst_addr) { - isc_result_t result; size_t ret; isc_region_t header_region = { 0 }; isc_buffer_t buf = { 0 }; @@ -693,12 +692,8 @@ isc_proxy2_handler_addresses(const isc_proxy2_handler_t *restrict handler, INSIST(handler->expect_data == 0); - result = isc__proxy2_handler_get_addresses( - (isc_proxy2_handler_t *)handler, &buf, psrc_addr, pdst_addr); - - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc__proxy2_handler_get_addresses( + (isc_proxy2_handler_t *)handler, &buf, psrc_addr, pdst_addr)); SET_IF_NOT_NULL(psocktype, proxy2_socktype_to_socktype(handler->proxy_socktype)); @@ -840,12 +835,8 @@ isc_proxy2_subtlv_tls_iterate(const isc_region_t *restrict tls_tlv_data, return ISC_R_RANGE; } - result = isc_proxy2_subtlv_tls_header_data(tls_tlv_data, &client_flags, - &client_cert_verified); - - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_proxy2_subtlv_tls_header_data(tls_tlv_data, &client_flags, + &client_cert_verified)); p = tls_tlv_data->base; p += ISC_PROXY2_TLS_SUBHEADER_MIN_SIZE; @@ -1041,14 +1032,10 @@ error_range: isc_result_t isc_proxy2_tlv_data_verify(const isc_region_t *restrict tlv_data) { - isc_result_t result; tlv_verify_cbarg_t cbarg = { .verify_result = ISC_R_SUCCESS }; - result = isc_proxy2_tlv_iterate(tlv_data, isc_proxy2_tlv_verify_cb, - &cbarg); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_proxy2_tlv_iterate(tlv_data, isc_proxy2_tlv_verify_cb, + &cbarg)); return cbarg.verify_result; } diff --git a/lib/isc/radix.c b/lib/isc/radix.c index 31cceed1b01..afa38ea4536 100644 --- a/lib/isc/radix.c +++ b/lib/isc/radix.c @@ -450,11 +450,7 @@ isc_radix_insert(isc_radix_tree_t *radix, isc_radix_node_t **target, *target = node; return ISC_R_SUCCESS; } else { - result = _ref_prefix(radix->mctx, &node->prefix, - prefix); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(_ref_prefix(radix->mctx, &node->prefix, prefix)); } INSIST(node->data[RADIX_V4] == NULL && node->node_num[RADIX_V4] == -1 && diff --git a/lib/isc/sockaddr.c b/lib/isc/sockaddr.c index f09d8aacbc3..cd1d7eb74fb 100644 --- a/lib/isc/sockaddr.c +++ b/lib/isc/sockaddr.c @@ -114,7 +114,6 @@ isc_sockaddr_eqaddrprefix(const isc_sockaddr_t *a, const isc_sockaddr_t *b, isc_result_t isc_sockaddr_totext(const isc_sockaddr_t *sockaddr, isc_buffer_t *target) { - isc_result_t result; isc_netaddr_t netaddr; char pbuf[sizeof("65000")]; unsigned int plen; @@ -144,10 +143,7 @@ isc_sockaddr_totext(const isc_sockaddr_t *sockaddr, isc_buffer_t *target) { INSIST(plen < sizeof(pbuf)); isc_netaddr_fromsockaddr(&netaddr, sockaddr); - result = isc_netaddr_totext(&netaddr, target); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_netaddr_totext(&netaddr, target)); if (1 + plen + 1 > isc_buffer_availablelength(target)) { return ISC_R_NOSPACE; diff --git a/lib/isc/url.c b/lib/isc/url.c index 6ba4cb49916..eaa10129b0d 100644 --- a/lib/isc/url.c +++ b/lib/isc/url.c @@ -622,12 +622,7 @@ isc_url_parse(const char *buf, size_t buflen, bool is_connect, } if (up->field_set & (1 << ISC_UF_HOST)) { - isc_result_t result; - - result = http_parse_host(buf, up, found_at); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(http_parse_host(buf, up, found_at)); } /* CONNECT requests can only contain "hostname:port" */ diff --git a/lib/isccc/base64.c b/lib/isccc/base64.c index 3ead3633e72..73f65641f55 100644 --- a/lib/isccc/base64.c +++ b/lib/isccc/base64.c @@ -42,17 +42,13 @@ isccc_base64_encode(isccc_region_t *source, int wordlength, const char *wordbreak, isccc_region_t *target) { isc_region_t sr; isc_buffer_t tb; - isc_result_t result; sr.base = source->rstart; sr.length = (unsigned int)(source->rend - source->rstart); isc_buffer_init(&tb, target->rstart, (unsigned int)(target->rend - target->rstart)); - result = isc_base64_totext(&sr, wordlength, wordbreak, &tb); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_base64_totext(&sr, wordlength, wordbreak, &tb)); source->rstart = source->rend; target->rstart = isc_buffer_used(&tb); return ISC_R_SUCCESS; @@ -61,14 +57,10 @@ isccc_base64_encode(isccc_region_t *source, int wordlength, isc_result_t isccc_base64_decode(const char *cstr, isccc_region_t *target) { isc_buffer_t b; - isc_result_t result; isc_buffer_init(&b, target->rstart, (unsigned int)(target->rend - target->rstart)); - result = isc_base64_decodestring(cstr, &b); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_base64_decodestring(cstr, &b)); target->rstart = isc_buffer_used(&b); return ISC_R_SUCCESS; } diff --git a/lib/isccc/cc.c b/lib/isccc/cc.c index 2df9305f36b..a8f1a759aff 100644 --- a/lib/isccc/cc.c +++ b/lib/isccc/cc.c @@ -146,10 +146,7 @@ value_towire(isccc_sexpr_t *elt, isc_buffer_t **buffer) { /* * Emit the table. */ - result = table_towire(elt, buffer); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(table_towire(elt, buffer)); len = (*buffer)->used - used; /* @@ -180,10 +177,7 @@ value_towire(isccc_sexpr_t *elt, isc_buffer_t **buffer) { /* * Emit the list. */ - result = list_towire(elt, buffer); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(list_towire(elt, buffer)); len = (*buffer)->used - used; /* @@ -229,10 +223,7 @@ table_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer) { /* * Emit the value. */ - result = value_towire(v, buffer); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(value_towire(v, buffer)); } return ISC_R_SUCCESS; @@ -240,13 +231,8 @@ table_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer) { static isc_result_t list_towire(isccc_sexpr_t *list, isc_buffer_t **buffer) { - isc_result_t result; - while (list != NULL) { - result = value_towire(ISCCC_SEXPR_CAR(list), buffer); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(value_towire(ISCCC_SEXPR_CAR(list), buffer)); list = ISCCC_SEXPR_CDR(list); } @@ -257,7 +243,6 @@ static isc_result_t sign(unsigned char *data, unsigned int length, unsigned char *out, uint32_t algorithm, isccc_region_t *secret) { const isc_md_type_t *md_type; - isc_result_t result; isccc_region_t source, target; unsigned char digest[ISC_MAX_MD_SIZE]; unsigned int digestlen = sizeof(digest); @@ -288,20 +273,14 @@ sign(unsigned char *data, unsigned int length, unsigned char *out, return ISC_R_NOTIMPLEMENTED; } - result = isc_hmac(md_type, secret->rstart, REGION_SIZE(*secret), data, - length, digest, &digestlen); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_hmac(md_type, secret->rstart, REGION_SIZE(*secret), data, + length, digest, &digestlen)); source.rend = digest + digestlen; memset(digestb64, 0, sizeof(digestb64)); target.rstart = digestb64; target.rend = digestb64 + sizeof(digestb64); - result = isccc_base64_encode(&source, 64, "", &target); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isccc_base64_encode(&source, 64, "", &target)); if (algorithm == ISCCC_ALG_HMACMD5) { PUT_MEM(digestb64, HMD5_LENGTH, out); } else { @@ -361,10 +340,7 @@ isccc_cc_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer, uint32_t algorithm, /* * Emit the message. */ - result = table_towire(alist, buffer); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(table_towire(alist, buffer)); if (secret != NULL) { return sign((unsigned char *)(*buffer)->base + signed_base, (*buffer)->used - signed_base, @@ -380,7 +356,6 @@ verify(isccc_sexpr_t *alist, unsigned char *data, unsigned int length, const isc_md_type_t *md_type; isccc_region_t source; isccc_region_t target; - isc_result_t result; isccc_sexpr_t *_auth, *hmacvalue; unsigned char digest[ISC_MAX_MD_SIZE]; unsigned int digestlen = sizeof(digest); @@ -429,20 +404,14 @@ verify(isccc_sexpr_t *alist, unsigned char *data, unsigned int length, return ISC_R_NOTIMPLEMENTED; } - result = isc_hmac(md_type, secret->rstart, REGION_SIZE(*secret), data, - length, digest, &digestlen); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_hmac(md_type, secret->rstart, REGION_SIZE(*secret), data, + length, digest, &digestlen)); source.rend = digest + digestlen; target.rstart = digestb64; target.rend = digestb64 + sizeof(digestb64); memset(digestb64, 0, sizeof(digestb64)); - result = isccc_base64_encode(&source, 64, "", &target); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isccc_base64_encode(&source, 64, "", &target)); /* * Verify. @@ -752,10 +721,7 @@ isccc_cc_createack(isccc_sexpr_t *message, bool ok, isccc_sexpr_t **ackp) { * Create the ack. */ ack = NULL; - result = createmessage(1, _to, _frm, serial, t, 0, &ack, false); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(createmessage(1, _to, _frm, serial, t, 0, &ack, false)); _ctrl = isccc_alist_lookup(ack, "_ctrl"); if (_ctrl == NULL) { @@ -834,11 +800,8 @@ isccc_cc_createresponse(isccc_sexpr_t *message, isccc_time_t now, * Create the response. */ alist = NULL; - result = isccc_cc_createmessage(1, _to, _frm, serial, now, expires, - &alist); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isccc_cc_createmessage(1, _to, _frm, serial, now, expires, + &alist)); _ctrl = isccc_alist_lookup(alist, "_ctrl"); if (_ctrl == NULL) { diff --git a/lib/isccfg/aclconf.c b/lib/isccfg/aclconf.c index 8dfb769606d..9324e7a5f72 100644 --- a/lib/isccfg/aclconf.c +++ b/lib/isccfg/aclconf.c @@ -75,13 +75,9 @@ ISC_REFCOUNT_IMPL(cfg_aclconfctx, destroy_aclctx); */ static isc_result_t get_acl_def(const cfg_obj_t *cctx, const char *name, const cfg_obj_t **ret) { - isc_result_t result; const cfg_obj_t *acls = NULL; - result = cfg_map_get(cctx, "acl", &acls); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(cfg_map_get(cctx, "acl", &acls)); CFG_LIST_FOREACH(acls, elt) { const cfg_obj_t *acl = cfg_listelt_value(elt); const char *aclname = @@ -202,11 +198,8 @@ count_acl_elements(const cfg_obj_t *caml, const cfg_obj_t *cctx, } else if (cfg_obj_islist(ce)) { bool negative; uint32_t sub; - result = count_acl_elements(ce, cctx, ctx, mctx, &sub, - &negative); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(count_acl_elements(ce, cctx, ctx, mctx, &sub, + &negative)); n += sub; if (negative) { n++; @@ -642,11 +635,8 @@ cfg_acl_fromconfig(const cfg_obj_t *acl_data, const cfg_obj_t *cctx, uint32_t nelem; if (nest_level == 0) { - result = count_acl_elements(caml, cctx, ctx, mctx, - &nelem, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(count_acl_elements(caml, cctx, ctx, mctx, &nelem, + NULL)); } else { nelem = cfg_list_length(caml, false); } diff --git a/lib/isccfg/check.c b/lib/isccfg/check.c index 8a64bbf2420..654e45a2b3b 100644 --- a/lib/isccfg/check.c +++ b/lib/isccfg/check.c @@ -315,16 +315,12 @@ check_forward(const cfg_obj_t *config, const cfg_obj_t *options, return ISC_R_FAILURE; } if (forwarders != NULL) { - isc_result_t result = ISC_R_SUCCESS; const cfg_obj_t *tlspobj = cfg_tuple_get(forwarders, "tls"); if (tlspobj != NULL && cfg_obj_isstring(tlspobj)) { const char *tls = cfg_obj_asstring(tlspobj); if (tls != NULL) { - result = validate_tls(config, tlspobj, tls); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(validate_tls(config, tlspobj, tls)); } } @@ -333,10 +329,7 @@ check_forward(const cfg_obj_t *config, const cfg_obj_t *options, const cfg_obj_t *forwarder = cfg_listelt_value(element); const char *tls = cfg_obj_getsockaddrtls(forwarder); if (tls != NULL) { - result = validate_tls(config, faddresses, tls); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(validate_tls(config, faddresses, tls)); } } } @@ -2380,13 +2373,9 @@ check_tls_definitions(const cfg_obj_t *config, isc_mem_t *mctx) { static isc_result_t get_remotes(const cfg_obj_t *cctx, const char *list, const char *name, const cfg_obj_t **ret) { - isc_result_t result = ISC_R_SUCCESS; const cfg_obj_t *obj = NULL; - result = cfg_map_get(cctx, list, &obj); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(cfg_map_get(cctx, list, &obj)); CFG_LIST_FOREACH(obj, elt) { const char *listname = NULL; @@ -4490,10 +4479,7 @@ check_keylist(const cfg_obj_t *keys, isc_symtab_t *symtab, isc_mem_t *mctx) { result = tresult; continue; } - tresult = isccfg_check_key(key); - if (tresult != ISC_R_SUCCESS) { - return tresult; - } + RETERR(isccfg_check_key(key)); dns_name_format(name, namebuf, sizeof(namebuf)); keyname = isc_mem_strdup(mctx, namebuf); diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 8385767c6df..0d80cc70ee4 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -436,16 +436,11 @@ cfg_parser_currentfile(cfg_parser_t *pctx) { isc_result_t cfg_parse_obj(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { - isc_result_t result; - REQUIRE(pctx != NULL); REQUIRE(type != NULL); REQUIRE(ret != NULL && *ret == NULL); - result = type->parse(pctx, type, ret); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(type->parse(pctx, type, ret)); ENSURE(*ret != NULL); return ISC_R_SUCCESS; } @@ -2007,17 +2002,13 @@ cfg_obj_asboolean(const cfg_obj_t *obj) { isc_result_t cfg_parse_boolean(cfg_parser_t *pctx, const cfg_type_t *type ISC_ATTR_UNUSED, cfg_obj_t **ret) { - isc_result_t result; bool value; cfg_obj_t *obj = NULL; REQUIRE(pctx != NULL); REQUIRE(ret != NULL && *ret == NULL); - result = cfg_gettoken(pctx, 0); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(cfg_gettoken(pctx, 0)); if (pctx->token.type != isc_tokentype_string) { goto bad_boolean; @@ -2891,7 +2882,6 @@ cfg_obj_ismap(const cfg_obj_t *obj) { isc_result_t cfg_map_get(const cfg_obj_t *mapobj, const char *name, const cfg_obj_t **obj) { - isc_result_t result; isc_symvalue_t val; const cfg_map_t *map; @@ -2901,10 +2891,7 @@ cfg_map_get(const cfg_obj_t *mapobj, const char *name, const cfg_obj_t **obj) { map = &mapobj->value.map; - result = isc_symtab_lookup(map->symtab, name, SYMTAB_DUMMY_TYPE, &val); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_symtab_lookup(map->symtab, name, SYMTAB_DUMMY_TYPE, &val)); *obj = val.as_pointer; return ISC_R_SUCCESS; } @@ -3143,13 +3130,8 @@ token_addr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na) { if (inet_pton(AF_INET6, buf, &in6a) == 1) { if (d != NULL) { - isc_result_t result; - - result = isc_netscope_pton( - AF_INET6, d + 1, &in6a, &zone); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_netscope_pton( + AF_INET6, d + 1, &in6a, &zone)); } isc_netaddr_fromin6(na, &in6a); @@ -3769,12 +3751,7 @@ cleanup: */ static isc_result_t cfg_getstringtoken(cfg_parser_t *pctx) { - isc_result_t result; - - result = cfg_gettoken(pctx, CFG_LEXOPT_QSTRING); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING)); if (pctx->token.type != isc_tokentype_string && pctx->token.type != isc_tokentype_qstring) diff --git a/lib/ns/client.c b/lib/ns/client.c index a99857bed4d..d35891d45b1 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -1074,10 +1074,7 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message) { .value = (unsigned char *)nsidp, .length = (uint16_t)strlen(nsidp), }; - result = dns_message_ednsaddopt(message, &option); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_ednsaddopt(message, &option)); } } @@ -1093,10 +1090,7 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message) { dns_ednsopt_t option = { .code = DNS_OPT_COOKIE, .length = COOKIE_SIZE, .value = cookie }; - result = dns_message_ednsaddopt(message, &option); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_ednsaddopt(message, &option)); } if ((client->inner.attributes & NS_CLIENTATTR_HAVEEXPIRE) != 0) { @@ -1108,10 +1102,7 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message) { dns_ednsopt_t option = { .code = DNS_OPT_EXPIRE, .value = expire, .length = 4 }; - result = dns_message_ednsaddopt(message, &option); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_ednsaddopt(message, &option)); } if (((client->inner.attributes & NS_CLIENTATTR_HAVEECS) != 0) && @@ -1170,10 +1161,7 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message) { dns_ednsopt_t option = { .code = DNS_OPT_CLIENT_SUBNET, .length = addrl + 4, .value = ecs }; - result = dns_message_ednsaddopt(message, &option); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_ednsaddopt(message, &option)); } if (TCP_CLIENT(client) && USEKEEPALIVE(client)) { @@ -1187,10 +1175,7 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message) { dns_ednsopt_t option = { .code = DNS_OPT_TCP_KEEPALIVE, .length = 2, .value = advtimo }; - result = dns_message_ednsaddopt(message, &option); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_ednsaddopt(message, &option)); } for (size_t i = 0; i < DNS_EDE_MAX_ERRORS; i++) { @@ -1203,10 +1188,7 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message) { dns_ednsopt_t option = { .code = DNS_OPT_EDE, .length = ede->length, .value = ede->value }; - result = dns_message_ednsaddopt(message, &option); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_ednsaddopt(message, &option)); } if ((client->inner.attributes & NS_CLIENTATTR_HAVEZONEVERSION) != 0) { dns_ednsopt_t option = { @@ -1214,10 +1196,7 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message) { .length = client->inner.zoneversionlength, .value = client->inner.zoneversion }; - result = dns_message_ednsaddopt(message, &option); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_ednsaddopt(message, &option)); } if (WANTRC(client)) { @@ -1231,10 +1210,7 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message) { .length = rad->length, .value = rad->ndata, }; - result = dns_message_ednsaddopt(message, &option); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_message_ednsaddopt(message, &option)); } } diff --git a/lib/ns/interfacemgr.c b/lib/ns/interfacemgr.c index 9cc1a74be8d..71ffda00460 100644 --- a/lib/ns/interfacemgr.c +++ b/lib/ns/interfacemgr.c @@ -840,11 +840,8 @@ setup_locals(isc_interface_t *interface, dns_acl_t *localhost, /* First add localhost address */ prefixlen = (netaddr->family == AF_INET) ? 32 : 128; - result = dns_iptable_addprefix(localhost->iptable, netaddr, prefixlen, - true); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_iptable_addprefix(localhost->iptable, netaddr, prefixlen, + true)); /* Then add localnets prefix */ result = isc_netaddr_masktoprefixlen(&interface->netmask, &prefixlen); @@ -873,11 +870,8 @@ setup_locals(isc_interface_t *interface, dns_acl_t *localhost, return ISC_R_SUCCESS; } - result = dns_iptable_addprefix(localnets->iptable, netaddr, prefixlen, - true); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_iptable_addprefix(localnets->iptable, netaddr, prefixlen, + true)); return ISC_R_SUCCESS; } @@ -1083,10 +1077,7 @@ do_scan(ns_interfacemgr_t *mgr, bool verbose, bool config) { isc_netaddr_any(&zero_address); isc_netaddr_any6(&zero_address6); - result = isc_interfaceiter_create(mgr->mctx, &iter); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_interfaceiter_create(mgr->mctx, &iter)); dns_acl_create(mgr->mctx, 0, &localhost); dns_acl_create(mgr->mctx, 0, &localnets); diff --git a/lib/ns/query.c b/lib/ns/query.c index a5ee19f3542..b9e7ebec636 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -1774,11 +1774,8 @@ query_additionalauth(query_ctx_t *qctx, const dns_name_t *name, version = NULL; dns_db_detach(&db); dns_getdb_options_t options = { .nolog = true }; - result = query_getzonedb(client, name, type, options, &zone, - &db, &version); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(query_getzonedb(client, name, type, options, &zone, &db, + &version)); dns_zone_detach(&zone); CTRACE(ISC_LOG_DEBUG(3), "query_additionalauth: other zone"); @@ -3734,11 +3731,8 @@ rpz_rewrite_ip_rrset(ns_client_t *client, dns_name_t *name, continue; } - result = rpz_rewrite_ip(client, &netaddr, qtype, - rpz_type, zbits, p_rdatasetp); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(rpz_rewrite_ip(client, &netaddr, qtype, rpz_type, + zbits, p_rdatasetp)); } } while (!done && client->query.rpz_st->m.policy == DNS_RPZ_POLICY_MISS); @@ -6344,10 +6338,7 @@ ns_query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qname, inc_stats(client, ns_statscounter_recursion); } - result = acquire_recursionquota(client); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(acquire_recursionquota(client)); /* * Invoke the resolver. @@ -9558,10 +9549,7 @@ query_synthcnamewildcard(query_ctx_t *qctx, dns_rdataset_t *rdataset, dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdata_cname_t cname; - result = query_synthwildcard(qctx, rdataset, sigrdataset); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(query_synthwildcard(qctx, rdataset, sigrdataset)); qctx->client->query.attributes |= NS_QUERYATTR_PARTIALANSWER; diff --git a/lib/ns/update.c b/lib/ns/update.c index a88e1c245b3..64366b961c1 100644 --- a/lib/ns/update.c +++ b/lib/ns/update.c @@ -523,17 +523,13 @@ typedef struct { */ static isc_result_t foreach_node_rr_action(void *data, dns_rdataset_t *rdataset) { - isc_result_t result; foreach_node_rr_ctx_t *ctx = data; DNS_RDATASET_FOREACH(rdataset) { rr_t rr = { 0, DNS_RDATA_INIT }; dns_rdataset_current(rdataset, &rr.rdata); rr.ttl = rdataset->ttl; - result = (*ctx->rr_action)(ctx->rr_action_data, &rr); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR((*ctx->rr_action)(ctx->rr_action_data, &rr)); } return ISC_R_SUCCESS; } @@ -1537,14 +1533,10 @@ check_soa_increment(dns_db_t *db, dns_dbversion_t *ver, dns_rdata_t *update_rdata, bool *ok) { uint32_t db_serial; uint32_t update_serial; - isc_result_t result; update_serial = dns_soa_getserial(update_rdata); - result = dns_db_getsoaserial(db, ver, &db_serial); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_getsoaserial(db, ver, &db_serial)); if (DNS_SERIAL_GE(db_serial, update_serial)) { *ok = false; @@ -2170,10 +2162,7 @@ get_iterations(dns_db_t *db, dns_dbversion_t *ver, dns_rdatatype_t privatetype, dns_rdataset_init(&rdataset); - result = dns_db_getoriginnode(db, &node); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_getoriginnode(db, &node)); result = dns_db_findrdataset(db, node, ver, dns_rdatatype_nsec3param, 0, (isc_stdtime_t)0, &rdataset, NULL); if (result == ISC_R_NOTFOUND) { @@ -3430,12 +3419,9 @@ send_forward(ns_client_t *client, dns_zone_t *zone) { char classbuf[DNS_RDATACLASS_FORMATSIZE]; update_t *uev = NULL; - result = checkupdateacl(client, dns_zone_getforwardacl(zone), - "update forwarding", dns_zone_getorigin(zone), - true, false); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(checkupdateacl(client, dns_zone_getforwardacl(zone), + "update forwarding", dns_zone_getorigin(zone), + true, false)); result = isc_quota_acquire(&client->manager->sctx->updquota); if (result != ISC_R_SUCCESS) { diff --git a/lib/ns/xfrout.c b/lib/ns/xfrout.c index 3ca1c1f7026..7b289cee2af 100644 --- a/lib/ns/xfrout.c +++ b/lib/ns/xfrout.c @@ -330,11 +330,9 @@ cleanup: static isc_result_t axfr_rrstream_first(rrstream_t *rs) { axfr_rrstream_t *s = (axfr_rrstream_t *)rs; - isc_result_t result; - result = dns_rriterator_first(&s->it); - if (result != ISC_R_SUCCESS) { - return result; - } + + RETERR(dns_rriterator_first(&s->it)); + /* Skip SOA records. */ for (;;) { dns_name_t *name_dummy = NULL; @@ -345,12 +343,10 @@ axfr_rrstream_first(rrstream_t *rs) { if (rdata->type != dns_rdatatype_soa) { break; } - result = dns_rriterator_next(&s->it); - if (result != ISC_R_SUCCESS) { - break; - } + RETERR(dns_rriterator_next(&s->it)); } - return result; + + return ISC_R_SUCCESS; } static isc_result_t diff --git a/tests/dns/dispatch_test.c b/tests/dns/dispatch_test.c index 663c9ff19cb..0165df27427 100644 --- a/tests/dns/dispatch_test.c +++ b/tests/dns/dispatch_test.c @@ -258,10 +258,7 @@ make_dispatchset(dns_dispatchmgr_t *dispatchmgr, unsigned int ndisps, dns_dispatch_t *disp = NULL; isc_sockaddr_any(&any); - result = dns_dispatch_createudp(dispatchmgr, &any, &disp); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_dispatch_createudp(dispatchmgr, &any, &disp)); result = dns_dispatchset_create(isc_g_mctx, disp, dsetp, ndisps); dns_dispatch_detach(&disp); diff --git a/tests/dns/master_test.c b/tests/dns/master_test.c index e5fdd75fa5b..1d822fed8db 100644 --- a/tests/dns/master_test.c +++ b/tests/dns/master_test.c @@ -88,7 +88,6 @@ rawdata_callback(dns_zone_t *zone, dns_masterrawheader_t *h) { static isc_result_t setup_master(void (*warn)(struct dns_rdatacallbacks *, const char *, ...), void (*error)(struct dns_rdatacallbacks *, const char *, ...)) { - isc_result_t result; int len; isc_buffer_t source; @@ -100,10 +99,7 @@ setup_master(void (*warn)(struct dns_rdatacallbacks *, const char *, ...), isc_buffer_setactive(&source, len); dns_master_initrawheader(&header); - result = dns_name_fromtext(dns_origin, &source, dns_rootname, 0); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromtext(dns_origin, &source, dns_rootname, 0)); dns_rdatacallbacks_init_stdio(&callbacks); callbacks.add = add_callback; @@ -116,7 +112,7 @@ setup_master(void (*warn)(struct dns_rdatacallbacks *, const char *, ...), callbacks.error = error; } headerset = false; - return result; + return ISC_R_SUCCESS; } static isc_result_t @@ -126,10 +122,7 @@ test_master(const char *workdir, const char *testfile, void (*error)(struct dns_rdatacallbacks *, const char *, ...)) { isc_result_t result; - result = setup_master(warn, error); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(setup_master(warn, error)); dns_rdatacallbacks_init_stdio(&callbacks); callbacks.add = add_callback; @@ -143,10 +136,7 @@ test_master(const char *workdir, const char *testfile, } if (workdir != NULL) { - result = isc_dir_chdir(workdir); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_dir_chdir(workdir)); } result = dns_master_loadfile(testfile, dns_origin, dns_origin, diff --git a/tests/libtest/dns.c b/tests/libtest/dns.c index 18b8f55052a..1abd26c5e30 100644 --- a/tests/libtest/dns.c +++ b/tests/libtest/dns.c @@ -65,10 +65,7 @@ dns_test_makeview(const char *name, bool with_dispatchmgr, bool with_cache, dns_dispatchmgr_t *dispatchmgr = NULL; if (with_dispatchmgr) { - result = dns_dispatchmgr_create(isc_g_mctx, &dispatchmgr); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_dispatchmgr_create(isc_g_mctx, &dispatchmgr)); } dns_view_create(isc_g_mctx, dispatchmgr, dns_rdataclass_in, name, @@ -211,16 +208,10 @@ dns_test_loaddb(dns_db_t **db, dns_dbtype_t dbtype, const char *origin, name = dns_fixedname_initname(&fixed); - result = dns_name_fromstring(name, origin, dns_rootname, 0, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromstring(name, origin, dns_rootname, 0, NULL)); - result = dns_db_create(isc_g_mctx, dbimp, name, dbtype, - dns_rdataclass_in, 0, NULL, db); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_create(isc_g_mctx, dbimp, name, dbtype, dns_rdataclass_in, + 0, NULL, db)); result = dns_db_load(*db, testfile, dns_masterformat_text, 0); return result; @@ -263,7 +254,7 @@ dns_test_tohex(const unsigned char *data, size_t len, char *buf, isc_result_t dns_test_getdata(const char *file, unsigned char *buf, size_t bufsiz, size_t *sizep) { - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; unsigned char *bp; char *rp, *wp; char s[BUFSIZ]; @@ -271,10 +262,7 @@ dns_test_getdata(const char *file, unsigned char *buf, size_t bufsiz, FILE *f = NULL; int n; - result = isc_stdio_open(file, "r", &f); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_stdio_open(file, "r", &f)); bp = buf; while (fgets(s, sizeof(s), f) != NULL) { diff --git a/tests/libtest/ns.c b/tests/libtest/ns.c index 359077e58a6..d91c849bf3b 100644 --- a/tests/libtest/ns.c +++ b/tests/libtest/ns.c @@ -146,10 +146,7 @@ ns_test_serve_zone(const char *zonename, const char *filename, /* * Prepare zone structure for further processing. */ - result = dns_test_makezone(zonename, &served_zone, view, false); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_test_makezone(zonename, &served_zone, view, false)); /* * Start zone manager. @@ -518,16 +515,10 @@ ns_test_loaddb(dns_db_t **db, dns_dbtype_t dbtype, const char *origin, name = dns_fixedname_initname(&fixed); - result = dns_name_fromstring(name, origin, dns_rootname, 0, NULL); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_name_fromstring(name, origin, dns_rootname, 0, NULL)); - result = dns_db_create(isc_g_mctx, dbimp, name, dbtype, - dns_rdataclass_in, 0, NULL, db); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(dns_db_create(isc_g_mctx, dbimp, name, dbtype, dns_rdataclass_in, + 0, NULL, db)); result = dns_db_load(*db, testfile, dns_masterformat_text, 0); return result; @@ -558,10 +549,7 @@ ns_test_getdata(const char *file, unsigned char *buf, size_t bufsiz, FILE *f = NULL; int n; - result = isc_stdio_open(file, "r", &f); - if (result != ISC_R_SUCCESS) { - return result; - } + RETERR(isc_stdio_open(file, "r", &f)); bp = buf; while (fgets(s, sizeof(s), f) != NULL) {