2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 06:55:30 +00:00

dns/ssu.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_ssutable_addrule()
 * dns_ssutable_create()
 * dns_ssutable_createdlz()
This commit is contained in:
Ondřej Surý
2021-10-06 13:18:16 +02:00
parent ecb74bae0d
commit 8fb4c5bb7a
4 changed files with 17 additions and 40 deletions

View File

@@ -202,7 +202,7 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone,
dns_ssutable_t *table = NULL; dns_ssutable_t *table = NULL;
isc_mem_t *mctx = dns_zone_getmctx(zone); isc_mem_t *mctx = dns_zone_getmctx(zone);
bool autoddns = false; bool autoddns = false;
isc_result_t result; isc_result_t result = ISC_R_SUCCESS;
(void)cfg_map_get(zconfig, "update-policy", &updatepolicy); (void)cfg_map_get(zconfig, "update-policy", &updatepolicy);
@@ -218,10 +218,7 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone,
updatepolicy = NULL; updatepolicy = NULL;
} }
result = dns_ssutable_create(mctx, &table); dns_ssutable_create(mctx, &table);
if (result != ISC_R_SUCCESS) {
return (result);
}
for (element = cfg_list_first(updatepolicy); element != NULL; for (element = cfg_list_first(updatepolicy); element != NULL;
element = cfg_list_next(element)) element = cfg_list_next(element))
@@ -342,15 +339,12 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone,
} }
INSIST(i == n); INSIST(i == n);
result = dns_ssutable_addrule( dns_ssutable_addrule(table, grant, dns_fixedname_name(&fident),
table, grant, dns_fixedname_name(&fident), mtype, mtype, dns_fixedname_name(&fname), n,
dns_fixedname_name(&fname), n, types); types);
if (types != NULL) { if (types != NULL) {
isc_mem_put(mctx, types, n * sizeof(*types)); isc_mem_put(mctx, types, n * sizeof(*types));
} }
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
} }
/* /*
@@ -371,17 +365,12 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone,
goto cleanup; goto cleanup;
} }
result = dns_ssutable_addrule( dns_ssutable_addrule(table, true,
table, true, named_g_server->session_keyname, named_g_server->session_keyname,
dns_ssumatchtype_local, dns_zone_getorigin(zone), 1, dns_ssumatchtype_local,
&any); dns_zone_getorigin(zone), 1, &any);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
} }
result = ISC_R_SUCCESS;
dns_zone_setssutable(zone, table); dns_zone_setssutable(zone, table);
cleanup: cleanup:

View File

@@ -464,11 +464,7 @@ dns_dlz_writeablezone(dns_view_t *view, dns_dlzdb_t *dlzdb,
dns_zone_setadded(zone, true); dns_zone_setadded(zone, true);
if (dlzdb->ssutable == NULL) { if (dlzdb->ssutable == NULL) {
result = dns_ssutable_createdlz(dlzdb->mctx, &dlzdb->ssutable, dns_ssutable_createdlz(dlzdb->mctx, &dlzdb->ssutable, dlzdb);
dlzdb);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
} }
dns_zone_setssutable(zone, dlzdb->ssutable); dns_zone_setssutable(zone, dlzdb->ssutable);

View File

@@ -52,7 +52,7 @@ typedef struct dns_ssuruletype {
unsigned int max; /* maximum number of records allowed. */ unsigned int max; /* maximum number of records allowed. */
} dns_ssuruletype_t; } dns_ssuruletype_t;
isc_result_t void
dns_ssutable_create(isc_mem_t *mctx, dns_ssutable_t **table); dns_ssutable_create(isc_mem_t *mctx, dns_ssutable_t **table);
/*%< /*%<
* Creates a table that will be used to store simple-secure-update rules. * Creates a table that will be used to store simple-secure-update rules.
@@ -67,7 +67,7 @@ dns_ssutable_create(isc_mem_t *mctx, dns_ssutable_t **table);
*\li ISC_R_NOMEMORY *\li ISC_R_NOMEMORY
*/ */
isc_result_t void
dns_ssutable_createdlz(isc_mem_t *mctx, dns_ssutable_t **tablep, dns_ssutable_createdlz(isc_mem_t *mctx, dns_ssutable_t **tablep,
dns_dlzdb_t *dlzdatabase); dns_dlzdb_t *dlzdatabase);
/*%< /*%<
@@ -104,7 +104,7 @@ dns_ssutable_detach(dns_ssutable_t **tablep);
* resources used by the table will be freed. * resources used by the table will be freed.
*/ */
isc_result_t void
dns_ssutable_addrule(dns_ssutable_t *table, bool grant, dns_ssutable_addrule(dns_ssutable_t *table, bool grant,
const dns_name_t *identity, dns_ssumatchtype_t matchtype, const dns_name_t *identity, dns_ssumatchtype_t matchtype,
const dns_name_t *name, unsigned int ntypes, const dns_name_t *name, unsigned int ntypes,

View File

@@ -57,7 +57,7 @@ struct dns_ssutable {
ISC_LIST(dns_ssurule_t) rules; ISC_LIST(dns_ssurule_t) rules;
}; };
isc_result_t void
dns_ssutable_create(isc_mem_t *mctx, dns_ssutable_t **tablep) { dns_ssutable_create(isc_mem_t *mctx, dns_ssutable_t **tablep) {
dns_ssutable_t *table; dns_ssutable_t *table;
@@ -71,7 +71,6 @@ dns_ssutable_create(isc_mem_t *mctx, dns_ssutable_t **tablep) {
ISC_LIST_INIT(table->rules); ISC_LIST_INIT(table->rules);
table->magic = SSUTABLEMAGIC; table->magic = SSUTABLEMAGIC;
*tablep = table; *tablep = table;
return (ISC_R_SUCCESS);
} }
static inline void static inline void
@@ -129,7 +128,7 @@ dns_ssutable_detach(dns_ssutable_t **tablep) {
} }
} }
isc_result_t void
dns_ssutable_addrule(dns_ssutable_t *table, bool grant, dns_ssutable_addrule(dns_ssutable_t *table, bool grant,
const dns_name_t *identity, dns_ssumatchtype_t matchtype, const dns_name_t *identity, dns_ssumatchtype_t matchtype,
const dns_name_t *name, unsigned int ntypes, const dns_name_t *name, unsigned int ntypes,
@@ -177,8 +176,6 @@ dns_ssutable_addrule(dns_ssutable_t *table, bool grant,
rule->magic = SSURULEMAGIC; rule->magic = SSURULEMAGIC;
ISC_LIST_INITANDAPPEND(table->rules, rule, link); ISC_LIST_INITANDAPPEND(table->rules, rule, link);
return (ISC_R_SUCCESS);
} }
static inline bool static inline bool
@@ -599,19 +596,15 @@ dns_ssutable_nextrule(dns_ssurule_t *rule, dns_ssurule_t **nextrule) {
/* /*
* Create a specialised SSU table that points at an external DLZ database * Create a specialised SSU table that points at an external DLZ database
*/ */
isc_result_t void
dns_ssutable_createdlz(isc_mem_t *mctx, dns_ssutable_t **tablep, dns_ssutable_createdlz(isc_mem_t *mctx, dns_ssutable_t **tablep,
dns_dlzdb_t *dlzdatabase) { dns_dlzdb_t *dlzdatabase) {
isc_result_t result;
dns_ssurule_t *rule; dns_ssurule_t *rule;
dns_ssutable_t *table = NULL; dns_ssutable_t *table = NULL;
REQUIRE(tablep != NULL && *tablep == NULL); REQUIRE(tablep != NULL && *tablep == NULL);
result = dns_ssutable_create(mctx, &table); dns_ssutable_create(mctx, &table);
if (result != ISC_R_SUCCESS) {
return (result);
}
table->dlzdatabase = dlzdatabase; table->dlzdatabase = dlzdatabase;
@@ -627,7 +620,6 @@ dns_ssutable_createdlz(isc_mem_t *mctx, dns_ssutable_t **tablep,
ISC_LIST_INITANDAPPEND(table->rules, rule, link); ISC_LIST_INITANDAPPEND(table->rules, rule, link);
*tablep = table; *tablep = table;
return (ISC_R_SUCCESS);
} }
isc_result_t isc_result_t