2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 15:05:23 +00:00

Remove error checks in dns_message for mem allocations

Removed error checks for several functions that can no longer fail due
to failed memory allocation.
This commit is contained in:
Evan Hunt
2021-05-19 17:18:22 -07:00
committed by Ondřej Surý
parent e754360170
commit 2ce0de6995
2 changed files with 1 additions and 32 deletions

View File

@@ -899,7 +899,6 @@ dns_message_gettempname(dns_message_t *msg, dns_name_t **item);
* *
* Returns: * Returns:
*\li #ISC_R_SUCCESS -- All is well. *\li #ISC_R_SUCCESS -- All is well.
*\li #ISC_R_NOMEMORY -- No item can be allocated.
*/ */
isc_result_t isc_result_t
@@ -916,7 +915,6 @@ dns_message_gettemprdata(dns_message_t *msg, dns_rdata_t **item);
* *
* Returns: * Returns:
*\li #ISC_R_SUCCESS -- All is well. *\li #ISC_R_SUCCESS -- All is well.
*\li #ISC_R_NOMEMORY -- No item can be allocated.
*/ */
isc_result_t isc_result_t
@@ -934,7 +932,6 @@ dns_message_gettemprdataset(dns_message_t *msg, dns_rdataset_t **item);
* *
* Returns: * Returns:
*\li #ISC_R_SUCCESS -- All is well. *\li #ISC_R_SUCCESS -- All is well.
*\li #ISC_R_NOMEMORY -- No item can be allocated.
*/ */
isc_result_t isc_result_t
@@ -951,7 +948,6 @@ dns_message_gettemprdatalist(dns_message_t *msg, dns_rdatalist_t **item);
* *
* Returns: * Returns:
*\li #ISC_R_SUCCESS -- All is well. *\li #ISC_R_SUCCESS -- All is well.
*\li #ISC_R_NOMEMORY -- No item can be allocated.
*/ */
void void

View File

@@ -295,10 +295,6 @@ newrdata(dns_message_t *msg) {
if (rdata == NULL) { if (rdata == NULL) {
msgblock = msgblock_allocate(msg->mctx, sizeof(dns_rdata_t), msgblock = msgblock_allocate(msg->mctx, sizeof(dns_rdata_t),
RDATA_COUNT); RDATA_COUNT);
if (msgblock == NULL) {
return (NULL);
}
ISC_LIST_APPEND(msg->rdatas, msgblock, link); ISC_LIST_APPEND(msg->rdatas, msgblock, link);
rdata = msgblock_get(msgblock, dns_rdata_t); rdata = msgblock_get(msgblock, dns_rdata_t);
@@ -329,19 +325,12 @@ newrdatalist(dns_message_t *msg) {
if (rdatalist == NULL) { if (rdatalist == NULL) {
msgblock = msgblock_allocate(msg->mctx, sizeof(dns_rdatalist_t), msgblock = msgblock_allocate(msg->mctx, sizeof(dns_rdatalist_t),
RDATALIST_COUNT); RDATALIST_COUNT);
if (msgblock == NULL) {
return (NULL);
}
ISC_LIST_APPEND(msg->rdatalists, msgblock, link); ISC_LIST_APPEND(msg->rdatalists, msgblock, link);
rdatalist = msgblock_get(msgblock, dns_rdatalist_t); rdatalist = msgblock_get(msgblock, dns_rdatalist_t);
} }
out: out:
if (rdatalist != NULL) { dns_rdatalist_init(rdatalist);
dns_rdatalist_init(rdatalist);
}
return (rdatalist); return (rdatalist);
} }
@@ -355,10 +344,6 @@ newoffsets(dns_message_t *msg) {
if (offsets == NULL) { if (offsets == NULL) {
msgblock = msgblock_allocate(msg->mctx, sizeof(dns_offsets_t), msgblock = msgblock_allocate(msg->mctx, sizeof(dns_offsets_t),
OFFSET_COUNT); OFFSET_COUNT);
if (msgblock == NULL) {
return (NULL);
}
ISC_LIST_APPEND(msg->offsets, msgblock, link); ISC_LIST_APPEND(msg->offsets, msgblock, link);
offsets = msgblock_get(msgblock, dns_offsets_t); offsets = msgblock_get(msgblock, dns_offsets_t);
@@ -2523,9 +2508,6 @@ dns_message_gettempname(dns_message_t *msg, dns_name_t **item) {
REQUIRE(item != NULL && *item == NULL); REQUIRE(item != NULL && *item == NULL);
fn = isc_mempool_get(msg->namepool); fn = isc_mempool_get(msg->namepool);
if (fn == NULL) {
return (ISC_R_NOMEMORY);
}
*item = dns_fixedname_initname(fn); *item = dns_fixedname_initname(fn);
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
@@ -2537,10 +2519,6 @@ dns_message_gettemprdata(dns_message_t *msg, dns_rdata_t **item) {
REQUIRE(item != NULL && *item == NULL); REQUIRE(item != NULL && *item == NULL);
*item = newrdata(msg); *item = newrdata(msg);
if (*item == NULL) {
return (ISC_R_NOMEMORY);
}
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
@@ -2550,7 +2528,6 @@ dns_message_gettemprdataset(dns_message_t *msg, dns_rdataset_t **item) {
REQUIRE(item != NULL && *item == NULL); REQUIRE(item != NULL && *item == NULL);
*item = isc_mempool_get(msg->rdspool); *item = isc_mempool_get(msg->rdspool);
dns_rdataset_init(*item); dns_rdataset_init(*item);
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
@@ -2561,10 +2538,6 @@ dns_message_gettemprdatalist(dns_message_t *msg, dns_rdatalist_t **item) {
REQUIRE(item != NULL && *item == NULL); REQUIRE(item != NULL && *item == NULL);
*item = newrdatalist(msg); *item = newrdatalist(msg);
if (*item == NULL) {
return (ISC_R_NOMEMORY);
}
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }