2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

dns/view.c: Return void when ISC_R_SUCCESS is only returned value

With isc_mem_get() and dns_name_dup() no longer being able to fail, some
functions can now only return ISC_R_SUCCESS.  Change the return type to
void for the following function(s):

 * dns_view_adddelegationonly()
 * dns_view_excludedelegationonly()
This commit is contained in:
Ondřej Surý 2021-10-06 13:40:32 +02:00
parent 8fb4c5bb7a
commit f51a9d834c
3 changed files with 12 additions and 14 deletions

View File

@ -5591,7 +5591,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
exclude = cfg_listelt_value(element); exclude = cfg_listelt_value(element);
CHECK(dns_name_fromstring( CHECK(dns_name_fromstring(
name, cfg_obj_asstring(exclude), 0, NULL)); name, cfg_obj_asstring(exclude), 0, NULL));
CHECK(dns_view_excludedelegationonly(view, name)); dns_view_excludedelegationonly(view, name);
} }
} else { } else {
dns_view_setrootdelonly(view, false); dns_view_setrootdelonly(view, false);
@ -6337,7 +6337,7 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
const cfg_obj_t *ixfrfromdiffs = NULL; const cfg_obj_t *ixfrfromdiffs = NULL;
const cfg_obj_t *only = NULL; const cfg_obj_t *only = NULL;
const cfg_obj_t *viewobj = NULL; const cfg_obj_t *viewobj = NULL;
isc_result_t result; isc_result_t result = ISC_R_SUCCESS;
isc_result_t tresult; isc_result_t tresult;
isc_buffer_t buffer; isc_buffer_t buffer;
dns_fixedname_t fixorigin; dns_fixedname_t fixorigin;
@ -6472,7 +6472,7 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
&only); &only);
if (tresult == ISC_R_SUCCESS && cfg_obj_asboolean(only)) if (tresult == ISC_R_SUCCESS && cfg_obj_asboolean(only))
{ {
CHECK(dns_view_adddelegationonly(view, origin)); dns_view_adddelegationonly(view, origin);
} }
} else { } else {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
@ -6504,7 +6504,7 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
only = NULL; only = NULL;
tresult = cfg_map_get(zoptions, "delegation-only", &only); tresult = cfg_map_get(zoptions, "delegation-only", &only);
if (tresult == ISC_R_SUCCESS && cfg_obj_asboolean(only)) { if (tresult == ISC_R_SUCCESS && cfg_obj_asboolean(only)) {
CHECK(dns_view_adddelegationonly(view, origin)); dns_view_adddelegationonly(view, origin);
} }
goto cleanup; goto cleanup;
} }
@ -6513,7 +6513,7 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
* "delegation-only zones" aren't zones either. * "delegation-only zones" aren't zones either.
*/ */
if (strcasecmp(ztypestr, "delegation-only") == 0) { if (strcasecmp(ztypestr, "delegation-only") == 0) {
result = dns_view_adddelegationonly(view, origin); dns_view_adddelegationonly(view, origin);
goto cleanup; goto cleanup;
} }
@ -6679,7 +6679,7 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
only = NULL; only = NULL;
if (cfg_map_get(zoptions, "delegation-only", &only) == ISC_R_SUCCESS) { if (cfg_map_get(zoptions, "delegation-only", &only) == ISC_R_SUCCESS) {
if (cfg_obj_asboolean(only)) { if (cfg_obj_asboolean(only)) {
CHECK(dns_view_adddelegationonly(view, origin)); dns_view_adddelegationonly(view, origin);
} }
} }

View File

@ -952,7 +952,7 @@ dns_view_flushname(dns_view_t *view, const dns_name_t *name);
* other returns are failures. * other returns are failures.
*/ */
isc_result_t void
dns_view_adddelegationonly(dns_view_t *view, const dns_name_t *name); dns_view_adddelegationonly(dns_view_t *view, const dns_name_t *name);
/*%< /*%<
* Add the given name to the delegation only table. * Add the given name to the delegation only table.
@ -966,7 +966,7 @@ dns_view_adddelegationonly(dns_view_t *view, const dns_name_t *name);
*\li #ISC_R_NOMEMORY *\li #ISC_R_NOMEMORY
*/ */
isc_result_t void
dns_view_excludedelegationonly(dns_view_t *view, const dns_name_t *name); dns_view_excludedelegationonly(dns_view_t *view, const dns_name_t *name);
/*%< /*%<
* Add the given name to be excluded from the root-delegation-only. * Add the given name to be excluded from the root-delegation-only.

View File

@ -1739,7 +1739,7 @@ dns_view_flushnode(dns_view_t *view, const dns_name_t *name, bool tree) {
return (result); return (result);
} }
isc_result_t void
dns_view_adddelegationonly(dns_view_t *view, const dns_name_t *name) { dns_view_adddelegationonly(dns_view_t *view, const dns_name_t *name) {
dns_name_t *item; dns_name_t *item;
unsigned int hash; unsigned int hash;
@ -1760,16 +1760,15 @@ dns_view_adddelegationonly(dns_view_t *view, const dns_name_t *name) {
item = ISC_LIST_NEXT(item, link); item = ISC_LIST_NEXT(item, link);
} }
if (item != NULL) { if (item != NULL) {
return (ISC_R_SUCCESS); return;
} }
item = isc_mem_get(view->mctx, sizeof(*item)); item = isc_mem_get(view->mctx, sizeof(*item));
dns_name_init(item, NULL); dns_name_init(item, NULL);
dns_name_dup(name, view->mctx, item); dns_name_dup(name, view->mctx, item);
ISC_LIST_APPEND(view->delonly[hash], item, link); ISC_LIST_APPEND(view->delonly[hash], item, link);
return (ISC_R_SUCCESS);
} }
isc_result_t void
dns_view_excludedelegationonly(dns_view_t *view, const dns_name_t *name) { dns_view_excludedelegationonly(dns_view_t *view, const dns_name_t *name) {
dns_name_t *item; dns_name_t *item;
unsigned int hash; unsigned int hash;
@ -1790,13 +1789,12 @@ dns_view_excludedelegationonly(dns_view_t *view, const dns_name_t *name) {
item = ISC_LIST_NEXT(item, link); item = ISC_LIST_NEXT(item, link);
} }
if (item != NULL) { if (item != NULL) {
return (ISC_R_SUCCESS); return;
} }
item = isc_mem_get(view->mctx, sizeof(*item)); item = isc_mem_get(view->mctx, sizeof(*item));
dns_name_init(item, NULL); dns_name_init(item, NULL);
dns_name_dup(name, view->mctx, item); dns_name_dup(name, view->mctx, item);
ISC_LIST_APPEND(view->rootexclude[hash], item, link); ISC_LIST_APPEND(view->rootexclude[hash], item, link);
return (ISC_R_SUCCESS);
} }
bool bool