Skip to content

Commit

Permalink
rem: dev: Clean up unused result codes
Browse files Browse the repository at this point in the history
A number of result codes are obsolete and can be removed. Others, including `ISC_R_NOMEMORY`, are still checked in various places even though they can't occur any longer. These have been cleaned up.

Merge branch 'each-cleanup-results' into 'main'

See merge request isc-projects/bind9!9942
  • Loading branch information
each committed Jan 24, 2025
2 parents af0a5df + 314741f commit d3455be
Show file tree
Hide file tree
Showing 92 changed files with 263 additions and 915 deletions.
19 changes: 8 additions & 11 deletions bin/check/check-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,8 @@ add(char *key, int value) {
}

if (symtab == NULL) {
result = isc_symtab_create(sym_mctx, 100, freekey, sym_mctx,
false, &symtab);
if (result != ISC_R_SUCCESS) {
return;
}
isc_symtab_create(sym_mctx, 100, freekey, sym_mctx, false,
&symtab);
}

key = isc_mem_strdup(sym_mctx, key);
Expand Down Expand Up @@ -660,17 +657,17 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
isc_buffer_add(&buffer, strlen(zonename));
origin = dns_fixedname_initname(&fixorigin);
CHECK(dns_name_fromtext(origin, &buffer, dns_rootname, 0, NULL));
CHECK(dns_zone_setorigin(zone, origin));
dns_zone_setorigin(zone, origin);
dns_zone_setdbtype(zone, 1, (const char *const *)dbtype);
if (strcmp(filename, "-") == 0) {
CHECK(dns_zone_setstream(zone, stdin, fileformat,
&dns_master_style_default));
dns_zone_setstream(zone, stdin, fileformat,
&dns_master_style_default);
} else {
CHECK(dns_zone_setfile(zone, filename, fileformat,
&dns_master_style_default));
dns_zone_setfile(zone, filename, fileformat,
&dns_master_style_default);
}
if (journal != NULL) {
CHECK(dns_zone_setjournal(zone, journal));
dns_zone_setjournal(zone, journal);
}

region.base = UNCONST(classname);
Expand Down
11 changes: 3 additions & 8 deletions bin/delv/delv.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,7 @@ key_fromconfig(const cfg_obj_t *key, dns_client_t *client, dns_view_t *toview) {
num_keys++;

cleanup:
if (result == DST_R_NOCRYPTO) {
cfg_obj_log(key, ISC_LOG_ERROR, "no crypto support");
} else if (result == DST_R_UNSUPPORTEDALG) {
if (result == DST_R_UNSUPPORTEDALG) {
cfg_obj_log(key, ISC_LOG_WARNING,
"skipping trusted key '%s': %s", keynamestr,
isc_result_totext(result));
Expand Down Expand Up @@ -823,9 +821,6 @@ load_keys(const cfg_obj_t *keys, dns_client_t *client, dns_view_t *toview) {
}

cleanup:
if (result == DST_R_NOCRYPTO) {
result = ISC_R_SUCCESS;
}
return result;
}

Expand Down Expand Up @@ -2202,8 +2197,8 @@ run_server(void *arg) {
CHECK(ns_interfacemgr_create(mctx, sctx, loopmgr, netmgr, dispatchmgr,
NULL, &interfacemgr));

CHECK(dns_view_create(mctx, loopmgr, dispatchmgr, dns_rdataclass_in,
"_default", &view));
dns_view_create(mctx, loopmgr, dispatchmgr, dns_rdataclass_in,
"_default", &view);
CHECK(dns_cache_create(loopmgr, dns_rdataclass_in, "", mctx, &cache));
dns_view_setcache(view, cache, false);
dns_cache_detach(&cache);
Expand Down
15 changes: 6 additions & 9 deletions bin/named/controlconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ control_recvmessage(isc_nmhandle_t *handle ISC_ATTR_UNUSED, isc_result_t result,
if ((sent + CLOCKSKEW) < conn->now ||
(sent - CLOCKSKEW) > conn->now)
{
result = ISCCC_R_CLOCKSKEW;
result = DNS_R_CLOCKSKEW;
goto cleanup;
}
} else {
Expand All @@ -503,7 +503,7 @@ control_recvmessage(isc_nmhandle_t *handle ISC_ATTR_UNUSED, isc_result_t result,
if (isccc_cc_lookupuint32(conn->ctrl, "_exp", &exp) == ISC_R_SUCCESS &&
conn->now > exp)
{
result = ISCCC_R_EXPIRED;
result = DNS_R_EXPIRED;
goto cleanup;
}

Expand Down Expand Up @@ -842,15 +842,12 @@ get_rndckey(isc_mem_t *mctx, controlkeylist_t *keyids) {
CHECK(cfg_map_get(config, "key", &key));

keyid = isc_mem_get(mctx, sizeof(*keyid));
*keyid = (controlkey_t){
.algorithm = DST_ALG_UNKNOWN,
.link = ISC_LINK_INITIALIZER,
};
keyid->keyname = isc_mem_strdup(mctx,
cfg_obj_asstring(cfg_map_getname(key)));
keyid->secret.base = NULL;
keyid->secret.length = 0;
keyid->algorithm = DST_ALG_UNKNOWN;
ISC_LINK_INIT(keyid, link);
if (keyid->keyname == NULL) {
CHECK(ISC_R_NOMEMORY);
}

CHECK(isccfg_check_key(key));

Expand Down
2 changes: 1 addition & 1 deletion bin/named/include/named/tkeyconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ named_tkeyctx_fromconfig(const cfg_obj_t *options, isc_mem_t *mctx,
*
* Returns:
*\li ISC_R_SUCCESS
*\li ISC_R_NOMEMORY
*\li return codes from dns_name_fromtext()
*/
3 changes: 2 additions & 1 deletion bin/named/include/named/tsigconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ named_tsigkeyring_fromconfig(const cfg_obj_t *config, const cfg_obj_t *vconfig,
*
* Returns:
* \li ISC_R_SUCCESS
* \li ISC_R_NOMEMORY
* \li DNS_R_BADALG
* \li return codes from dns_name_fromtext()
*/
9 changes: 1 addition & 8 deletions bin/named/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1414,14 +1414,7 @@ named_smf_get_instance(char **ins_name, int debug, isc_mem_t *mctx) {
return ISC_R_FAILURE;
}

if ((instance = isc_mem_allocate(mctx, namelen + 1)) == NULL) {
UNEXPECTED_ERROR("named_smf_get_instance memory "
"allocation failed: %s",
isc_result_totext(ISC_R_NOMEMORY));
scf_handle_destroy(h);
return ISC_R_FAILURE;
}

instance = isc_mem_allocate(mctx, namelen + 1);
if (scf_myname(h, instance, namelen + 1) == -1) {
if (debug) {
UNEXPECTED_ERROR("scf_myname() failed: %s",
Expand Down
Loading

0 comments on commit d3455be

Please sign in to comment.