Commit d72952cf authored by Mark Andrews's avatar Mark Andrews

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

(cherry picked from commit f9f3f20d)
parent 68d7ff13
4739. [cleanup] Address clang static analysis warnings. [RT #45952]
4738. [port] win32: strftime mishandles %Z. [RT #46039]
4737. [cleanup] Address Coverity warnings. [RT #46012]
......
......@@ -1110,7 +1110,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;
}
......
......@@ -340,6 +340,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);
......@@ -471,6 +473,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);
}
......@@ -670,6 +674,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);
......@@ -9085,6 +9091,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");
/*
......
......@@ -7158,7 +7158,6 @@ load_configuration(const char *filename, ns_server_t *server,
/*
* Parse the configuration file using the new config code.
*/
result = ISC_R_FAILURE;
config = NULL;
/*
......@@ -11340,6 +11339,7 @@ nzd_env_reopen(dns_view_t *view) {
view->new_zone_dbenv = env;
env = NULL;
result = ISC_R_SUCCESS;
cleanup:
if (env != 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);
......
......@@ -8532,6 +8532,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.
......
......@@ -2111,6 +2111,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 */
......@@ -2129,7 +2130,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.
*/
......@@ -2491,7 +2492,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);
......@@ -2520,7 +2521,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,
......@@ -2549,7 +2550,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);
}
......@@ -2587,8 +2588,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);
......
......@@ -64,14 +64,15 @@ add_tsig(dst_context_t *tsigctx, dns_tsigkey_t *key, isc_buffer_t *target) {
isc_stdtime_t now;
unsigned char tsigbuf[1024];
unsigned int count;
unsigned int sigsize;
unsigned int sigsize = 0;
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);
......@@ -140,10 +141,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,
......@@ -220,6 +219,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) || \
......
......@@ -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;
......
......@@ -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