Commit 30b85fe4 authored by Mark Andrews's avatar Mark Andrews
Browse files

Merge branch '1969-silence-cppcheck-warnings' into 'main'

Resolve "Silence CPPCHECK warnings"

Closes #1969

See merge request !3741
parents 6d5fde62 abe2c84b
Pipeline #45213 passed with stages
in 2 minutes and 58 seconds
......@@ -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);
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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));
......
......@@ -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".
......
......@@ -232,15 +232,16 @@ 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 +252,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;
}
......
......@@ -1365,7 +1365,9 @@ process_ecs(ns_client_t *client, isc_buffer_t *buf, size_t optlen) {
if ((addrlen % 8) != 0) {
uint8_t bits = ~0U << (8 - (addrlen % 8));
/* cppcheck-suppress objectIndex */
bits &= paddr[addrbytes - 1];
/* cppcheck-suppress objectIndex */
if (bits != paddr[addrbytes - 1]) {
return (DNS_R_OPTERR);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment