]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
work around cppcheck false positive
authorMark Andrews <marka@isc.org>
Mon, 28 May 2018 07:26:39 +0000 (17:26 +1000)
committerMark Andrews <marka@isc.org>
Mon, 28 May 2018 23:55:25 +0000 (09:55 +1000)
(cherry picked from commit cb5802e854d11800e8547ad40e19969ca0c5b14d)

lib/dns/master.c

index 13dce9ef578c1409048eada323335fe46de7d130..183cd7b57891bee95dd92d993d5b0376bdb43a31 100644 (file)
@@ -1019,7 +1019,19 @@ check_wildcard(dns_incctx_t *ictx, const char *source, unsigned long line,
        }
 }
 
-static isc_result_t
+static int
+find_free_name(dns_incctx_t *incctx) {
+       int i;
+
+       for (i = 0; i < (NBUFS - 1); i++) {
+               if (!incctx->in_use[i]) {
+                       break;
+               }
+       }
+       INSIST(!incctx->in_use[i]);
+       return (i);
+}
+
 load_text(dns_loadctx_t *lctx) {
        dns_rdataclass_t rdclass;
        dns_rdatatype_t type, covers;
@@ -1388,14 +1400,8 @@ load_text(dns_loadctx_t *lctx) {
 
                        /*
                         * Normal processing resumes.
-                        *
-                        * Find a free name buffer.
                         */
-                       for (new_in_use = 0; new_in_use < NBUFS; new_in_use++)
-                               if (!ictx->in_use[new_in_use])
-                                       break;
-                       INSIST(new_in_use < NBUFS);
-                       dns_fixedname_init(&ictx->fixed[new_in_use]);
+                       new_in_use = find_free_name(ictx);
                        new_name = dns_fixedname_name(&ictx->fixed[new_in_use]);
                        isc_buffer_init(&buffer, token.value.as_region.base,
                                        token.value.as_region.length);
@@ -2081,7 +2087,6 @@ pushfile(const char *master_file, dns_name_t *origin, dns_loadctx_t *lctx) {
        dns_incctx_t *ictx;
        dns_incctx_t *newctx = NULL;
        isc_region_t r;
-       int new_in_use;
 
        REQUIRE(master_file != NULL);
        REQUIRE(DNS_LCTX_VALID(lctx));
@@ -2100,11 +2105,7 @@ pushfile(const char *master_file, dns_name_t *origin, dns_loadctx_t *lctx) {
 
        /* Set current domain. */
        if (ictx->glue != NULL || ictx->current != NULL) {
-               for (new_in_use = 0; new_in_use < NBUFS; new_in_use++)
-                       if (!newctx->in_use[new_in_use])
-                               break;
-               INSIST(new_in_use < NBUFS);
-               newctx->current_in_use = new_in_use;
+               newctx->current_in_use = find_free_name(newctx);
                newctx->current =
                        dns_fixedname_name(&newctx->fixed[newctx->current_in_use]);
                newctx->in_use[newctx->current_in_use] = ISC_TRUE;