]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix cppcheck warnings 1969-fix-cppcheck-warnings
authorMatthijs Mekking <matthijs@isc.org>
Wed, 24 Jun 2020 12:14:29 +0000 (14:14 +0200)
committerMatthijs Mekking <matthijs@isc.org>
Wed, 24 Jun 2020 12:55:18 +0000 (14:55 +0200)
bin/dig/dighost.c
bin/dnssec/dnssec-keyfromlabel.c
bin/dnssec/dnssec-keygen.c
doc/man/dnssec-importkey.1in
lib/dns/update.c
lib/isc/mem.c
lib/isc/radix.c
lib/ns/client.c

index a12ff400192b7dfa19720df579ade8bc60cbc255..7c720ea672a966bbe375ba8a68b95ef05f62f694 100644 (file)
@@ -1494,6 +1494,7 @@ save_opt(dig_lookup_t *lookup, char *code, char *value) {
        if (lookup->ednsopts == NULL) {
                cloneopts(lookup, NULL);
        }
+       INSIST(lookup->ednsopts != NULL);
 
        if (lookup->ednsopts[lookup->ednsoptscnt].value != NULL) {
                isc_mem_free(mctx, lookup->ednsopts[lookup->ednsoptscnt].value);
index dc3b8d242874de7882c4fcb3f8ed0d2610d8fe29..e12169043a86dd4eb13a48226695e3d06dab6331 100644 (file)
@@ -362,6 +362,7 @@ main(int argc, char **argv) {
        setup_logging(mctx, &log);
 
        if (predecessor == NULL) {
+               /* cppcheck-suppress nullPointerRedundantCheck */
                if (label == NULL) {
                        fatal("the key label was not specified");
                }
@@ -383,6 +384,7 @@ main(int argc, char **argv) {
                              isc_result_totext(ret));
                }
 
+               /* cppcheck-suppress nullPointerRedundantCheck */
                if (strchr(label, ':') == NULL) {
                        char *l;
                        int len;
@@ -394,11 +396,13 @@ main(int argc, char **argv) {
                        label = l;
                }
 
+               /* cppcheck-suppress nullPointerRedundantCheck */
                if (algname == NULL) {
                        fatal("no algorithm specified");
                }
 
                r.base = algname;
+               /* cppcheck-suppress nullPointerRedundantCheck */
                r.length = strlen(algname);
                ret = dns_secalg_fromtext(&alg, &r);
                if (ret != ISC_R_SUCCESS) {
index 996b3ac6a62af49045730db95003518c0a9da556..849947f08d96243d2143dcd0719a8fe8c7b0c3f3 100644 (file)
@@ -1180,10 +1180,12 @@ main(int argc, char **argv) {
        }
 
        if (ctx.predecessor == NULL && ctx.policy == NULL) {
+               /* cppcheck-suppress nullPointerRedundantCheck */
                if (algname == NULL) {
                        fatal("no algorithm specified");
                }
                r.base = algname;
+               /* cppcheck-suppress nullPointerRedundantCheck */
                r.length = strlen(algname);
                ret = dns_secalg_fromtext(&ctx.alg, &r);
                if (ret != ISC_R_SUCCESS) {
index cc941ac00f67b5ed6cf5f23f75919261a63a5b5e..78a094684aa701620de75d9082101bfe75e0fba5 100644 (file)
@@ -39,7 +39,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
 .sp
 \fBdnssec\-importkey\fP reads a public DNSKEY record and generates a pair
 of .key/.private files. The DNSKEY record may be read from an existing
-\&.key file, in which case a corresponding .private file will be
+.key file, in which case a corresponding .private file will be
 generated, or it may be read from any other file or from the standard
 input, in which case both .key and .private files will be generated.
 .sp
index 49f177002b5efe672c4413e917675dfe3af62a90..2de3b5bf466632a3daaef2a208bee61dc041cc47 100644 (file)
@@ -2183,7 +2183,7 @@ failure:
                dst_key_free(&state->zone_keys[i]);
        }
 
-       if (state != &mystate && state != NULL) {
+       if (state != &mystate) {
                *statep = NULL;
                state->magic = 0;
                isc_mem_put(diff->mctx, state, sizeof(*state));
index f90c520540b7f27c745091d8e3bb0f8d502e21eb..ba58d02d1566d4dbc3e93ee571421de866f44c9a 100644 (file)
@@ -445,6 +445,7 @@ more_frags(isc__mem_t *ctx, size_t new_size) {
        if (ctx->basic_blocks == NULL) {
                more_basic_blocks(ctx);
        }
+       INSIST(ctx->basic_blocks != NULL);
 
        total_size = ctx->mem_target;
        tmp = ctx->basic_blocks;
@@ -516,6 +517,7 @@ mem_getunlocked(isc__mem_t *ctx, size_t size) {
        if (ctx->freelists[new_size] == NULL) {
                more_frags(ctx, new_size);
        }
+       INSIST(ctx->freelists[new_size] != NULL);
 
        /*
         * The free list uses the "rounded-up" size "new_size".
index 72416a61a5982a32e3d232132012cba51bd51e46..6410e9d74d3af4788bf30dfb3fdae7d1aaef08f9 100644 (file)
@@ -232,15 +232,15 @@ isc_radix_search(isc_radix_tree_t *radix, isc_radix_node_t **target,
 
        *target = NULL;
 
-       if (radix->head == NULL) {
+       node = radix->head;
+       if (node == NULL) {
                return (ISC_R_NOTFOUND);
        }
 
-       node = radix->head;
        addr = isc_prefix_touchar(prefix);
        bitlen = prefix->bitlen;
 
-       while (node->bit < bitlen) {
+       while (node != NULL && node->bit < bitlen) {
                if (node->prefix) {
                        stack[cnt++] = node;
                }
@@ -251,13 +251,9 @@ isc_radix_search(isc_radix_tree_t *radix, isc_radix_node_t **target,
                } else {
                        node = node->l;
                }
-
-               if (node == NULL) {
-                       break;
-               }
        }
 
-       if (node && node->prefix) {
+       if (node != NULL && node->prefix) {
                stack[cnt++] = node;
        }
 
index 00badb4ac5649f77d7cb39395a1a036a0cf1b529..41612224027ad18ef1768a68a9f4df018be1682c 100644 (file)
@@ -1358,7 +1358,7 @@ process_ecs(ns_client_t *client, isc_buffer_t *buf, size_t optlen) {
        }
 
        paddr = (uint8_t *)&caddr.type;
-       if (addrbytes != 0U) {
+       if (addrbytes > 0U) {
                memmove(paddr, isc_buffer_current(buf), addrbytes);
                isc_buffer_forward(buf, addrbytes);
                optlen -= addrbytes;