Commit f9f3f20d authored by Mark Andrews's avatar Mark Andrews
Browse files

4739. [cleanup] Address clang static analysis warnings. [RT #45952]

parent 744061a0
4739. [cleanup] Address clang static analysis warnings. [RT #45952]
4738. [port] win32: strftime mishandles %Z. [RT #46039]
 
4737. [cleanup] Address Coverity warnings. [RT #46012]
......
......@@ -899,7 +899,6 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) {
if (strcmp(buf, "0") == 0) {
sa->type.sa.sa_family = AF_UNSPEC;
parsed = ISC_TRUE;
prefix_length = 0;
goto done;
}
......
......@@ -7570,7 +7570,6 @@ load_configuration(const char *filename, named_server_t *server,
/*
* Parse the configuration file using the new config code.
*/
result = ISC_R_FAILURE;
config = NULL;
isc_log_write(named_g_lctx,
NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
......@@ -11912,6 +11911,7 @@ nzd_env_reopen(dns_view_t *view) {
view->new_zone_dbenv = env;
env = NULL;
result = ISC_R_SUCCESS;
cleanup:
if (env != NULL) {
......@@ -14548,16 +14548,15 @@ named_server_servestale(named_server_t *server, isc_lex_t *lex,
r.length = strlen(classtxt);
result = dns_rdataclass_fromtext(&rdclass, &r);
if (result != ISC_R_SUCCESS) {
if (viewtxt == NULL) {
viewtxt = classtxt;
classtxt = NULL;
result = ISC_R_SUCCESS;
} else {
if (viewtxt != NULL) {
snprintf(msg, sizeof(msg),
"unknown class '%s'", classtxt);
(void) putstr(text, msg);
goto cleanup;
}
viewtxt = classtxt;
classtxt = NULL;
}
}
......
......@@ -47,6 +47,9 @@ usage(void) {
exit(0);
}
ISC_PLATFORM_NORETURN_PRE static void
fatal(const char *format, ...) ISC_PLATFORM_NORETURN_POST;
static void
fatal(const char *format, ...) {
va_list args;
......
......@@ -121,6 +121,7 @@ isc_result_t
dns_catz_options_copy(isc_mem_t *mctx, const dns_catz_options_t *src,
dns_catz_options_t *dst)
{
REQUIRE(src != NULL);
REQUIRE(dst != NULL);
REQUIRE(dst->masters.count == 0);
REQUIRE(dst->allow_query == NULL);
......
......@@ -8509,6 +8509,7 @@ dns_rbtdb_create
free_rbtdb(rbtdb, ISC_FALSE, NULL);
return (result);
}
INSIST(rbtdb->origin_node != NULL);
rbtdb->origin_node->nsec = DNS_RBT_NSEC_NORMAL;
/*
* We need to give the origin node the right locknum.
......@@ -9949,15 +9950,15 @@ glue_nsdname_cb(void *arg, const dns_name_t *name, dns_rdatatype_t qtype) {
rbtdb_glue_additionaldata_ctx_t *ctx;
isc_result_t result;
dns_fixedname_t fixedname_a;
dns_name_t *name_a;
dns_name_t *name_a = NULL;
dns_rdataset_t rdataset_a, sigrdataset_a;
dns_rbtnode_t *node_a;
dns_rbtnode_t *node_a = NULL;
dns_fixedname_t fixedname_aaaa;
dns_name_t *name_aaaa;
dns_name_t *name_aaaa = NULL;
dns_rdataset_t rdataset_aaaa, sigrdataset_aaaa;
dns_rbtnode_t *node_aaaa;
rbtdb_glue_t *glue;
dns_name_t *gluename;
dns_rbtnode_t *node_aaaa = NULL;
rbtdb_glue_t *glue = NULL;
dns_name_t *gluename = NULL;
/*
* NS records want addresses in additional records.
......@@ -9965,10 +9966,6 @@ glue_nsdname_cb(void *arg, const dns_name_t *name, dns_rdatatype_t qtype) {
INSIST(qtype == dns_rdatatype_a);
ctx = (rbtdb_glue_additionaldata_ctx_t *) arg;
result = ISC_R_FAILURE;
glue = NULL;
node_a = NULL;
node_aaaa = NULL;
dns_fixedname_init(&fixedname_a);
name_a = dns_fixedname_name(&fixedname_a);
......@@ -10078,8 +10075,8 @@ rdataset_addglue(dns_rdataset_t *rdataset,
rbtdb_version_t *rbtversion = version;
isc_uint32_t idx;
rbtdb_glue_table_node_t *cur;
isc_boolean_t found;
isc_boolean_t restarted;
isc_boolean_t found = ISC_FALSE;
isc_boolean_t restarted = ISC_FALSE;
rbtdb_glue_t *ge;
rbtdb_glue_additionaldata_ctx_t ctx;
isc_result_t result;
......@@ -10088,10 +10085,6 @@ rdataset_addglue(dns_rdataset_t *rdataset,
INSIST(rbtdb == rbtversion->rbtdb);
INSIST(!IS_CACHE(rbtdb) && !IS_STUB(rbtdb));
found = ISC_FALSE;
restarted = ISC_FALSE;
result = ISC_R_FAILURE;
/*
* The glue table cache that forms a part of the DB version
* structure is not explicitly bounded and there's no cache
......@@ -10162,7 +10155,6 @@ restart:
result = dns_message_gettemprdataset(msg, &rdataset_a);
if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
dns_message_puttempname(msg, &name);
isc_buffer_free(&buffer);
goto no_glue;
}
}
......@@ -10176,7 +10168,6 @@ restart:
&rdataset_a);
}
dns_message_puttempname(msg, &name);
isc_buffer_free(&buffer);
goto no_glue;
}
}
......@@ -10188,7 +10179,6 @@ restart:
&rdataset_aaaa);
if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
dns_message_puttempname(msg, &name);
isc_buffer_free(&buffer);
if (rdataset_a != NULL) {
dns_message_puttemprdataset(msg,
&rdataset_a);
......@@ -10206,7 +10196,6 @@ restart:
&sigrdataset_aaaa);
if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
dns_message_puttempname(msg, &name);
isc_buffer_free(&buffer);
if (rdataset_a != NULL) {
dns_message_puttemprdataset(msg,
&rdataset_a);
......@@ -10222,25 +10211,25 @@ restart:
}
}
if (ISC_LIKELY(dns_rdataset_isassociated(&ge->rdataset_a))) {
if (ISC_LIKELY(rdataset_a != NULL)) {
dns_rdataset_clone(&ge->rdataset_a, rdataset_a);
ISC_LIST_APPEND(name->list, rdataset_a, link);
}
if (dns_rdataset_isassociated(&ge->sigrdataset_a)) {
if (sigrdataset_a != NULL) {
dns_rdataset_clone(&ge->sigrdataset_a, sigrdataset_a);
ISC_LIST_APPEND(name->list, sigrdataset_a, link);
}
if (ISC_LIKELY((options & DNS_RDATASETADDGLUE_FILTERAAAA) == 0))
{
if (dns_rdataset_isassociated(&ge->rdataset_aaaa)) {
if (rdataset_aaaa != NULL) {
dns_rdataset_clone(&ge->rdataset_aaaa,
rdataset_aaaa);
ISC_LIST_APPEND(name->list, rdataset_aaaa,
link);
}
if (dns_rdataset_isassociated(&ge->sigrdataset_aaaa)) {
if (sigrdataset_aaaa != NULL) {
dns_rdataset_clone(&ge->sigrdataset_aaaa,
sigrdataset_aaaa);
ISC_LIST_APPEND(name->list, sigrdataset_aaaa,
......
......@@ -318,6 +318,7 @@ towiresorted(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
unsigned int headlen;
isc_boolean_t question = ISC_FALSE;
isc_boolean_t shuffle = ISC_FALSE, sort = ISC_FALSE;
isc_boolean_t want_random, want_cyclic;
dns_rdata_t in_fixed[MAX_SHUFFLE];
dns_rdata_t *in = in_fixed;
struct towire_sort out_fixed[MAX_SHUFFLE];
......@@ -338,6 +339,9 @@ towiresorted(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
REQUIRE(countp != NULL);
REQUIRE(cctx != NULL && cctx->mctx != NULL);
want_random = WANT_RANDOM(rdataset);
want_cyclic = WANT_CYCLIC(rdataset);
if ((rdataset->attributes & DNS_RDATASETATTR_QUESTION) != 0) {
question = ISC_TRUE;
count = 1;
......@@ -368,7 +372,7 @@ towiresorted(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
if (order != NULL) {
sort = ISC_TRUE;
}
if (WANT_RANDOM(rdataset) || WANT_CYCLIC(rdataset)) {
if (want_random || want_cyclic) {
shuffle = ISC_TRUE;
}
}
......@@ -398,7 +402,7 @@ towiresorted(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
}
if (shuffle) {
if (WANT_RANDOM(rdataset)) {
if (want_random) {
/*
* 'Random' order.
*/
......@@ -417,7 +421,7 @@ towiresorted(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
out[i].key = 0; /* Unused */
out[i].rdata = &in[i];
}
} else if (WANT_CYCLIC(rdataset)) {
} else if (want_cyclic) {
/*
* 'Cyclic' order.
*/
......
......@@ -2329,6 +2329,7 @@ resquery_send(resquery_t *query) {
isc_boolean_t cleanup_cctx = ISC_FALSE;
isc_boolean_t secure_domain;
isc_boolean_t connecting = ISC_FALSE;
isc_boolean_t tcp = ISC_TF((query->options & DNS_FETCHOPT_TCP) != 0);
dns_ednsopt_t ednsopts[DNS_EDNSOPTIONS];
unsigned ednsopt = 0;
isc_uint16_t hint = 0, udpsize = 0; /* No EDNS */
......@@ -2347,7 +2348,7 @@ resquery_send(resquery_t *query) {
task = res->buckets[fctx->bucketnum].task;
address = NULL;
if ((query->options & DNS_FETCHOPT_TCP) != 0) {
if (tcp) {
/*
* Reserve space for the TCP message length.
*/
......@@ -2612,8 +2613,7 @@ resquery_send(resquery_t *query) {
}
/* Add TCP keepalive option if appropriate */
if ((peer != NULL) &&
(query->options & DNS_FETCHOPT_TCP) != 0)
if ((peer != NULL) && tcp)
(void) dns_peer_gettcpkeepalive(peer,
&tcpkeepalive);
if (tcpkeepalive) {
......@@ -2625,8 +2625,7 @@ resquery_send(resquery_t *query) {
}
/* Add PAD for current peer? Require TCP for now */
if ((peer != NULL) &&
(query->options & DNS_FETCHOPT_TCP) != 0)
if ((peer != NULL) && tcp)
(void) dns_peer_getpadding(peer, &padding);
if (padding != 0) {
INSIST(ednsopt < DNS_EDNSOPTIONS);
......@@ -2738,7 +2737,7 @@ resquery_send(resquery_t *query) {
* If using TCP, write the length of the message at the beginning
* of the buffer.
*/
if ((query->options & DNS_FETCHOPT_TCP) != 0) {
if (tcp) {
isc_buffer_usedregion(&query->buffer, &r);
isc_buffer_putuint16(&tcpbuffer, (isc_uint16_t)r.length);
isc_buffer_add(&tcpbuffer, r.length);
......@@ -2767,7 +2766,7 @@ resquery_send(resquery_t *query) {
/*
* Send the query!
*/
if ((query->options & DNS_FETCHOPT_TCP) == 0) {
if (tcp) {
address = &query->addrinfo->sockaddr;
if (query->exclusivesocket) {
result = isc_socket_connect(sock, address, task,
......@@ -2796,7 +2795,7 @@ resquery_send(resquery_t *query) {
} else {
query->sendevent.attributes |= ISC_SOCKEVENTATTR_DSCP;
query->sendevent.dscp = query->dscp;
if ((query->options & DNS_FETCHOPT_TCP) != 0)
if (tcp)
isc_socket_dscp(sock, query->dscp);
}
......@@ -2834,8 +2833,7 @@ resquery_send(resquery_t *query) {
la = &localaddr;
dns_dt_send(fctx->res->view, dtmsgtype, la, &query->addrinfo->sockaddr,
ISC_TF((query->options & DNS_FETCHOPT_TCP) != 0),
&zr, &query->start, NULL, &query->buffer);
tcp, &zr, &query->start, NULL, &query->buffer);
#endif /* HAVE_DNSTAP */
return (ISC_R_SUCCESS);
......
......@@ -1813,9 +1813,8 @@ finish_update(dns_rpz_zone_t *rpz) {
"too soon, deferring update for "
"%llu seconds", dname, defer);
isc_interval_set(&interval, (unsigned int)defer, 0);
result = isc_timer_reset(rpz->updatetimer,
isc_timertype_once,
NULL, &interval, ISC_TRUE);
isc_timer_reset(rpz->updatetimer, isc_timertype_once,
NULL, &interval, ISC_TRUE);
}
UNLOCK(&rpz->rpzs->maint_lock);
......
......@@ -78,11 +78,12 @@ add_tsig(dst_context_t *tsigctx, dns_tsigkey_t *key, isc_buffer_t *target) {
unsigned int sigsize;
isc_boolean_t invalidate_ctx = ISC_FALSE;
memset(&tsig, 0, sizeof(tsig));
CHECK(dns_compress_init(&cctx, -1, mctx));
invalidate_ctx = ISC_TRUE;
memset(&tsig, 0, sizeof(tsig));
tsig.common.rdclass = dns_rdataclass_any;
tsig.common.rdclass = dns_rdataclass_any;
tsig.common.rdtype = dns_rdatatype_tsig;
ISC_LINK_INIT(&tsig.common, link);
dns_name_init(&tsig.algorithm, NULL);
......@@ -151,10 +152,8 @@ printmessage(dns_message_t *msg) {
do {
buf = isc_mem_get(mctx, len);
if (buf == NULL) {
result = ISC_R_NOMEMORY;
break;
}
if (buf == NULL)
return;
isc_buffer_init(&b, buf, len);
result = dns_message_totext(msg, &dns_master_style_debug,
......@@ -231,6 +230,9 @@ render(isc_buffer_t *buf, unsigned flags, dns_tsigkey_t *key,
isc_buffer_usedregion(buf, &r);
result = dst_context_adddata(tsigctx, &r);
ATF_CHECK_EQ_MSG(result, ISC_R_SUCCESS,
"dst_context_adddata: %s",
dns_result_totext(result));
} else {
if (tsigin == tsigout && *tsigin != NULL)
isc_buffer_free(tsigin);
......
......@@ -42,8 +42,8 @@ isc_error_fatal(const char *, int, const char *, ...)
ISC_FORMAT_PRINTF(3, 4) ISC_PLATFORM_NORETURN_POST;
/*% runtimecheck error */
void
isc_error_runtimecheck(const char *, int, const char *);
ISC_PLATFORM_NORETURN_PRE void
isc_error_runtimecheck(const char *, int, const char *) ISC_PLATFORM_NORETURN_POST;
#define ISC_ERROR_RUNTIMECHECK(cond) \
((void) (ISC_LIKELY(cond) || \
......
......@@ -177,6 +177,7 @@ ATF_TC_BODY(isc_mem_noflags, tc) {
result = isc_stdio_open("mem.output", "r", &f);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
result = isc_stdio_read(buf, sizeof(buf), 1, f, &size);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
isc_stdio_close(f);
isc_file_remove("mem.output");
......@@ -224,6 +225,7 @@ ATF_TC_BODY(isc_mem_recordflag, tc) {
result = isc_stdio_open("mem.output", "r", &f);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
result = isc_stdio_read(buf, sizeof(buf), 1, f, &size);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
isc_stdio_close(f);
isc_file_remove("mem.output");
......@@ -269,6 +271,7 @@ ATF_TC_BODY(isc_mem_traceflag, tc) {
result = isc_stdio_open("mem.output", "r", &f);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
result = isc_stdio_read(buf, sizeof(buf), 1, f, &size);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
isc_stdio_close(f);
isc_file_remove("mem.output");
......
......@@ -307,7 +307,7 @@ cfg_print_tuple(cfg_printer_t *pctx, const cfg_obj_t *obj) {
void
cfg_doc_tuple(cfg_printer_t *pctx, const cfg_type_t *type) {
const cfg_tuplefielddef_t *fields = type->of;
const cfg_tuplefielddef_t *fields;
const cfg_tuplefielddef_t *f;
isc_boolean_t need_space = ISC_FALSE;
......
......@@ -607,6 +607,8 @@ query_freefreeversions(ns_client_t *client, isc_boolean_t everything) {
void
ns_query_cancel(ns_client_t *client) {
REQUIRE(NS_CLIENT_VALID(client));
LOCK(&client->query.fetchlock);
if (client->query.fetch != NULL) {
dns_resolver_cancelfetch(client->query.fetch);
......@@ -739,6 +741,8 @@ query_next_callback(ns_client_t *client) {
void
ns_query_free(ns_client_t *client) {
REQUIRE(NS_CLIENT_VALID(client));
query_reset(client, ISC_TRUE);
}
......@@ -939,6 +943,8 @@ isc_result_t
ns_query_init(ns_client_t *client) {
isc_result_t result;
REQUIRE(NS_CLIENT_VALID(client));
ISC_LIST_INIT(client->query.namebufs);
ISC_LIST_INIT(client->query.activeversions);
ISC_LIST_INIT(client->query.freeversions);
......@@ -1915,7 +1921,6 @@ query_addadditional(void *arg, const dns_name_t *name, dns_rdatatype_t qtype) {
if (sigrdataset != NULL &&
dns_rdataset_isassociated(sigrdataset))
dns_rdataset_disassociate(sigrdataset);
result = ISC_R_NOTFOUND;
} else if (!query_isduplicate(client, fname,
dns_rdatatype_a, &mname)) {
if (mname != fname) {
......@@ -1983,7 +1988,6 @@ query_addadditional(void *arg, const dns_name_t *name, dns_rdatatype_t qtype) {
if (sigrdataset != NULL &&
dns_rdataset_isassociated(sigrdataset))
dns_rdataset_disassociate(sigrdataset);
result = ISC_R_NOTFOUND;
} else if (!query_isduplicate(client, fname,
dns_rdatatype_aaaa, &mname)) {
if (mname != fname) {
......@@ -10207,6 +10211,8 @@ ns_query_start(ns_client_t *client) {
unsigned int saved_extflags = client->extflags;
unsigned int saved_flags = client->message->flags;
REQUIRE(NS_CLIENT_VALID(client));
CTRACE(ISC_LOG_DEBUG(3), "ns_query_start");
/*
......
......@@ -137,12 +137,14 @@ main(int argc, char *argv[]) {
dns_rdata_t *rdata;
dns_namelist_t updatelist, prereqlist, *prereqlistp = NULL;
isc_mem_t *umctx = NULL;
isc_boolean_t sendtwice;
isc_boolean_t sendtwice = ISC_FALSE;
ISC_LIST_INIT(auth_servers);
ISC_LIST_INIT(rec_servers);
while ((ch = isc_commandline_parse(argc, argv, "a:k:p:P:r:sz:")) != EOF) {
while ((ch = isc_commandline_parse(argc, argv,
"a:k:p:P:r:sz:")) != EOF)
{
switch (ch) {
case 'k':
keyfilename = isc_commandline_argument;
......
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