]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove error checks in dns_message for mem allocations
authorEvan Hunt <each@isc.org>
Thu, 20 May 2021 00:18:22 +0000 (17:18 -0700)
committerOndřej Surý <ondrej@sury.org>
Fri, 9 Jul 2021 13:58:02 +0000 (15:58 +0200)
Removed error checks for several functions that can no longer fail due
to failed memory allocation.

lib/dns/include/dns/message.h
lib/dns/message.c

index fb114e70ab885af9d81ef7ec9723d801c9e99880..2d15c481c99378763c32dac6acc137f5d9c04b2a 100644 (file)
@@ -899,7 +899,6 @@ dns_message_gettempname(dns_message_t *msg, dns_name_t **item);
  *
  * Returns:
  *\li  #ISC_R_SUCCESS          -- All is well.
- *\li  #ISC_R_NOMEMORY         -- No item can be allocated.
  */
 
 isc_result_t
@@ -916,7 +915,6 @@ dns_message_gettemprdata(dns_message_t *msg, dns_rdata_t **item);
  *
  * Returns:
  *\li  #ISC_R_SUCCESS          -- All is well.
- *\li  #ISC_R_NOMEMORY         -- No item can be allocated.
  */
 
 isc_result_t
@@ -934,7 +932,6 @@ dns_message_gettemprdataset(dns_message_t *msg, dns_rdataset_t **item);
  *
  * Returns:
  *\li  #ISC_R_SUCCESS          -- All is well.
- *\li  #ISC_R_NOMEMORY         -- No item can be allocated.
  */
 
 isc_result_t
@@ -951,7 +948,6 @@ dns_message_gettemprdatalist(dns_message_t *msg, dns_rdatalist_t **item);
  *
  * Returns:
  *\li  #ISC_R_SUCCESS          -- All is well.
- *\li  #ISC_R_NOMEMORY         -- No item can be allocated.
  */
 
 void
index 976f3e78efe5c3cb7fbd0e5e5254d7e891bbd137..ad36e1887ba8dbae952186bbf4205c833269cd2c 100644 (file)
@@ -295,10 +295,6 @@ newrdata(dns_message_t *msg) {
        if (rdata == NULL) {
                msgblock = msgblock_allocate(msg->mctx, sizeof(dns_rdata_t),
                                             RDATA_COUNT);
-               if (msgblock == NULL) {
-                       return (NULL);
-               }
-
                ISC_LIST_APPEND(msg->rdatas, msgblock, link);
 
                rdata = msgblock_get(msgblock, dns_rdata_t);
@@ -329,19 +325,12 @@ newrdatalist(dns_message_t *msg) {
        if (rdatalist == NULL) {
                msgblock = msgblock_allocate(msg->mctx, sizeof(dns_rdatalist_t),
                                             RDATALIST_COUNT);
-               if (msgblock == NULL) {
-                       return (NULL);
-               }
-
                ISC_LIST_APPEND(msg->rdatalists, msgblock, link);
 
                rdatalist = msgblock_get(msgblock, dns_rdatalist_t);
        }
 out:
-       if (rdatalist != NULL) {
-               dns_rdatalist_init(rdatalist);
-       }
-
+       dns_rdatalist_init(rdatalist);
        return (rdatalist);
 }
 
@@ -355,10 +344,6 @@ newoffsets(dns_message_t *msg) {
        if (offsets == NULL) {
                msgblock = msgblock_allocate(msg->mctx, sizeof(dns_offsets_t),
                                             OFFSET_COUNT);
-               if (msgblock == NULL) {
-                       return (NULL);
-               }
-
                ISC_LIST_APPEND(msg->offsets, msgblock, link);
 
                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);
 
        fn = isc_mempool_get(msg->namepool);
-       if (fn == NULL) {
-               return (ISC_R_NOMEMORY);
-       }
        *item = dns_fixedname_initname(fn);
 
        return (ISC_R_SUCCESS);
@@ -2537,10 +2519,6 @@ dns_message_gettemprdata(dns_message_t *msg, dns_rdata_t **item) {
        REQUIRE(item != NULL && *item == NULL);
 
        *item = newrdata(msg);
-       if (*item == NULL) {
-               return (ISC_R_NOMEMORY);
-       }
-
        return (ISC_R_SUCCESS);
 }
 
@@ -2550,7 +2528,6 @@ dns_message_gettemprdataset(dns_message_t *msg, dns_rdataset_t **item) {
        REQUIRE(item != NULL && *item == NULL);
 
        *item = isc_mempool_get(msg->rdspool);
-
        dns_rdataset_init(*item);
        return (ISC_R_SUCCESS);
 }
@@ -2561,10 +2538,6 @@ dns_message_gettemprdatalist(dns_message_t *msg, dns_rdatalist_t **item) {
        REQUIRE(item != NULL && *item == NULL);
 
        *item = newrdatalist(msg);
-       if (*item == NULL) {
-               return (ISC_R_NOMEMORY);
-       }
-
        return (ISC_R_SUCCESS);
 }