]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Refactor the isc_buffer_allocate() usage using the semantic patch
authorOndřej Surý <ondrej@isc.org>
Sun, 2 Feb 2020 07:35:46 +0000 (08:35 +0100)
committerOndřej Surý <ondrej@isc.org>
Mon, 3 Feb 2020 07:29:00 +0000 (08:29 +0100)
The isc_buffer_allocate() function now cannot fail with ISC_R_MEMORY.
This commit removes all the checks on the return code using the semantic
patch from previous commit, as isc_buffer_allocate() now returns void.

41 files changed:
bin/dig/dig.c
bin/dig/dighost.c
bin/dig/host.c
bin/dig/nslookup.c
bin/dnssec/dnssec-cds.c
bin/dnssec/dnssec-signzone.c
bin/named/controlconf.c
bin/named/server.c
bin/nsupdate/nsupdate.c
bin/rndc/rndc.c
bin/tests/wire_test.c
bin/tools/mdig.c
lib/dns/catz.c
lib/dns/client.c
lib/dns/dnssec.c
lib/dns/dst_api.c
lib/dns/gssapi_link.c
lib/dns/gssapictx.c
lib/dns/keytable.c
lib/dns/message.c
lib/dns/nta.c
lib/dns/openssleddsa_link.c
lib/dns/pkcs11eddsa_link.c
lib/dns/rbtdb.c
lib/dns/rdata.c
lib/dns/request.c
lib/dns/sdb.c
lib/dns/sdlz.c
lib/dns/tests/dnstest.c
lib/dns/tests/tsig_test.c
lib/dns/tkey.c
lib/dns/tsig.c
lib/dns/zone.c
lib/irs/dnsconf.c
lib/isc/buffer.c
lib/isc/lex.c
lib/isc/tests/buffer_test.c
lib/ns/client.c
lib/ns/query.c
lib/samples/sample-request.c
lib/samples/sample-update.c

index 4bc848a4c642217240952789329fd11d7483da0d..008a67923ace36f72d9a151177180a829a33bd02 100644 (file)
@@ -568,8 +568,7 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
        if (!query->lookup->comments)
                flags |= DNS_MESSAGETEXTFLAG_NOCOMMENTS;
 
-       result = isc_buffer_allocate(mctx, &buf, len);
-       check_result(result, "isc_buffer_allocate");
+       isc_buffer_allocate(mctx, &buf, len);
 
        if (yaml) {
                enum { Q = 0x1, R = 0x2 }; /* Q:query; R:ecursive */
@@ -742,11 +741,8 @@ repopulate_buffer:
 buftoosmall:
                        len += OUTPUTBUF;
                        isc_buffer_free(&buf);
-                       result = isc_buffer_allocate(mctx, &buf, len);
-                       if (result == ISC_R_SUCCESS)
-                               goto repopulate_buffer;
-                       else
-                               goto cleanup;
+                       isc_buffer_allocate(mctx, &buf, len);
+                       goto repopulate_buffer;
                }
                check_result(result,
                     "dns_message_pseudosectiontotext");
@@ -827,7 +823,6 @@ buftoosmall:
               (char *)isc_buffer_base(buf));
        isc_buffer_free(&buf);
 
-cleanup:
        if (style != NULL)
                dns_master_styledestroy(&style, mctx);
        return (result);
