mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-04 00:25:29 +00:00
Refactor dns_zone_create() to return void
After isc_stats_create() change, the dns_zone_create() cannot fail, so refactor the function to return void and fix all its uses.
This commit is contained in:
committed by
Ondřej Surý
parent
045d8d9ed6
commit
ea2fe8eea4
@@ -595,7 +595,7 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
|
|||||||
zonename, filename, classname);
|
zonename, filename, classname);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK(dns_zone_create(&zone, mctx, 0));
|
dns_zone_create(&zone, mctx, 0);
|
||||||
|
|
||||||
dns_zone_settype(zone, dns_zone_primary);
|
dns_zone_settype(zone, dns_zone_primary);
|
||||||
|
|
||||||
|
@@ -1938,7 +1938,7 @@ dns64_reverse(dns_view_t *view, isc_mem_t *mctx, isc_netaddr_t *na,
|
|||||||
isc_buffer_constinit(&b, reverse, strlen(reverse));
|
isc_buffer_constinit(&b, reverse, strlen(reverse));
|
||||||
isc_buffer_add(&b, strlen(reverse));
|
isc_buffer_add(&b, strlen(reverse));
|
||||||
CHECK(dns_name_fromtext(name, &b, dns_rootname, 0, NULL));
|
CHECK(dns_name_fromtext(name, &b, dns_rootname, 0, NULL));
|
||||||
CHECK(dns_zone_create(&zone, mctx, 0));
|
dns_zone_create(&zone, mctx, 0);
|
||||||
CHECK(dns_zone_setorigin(zone, name));
|
CHECK(dns_zone_setorigin(zone, name));
|
||||||
dns_zone_setview(zone, view);
|
dns_zone_setview(zone, view);
|
||||||
CHECK(dns_zonemgr_managezone(named_g_server->zonemgr, zone));
|
CHECK(dns_zonemgr_managezone(named_g_server->zonemgr, zone));
|
||||||
@@ -3613,7 +3613,7 @@ create_ipv4only_zone(dns_zone_t *pzone, dns_view_t *view,
|
|||||||
/*
|
/*
|
||||||
* Create the actual zone.
|
* Create the actual zone.
|
||||||
*/
|
*/
|
||||||
CHECK(dns_zone_create(&zone, mctx, 0));
|
dns_zone_create(&zone, mctx, 0);
|
||||||
CHECK(dns_zone_setorigin(zone, name));
|
CHECK(dns_zone_setorigin(zone, name));
|
||||||
CHECK(dns_zonemgr_managezone(named_g_server->zonemgr, zone));
|
CHECK(dns_zonemgr_managezone(named_g_server->zonemgr, zone));
|
||||||
dns_zone_setclass(zone, view->rdclass);
|
dns_zone_setclass(zone, view->rdclass);
|
||||||
@@ -6793,8 +6793,8 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
|
|||||||
if (inline_signing) {
|
if (inline_signing) {
|
||||||
dns_zone_getraw(zone, &raw);
|
dns_zone_getraw(zone, &raw);
|
||||||
if (raw == NULL) {
|
if (raw == NULL) {
|
||||||
CHECK(dns_zone_create(&raw, dns_zone_getmem(zone),
|
dns_zone_create(&raw, dns_zone_getmem(zone),
|
||||||
dns_zone_gettid(zone)));
|
dns_zone_gettid(zone));
|
||||||
CHECK(dns_zone_setorigin(raw, origin));
|
CHECK(dns_zone_setorigin(raw, origin));
|
||||||
dns_zone_setview(raw, view);
|
dns_zone_setview(raw, view);
|
||||||
dns_zone_setstats(raw, named_g_server->zonestats);
|
dns_zone_setstats(raw, named_g_server->zonestats);
|
||||||
|
@@ -66,12 +66,8 @@ create_zone(sample_instance_t *const inst, dns_name_t *const name,
|
|||||||
|
|
||||||
zone_argv[0] = inst->db_name;
|
zone_argv[0] = inst->db_name;
|
||||||
|
|
||||||
result = dns_zone_create(&raw, inst->mctx, 0); /* FIXME */
|
dns_zone_create(&raw, inst->mctx, 0); /* FIXME: all zones are assigned
|
||||||
if (result != ISC_R_SUCCESS) {
|
to loop 0 */
|
||||||
log_write(ISC_LOG_ERROR, "create_zone: dns_zone_create -> %s\n",
|
|
||||||
isc_result_totext(result));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
result = dns_zone_setorigin(raw, name);
|
result = dns_zone_setorigin(raw, name);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
log_write(ISC_LOG_ERROR,
|
log_write(ISC_LOG_ERROR,
|
||||||
|
@@ -274,12 +274,7 @@ LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_zone_create(&zone, mctx, 0);
|
dns_zone_create(&zone, mctx, 0);
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
fprintf(stderr, "dns_zone_create failed: %s\n",
|
|
||||||
isc_result_totext(result));
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
result = dns_zone_setorigin(zone, name);
|
result = dns_zone_setorigin(zone, name);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
@@ -450,10 +450,7 @@ dns_dlz_writeablezone(dns_view_t *view, dns_dlzdb_t *dlzdb,
|
|||||||
INSIST(dupzone == NULL);
|
INSIST(dupzone == NULL);
|
||||||
|
|
||||||
/* Create it */
|
/* Create it */
|
||||||
result = dns_zone_create(&zone, view->mctx, 0);
|
dns_zone_create(&zone, view->mctx, 0);
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
result = dns_zone_setorigin(zone, origin);
|
result = dns_zone_setorigin(zone, origin);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@@ -149,7 +149,7 @@ ISC_LANG_BEGINDECLS
|
|||||||
*** Functions
|
*** Functions
|
||||||
***/
|
***/
|
||||||
|
|
||||||
isc_result_t
|
void
|
||||||
dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid);
|
dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid);
|
||||||
/*%<
|
/*%<
|
||||||
* Creates a new empty zone and attach '*zonep' to it.
|
* Creates a new empty zone and attach '*zonep' to it.
|
||||||
@@ -160,11 +160,6 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid);
|
|||||||
*
|
*
|
||||||
* Ensures:
|
* Ensures:
|
||||||
*\li '*zonep' refers to a valid zone.
|
*\li '*zonep' refers to a valid zone.
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
*\li #ISC_R_SUCCESS
|
|
||||||
*\li #ISC_R_NOMEMORY
|
|
||||||
*\li #ISC_R_UNEXPECTED
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -1080,7 +1080,7 @@ inc_stats(dns_zone_t *zone, isc_statscounter_t counter) {
|
|||||||
*** Public functions.
|
*** Public functions.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
isc_result_t
|
void
|
||||||
dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid) {
|
dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid) {
|
||||||
isc_time_t now;
|
isc_time_t now;
|
||||||
dns_zone_t *zone = NULL;
|
dns_zone_t *zone = NULL;
|
||||||
@@ -1165,7 +1165,6 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid) {
|
|||||||
dns_zone_setdbtype(zone, dbargc_default, dbargv_default);
|
dns_zone_setdbtype(zone, dbargc_default, dbargv_default);
|
||||||
|
|
||||||
*zonep = zone;
|
*zonep = zone;
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -18242,7 +18241,6 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *netmgr,
|
|||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_zonemgr_createzone(dns_zonemgr_t *zmgr, dns_zone_t **zonep) {
|
dns_zonemgr_createzone(dns_zonemgr_t *zmgr, dns_zone_t **zonep) {
|
||||||
isc_result_t result;
|
|
||||||
isc_mem_t *mctx = NULL;
|
isc_mem_t *mctx = NULL;
|
||||||
dns_zone_t *zone = NULL;
|
dns_zone_t *zone = NULL;
|
||||||
unsigned int tid;
|
unsigned int tid;
|
||||||
@@ -18261,13 +18259,11 @@ dns_zonemgr_createzone(dns_zonemgr_t *zmgr, dns_zone_t **zonep) {
|
|||||||
return (ISC_R_FAILURE);
|
return (ISC_R_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_zone_create(&zone, mctx, tid);
|
dns_zone_create(&zone, mctx, tid);
|
||||||
|
|
||||||
if (result == ISC_R_SUCCESS) {
|
*zonep = zone;
|
||||||
*zonep = zone;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (result);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
|
@@ -104,10 +104,7 @@ dns_test_makezone(const char *name, dns_zone_t **zonep, dns_view_t *view,
|
|||||||
/*
|
/*
|
||||||
* Create the zone structure.
|
* Create the zone structure.
|
||||||
*/
|
*/
|
||||||
result = dns_zone_create(&zone, mctx, 0);
|
dns_zone_create(&zone, mctx, 0);
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set zone type and origin.
|
* Set zone type and origin.
|
||||||
|
Reference in New Issue
Block a user