]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Change the return type of isc_lex_create() to void
authorOndřej Surý <ondrej@isc.org>
Wed, 26 Oct 2022 10:35:41 +0000 (12:35 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 26 Oct 2022 10:55:06 +0000 (12:55 +0200)
The isc_lex_create() cannot fail, so cleanup the return type from
isc_result_t to void.

17 files changed:
bin/named/control.c
bin/nsupdate/nsupdate.c
bin/tools/named-rrchecker.c
fuzz/dns_rdata_fromtext.c
fuzz/dns_rdata_fromwire_text.c
fuzz/isc_lex_getmastertoken.c
fuzz/isc_lex_gettoken.c
lib/dns/dst_api.c
lib/dns/master.c
lib/dns/sdb.c
lib/dns/sdlz.c
lib/dns/view.c
lib/isc/include/isc/lex.h
lib/isc/lex.c
lib/isccfg/parser.c
tests/isc/lex_test.c
tests/libtest/dns.c

index 8f2e1f0678172e53d95ca99c8e9fc92eb5614878..7186358793285522e8e4883d72efc3e7df847176 100644 (file)
@@ -97,10 +97,7 @@ named_control_docommand(isccc_sexpr_t *message, bool readonly,
                return (result);
        }
 
-       result = isc_lex_create(named_g_mctx, strlen(cmdline), &lex);
-       if (result != ISC_R_SUCCESS) {
-               return (result);
-       }
+       isc_lex_create(named_g_mctx, strlen(cmdline), &lex);
 
        isc_buffer_init(&src, cmdline, strlen(cmdline));
        isc_buffer_add(&src, strlen(cmdline));
index 205a962eb4ab26ea554d0f95c9343c346da4b633..f939281bf34f93000ff253ff87147de7bd169b59 100644 (file)
@@ -1377,8 +1377,7 @@ parse_rdata(char **cmdlinep, dns_rdataclass_t rdataclass,
 
        if (*cmdline != 0) {
                dns_rdatacallbacks_init(&callbacks);
-               result = isc_lex_create(gmctx, strlen(cmdline), &lex);
-               check_result(result, "isc_lex_create");
+               isc_lex_create(gmctx, strlen(cmdline), &lex);
                isc_buffer_init(&source, cmdline, strlen(cmdline));
                isc_buffer_add(&source, strlen(cmdline));
                result = isc_lex_openbuffer(lex, &source);
index 2ea0ef48e4f246369709d1ab2f8244fc33cbc331..ce4a948343afea9c23c268e85cbd3e5808d1d86c 100644 (file)
@@ -157,7 +157,7 @@ main(int argc, char *argv[]) {
        }
 
        isc_mem_create(&mctx);
-       RUNTIME_CHECK(isc_lex_create(mctx, 256, &lex) == ISC_R_SUCCESS);
+       isc_lex_create(mctx, 256, &lex);
 
        /*
         * Set up to lex DNS master file.
index b52a18f276d6e65959a79889f3699ff1e7d90cea..03ec0935c5a8fbd782349968dc5dd472ebe7ac54 100644 (file)
@@ -69,7 +69,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
        isc_buffer_add(&inbuf, size);
        isc_buffer_setactive(&inbuf, size);
 
-       RUNTIME_CHECK(isc_lex_create(mctx, 256, &lex) == ISC_R_SUCCESS);
+       isc_lex_create(mctx, 256, &lex);
 
        /*
         * Set up to lex DNS master file.
index d42dc543d4f3ec126775871946b78e572e0dbdf4..67f3ce3830bb483640e4dd5728fc62b6723748ba 100644 (file)
@@ -47,7 +47,7 @@ LLVMFuzzerInitialize(int *argc __attribute__((unused)),
        isc_lexspecials_t specials;
 
        isc_mem_create(&mctx);
-       CHECK(isc_lex_create(mctx, 64, &lex));
+       isc_lex_create(mctx, 64, &lex);
 
        memset(specials, 0, sizeof(specials));
        specials[0] = 1;
index 5931e1814fc894a65bfa337a073ff4e37ef5454a..1967bfb4932089dbb3a52fa66432782f0348cd03 100644 (file)
@@ -37,12 +37,8 @@ static isc_lex_t *lex = NULL;
 int
 LLVMFuzzerInitialize(int *argc __attribute__((unused)),
                     char ***argv __attribute__((unused))) {
-       isc_result_t result;
-
        isc_mem_create(&mctx);
-
-       result = isc_lex_create(mctx, 1024, &lex);
-       REQUIRE(result == ISC_R_SUCCESS);
+       isc_lex_create(mctx, 1024, &lex);
 
        return (0);
 }
index c295145e427d5c19eb1df67e8dd7894ec49c26cc..c98d5138e2a6613d2779ab0680ff76a78518cd16 100644 (file)
@@ -29,12 +29,8 @@ static isc_lex_t *lex = NULL;
 int
 LLVMFuzzerInitialize(int *argc __attribute__((unused)),
                     char ***argv __attribute__((unused))) {
-       isc_result_t result;
-
        isc_mem_create(&mctx);
-
-       result = isc_lex_create(mctx, 1024, &lex);
-       REQUIRE(result == ISC_R_SUCCESS);
+       isc_lex_create(mctx, 1024, &lex);
 
        return (0);
 }
index b844a82d58ad01ca71b3c0906462ae2269f5b7ed..14a1c7e4a8c2538de68a5a4f5323dcac092ccecd 100644 (file)
@@ -663,7 +663,7 @@ dst_key_fromnamedfile(const char *filename, const char *dirname, int type,
                           ".private");
        INSIST(result == ISC_R_SUCCESS);
 
-       RETERR(isc_lex_create(mctx, 1500, &lex));
+       isc_lex_create(mctx, 1500, &lex);
        RETERR(isc_lex_openfile(lex, newfilename));
        isc_mem_put(mctx, newfilename, newfilenamelen);
 
@@ -843,7 +843,7 @@ dst_key_privatefrombuffer(dst_key_t *key, isc_buffer_t *buffer) {
                RETERR(DST_R_UNSUPPORTEDALG);
        }
 
-       RETERR(isc_lex_create(key->mctx, 1500, &lex));
+       isc_lex_create(key->mctx, 1500, &lex);
        RETERR(isc_lex_openbuffer(lex, buffer));
        RETERR(key->func->parse(key, lex, NULL));
 out:
@@ -1587,10 +1587,7 @@ dst_key_read_public(const char *filename, int type, isc_mem_t *mctx,
         */
 
        /* 1500 should be large enough for any key */
-       ret = isc_lex_create(mctx, 1500, &lex);
-       if (ret != ISC_R_SUCCESS) {
-               goto cleanup;
-       }
+       isc_lex_create(mctx, 1500, &lex);
 
        memset(specials, 0, sizeof(specials));
        specials['('] = 1;
@@ -1740,10 +1737,7 @@ dst_key_read_state(const char *filename, isc_mem_t *mctx, dst_key_t **keyp) {
        isc_result_t ret;
        unsigned int opt = ISC_LEXOPT_EOL;
 
-       ret = isc_lex_create(mctx, 1500, &lex);
-       if (ret != ISC_R_SUCCESS) {
-               goto cleanup;
-       }
+       isc_lex_create(mctx, 1500, &lex);
        isc_lex_setcomments(lex, ISC_LEXCOMMENT_DNSMASTERFILE);
 
        ret = isc_lex_openfile(lex, filename);
index b433f146c86f5ae4b87f228b0a813145b14df450..8821d3724818a210fe721a022d66a0126f47e735 100644 (file)
@@ -547,10 +547,7 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx, unsigned int options,
                lctx->keep_lex = true;
        } else {
                lctx->lex = NULL;
-               result = isc_lex_create(mctx, TOKENSIZ, &lctx->lex);
-               if (result != ISC_R_SUCCESS) {
-                       goto cleanup_inc;
-               }
+               isc_lex_create(mctx, TOKENSIZ, &lctx->lex);
                lctx->keep_lex = false;
                /*
                 * If specials change update dns_test_rdatafromstring()
@@ -607,8 +604,6 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx, unsigned int options,
        *lctxp = lctx;
        return (ISC_R_SUCCESS);
 
-cleanup_inc:
-       incctx_destroy(mctx, lctx->inc);
 cleanup_ctx:
        isc_mem_put(mctx, lctx, sizeof(*lctx));
        return (result);
index 7399d7a053025b26e09732771e2bb284274b82e7..c5915a7444cc3dd563822ec53bc11d82ae17f1c8 100644 (file)
@@ -351,10 +351,7 @@ dns_sdb_putrr(dns_sdblookup_t *lookup, const char *type, dns_ttl_t ttl,
                origin = dns_rootname;
        }
 
-       result = isc_lex_create(mctx, 64, &lex);
-       if (result != ISC_R_SUCCESS) {
-               goto failure;
-       }
+       isc_lex_create(mctx, 64, &lex);
 
        datalen = strlen(data);
        size = initial_size(datalen);
index a982078ab9cea717ba274fd01ef366b0514fe0e1..26ba3833aa6678f9a210d5c0563338c53477a30c 100644 (file)
@@ -1816,10 +1816,7 @@ dns_sdlz_putrr(dns_sdlzlookup_t *lookup, const char *type, dns_ttl_t ttl,
        }
 
        lex = NULL;
-       result = isc_lex_create(mctx, 64, &lex);
-       if (result != ISC_R_SUCCESS) {
-               goto failure;
-       }
+       isc_lex_create(mctx, 64, &lex);
 
        size = initial_size(data);
        do {
index 22f43f757a1ed6a5d6bafe3d5fa83b0e6fbb1f7c..38fb06a66564b5a447c6da849c071260f99a5cbd 100644 (file)
@@ -2165,7 +2165,7 @@ dns_view_loadnta(dns_view_t *view) {
                return (ISC_R_SUCCESS);
        }
 
-       CHECK(isc_lex_create(view->mctx, 1025, &lex));
+       isc_lex_create(view->mctx, 1025, &lex);
        CHECK(isc_lex_openfile(lex, view->nta_file));
        CHECK(dns_view_getntatable(view, &ntatable));
        isc_stdtime_get(&now);
index 14b29cf94d977fd884c750f9a14e9ff4d9321904..2579ea46476b0a0258f77f29883ffd9402b8a3b4 100644 (file)
@@ -142,7 +142,7 @@ typedef struct isc_token {
  *** Functions
  ***/
 
-isc_result_t
+void
 isc_lex_create(isc_mem_t *mctx, size_t max_token, isc_lex_t **lexp);
 /*%<
  * Create a lexer.
index 63b9b79d343d174c77297dd0bb41c364272ca753..61476808edbb2c36e4bf8fd6123be0e1b20a46d7 100644 (file)
@@ -82,7 +82,7 @@ grow_data(isc_lex_t *lex, size_t *remainingp, char **currp, char **prevp) {
        return (ISC_R_SUCCESS);
 }
 
-isc_result_t
+void
 isc_lex_create(isc_mem_t *mctx, size_t max_token, isc_lex_t **lexp) {
        isc_lex_t *lex;
 
@@ -110,8 +110,6 @@ isc_lex_create(isc_mem_t *mctx, size_t max_token, isc_lex_t **lexp) {
        lex->magic = LEX_MAGIC;
 
        *lexp = lex;
-
-       return (ISC_R_SUCCESS);
 }
 
 void
index e35b4e7f3bd28b9ae4dd80a976000065aeaa5d1f..140bdfc7b31a5e137bb651aec031854c181f2a55 100644 (file)
@@ -530,7 +530,7 @@ cfg_parser_create(isc_mem_t *mctx, isc_log_t *lctx, cfg_parser_t **ret) {
        specials['"'] = 1;
        specials['!'] = 1;
 
-       CHECK(isc_lex_create(pctx->mctx, 1024, &pctx->lexer));
+       isc_lex_create(pctx->mctx, 1024, &pctx->lexer);
 
        isc_lex_setspecials(pctx->lexer, specials);
        isc_lex_setcomments(pctx->lexer,
index 48c7915f5ce283d97feba8956d41dbe6a81cfabe..538e135982035eb2795c662e2dc0e89fbb4d566b 100644 (file)
@@ -42,8 +42,7 @@ ISC_RUN_TEST_IMPL(lex_0xff) {
 
        UNUSED(state);
 
-       result = isc_lex_create(mctx, 1024, &lex);
-       assert_int_equal(result, ISC_R_SUCCESS);
+       isc_lex_create(mctx, 1024, &lex);
 
        isc_buffer_init(&death_buf, &death[0], sizeof(death));
        isc_buffer_add(&death_buf, sizeof(death));
@@ -69,8 +68,7 @@ ISC_RUN_TEST_IMPL(lex_setline) {
 
        UNUSED(state);
 
-       result = isc_lex_create(mctx, 1024, &lex);
-       assert_int_equal(result, ISC_R_SUCCESS);
+       isc_lex_create(mctx, 1024, &lex);
 
        isc_buffer_init(&buf, &text[0], sizeof(text));
        isc_buffer_add(&buf, sizeof(text));
@@ -192,8 +190,7 @@ ISC_RUN_TEST_IMPL(lex_string) {
        UNUSED(state);
 
        for (i = 0; i < ARRAY_SIZE(parse_tests); i++) {
-               result = isc_lex_create(mctx, 1024, &lex);
-               assert_int_equal(result, ISC_R_SUCCESS);
+               isc_lex_create(mctx, 1024, &lex);
 
                isc_buffer_constinit(&buf, parse_tests[i].text,
                                     strlen(parse_tests[i].text));
@@ -246,8 +243,7 @@ ISC_RUN_TEST_IMPL(lex_qstring) {
        UNUSED(state);
 
        for (i = 0; i < ARRAY_SIZE(parse_tests); i++) {
-               result = isc_lex_create(mctx, 1024, &lex);
-               assert_int_equal(result, ISC_R_SUCCESS);
+               isc_lex_create(mctx, 1024, &lex);
 
                isc_buffer_constinit(&buf, parse_tests[i].text,
                                     strlen(parse_tests[i].text));
@@ -301,8 +297,7 @@ ISC_RUN_TEST_IMPL(lex_keypair) {
        UNUSED(state);
 
        for (i = 0; i < ARRAY_SIZE(parse_tests); i++) {
-               result = isc_lex_create(mctx, 1024, &lex);
-               assert_int_equal(result, ISC_R_SUCCESS);
+               isc_lex_create(mctx, 1024, &lex);
 
                isc_buffer_constinit(&buf, parse_tests[i].text,
                                     strlen(parse_tests[i].text));
index ec3dd1e5f9a7dea7fc0c3514f26ad4a9b797d158..c292106ae67172959e50e3c8673e2ea95f2962b3 100644 (file)
@@ -352,10 +352,7 @@ dns_test_rdatafromstring(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
        /*
         * Create a lexer as one is required by dns_rdata_fromtext().
         */
-       result = isc_lex_create(mctx, 64, &lex);
-       if (result != ISC_R_SUCCESS) {
-               return (result);
-       }
+       isc_lex_create(mctx, 64, &lex);
 
        /*
         * Set characters which will be treated as valid multi-line RDATA