index c92ea2903a05b2f6393e3d151cb8473fd573c409..cc11f5dd1db7bd8a00d155529e19cd82a9405fb2 100644 (file)
@@ -883,10 +883,8 @@ setup_text_key(void) {
        unsigned char *secretstore;
 
        debug("setup_text_key()");
-       result = isc_buffer_allocate(mctx, &namebuf, MXNAME);
-       check_result(result, "isc_buffer_allocate");
+       isc_buffer_allocate(mctx, &namebuf, MXNAME);
        dns_name_init(&keyname, NULL);
-       check_result(result, "dns_name_init");
        isc_buffer_putstr(namebuf, keynametext);
        secretsize = (unsigned int) strlen(keysecret) * 3 / 4;
        secretstore = isc_mem_allocate(mctx, secretsize);
index fa36e45326a920decf50c720fc82b75be3764f3f..53a3a5fc8b27bf673b4a3931165e79a0152b3e21 100644 (file)
@@ -199,8 +199,7 @@ say_message(dns_name_t *name, const char *msg, dns_rdata_t *rdata,
 
        dns_name_format(name, namestr, sizeof(namestr));
  retry:
-       result = isc_buffer_allocate(mctx, &b, bufsize);
-       check_result(result, "isc_buffer_allocate");
+       isc_buffer_allocate(mctx, &b, bufsize);
        result = dns_rdata_totext(rdata, NULL, b);
        if (result == ISC_R_NOSPACE) {
                isc_buffer_free(&b);
index dee833c671f370060639710fcb6f74a42ffddf79..eb81658b27ddb71567436d21b703d4c704a3e8e4 100644 (file)
@@ -221,9 +221,7 @@ printrdata(dns_rdata_t *rdata) {
                printf("rdata_%d = ", rdata->type);
 
        while (!done) {
-               result = isc_buffer_allocate(mctx, &b, size);
-               if (result != ISC_R_SUCCESS)
-                       check_result(result, "isc_buffer_allocate");
+               isc_buffer_allocate(mctx, &b, size);
                result = dns_rdata_totext(rdata, NULL, b);
                if (result == ISC_R_SUCCESS) {
                        printf("%.*s\n", (int)isc_buffer_usedlength(b),
index 8796bc078af41c55241b5fc2fc15f72c9cfe0869..283e754cdc32d9b95b97cb947bdfca1bbd99f585 100644 (file)
@@ -370,8 +370,7 @@ formatset(dns_rdataset_t *rdataset) {
                                        mctx);
        check_result(result, "dns_master_stylecreate2 failed");
 
-       result = isc_buffer_allocate(mctx, &buf, MAX_CDS_RDATA_TEXT_SIZE);
-       check_result(result, "printing DS records");
+       isc_buffer_allocate(mctx, &buf, MAX_CDS_RDATA_TEXT_SIZE);
        result = dns_master_rdatasettotext(name, rdataset, style, NULL, buf);
 
        if ((result == ISC_R_SUCCESS) && isc_buffer_availablelength(buf) < 1) {
@@ -834,8 +833,7 @@ make_new_ds_set(ds_maker_func_t *ds_from_rdata,
                result = dns_rdatalist_tordataset(dslist, &new_ds_set);
                check_result(result, "dns_rdatalist_tordataset(dslist)");
 
-               result = isc_buffer_allocate(mctx, &new_ds_buf, size);
-               check_result(result, "building new DS records");
+               isc_buffer_allocate(mctx, &new_ds_buf, size);
 
                for (result = dns_rdataset_first(rdset);
                     result == ISC_R_SUCCESS;
index 8008ed7712646599adbf3b5df76ad16aab6c195d..532a71aa94df6478b7fdce05d5ae2123d7a2f9e6 100644 (file)
@@ -226,8 +226,7 @@ dumpnode(dns_name_t *name, dns_dbnode_t *node) {
 
        dns_rdataset_init(&rds);
 
-       result = isc_buffer_allocate(mctx, &buffer, bufsize);
-       check_result(result, "isc_buffer_allocate");
+       isc_buffer_allocate(mctx, &buffer, bufsize);
 
        for (result = dns_rdatasetiter_first(iter);
             result == ISC_R_SUCCESS;
@@ -253,8 +252,7 @@ dumpnode(dns_name_t *name, dns_dbnode_t *node) {
 
                        bufsize <<= 1;
                        isc_buffer_free(&buffer);
-                       result = isc_buffer_allocate(mctx, &buffer, bufsize);
-                       check_result(result, "isc_buffer_allocate");
+                       isc_buffer_allocate(mctx, &buffer, bufsize);
                }
                check_result(result, "dns_master_rdatasettotext");
 
index 1560879bf3bd48fe2de0680748b06426d233595f..f07590652a1c22baf0e88d74ceaa9d7dfc3a9834 100644 (file)
@@ -445,9 +445,7 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
                goto cleanup_request;
        }
 
-       result = isc_buffer_allocate(listener->mctx, &text, 2 * 2048);
-       if (result != ISC_R_SUCCESS)
-               goto cleanup_request;
+       isc_buffer_allocate(listener->mctx, &text, 2 * 2048);
 
        /*
         * Establish nonce.
@@ -493,10 +491,7 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
                goto cleanup_response;
 
        if (conn->buffer == NULL) {
-               result = isc_buffer_allocate(listener->mctx,
-                                            &conn->buffer, 2 * 2048);
-               if (result != ISC_R_SUCCESS)
-                       goto cleanup_response;
+               isc_buffer_allocate(listener->mctx, &conn->buffer, 2 * 2048);
        }
 
        isc_buffer_clear(conn->buffer);
index 14088fb3c6e87acd322005bc76f283a67db56304..f7f0f7dd16af417fcf414f609d79a7fdad3aa95a 100644 (file)
@@ -7694,9 +7694,7 @@ data_to_cfg(dns_view_t *view, MDB_val *key, MDB_val *data,
        REQUIRE(zoneconfig != NULL && *zoneconfig == NULL);
 
        if (*text == NULL) {
-               result = isc_buffer_allocate(view->mctx, text, 256);
-               if (result != ISC_R_SUCCESS)
-                       goto cleanup;
+               isc_buffer_allocate(view->mctx, text, 256);
        } else {
                isc_buffer_clear(*text);
        }
@@ -12394,17 +12392,7 @@ nzd_save(MDB_txn **txnp, MDB_dbi dbi, dns_zone_t *zone,
                /* We're creating or overwriting the zone */
                const cfg_obj_t *zoptions;
 
-               result = isc_buffer_allocate(view->mctx, &text, 256);
-               if (result != ISC_R_SUCCESS) {
-                       isc_log_write(named_g_lctx,
-                                     NAMED_LOGCATEGORY_GENERAL,
-                                     NAMED_LOGMODULE_SERVER,
-                                     ISC_LOG_ERROR,
-                                     "Unable to allocate buffer in "
-                                     "nzd_save(): %s",
-                                     isc_result_totext(result));
-                       goto cleanup;
-               }
+               isc_buffer_allocate(view->mctx, &text, 256);
 
                zoptions = cfg_tuple_get(zconfig, "options");
                if (zoptions == NULL) {
@@ -12429,7 +12417,7 @@ nzd_save(MDB_txn **txnp, MDB_dbi dbi, dns_zone_t *zone,
                                      ISC_LOG_ERROR,
                                      "Error writing zone config to "
                                      "buffer in nzd_save(): %s",
-                                     isc_result_totext(result));
+                                     isc_result_totext(dzarg.result));
                        result = dzarg.result;
                        goto cleanup;
                }
@@ -12761,7 +12749,7 @@ migrate_nzf(dns_view_t *view) {
 
        CHECK(nzd_open(view, 0, &txn, &dbi));
 
-       CHECK(isc_buffer_allocate(view->mctx, &text, 256));
+       isc_buffer_allocate(view->mctx, &text, 256);
 
        for (element = cfg_list_first(zonelist);
             element != NULL;
index 4b4ce5cfad0b0556b8fe575b8368e6430ed4c14b..c431ebe39fb6d5cf1d57d2aaadcdd82b57c826a6 100644 (file)
@@ -1238,8 +1238,7 @@ parse_name(char **cmdlinep, dns_message_t *msg, dns_name_t **namep) {
 
        result = dns_message_gettempname(msg, namep);
        check_result(result, "dns_message_gettempname");
-       result = isc_buffer_allocate(gmctx, &namebuf, DNS_NAME_MAXWIRE);
-       check_result(result, "isc_buffer_allocate");
+       isc_buffer_allocate(gmctx, &namebuf, DNS_NAME_MAXWIRE);
        dns_name_init(*namep, NULL);
        dns_name_setbuffer(*namep, namebuf);
        dns_message_takebuffer(msg, &namebuf);
@@ -1284,16 +1283,14 @@ parse_rdata(char **cmdlinep, dns_rdataclass_t rdataclass,
                isc_buffer_add(&source, strlen(cmdline));
                result = isc_lex_openbuffer(lex, &source);
                check_result(result, "isc_lex_openbuffer");
-               result = isc_buffer_allocate(gmctx, &buf, MAXWIRE);
-               check_result(result, "isc_buffer_allocate");
+               isc_buffer_allocate(gmctx, &buf, MAXWIRE);
                result = dns_rdata_fromtext(NULL, rdataclass, rdatatype, lex,
                                            dns_rootname, 0, gmctx, buf,
                                            &callbacks);
                isc_lex_destroy(&lex);
                if (result == ISC_R_SUCCESS) {
                        isc_buffer_usedregion(buf, &r);
-                       result = isc_buffer_allocate(gmctx, &newbuf, r.length);
-                       check_result(result, "isc_buffer_allocate");
+                       isc_buffer_allocate(gmctx, &newbuf, r.length);
                        isc_buffer_putmem(newbuf, r.base, r.length);
                        isc_buffer_usedregion(newbuf, &r);
                        dns_rdata_fromregion(rdata, rdataclass, rdatatype, &r);
@@ -2041,8 +2038,7 @@ show_message(FILE *stream, dns_message_t *msg, const char *description) {
                }
                if (buf != NULL)
                        isc_buffer_free(&buf);
-               result = isc_buffer_allocate(gmctx, &buf, bufsz);
-               check_result(result, "isc_buffer_allocate");
+               isc_buffer_allocate(gmctx, &buf, bufsz);
                result = dns_message_totext(msg, style, 0, buf);
                bufsz *= 2;
        } while (result == ISC_R_NOSPACE);
index 099592657c2638066fdd5ff99e96b374e8d13442..baa71945801bfea249a77f465fe80cdf91675a40 100644 (file)
@@ -965,8 +965,7 @@ main(int argc, char **argv) {
 
        command = *argv;
 
-       DO("allocate data buffer",
-          isc_buffer_allocate(rndc_mctx, &databuf, 2048));
+       isc_buffer_allocate(rndc_mctx, &databuf, 2048);
 
        /*
         * Convert argc/argv into a space-delimited command string
index 191c4507aa15becfa86798d6b26a9d9671bce21c..963b503c2897e6be3a0a7bbc87258ab0ada6d02c 100644 (file)
@@ -175,8 +175,7 @@ main(int argc, char *argv[]) {
        } else
                f = stdin;
 
-       result = isc_buffer_allocate(mctx, &input, 64 * 1024);
-       RUNTIME_CHECK(result == ISC_R_SUCCESS);
+       isc_buffer_allocate(mctx, &input, 64 * 1024);
 
        if (rawdata) {
                while (fread(&c, 1, 1, f) != 0) {
index c8a2494256bfb0528a5ef66c94041d64078e1189..c72aba65c1d903b297287ce8fcde28b442fa4b8c 100644 (file)
@@ -309,8 +309,7 @@ recvresponse(isc_task_t *task, isc_event_t *event) {
        if (!display_comments)
                flags |= DNS_MESSAGETEXTFLAG_NOCOMMENTS;
 
-       result = isc_buffer_allocate(mctx, &buf, len);
-       CHECK("isc_buffer_allocate", result);
+       isc_buffer_allocate(mctx, &buf, len);
 
        if (yaml) {
                char sockstr[ISC_SOCKADDR_FORMATSIZE];
@@ -416,11 +415,8 @@ repopulate_buffer:
 buftoosmall:
                        len += OUTPUTBUF;
                        isc_buffer_free(&buf);
-                       result = isc_buffer_allocate(mctx, &buf, len);
-                       if (result == ISC_R_SUCCESS)
-                               goto repopulate_buffer;
-                       else
-                               goto cleanup;
+                       isc_buffer_allocate(mctx, &buf, len);
+                       goto repopulate_buffer;
                }
                CHECK("dns_message_pseudosectiontotext", result);
        }
index d171c17481f526fd9967cd75704713799d0077b1..6e245505148b4142b798da9ef166305d31ee29c9 100644 (file)
@@ -1239,10 +1239,8 @@ catz_process_apl(dns_catz_zone_t *zone, isc_buffer_t **aclbp,
        result = dns_rdata_tostruct(&rdata, &rdata_apl, zone->catzs->mctx);
        if (result != ISC_R_SUCCESS)
                return (result);
-       result = isc_buffer_allocate(zone->catzs->mctx, &aclb, 16);
+       isc_buffer_allocate(zone->catzs->mctx, &aclb, 16);
        isc_buffer_setautorealloc(aclb, true);
-       if (result != ISC_R_SUCCESS)
-               goto cleanup;
        for (result = dns_rdata_apl_first(&rdata_apl);
             result == ISC_R_SUCCESS;
             result = dns_rdata_apl_next(&rdata_apl)) {
@@ -1462,12 +1460,9 @@ dns_catz_generate_masterfilename(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
        REQUIRE(entry != NULL);
        REQUIRE(buffer != NULL && *buffer != NULL);
 
-       result = isc_buffer_allocate(zone->catzs->mctx, &tbuf,
-                                    strlen(zone->catzs->view->name) +
-                                    2 * DNS_NAME_FORMATSIZE + 2);
-       if (result != ISC_R_SUCCESS)
-               return (result);
-       INSIST(tbuf != NULL);
+       isc_buffer_allocate(zone->catzs->mctx, &tbuf,
+                           strlen(zone->catzs->view->name) + 2 *
+                           DNS_NAME_FORMATSIZE + 2);
 
        isc_buffer_putstr(tbuf, zone->catzs->view->name);
        isc_buffer_putstr(tbuf, "_");
@@ -1552,11 +1547,7 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
         * The buffer will be reallocated if something won't fit,
         * ISC_BUFFER_INCR seems like a good start.
         */
-       result = isc_buffer_allocate(zone->catzs->mctx, &buffer,
-                                    ISC_BUFFER_INCR);
-       if (result != ISC_R_SUCCESS) {
-               goto cleanup;
-       }
+       isc_buffer_allocate(zone->catzs->mctx, &buffer, ISC_BUFFER_INCR);
 
        isc_buffer_setautorealloc(buffer, true);
        isc_buffer_putstr(buffer, "zone ");
index 54e14ce1110182959fc23869397e83707deb363b..985b6f42c96867f41b90de21b985ec9dfaaa48be 100644 (file)
@@ -2556,9 +2556,7 @@ copy_name(isc_mem_t *mctx, dns_message_t *msg, const dns_name_t *name,
        result = dns_message_gettempname(msg, &newname);
        if (result != ISC_R_SUCCESS)
                return (result);
-       result = isc_buffer_allocate(mctx, &namebuf, DNS_NAME_MAXWIRE);
-       if (result != ISC_R_SUCCESS)
-               goto fail;
+       isc_buffer_allocate(mctx, &namebuf, DNS_NAME_MAXWIRE);
        dns_name_init(newname, NULL);
        dns_name_setbuffer(newname, namebuf);
        dns_message_takebuffer(msg, &namebuf);
@@ -2587,10 +2585,7 @@ copy_name(isc_mem_t *mctx, dns_message_t *msg, const dns_name_t *name,
                                goto fail;
                        dns_rdata_toregion(&rdata, &r);
                        rdatabuf = NULL;
-                       result = isc_buffer_allocate(mctx, &rdatabuf,
-                                                    r.length);
-                       if (result != ISC_R_SUCCESS)
-                               goto fail;
+                       isc_buffer_allocate(mctx, &rdatabuf, r.length);
                        isc_buffer_putmem(rdatabuf, r.base, r.length);
                        isc_buffer_usedregion(rdatabuf, &r);
                        dns_rdata_init(newrdata);
index 9d40ac65277dddda5f982838b5461fe48f925d4a..2bfa47aee7ecc77d235cff5359a8e8ecc5114454 100644 (file)
@@ -257,9 +257,7 @@ dns_dnssec_sign(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
         */
        sig.signature = isc_mem_get(mctx, sig.siglen);
 
-       ret = isc_buffer_allocate(mctx, &databuf, sigsize + 256 + 18);
-       if (ret != ISC_R_SUCCESS)
-               goto cleanup_signature;
+       isc_buffer_allocate(mctx, &databuf, sigsize + 256 + 18);
 
        dns_rdata_init(&tmpsigrdata);
        ret = dns_rdata_fromstruct(&tmpsigrdata, sig.common.rdclass,
@@ -355,7 +353,6 @@ cleanup_context:
        dst_context_destroy(&ctx);
 cleanup_databuf:
        isc_buffer_free(&databuf);
-cleanup_signature:
        isc_mem_put(mctx, sig.signature, sig.siglen);
 
        return (ret);
@@ -997,7 +994,7 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
 
        rdata = NULL;
        RETERR(dns_message_gettemprdata(msg, &rdata));
-       RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 1024));
+       isc_buffer_allocate(msg->mctx, &dynbuf, 1024);
        RETERR(dns_rdata_fromstruct(rdata, dns_rdataclass_any,
                                    dns_rdatatype_sig /* SIG(0) */,
                                    &sig, dynbuf));
index 9ecfe0b18758a7f24a103573d85c11b5baa9a519..14cff047debf26a001d467a49e8e8a0f4c19d32c 100644 (file)
@@ -865,8 +865,8 @@ dst_key_fromgssapi(const dns_name_t *name, gss_ctx_id_t gssctx,
                 * Keep the token for use by external ssu rules. They may need
                 * to examine the PAC in the kerberos ticket.
                 */
-               RETERR(isc_buffer_allocate(key->mctx, &key->key_tkeytoken,
-                      intoken->length));
+               isc_buffer_allocate(key->mctx, &key->key_tkeytoken,
+                                   intoken->length);
                RETERR(isc_buffer_copyregion(key->key_tkeytoken, intoken));
        }
 
index e9bbf4d05c951661d3ecadc5bda6e6e6a75d2a71..5c952cdaf5d6f9d14e9076cbb367c7974f5011f8 100644 (file)
@@ -54,18 +54,12 @@ struct dst_gssapi_signverifyctx {
 static isc_result_t
 gssapi_create_signverify_ctx(dst_key_t *key, dst_context_t *dctx) {
        dst_gssapi_signverifyctx_t *ctx;
-       isc_result_t result;
 
        UNUSED(key);
 
        ctx = isc_mem_get(dctx->mctx, sizeof(dst_gssapi_signverifyctx_t));
        ctx->buffer = NULL;
-       result = isc_buffer_allocate(dctx->mctx, &ctx->buffer,
-                                    INITIAL_BUFFER_SIZE);
-       if (result != ISC_R_SUCCESS) {
-               isc_mem_put(dctx->mctx, ctx, sizeof(dst_gssapi_signverifyctx_t));
-               return (result);
-       }
+       isc_buffer_allocate(dctx->mctx, &ctx->buffer, INITIAL_BUFFER_SIZE);
 
        dctx->ctxdata.gssctx = ctx;
 
@@ -107,9 +101,7 @@ gssapi_adddata(dst_context_t *dctx, const isc_region_t *data) {
 
        length = isc_buffer_length(ctx->buffer) + data->length + BUFFER_EXTRA;
 
-       result = isc_buffer_allocate(dctx->mctx, &newbuffer, length);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       isc_buffer_allocate(dctx->mctx, &newbuffer, length);
 
        isc_buffer_usedregion(ctx->buffer, &r);
        (void)isc_buffer_copyregion(newbuffer, &r);
@@ -276,9 +268,7 @@ gssapi_restore(dst_key_t *key, const char *keystr) {
 
        len = (len / 4) * 3;
 
-       result = isc_buffer_allocate(key->mctx, &b, len);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       isc_buffer_allocate(key->mctx, &b, len);
 
        result = isc_base64_decodestring(keystr, b);
        if (result != ISC_R_SUCCESS) {
index 5085b5fb14a1ad0320140d9f396c3eeb557e537a..e97f697a3ebfc74179eaacfc8884c8c797eb6292 100644 (file)
@@ -752,8 +752,8 @@ dst_gssapi_acceptctx(gss_cred_id_t cred,
        }
 
        if (gouttoken.length > 0U) {
-               RETERR(isc_buffer_allocate(mctx, outtoken,
-                                          (unsigned int)gouttoken.length));
+               isc_buffer_allocate(mctx, outtoken,
+                                   (unsigned int)gouttoken.length);
                GBUFFER_TO_REGION(gouttoken, r);
                RETERR(isc_buffer_copyregion(*outtoken, &r));
                (void)gss_release_buffer(&minor, &gouttoken);
index d6456439dd982eea0a566e6f28b1e02910db1022..42e8e4d2daf321cf257f6b2e4d96b3dfd0088f95 100644 (file)
@@ -592,9 +592,7 @@ dns_keytable_dump(dns_keytable_t *keytable, FILE *fp) {
        REQUIRE(VALID_KEYTABLE(keytable));
        REQUIRE(fp != NULL);
 
-       result = isc_buffer_allocate(keytable->mctx, &text, 4096);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       isc_buffer_allocate(keytable->mctx, &text, 4096);
 
        result = dns_keytable_totext(keytable, &text);
 
index acecc37e1cbf7e78c459e3a7b3b21a5cf7428c20..767db4ce8a3c7c17fcb1a973b6072d96d3f74b7a 100644 (file)
@@ -243,13 +243,10 @@ msgblock_free(isc_mem_t *mctx, dns_msgblock_t *block, unsigned int sizeof_type)
  */
 static inline isc_result_t
 newbuffer(dns_message_t *msg, unsigned int size) {
-       isc_result_t result;
        isc_buffer_t *dynbuf;
 
        dynbuf = NULL;
-       result = isc_buffer_allocate(msg->mctx, &dynbuf, size);
-       if (result != ISC_R_SUCCESS)
-               return (ISC_R_NOMEMORY);
+       isc_buffer_allocate(msg->mctx, &dynbuf, size);
 
        ISC_LIST_APPEND(msg->scratchpad, dynbuf, link);
        return (ISC_R_SUCCESS);
@@ -702,7 +699,6 @@ isc_result_t
 dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp)
 {
        dns_message_t *m;
-       isc_result_t result;
        isc_buffer_t *dynbuf;
        unsigned int i;
 
@@ -755,33 +751,13 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp)
        isc_mempool_setname(m->rdspool, "msg:rdataset");
 
        dynbuf = NULL;
-       result = isc_buffer_allocate(mctx, &dynbuf, SCRATCHPAD_SIZE);
-       if (result != ISC_R_SUCCESS)
-               goto cleanup;
+       isc_buffer_allocate(mctx, &dynbuf, SCRATCHPAD_SIZE);
        ISC_LIST_APPEND(m->scratchpad, dynbuf, link);
 
        m->cctx = NULL;
 
        *msgp = m;
        return (ISC_R_SUCCESS);
-
-       /*
-        * Cleanup for error returns.
-        */
- cleanup:
-       dynbuf = ISC_LIST_HEAD(m->scratchpad);
-       if (dynbuf != NULL) {
-               ISC_LIST_UNLINK(m->scratchpad, dynbuf, link);
-               isc_buffer_free(&dynbuf);
-       }
-       if (m->namepool != NULL)
-               isc_mempool_destroy(&m->namepool);
-       if (m->rdspool != NULL)
-               isc_mempool_destroy(&m->rdspool);
-       m->magic = 0;
-       isc_mem_putanddetach(&mctx, m, sizeof(dns_message_t));
-
-       return (ISC_R_NOMEMORY);
 }
 
 void
@@ -2861,9 +2837,7 @@ dns_message_setquerytsig(dns_message_t *msg, isc_buffer_t *querytsig) {
                goto cleanup;
 
        isc_buffer_usedregion(querytsig, &r);
-       result = isc_buffer_allocate(msg->mctx, &buf, r.length);
-       if (result != ISC_R_SUCCESS)
-               goto cleanup;
+       isc_buffer_allocate(msg->mctx, &buf, r.length);
        isc_buffer_putmem(buf, r.base, r.length);
        isc_buffer_usedregion(buf, &r);
        dns_rdata_init(rdata);
@@ -2908,9 +2882,7 @@ dns_message_getquerytsig(dns_message_t *msg, isc_mem_t *mctx,
        dns_rdataset_current(msg->tsig, &rdata);
        dns_rdata_toregion(&rdata, &r);
 
-       result = isc_buffer_allocate(mctx, querytsig, r.length);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       isc_buffer_allocate(mctx, querytsig, r.length);
        isc_buffer_putmem(*querytsig, r.base, r.length);
        return (ISC_R_SUCCESS);
 }
@@ -3029,9 +3001,7 @@ dns_message_signer(dns_message_t *msg, dns_name_t *signer) {
 
        if (!dns_name_hasbuffer(signer)) {
                isc_buffer_t *dynbuf = NULL;
-               result = isc_buffer_allocate(msg->mctx, &dynbuf, 512);
-               if (result != ISC_R_SUCCESS)
-                       return (result);
+               isc_buffer_allocate(msg->mctx, &dynbuf, 512);
                dns_name_setbuffer(signer, dynbuf);
                dns_message_takebuffer(msg, &dynbuf);
        }
@@ -4475,9 +4445,7 @@ dns_message_buildopt(dns_message_t *message, dns_rdataset_t **rdatasetp,
                        goto cleanup;
                }
 
-               result = isc_buffer_allocate(message->mctx, &buf, len);
-               if (result != ISC_R_SUCCESS)
-                       goto cleanup;
+               isc_buffer_allocate(message->mctx, &buf, len);
 
                for (i = 0; i < count; i++)  {
                        if (ednsopts[i].code == DNS_OPT_PAD &&
index 3058ffcaa86e858302f8e84e9665cab884300d8c..010d8dc3b8fad8df256a64e749745bd6ea9c4bd4 100644 (file)
@@ -568,9 +568,7 @@ dns_ntatable_dump(dns_ntatable_t *ntatable, FILE *fp) {
        isc_buffer_t *text = NULL;
        int len = 4096;
 
-       result = isc_buffer_allocate(ntatable->view->mctx, &text, len);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       isc_buffer_allocate(ntatable->view->mctx, &text, len);
 
        result = dns_ntatable_totext(ntatable, NULL, &text);
 
index 717e9eaa82174cc61c4614313575da3f2046c3e1..a6b28b30077881202b6fdce5d344fe1cad3f76f7 100644 (file)
@@ -273,16 +273,15 @@ static isc_result_t openssleddsa_todns(const dst_key_t *key,
 static isc_result_t
 openssleddsa_createctx(dst_key_t *key, dst_context_t *dctx) {
        isc_buffer_t *buf = NULL;
-       isc_result_t result;
 
        UNUSED(key);
        REQUIRE(dctx->key->key_alg == DST_ALG_ED25519 ||
                dctx->key->key_alg == DST_ALG_ED448);
 
-       result = isc_buffer_allocate(dctx->mctx, &buf, 64);
+       isc_buffer_allocate(dctx->mctx, &buf, 64);
        dctx->ctxdata.generic = buf;
 
-       return (result);
+       return (ISC_R_SUCCESS);
 }
 
 static void
@@ -312,9 +311,7 @@ openssleddsa_adddata(dst_context_t *dctx, const isc_region_t *data) {
                return (ISC_R_SUCCESS);
 
        length = isc_buffer_length(buf) + data->length + 64;
-       result = isc_buffer_allocate(dctx->mctx, &nbuf, length);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       isc_buffer_allocate(dctx->mctx, &nbuf, length);
        isc_buffer_usedregion(buf, &r);
        (void) isc_buffer_copyregion(nbuf, &r);
        (void) isc_buffer_copyregion(nbuf, data);
index 9930e8e8f5ef9dff69cced1cca8cb0b4ac1b5c3a..304f2543785346408d7f91decd471bb6f76baab1 100644 (file)
@@ -108,9 +108,7 @@ pkcs11eddsa_adddata(dst_context_t *dctx, const isc_region_t *data) {
                return (ISC_R_SUCCESS);
 
        length = isc_buffer_length(buf) + data->length + 64;
-       result = isc_buffer_allocate(dctx->mctx, &nbuf, length);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       isc_buffer_allocate(dctx->mctx, &nbuf, length);
        isc_buffer_usedregion(buf, &r);
        (void) isc_buffer_copyregion(nbuf, &r);
        (void) isc_buffer_copyregion(nbuf, data);
index 266e0213dd8ae24506fadd682a0e4871b27d96df..4ab1a1ccb4abde618d7720113d685a5ab58b4cea 100644 (file)
@@ -9884,10 +9884,7 @@ restart:
                dns_rdataset_t *sigrdataset_aaaa = NULL;
                dns_name_t *gluename = dns_fixedname_name(&ge->fixedname);
 
-               result = isc_buffer_allocate(msg->mctx, &buffer, 512);
-               if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
-                       goto no_glue;
-               }
+               isc_buffer_allocate(msg->mctx, &buffer, 512);
 
                result = dns_message_gettempname(msg, &name);
                if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
index 6a21c2fe3cf3a27851bbc6339c6d735c0b24660e..a46c5e33f1654a98c1f002c4b11fdd4e4fc3dc31 100644 (file)
@@ -857,9 +857,7 @@ unknown_fromtext(dns_rdataclass_t rdclass, dns_rdatatype_t type,
                                        false));
        if (token.value.as_ulong > 65535U)
                return (ISC_R_RANGE);
-       result = isc_buffer_allocate(mctx, &buf, token.value.as_ulong);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       isc_buffer_allocate(mctx, &buf, token.value.as_ulong);
 
        if (token.value.as_ulong != 0U) {
                result = isc_hex_tobuffer(lexer, buf,
index 0367c172651abc5eb75e6b56718ae87f2d7a503b..ab1d553eddcc1952850d1d55c2679ab4b25087d0 100644 (file)
@@ -780,10 +780,7 @@ dns_request_createraw(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
        sock = req_getsocket(request);
        INSIST(sock != NULL);
 
-       result = isc_buffer_allocate(mctx, &request->query,
-                                    r.length + (tcp ? 2 : 0));
-       if (result != ISC_R_SUCCESS)
-               goto cleanup;
+       isc_buffer_allocate(mctx, &request->query, r.length + (tcp ? 2 : 0));
        if (tcp)
                isc_buffer_putuint16(request->query, (uint16_t)r.length);
        result = isc_buffer_copyregion(request->query, &r);
@@ -1040,9 +1037,7 @@ req_render(dns_message_t *message, isc_buffer_t **bufferp,
        /*
         * Create buffer able to hold largest possible message.
         */
-       result = isc_buffer_allocate(mctx, &buf1, 65535);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       isc_buffer_allocate(mctx, &buf1, 65535);
 
        result = dns_compress_init(&cctx, -1, mctx);
        if (result != ISC_R_SUCCESS)
@@ -1087,9 +1082,7 @@ req_render(dns_message_t *message, isc_buffer_t **bufferp,
                result = DNS_R_USETCP;
                goto cleanup;
        }
-       result = isc_buffer_allocate(mctx, &buf2, r.length + (tcp ? 2 : 0));
-       if (result != ISC_R_SUCCESS)
-               goto cleanup;
+       isc_buffer_allocate(mctx, &buf2, r.length + (tcp ? 2 : 0));
        if (tcp)
                isc_buffer_putuint16(buf2, (uint16_t)r.length);
        result = isc_buffer_copyregion(buf2, &r);
@@ -1348,10 +1341,7 @@ req_response(isc_task_t *task, isc_event_t *event) {
         * Copy buffer to request.
         */
        isc_buffer_usedregion(&devent->buffer, &r);
-       result = isc_buffer_allocate(request->mctx, &request->answer,
-                                    r.length);
-       if (result != ISC_R_SUCCESS)
-               goto done;
+       isc_buffer_allocate(request->mctx, &request->answer, r.length);
        result = isc_buffer_copyregion(request->answer, &r);
        if (result != ISC_R_SUCCESS)
                isc_buffer_free(&request->answer);
index fa30944450ffa5bd11a7170f830ff3ad0aa114d5..031928322fef9374fd7643d003cee4a2665dffc7 100644 (file)
@@ -273,7 +273,6 @@ dns_sdb_putrdata(dns_sdblookup_t *lookup, dns_rdatatype_t typeval,
        dns_rdatalist_t *rdatalist;
        dns_rdata_t *rdata;
        isc_buffer_t *rdatabuf = NULL;
-       isc_result_t result;
        isc_mem_t *mctx;
        isc_region_t region;
 
@@ -299,9 +298,7 @@ dns_sdb_putrdata(dns_sdblookup_t *lookup, dns_rdatatype_t typeval,
 
        rdata = isc_mem_get(mctx, sizeof(dns_rdata_t));
 
-       result = isc_buffer_allocate(mctx, &rdatabuf, rdlen);
-       if (result != ISC_R_SUCCESS)
-               goto failure;
+       isc_buffer_allocate(mctx, &rdatabuf, rdlen);
        DE_CONST(rdatap, region.base);
        region.length = rdlen;
        isc_buffer_copyregion(rdatabuf, &region);
@@ -311,12 +308,8 @@ dns_sdb_putrdata(dns_sdblookup_t *lookup, dns_rdatatype_t typeval,
                             &region);
        ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
        ISC_LIST_APPEND(lookup->buffers, rdatabuf, link);
-       rdata = NULL;
 
- failure:
-       if (rdata != NULL)
-               isc_mem_put(mctx, rdata, sizeof(dns_rdata_t));
-       return (result);
+       return (ISC_R_SUCCESS);
 }
 
 isc_result_t
index 3fa7f5bc5dc3a0fd4d173d7d8b2ae0327b66623d..f163a9b637cf5b24c658c42528e7524fe7246dd8 100644 (file)
@@ -1076,9 +1076,7 @@ modrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
 
        mctx = sdlz->common.mctx;
 
-       result = isc_buffer_allocate(mctx, &buffer, 1024);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       isc_buffer_allocate(mctx, &buffer, 1024);
 
        result = dns_master_stylecreate(&style, 0, 0, 0, 0, 0, 0, 1,
                                        0xffffffff, mctx);
@@ -1869,9 +1867,7 @@ dns_sdlz_putrr(dns_sdlzlookup_t *lookup, const char *type, dns_ttl_t ttl,
                        goto failure;
 
                rdatabuf = NULL;
-               result = isc_buffer_allocate(mctx, &rdatabuf, size);
-               if (result != ISC_R_SUCCESS)
-                       goto failure;
+               isc_buffer_allocate(mctx, &rdatabuf, size);
 
                result = dns_rdata_fromtext(rdata, rdatalist->rdclass,
                                            rdatalist->type, lex,
index ad525cebe0fa3e9e0e44d5ad810314bf554c7fd8..2d11501cbdf616c3d28f738467a4b460a7b80d66 100644 (file)
@@ -571,8 +571,7 @@ dns_test_namefromstring(const char *namestr, dns_fixedname_t *fname) {
 
        name = dns_fixedname_initname(fname);
 
-       result = isc_buffer_allocate(dt_mctx, &b, length);
-       assert_int_equal(result, ISC_R_SUCCESS);
+       isc_buffer_allocate(dt_mctx, &b, length);
 
        isc_buffer_putmem(b, (const unsigned char *) namestr, length);
        result = dns_name_fromtext(name, b, dns_rootname, 0, NULL);
index ff14d2de421607461ce7d7fa3fc3ffc38792598e..648500a6b8a03b9285b5b31f1a963f8770001287 100644 (file)
@@ -141,7 +141,7 @@ add_tsig(dst_context_t *tsigctx, dns_tsigkey_t *key, isc_buffer_t *target) {
        tsig.siglen = isc_buffer_usedlength(&sigbuf);
        assert_int_equal(sigsize, tsig.siglen);
 
-       CHECK(isc_buffer_allocate(dt_mctx, &dynbuf, 512));
+       isc_buffer_allocate(dt_mctx, &dynbuf, 512);
        CHECK(dns_rdata_fromstruct(&rdata, dns_rdataclass_any,
                                   dns_rdatatype_tsig, &tsig, dynbuf));
        dns_rdatalist_init(&rdatalist);
@@ -312,16 +312,14 @@ tsig_tcp_test(void **state) {
        /*
         * Create request.
         */
-       result = isc_buffer_allocate(dt_mctx, &buf, 65535);
-       assert_int_equal(result, ISC_R_SUCCESS);
+       isc_buffer_allocate(dt_mctx, &buf, 65535);
        render(buf, 0, key, &tsigout, &querytsig, NULL);
        isc_buffer_free(&buf);
 
        /*
         * Create response message 1.
         */
-       result = isc_buffer_allocate(dt_mctx, &buf, 65535);
-       assert_int_equal(result, ISC_R_SUCCESS);
+       isc_buffer_allocate(dt_mctx, &buf, 65535);
        render(buf, DNS_MESSAGEFLAG_QR, key, &querytsig, &tsigout, NULL);
 
        /*
@@ -374,8 +372,7 @@ tsig_tcp_test(void **state) {
        /*
         * Create response message 2.
         */
-       result = isc_buffer_allocate(dt_mctx, &buf, 65535);
-       assert_int_equal(result, ISC_R_SUCCESS);
+       isc_buffer_allocate(dt_mctx, &buf, 65535);
 
        assert_int_equal(result, ISC_R_SUCCESS);
        render(buf, DNS_MESSAGEFLAG_QR, key, &tsigout, &tsigout, outctx);
@@ -421,8 +418,7 @@ tsig_tcp_test(void **state) {
        /*
         * Create response message 3.
         */
-       result = isc_buffer_allocate(dt_mctx, &buf, 65535);
-       assert_int_equal(result, ISC_R_SUCCESS);
+       isc_buffer_allocate(dt_mctx, &buf, 65535);
        render(buf, DNS_MESSAGEFLAG_QR, key, &tsigout, &tsigout, outctx);
 
        result = add_tsig(outctx, key, buf);
index 181daaf73982a973db4a0fad4ac53019c99b4a21..258bce17da2ea7db9f3fc492533e62b6c1db6575 100644 (file)
@@ -164,7 +164,7 @@ add_rdata_to_list(dns_message_t *msg, dns_name_t *name, dns_rdata_t *rdata,
        RETERR(dns_message_gettemprdata(msg, &newrdata));
 
        dns_rdata_toregion(rdata, &r);
-       RETERR(isc_buffer_allocate(msg->mctx, &tmprdatabuf, r.length));
+       isc_buffer_allocate(msg->mctx, &tmprdatabuf, r.length);
        isc_buffer_availableregion(tmprdatabuf, &newr);
        memmove(newr.base, r.base, r.length);
        dns_rdata_fromregion(newrdata, rdata->rdclass, rdata->type, &newr);
@@ -438,7 +438,7 @@ process_dhtkey(dns_message_t *msg, dns_name_t *signer, dns_name_t *name,
        RETERR(add_rdata_to_list(msg, &ourname, &ourkeyrdata, 0, namelist));
 
        RETERR(dst_key_secretsize(tctx->dhkey, &sharedsize));
-       RETERR(isc_buffer_allocate(msg->mctx, &shared, sharedsize));
+       isc_buffer_allocate(msg->mctx, &shared, sharedsize);
 
        result = dst_key_computesecret(pubkey, tctx->dhkey, shared);
        if (result != ISC_R_SUCCESS) {
@@ -940,9 +940,9 @@ buildquery(dns_message_t *msg, const dns_name_t *name,
                                  dns_rdatatype_tkey);
 
        len = 16 + tkey->algorithm.length + tkey->keylen + tkey->otherlen;
-       RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, len));
-       RETERR(isc_buffer_allocate(msg->mctx, &anamebuf, name->length));
-       RETERR(isc_buffer_allocate(msg->mctx, &qnamebuf, name->length));
+       isc_buffer_allocate(msg->mctx, &dynbuf, len);
+       isc_buffer_allocate(msg->mctx, &anamebuf, name->length);
+       isc_buffer_allocate(msg->mctx, &qnamebuf, name->length);
        RETERR(dns_message_gettemprdata(msg, &rdata));
 
        RETERR(dns_rdata_fromstruct(rdata, dns_rdataclass_any,
@@ -1046,7 +1046,7 @@ dns_tkey_builddhquery(dns_message_t *msg, dst_key_t *key,
        RETERR(buildquery(msg, name, &tkey, false));
 
        RETERR(dns_message_gettemprdata(msg, &rdata));
-       RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 1024));
+       isc_buffer_allocate(msg->mctx, &dynbuf, 1024);
        RETERR(dst_key_todns(key, dynbuf));
        isc_buffer_usedregion(dynbuf, &r);
        dns_rdata_fromregion(rdata, dns_rdataclass_any,
@@ -1265,7 +1265,7 @@ dns_tkey_processdhresponse(dns_message_t *qmsg, dns_message_t *rmsg,
                                       rmsg->mctx, &theirkey));
 
        RETERR(dst_key_secretsize(key, &sharedsize));
-       RETERR(isc_buffer_allocate(rmsg->mctx, &shared, sharedsize));
+       isc_buffer_allocate(rmsg->mctx, &shared, sharedsize);
 
        RETERR(dst_key_computesecret(theirkey, key, shared));
 
index 83f76b97dd82096fd138c6f0f9f99285bc302597..c289bc4cb3a8f13b7335966d8d8465ad6ae7a779 100644 (file)
@@ -975,9 +975,7 @@ dns_tsig_sign(dns_message_t *msg) {
        ret = dns_message_gettemprdata(msg, &rdata);
        if (ret != ISC_R_SUCCESS)
                goto cleanup_signature;
-       ret = isc_buffer_allocate(msg->mctx, &dynbuf, 512);
-       if (ret != ISC_R_SUCCESS)
-               goto cleanup_rdata;
+       isc_buffer_allocate(msg->mctx, &dynbuf, 512);
        ret = dns_rdata_fromstruct(rdata, dns_rdataclass_any,
                                   dns_rdatatype_tsig, &tsig, dynbuf);
        if (ret != ISC_R_SUCCESS)
index fe8cc06e9b1e33d8d1dfda9286bf57b0aae01b0d..f55be93ff8b9fdbce1e84a043f7977df227c3619 100644 (file)
@@ -13822,9 +13822,7 @@ notify_createmessage(dns_zone_t *zone, unsigned int flags,
                goto soa_cleanup;
        dns_rdataset_current(&rdataset, &rdata);
        dns_rdata_toregion(&rdata, &r);
-       result = isc_buffer_allocate(zone->mctx, &b, r.length);
-       if (result != ISC_R_SUCCESS)
-               goto soa_cleanup;
+       isc_buffer_allocate(zone->mctx, &b, r.length);
        isc_buffer_putmem(b, r.base, r.length);
        isc_buffer_usedregion(b, &r);
        dns_rdata_init(temprdata);
@@ -16712,9 +16710,7 @@ dns_zone_forwardupdate(dns_zone_t *zone, dns_message_t *msg,
                goto cleanup;
        }
 
-       result = isc_buffer_allocate(zone->mctx, &forward->msgbuf, mr->length);
-       if (result != ISC_R_SUCCESS)
-               goto cleanup;
+       isc_buffer_allocate(zone->mctx, &forward->msgbuf, mr->length);
        result = isc_buffer_copyregion(forward->msgbuf, mr);
        if (result != ISC_R_SUCCESS)
                goto cleanup;
index 1a3e8d19c1738f7028d2e6bb9299985f9e48de97..d98c220b26f512186458791c2305c5a8e7966b45 100644 (file)
@@ -109,11 +109,7 @@ configure_key(isc_mem_t *mctx, const cfg_obj_t *key, irs_dnsconf_t *conf,
                return (result);
        }
        isc_buffer_usedregion(&rrdatabuf, &r);
-       result = isc_buffer_allocate(mctx, &keydatabuf,
-                                    r.length);
-       if (result != ISC_R_SUCCESS) {
-               return (result);
-       }
+       isc_buffer_allocate(mctx, &keydatabuf, r.length);
        result = isc_buffer_copyregion(keydatabuf, &r);
        if (result != ISC_R_SUCCESS) {
                goto cleanup;
index 8489aa55602c6dfaea29eabc2985b32383f41d2d..04b081b025cc013ffee033dacc496014cecb1ea5 100644 (file)
@@ -500,9 +500,7 @@ isc_buffer_dup(isc_mem_t *mctx, isc_buffer_t **dstp, const isc_buffer_t *src) {
 
        isc_buffer_usedregion(src, &region);
 
-       result = isc_buffer_allocate(mctx, &dst, region.length);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       isc_buffer_allocate(mctx, &dst, region.length);
 
        result = isc_buffer_copyregion(dst, &region);
        RUNTIME_CHECK(result == ISC_R_SUCCESS); /* NOSPACE is impossible */
index 902fa5fdd39b355f44caf92c95ecb4375e355187..f8ed95e14fd4c3f29fe209908727bd596ae3cba9 100644 (file)
@@ -181,7 +181,6 @@ new_source(isc_lex_t *lex, bool is_file, bool need_close,
           void *input, const char *name)
 {
        inputsource *source;
-       isc_result_t result;
 
        source = isc_mem_get(lex->mctx, sizeof(*source));
        source->result = ISC_R_SUCCESS;
@@ -192,13 +191,8 @@ new_source(isc_lex_t *lex, bool is_file, bool need_close,
        source->input = input;
        source->name = isc_mem_strdup(lex->mctx, name);
        source->pushback = NULL;
-       result = isc_buffer_allocate(lex->mctx, &source->pushback,
-                                    (unsigned int)lex->max_token);
-       if (result != ISC_R_SUCCESS) {
-               isc_mem_free(lex->mctx, source->name);
-               isc_mem_put(lex->mctx, source, sizeof(*source));
-               return (result);
-       }
+       isc_buffer_allocate(lex->mctx, &source->pushback,
+                           (unsigned int)lex->max_token);
        source->ignored = 0;
        source->line = 1;
        ISC_LIST_INITANDPREPEND(lex->sources, source, link);
@@ -320,9 +314,7 @@ pushandgrow(isc_lex_t *lex, inputsource *source, int c) {
                isc_result_t result;
 
                oldlen = isc_buffer_length(source->pushback);
-               result = isc_buffer_allocate(lex->mctx, &tbuf, oldlen * 2);
-               if (result != ISC_R_SUCCESS)
-                       return (result);
+               isc_buffer_allocate(lex->mctx, &tbuf, oldlen * 2);
                isc_buffer_usedregion(source->pushback, &used);
                result = isc_buffer_copyregion(tbuf, &used);
                INSIST(result == ISC_R_SUCCESS);
index 71b9aa2110242a2cd123992fff7cdb5e43aa242f..b815e3f6e6b2d726aa6f4ee5e3a9aa90726d9b8c 100644 (file)
@@ -65,8 +65,7 @@ isc_buffer_reserve_test(void **state) {
        UNUSED(state);
 
        b = NULL;
-       result = isc_buffer_allocate(test_mctx, &b, 1024);
-       assert_int_equal(result, ISC_R_SUCCESS);
+       isc_buffer_allocate(test_mctx, &b, 1024);
        assert_int_equal(b->length, 1024);
 
        /*
@@ -127,7 +126,6 @@ isc_buffer_reserve_test(void **state) {
 /* dynamic buffer automatic reallocation */
 static void
 isc_buffer_dynamic_test(void **state) {
-       isc_result_t result;
        isc_buffer_t *b;
        size_t last_length = 10;
        int i;
@@ -135,8 +133,7 @@ isc_buffer_dynamic_test(void **state) {
        UNUSED(state);
 
        b = NULL;
-       result = isc_buffer_allocate(test_mctx, &b, last_length);
-       assert_int_equal(result, ISC_R_SUCCESS);
+       isc_buffer_allocate(test_mctx, &b, last_length);
        assert_non_null(b);
        assert_int_equal(b->length, last_length);
 
@@ -194,8 +191,7 @@ isc_buffer_copyregion_test(void **state) {
 
        UNUSED(state);
 
-       result = isc_buffer_allocate(test_mctx, &b, sizeof(data));
-       assert_int_equal(result, ISC_R_SUCCESS);
+       isc_buffer_allocate(test_mctx, &b, sizeof(data));
 
        /*
         * Fill originally allocated buffer space.
@@ -234,8 +230,7 @@ isc_buffer_printf_test(void **state) {
         * Prepare a buffer with auto-reallocation enabled.
         */
        b = NULL;
-       result = isc_buffer_allocate(test_mctx, &b, 0);
-       assert_int_equal(result, ISC_R_SUCCESS);
+       isc_buffer_allocate(test_mctx, &b, 0);
        isc_buffer_setautorealloc(b, true);
 
        /*
index b60db14c80814f4fea8b0c5c40580b9835ab1be7..47664cbdf033435f5e7186e2aa2784a47adcc633 100644 (file)
@@ -2858,17 +2858,11 @@ ns_client_putrdataset(ns_client_t *client, dns_rdataset_t **rdatasetp) {
 isc_result_t
 ns_client_newnamebuf(ns_client_t *client) {
        isc_buffer_t *dbuf;
-       isc_result_t result;
 
        CTRACE("ns_client_newnamebuf");
 
        dbuf = NULL;
-       result = isc_buffer_allocate(client->mctx, &dbuf, 1024);
-       if (result != ISC_R_SUCCESS) {
-               CTRACE("ns_client_newnamebuf: "
-                      "isc_buffer_allocate failed: done");
-               return (result);
-       }
+       isc_buffer_allocate(client->mctx, &dbuf, 1024);
        ISC_LIST_APPEND(client->query.namebufs, dbuf, link);
 
        CTRACE("ns_client_newnamebuf: done");
index f5ddfcb88ee6b8e80d1000f828b528e4559e21e8..112eef00e128ac84c9089cfca8667e1bd113bb72 100644 (file)
@@ -7458,11 +7458,9 @@ query_dns64(query_ctx_t *qctx) {
 
        isc_netaddr_fromsockaddr(&netaddr, &client->peeraddr);
 
-       result = isc_buffer_allocate(client->mctx, &buffer,
-                                    view->dns64cnt * 16 *
-                                    dns_rdataset_count(qctx->rdataset));
-       if (result != ISC_R_SUCCESS)
-               goto cleanup;
+       isc_buffer_allocate(client->mctx, &buffer,
+                           view->dns64cnt * 16 *
+                           dns_rdataset_count(qctx->rdataset));
        result = dns_message_gettemprdataset(client->message,
                                             &dns64_rdataset);
        if (result != ISC_R_SUCCESS)
@@ -7628,10 +7626,8 @@ query_filter64(query_ctx_t *qctx) {
                client->query.attributes &= ~NS_QUERYATTR_SECURE;
        }
 
-       result = isc_buffer_allocate(client->mctx, &buffer,
-                                    16 * dns_rdataset_count(qctx->rdataset));
-       if (result != ISC_R_SUCCESS)
-               goto cleanup;
+       isc_buffer_allocate(client->mctx, &buffer,
+                           16 * dns_rdataset_count(qctx->rdataset));
        result = dns_message_gettemprdataset(client->message, &myrdataset);
        if (result != ISC_R_SUCCESS)
                goto cleanup;
index b053f393222e6488597c637de9ca13a02f88010b..def49766c2be8d6825021dbd36945147646f1d52 100644 (file)
@@ -236,11 +236,7 @@ main(int argc, char *argv[]) {
 
        /* Dump the response */
        outputbuf = NULL;
-       result = isc_buffer_allocate(mctx, &outputbuf, 65535);
-       if (result != ISC_R_SUCCESS) {
-               fprintf(stderr, "failed to allocate a result buffer\n");
-               exit(1);
-       }
+       isc_buffer_allocate(mctx, &outputbuf, 65535);
        for (i = 0; i < DNS_SECTION_MAX; i++) {
                print_section(rmessage, i, outputbuf);
                isc_buffer_clear(outputbuf);
index 9fa50c136db4b89a06a71d50c1beab1961851be3..16484bd184ce2862ce7598c7acc66c89b6952332 100644 (file)
@@ -443,16 +443,14 @@ parse_rdata(isc_mem_t *mctx, char **cmdlinep, dns_rdataclass_t rdataclass,
                isc_buffer_add(&source, strlen(cmdline));
                result = isc_lex_openbuffer(lex, &source);
                check_result(result, "isc_lex_openbuffer");
-               result = isc_buffer_allocate(mctx, &buf, MAXWIRE);
-               check_result(result, "isc_buffer_allocate");
+               isc_buffer_allocate(mctx, &buf, MAXWIRE);
                result = dns_rdata_fromtext(rdata, rdataclass, rdatatype, lex,
                                            dns_rootname, 0, mctx, buf,
                                            &callbacks);
                isc_lex_destroy(&lex);
                if (result == ISC_R_SUCCESS) {
                        isc_buffer_usedregion(buf, &r);
-                       result = isc_buffer_allocate(mctx, &newbuf, r.length);
-                       check_result(result, "isc_buffer_allocate");
+                       isc_buffer_allocate(mctx, &newbuf, r.length);
                        isc_buffer_putmem(newbuf, r.base, r.length);
                        isc_buffer_usedregion(newbuf, &r);
                        dns_rdata_reset(rdata);