diff --git a/src/lib/ares__addrinfo2hostent.c b/src/lib/ares__addrinfo2hostent.c index 3e22bc27..b441e975 100644 --- a/src/lib/ares__addrinfo2hostent.c +++ b/src/lib/ares__addrinfo2hostent.c @@ -195,7 +195,7 @@ enomem: ares_free_hostent(*host); *host = NULL; return ARES_ENOMEM; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } ares_status_t ares__addrinfo2addrttl(const struct ares_addrinfo *ai, int family, diff --git a/src/lib/ares__addrinfo_localhost.c b/src/lib/ares__addrinfo_localhost.c index d0fd1060..8a6cba11 100644 --- a/src/lib/ares__addrinfo_localhost.c +++ b/src/lib/ares__addrinfo_localhost.c @@ -208,7 +208,7 @@ ares_status_t ares__addrinfo_localhost(const char *name, unsigned short port, case AF_INET6: case AF_UNSPEC: break; - default: /* LCOV_EXCL_LINE: DefensiveCoding */ + default: /* LCOV_EXCL_LINE: DefensiveCoding */ return ARES_EBADFAMILY; /* LCOV_EXCL_LINE: DefensiveCoding */ } @@ -233,5 +233,5 @@ enomem: ares_free(ai->name); ai->name = NULL; return ARES_ENOMEM; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } diff --git a/src/lib/ares__buf.c b/src/lib/ares__buf.c index c649e7ee..923a2bef 100644 --- a/src/lib/ares__buf.c +++ b/src/lib/ares__buf.c @@ -1187,24 +1187,24 @@ ares_status_t ares__buf_load_file(const char *filename, ares__buf_t *buf) /* Get length portably, fstat() is POSIX, not C */ if (fseek(fp, 0, SEEK_END) != 0) { status = ARES_EFILE; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } ftell_len = ftell(fp); if (ftell_len < 0) { status = ARES_EFILE; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } len = (size_t)ftell_len; if (fseek(fp, 0, SEEK_SET) != 0) { status = ARES_EFILE; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (len == 0) { status = ARES_SUCCESS; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Read entire data into buffer */ @@ -1212,13 +1212,13 @@ ares_status_t ares__buf_load_file(const char *filename, ares__buf_t *buf) ptr = ares__buf_append_start(buf, &ptr_len); if (ptr == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } ptr_len = fread(ptr, 1, len, fp); if (ptr_len != len) { status = ARES_EFILE; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__buf_append_finish(buf, len); diff --git a/src/lib/ares__hosts_file.c b/src/lib/ares__hosts_file.c index 0f287576..db91b768 100644 --- a/src/lib/ares__hosts_file.c +++ b/src/lib/ares__hosts_file.c @@ -316,7 +316,7 @@ static ares_status_t ares__hosts_file_add(ares_hosts_file_t *hosts, status = ares__hosts_file_merge_entry(hosts, match, entry, matchtype); if (status != ARES_SUCCESS) { ares__hosts_entry_destroy(entry); /* LCOV_EXCL_LINE: DefensiveCoding */ - return status; /* LCOV_EXCL_LINE: DefensiveCoding */ + return status; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* entry was invalidated above by merging */ entry = match; @@ -617,7 +617,8 @@ static ares_bool_t ares__hosts_expired(const char *filename, /* Expire every 60s if we can't get a time */ if (mod_ts == 0) { - mod_ts = time(NULL) - 60; /* LCOV_EXCL_LINE: only on systems without stat() */ + mod_ts = + time(NULL) - 60; /* LCOV_EXCL_LINE: only on systems without stat() */ } /* If filenames are different, its expired */ @@ -779,7 +780,7 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, *hostent = ares_malloc_zero(sizeof(**hostent)); if (*hostent == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } (*hostent)->h_addrtype = (HOSTENT_ADDRTYPE_TYPE)family; @@ -814,7 +815,7 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, (idx + 2) * sizeof(*(*hostent)->h_addr_list)); if (temp == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } (*hostent)->h_addr_list = temp; @@ -822,7 +823,7 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, (*hostent)->h_addr_list[idx] = ares_malloc(ptr_len); if ((*hostent)->h_addr_list[idx] == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } memcpy((*hostent)->h_addr_list[idx], ptr, ptr_len); @@ -840,7 +841,7 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, (*hostent)->h_name = ares_strdup(ares__llist_first_val(entry->hosts)); if ((*hostent)->h_name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Copy aliases */ @@ -856,7 +857,7 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, ares_malloc_zero((naliases + 1) * sizeof(*(*hostent)->h_aliases)); if ((*hostent)->h_aliases == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Copy all entries to the alias except the first */ @@ -867,7 +868,7 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, (*hostent)->h_aliases[idx] = ares_strdup(ares__llist_node_val(node)); if ((*hostent)->h_aliases[idx] == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } idx++; @@ -885,7 +886,7 @@ fail: ares_free_hostent(*hostent); *hostent = NULL; return status; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } static ares_status_t @@ -917,19 +918,19 @@ static ares_status_t cname = ares__append_addrinfo_cname(&cnames); if (cname == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->alias = ares_strdup(host); if (cname->alias == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->name = ares_strdup(primaryhost); if (cname->name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } node = ares__llist_node_next(node); @@ -940,13 +941,13 @@ static ares_status_t cname = ares__append_addrinfo_cname(&cnames); if (cname == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->name = ares_strdup(primaryhost); if (cname->name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } status = ARES_SUCCESS; @@ -954,7 +955,7 @@ static ares_status_t done: if (status != ARES_SUCCESS) { ares__freeaddrinfo_cnames(cnames); /* LCOV_EXCL_LINE: DefensiveCoding */ - return status; /* LCOV_EXCL_LINE: DefensiveCoding */ + return status; /* LCOV_EXCL_LINE: DefensiveCoding */ } *cnames_out = cnames; @@ -977,14 +978,14 @@ ares_status_t ares__hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry, case AF_INET6: case AF_UNSPEC: break; - default: /* LCOV_EXCL_LINE: DefensiveCoding */ + default: /* LCOV_EXCL_LINE: DefensiveCoding */ return ARES_EBADFAMILY; /* LCOV_EXCL_LINE: DefensiveCoding */ } ai->name = ares_strdup(name); if (ai->name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } for (node = ares__llist_node_first(entry->ips); node != NULL; diff --git a/src/lib/ares__htable.c b/src/lib/ares__htable.c index f09c9ea2..2e673fa8 100644 --- a/src/lib/ares__htable.c +++ b/src/lib/ares__htable.c @@ -207,7 +207,7 @@ static ares_bool_t ares__htable_expand(ares__htable_t *htable) * middle, we wouldn't be able to recover. */ buckets = ares_malloc_zero(sizeof(*buckets) * htable->size); if (buckets == NULL) { - goto done; /* LCOV_EXCL_LINE */ + goto done; /* LCOV_EXCL_LINE */ } /* The maximum number of new llists we'll need is the number of collisions @@ -270,7 +270,7 @@ static ares_bool_t ares__htable_expand(ares__htable_t *htable) if (buckets[idx] == NULL) { /* Silence static analysis, this isn't possible but it doesn't know */ if (prealloc_llist == NULL || prealloc_llist_len == 0) { - goto done; /* LCOV_EXCL_LINE */ + goto done; /* LCOV_EXCL_LINE */ } buckets[idx] = prealloc_llist[prealloc_llist_len - 1]; prealloc_llist_len--; @@ -304,7 +304,7 @@ done: /* On failure, we need to restore the htable size */ if (rv != ARES_TRUE) { - htable->size = old_size; /* LCOV_EXCL_LINE */ + htable->size = old_size; /* LCOV_EXCL_LINE */ } return rv; @@ -336,7 +336,7 @@ ares_bool_t ares__htable_insert(ares__htable_t *htable, void *bucket) if (htable->num_keys + 1 > (htable->size * ARES__HTABLE_EXPAND_PERCENT) / 100) { if (!ares__htable_expand(htable)) { - return ARES_FALSE; /* LCOV_EXCL_LINE */ + return ARES_FALSE; /* LCOV_EXCL_LINE */ } /* If we expanded, need to calculate a new index */ idx = HASH_IDX(htable, key); diff --git a/src/lib/ares__htable_asvp.c b/src/lib/ares__htable_asvp.c index 42951712..ce7f05bc 100644 --- a/src/lib/ares__htable_asvp.c +++ b/src/lib/ares__htable_asvp.c @@ -134,7 +134,7 @@ ares_socket_t *ares__htable_asvp_keys(const ares__htable_asvp_t *htable, out = ares_malloc_zero(sizeof(*out) * cnt); if (out == NULL) { ares_free(buckets); /* LCOV_EXCL_LINE: OutOfMemory */ - return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } for (i = 0; i < cnt; i++) { diff --git a/src/lib/ares__htable_vpvp.c b/src/lib/ares__htable_vpvp.c index e0c009a6..f99e1a68 100644 --- a/src/lib/ares__htable_vpvp.c +++ b/src/lib/ares__htable_vpvp.c @@ -114,7 +114,7 @@ fail: ares_free(htable); } return NULL; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } ares_bool_t ares__htable_vpvp_insert(ares__htable_vpvp_t *htable, void *key, diff --git a/src/lib/ares__iface_ips.c b/src/lib/ares__iface_ips.c index 4ec6bfbf..e56e32d2 100644 --- a/src/lib/ares__iface_ips.c +++ b/src/lib/ares__iface_ips.c @@ -92,7 +92,7 @@ static ares__iface_ips_t *ares__iface_ips_alloc(ares__iface_ip_flags_t flags) ips->ips = ares_malloc_zero(ips->alloc_size * sizeof(*ips->ips)); if (ips->ips == NULL) { ares_free(ips); /* LCOV_EXCL_LINE: OutOfMemory */ - return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } ips->enum_flags = flags; return ips; @@ -218,8 +218,8 @@ static ares_status_t /* Add */ idx = ips->cnt++; - ips->ips[idx].flags = flags; - ips->ips[idx].netmask = netmask; + ips->ips[idx].flags = flags; + ips->ips[idx].netmask = netmask; if (flags & ARES_IFACE_IP_LINKLOCAL) { ips->ips[idx].ll_scope = ll_scope; } @@ -529,8 +529,9 @@ static ares_status_t ares__iface_ips_enumerate(ares__iface_ips_t *ips, unsigned int ares__if_nametoindex(const char *name) { #ifdef HAVE_IF_NAMETOINDEX - if (name == NULL) + if (name == NULL) { return 0; + } return if_nametoindex(name); #else ares_status_t status; @@ -538,8 +539,9 @@ unsigned int ares__if_nametoindex(const char *name) size_t i; unsigned int index = 0; - if (name == NULL) + if (name == NULL) { return 0; + } status = ares__iface_ips(&ips, ARES_IFACE_IP_V6 | ARES_IFACE_IP_LINKLOCAL, name); diff --git a/src/lib/ares__parse_into_addrinfo.c b/src/lib/ares__parse_into_addrinfo.c index e886585d..0e540c1a 100644 --- a/src/lib/ares__parse_into_addrinfo.c +++ b/src/lib/ares__parse_into_addrinfo.c @@ -108,18 +108,18 @@ ares_status_t ares__parse_into_addrinfo(const ares_dns_record_t *dnsrec, cname = ares__append_addrinfo_cname(&cnames); if (cname == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->ttl = (int)ares_dns_rr_get_ttl(rr); cname->alias = ares_strdup(ares_dns_rr_get_name(rr)); if (cname->alias == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->name = ares_strdup(hostname); if (cname->name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } else if (rtype == ARES_REC_TYPE_A) { got_a = ARES_TRUE; @@ -154,7 +154,7 @@ ares_status_t ares__parse_into_addrinfo(const ares_dns_record_t *dnsrec, ai->name = ares_strdup(hostname); if (ai->name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/src/lib/ares__slist.c b/src/lib/ares__slist.c index 0c92b552..05b32e8d 100644 --- a/src/lib/ares__slist.c +++ b/src/lib/ares__slist.c @@ -254,7 +254,7 @@ fail: ares_free(node); } return NULL; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } static void ares__slist_node_pop(ares__slist_node_t *node) diff --git a/src/lib/ares__socket.c b/src/lib/ares__socket.c index 7c19574e..e006789b 100644 --- a/src/lib/ares__socket.c +++ b/src/lib/ares__socket.c @@ -305,7 +305,7 @@ ares_status_t ares__open_connection(ares_channel_t *channel, setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (void *)&opt, sizeof(opt)) == -1) { ares__close_socket(channel, s); /* LCOV_EXCL_LINE: UntestablePath */ - return ARES_ECONNREFUSED; /* LCOV_EXCL_LINE: UntestablePath */ + return ARES_ECONNREFUSED; /* LCOV_EXCL_LINE: UntestablePath */ } } #endif @@ -339,7 +339,7 @@ ares_status_t ares__open_connection(ares_channel_t *channel, conn = ares_malloc(sizeof(*conn)); if (conn == NULL) { ares__close_socket(channel, s); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(conn, 0, sizeof(*conn)); conn->fd = s; diff --git a/src/lib/ares__threads.c b/src/lib/ares__threads.c index efa0e09e..e48af409 100644 --- a/src/lib/ares__threads.c +++ b/src/lib/ares__threads.c @@ -227,7 +227,7 @@ ares__thread_mutex_t *ares__thread_mutex_create(void) if (pthread_mutexattr_init(&attr) != 0) { ares_free(mut); /* LCOV_EXCL_LINE: UntestablePath */ - return NULL; /* LCOV_EXCL_LINE: UntestablePath */ + return NULL; /* LCOV_EXCL_LINE: UntestablePath */ } if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) { @@ -246,7 +246,7 @@ fail: pthread_mutexattr_destroy(&attr); ares_free(mut); return NULL; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } void ares__thread_mutex_destroy(ares__thread_mutex_t *mut) @@ -384,7 +384,7 @@ ares_status_t ares__thread_create(ares__thread_t **thread, return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } if (pthread_create(&thr->thread, NULL, func, arg) != 0) { - ares_free(thr); /* LCOV_EXCL_LINE: UntestablePath */ + ares_free(thr); /* LCOV_EXCL_LINE: UntestablePath */ return ARES_ESERVFAIL; /* LCOV_EXCL_LINE: UntestablePath */ } diff --git a/src/lib/ares_cancel.c b/src/lib/ares_cancel.c index 8686c366..581a4186 100644 --- a/src/lib/ares_cancel.c +++ b/src/lib/ares_cancel.c @@ -58,7 +58,7 @@ void ares_cancel(ares_channel_t *channel) * can't report to caller */ if (channel->all_queries == NULL) { channel->all_queries = list_copy; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } node = ares__llist_node_first(list_copy); diff --git a/src/lib/ares_dns_mapping.c b/src/lib/ares_dns_mapping.c index 6c4362f0..738222e3 100644 --- a/src/lib/ares_dns_mapping.c +++ b/src/lib/ares_dns_mapping.c @@ -548,18 +548,14 @@ static const ares_dns_rr_key_t rr_hinfo_keys[] = { ARES_RR_HINFO_CPU, ARES_RR_HINFO_OS }; static const ares_dns_rr_key_t rr_mx_keys[] = { ARES_RR_MX_PREFERENCE, ARES_RR_MX_EXCHANGE }; -static const ares_dns_rr_key_t rr_sig_keys[] = { ARES_RR_SIG_TYPE_COVERED, - ARES_RR_SIG_ALGORITHM, - ARES_RR_SIG_LABELS, - ARES_RR_SIG_ORIGINAL_TTL, - ARES_RR_SIG_EXPIRATION, - ARES_RR_SIG_INCEPTION, - ARES_RR_SIG_KEY_TAG, - ARES_RR_SIG_SIGNERS_NAME, - ARES_RR_SIG_SIGNATURE }; -static const ares_dns_rr_key_t rr_txt_keys[] = { ARES_RR_TXT_DATA }; -static const ares_dns_rr_key_t rr_aaaa_keys[] = { ARES_RR_AAAA_ADDR }; -static const ares_dns_rr_key_t rr_srv_keys[] = { +static const ares_dns_rr_key_t rr_sig_keys[] = { + ARES_RR_SIG_TYPE_COVERED, ARES_RR_SIG_ALGORITHM, ARES_RR_SIG_LABELS, + ARES_RR_SIG_ORIGINAL_TTL, ARES_RR_SIG_EXPIRATION, ARES_RR_SIG_INCEPTION, + ARES_RR_SIG_KEY_TAG, ARES_RR_SIG_SIGNERS_NAME, ARES_RR_SIG_SIGNATURE +}; +static const ares_dns_rr_key_t rr_txt_keys[] = { ARES_RR_TXT_DATA }; +static const ares_dns_rr_key_t rr_aaaa_keys[] = { ARES_RR_AAAA_ADDR }; +static const ares_dns_rr_key_t rr_srv_keys[] = { ARES_RR_SRV_PRIORITY, ARES_RR_SRV_WEIGHT, ARES_RR_SRV_PORT, ARES_RR_SRV_TARGET }; static const ares_dns_rr_key_t rr_naptr_keys[] = { diff --git a/src/lib/ares_dns_name.c b/src/lib/ares_dns_name.c index 754f9fad..0086ca30 100644 --- a/src/lib/ares_dns_name.c +++ b/src/lib/ares_dns_name.c @@ -59,7 +59,7 @@ static ares_status_t ares__nameoffset_create(ares__llist_t **list, } if (*list == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } off = ares_malloc_zero(sizeof(*off)); @@ -73,7 +73,7 @@ static ares_status_t ares__nameoffset_create(ares__llist_t **list, if (ares__llist_insert_last(*list, off) == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_SUCCESS; @@ -82,7 +82,7 @@ static ares_status_t ares__nameoffset_create(ares__llist_t **list, fail: ares__nameoffset_free(off); return status; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } static const ares_nameoffset_t *ares__nameoffset_find(ares__llist_t *list, @@ -269,7 +269,7 @@ static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels, namebuf = ares__buf_create(); if (namebuf == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } if (*name != '\0') { @@ -284,7 +284,7 @@ static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels, label = ares_dns_labels_add(labels); if (label == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } while (ares__buf_fetch_bytes(namebuf, &c, 1) == ARES_SUCCESS) { @@ -293,7 +293,7 @@ static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels, label = ares_dns_labels_add(labels); if (label == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } continue; } @@ -663,7 +663,7 @@ ares_status_t ares__dns_name_parse(ares__buf_t *buf, char **name, *name = ares__buf_finish_str(namebuf, NULL); if (*name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/src/lib/ares_dns_record.c b/src/lib/ares_dns_record.c index 5d109999..2a644534 100644 --- a/src/lib/ares_dns_record.c +++ b/src/lib/ares_dns_record.c @@ -293,7 +293,7 @@ ares_status_t ares_dns_record_query_set_name(ares_dns_record_t *dnsrec, dnsrec->qd[idx].name = ares_strdup(name); if (dnsrec->qd[idx].name == NULL) { dnsrec->qd[idx].name = orig_name; /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } ares_free(orig_name); diff --git a/src/lib/ares_event_configchg.c b/src/lib/ares_event_configchg.c index b7c5ad8c..dfb71690 100644 --- a/src/lib/ares_event_configchg.c +++ b/src/lib/ares_event_configchg.c @@ -149,7 +149,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, c->inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC); if (c->inotify_fd == -1) { status = ARES_ESERVFAIL; /* LCOV_EXCL_LINE: UntestablePath */ - goto done; /* LCOV_EXCL_LINE: UntestablePath */ + goto done; /* LCOV_EXCL_LINE: UntestablePath */ } /* We need to monitor /etc/resolv.conf, /etc/nsswitch.conf */ @@ -157,7 +157,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, IN_CREATE | IN_MODIFY | IN_MOVED_TO | IN_ONLYDIR) == -1) { status = ARES_ESERVFAIL; /* LCOV_EXCL_LINE: UntestablePath */ - goto done; /* LCOV_EXCL_LINE: UntestablePath */ + goto done; /* LCOV_EXCL_LINE: UntestablePath */ } status = @@ -250,32 +250,29 @@ static void ares_event_configchg_ip_cb(PVOID CallerContext, } # endif -static ares_bool_t ares_event_configchg_regnotify(ares_event_configchg_t *configchg) +static ares_bool_t + ares_event_configchg_regnotify(ares_event_configchg_t *configchg) { # if defined(__WATCOMC__) && !defined(REG_NOTIFY_THREAD_AGNOSTIC) # define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000L # endif - DWORD flags = - REG_NOTIFY_CHANGE_NAME|REG_NOTIFY_CHANGE_LAST_SET|REG_NOTIFY_THREAD_AGNOSTIC; + DWORD flags = REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_LAST_SET | + REG_NOTIFY_THREAD_AGNOSTIC; - if (RegNotifyChangeKeyValue(configchg->regip4, TRUE, - flags, - configchg->regip4_event, - TRUE) != ERROR_SUCCESS) { + if (RegNotifyChangeKeyValue(configchg->regip4, TRUE, flags, + configchg->regip4_event, TRUE) != ERROR_SUCCESS) { return ARES_FALSE; } - if (RegNotifyChangeKeyValue(configchg->regip6, TRUE, - flags, - configchg->regip6_event, - TRUE) != ERROR_SUCCESS) { + if (RegNotifyChangeKeyValue(configchg->regip6, TRUE, flags, + configchg->regip6_event, TRUE) != ERROR_SUCCESS) { return ARES_FALSE; } return ARES_TRUE; } -static VOID CALLBACK ares_event_configchg_reg_cb(PVOID lpParameter, +static VOID CALLBACK ares_event_configchg_reg_cb(PVOID lpParameter, BOOLEAN TimerOrWaitFired) { ares_event_configchg_t *configchg = lpParameter; @@ -301,7 +298,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, c->e = e; -#ifndef __WATCOMC__ +# ifndef __WATCOMC__ /* NOTE: If a user goes into the control panel and changes the network * adapter DNS addresses manually, this will NOT trigger a notification. * We've also tried listening on NotifyUnicastIpAddressChange(), but @@ -313,19 +310,21 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, status = ARES_ESERVFAIL; goto done; } -#endif +# endif /* Monitor HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Interfaces * and HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces * for changes via RegNotifyChangeKeyValue() */ - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", - 0, KEY_NOTIFY, &c->regip4) != ERROR_SUCCESS) { + if (RegOpenKeyEx( + HKEY_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", 0, + KEY_NOTIFY, &c->regip4) != ERROR_SUCCESS) { status = ARES_ESERVFAIL; goto done; } - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, + if (RegOpenKeyEx( + HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip6\\Parameters\\Interfaces", 0, KEY_NOTIFY, &c->regip6) != ERROR_SUCCESS) { status = ARES_ESERVFAIL; @@ -345,13 +344,15 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, } if (!RegisterWaitForSingleObject(&c->regip4_wait, c->regip4_event, - ares_event_configchg_reg_cb, c, INFINITE, WT_EXECUTEDEFAULT)) { + ares_event_configchg_reg_cb, c, INFINITE, + WT_EXECUTEDEFAULT)) { status = ARES_ESERVFAIL; goto done; } if (!RegisterWaitForSingleObject(&c->regip6_wait, c->regip6_event, - ares_event_configchg_reg_cb, c, INFINITE, WT_EXECUTEDEFAULT)) { + ares_event_configchg_reg_cb, c, INFINITE, + WT_EXECUTEDEFAULT)) { status = ARES_ESERVFAIL; goto done; } @@ -446,15 +447,16 @@ static void ares_event_configchg_cb(ares_event_thread_t *e, ares_socket_t fd, ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, ares_event_thread_t *e) { - ares_status_t status = ARES_SUCCESS; - void *handle = NULL; - const char *(*pdns_configuration_notify_key)(void) = NULL; - const char *notify_key = NULL; - int flags; - size_t i; - const char *searchlibs[] = { + ares_status_t status = ARES_SUCCESS; + void *handle = NULL; + const char *(*pdns_configuration_notify_key)(void) = NULL; + const char *notify_key = NULL; + int flags; + size_t i; + const char *searchlibs[] = { "/usr/lib/libSystem.dylib", - "/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration", + "/System/Library/Frameworks/SystemConfiguration.framework/" + "SystemConfiguration", NULL }; @@ -464,14 +466,15 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, } /* Load symbol as it isn't normally public */ - for (i=0; searchlibs[i] != NULL; i++) { + for (i = 0; searchlibs[i] != NULL; i++) { handle = dlopen(searchlibs[i], RTLD_LAZY); if (handle == NULL) { /* Fail, loop! */ continue; } - pdns_configuration_notify_key = dlsym(handle, "dns_configuration_notify_key"); + pdns_configuration_notify_key = + dlsym(handle, "dns_configuration_notify_key"); if (pdns_configuration_notify_key != NULL) { break; } diff --git a/src/lib/ares_event_epoll.c b/src/lib/ares_event_epoll.c index a77a0599..1333089a 100644 --- a/src/lib/ares_event_epoll.c +++ b/src/lib/ares_event_epoll.c @@ -76,13 +76,13 @@ static ares_bool_t ares_evsys_epoll_init(ares_event_thread_t *e) ep->epoll_fd = epoll_create1(EPOLL_CLOEXEC); if (ep->epoll_fd == -1) { ares_evsys_epoll_destroy(e); /* LCOV_EXCL_LINE: UntestablePath */ - return ARES_FALSE; /* LCOV_EXCL_LINE: UntestablePath */ + return ARES_FALSE; /* LCOV_EXCL_LINE: UntestablePath */ } e->ev_signal = ares_pipeevent_create(e); if (e->ev_signal == NULL) { ares_evsys_epoll_destroy(e); /* LCOV_EXCL_LINE: UntestablePath */ - return ARES_FALSE; /* LCOV_EXCL_LINE: UntestablePath */ + return ARES_FALSE; /* LCOV_EXCL_LINE: UntestablePath */ } return ARES_TRUE; diff --git a/src/lib/ares_event_thread.c b/src/lib/ares_event_thread.c index 75b9b6e7..4406be2a 100644 --- a/src/lib/ares_event_thread.c +++ b/src/lib/ares_event_thread.c @@ -128,7 +128,7 @@ ares_status_t ares_event_update(ares_event_t **event, ares_event_thread_t *e, } if (ares__llist_insert_last(e->ev_updates, ev) == NULL) { - ares_free(ev); /* LCOV_EXCL_LINE: OutOfMemory */ + ares_free(ev); /* LCOV_EXCL_LINE: OutOfMemory */ return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -394,7 +394,7 @@ static const ares_event_sys_t *ares_event_fetch_sys(ares_evsys_t evsys) break; } - /* default */ + /* default */ #if defined(USE_WINSOCK) return &ares_evsys_win32; #elif defined(HAVE_KQUEUE) @@ -422,25 +422,25 @@ ares_status_t ares_event_thread_init(ares_channel_t *channel) e->mutex = ares__thread_mutex_create(); if (e->mutex == NULL) { ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } e->ev_updates = ares__llist_create(NULL); if (e->ev_updates == NULL) { ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } e->ev_sock_handles = ares__htable_asvp_create(ares_event_destroy_cb); if (e->ev_sock_handles == NULL) { ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } e->ev_cust_handles = ares__htable_vpvp_create(NULL, ares_event_destroy_cb); if (e->ev_cust_handles == NULL) { ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } e->channel = channel; @@ -448,7 +448,7 @@ ares_status_t ares_event_thread_init(ares_channel_t *channel) e->ev_sys = ares_event_fetch_sys(channel->evsys); if (e->ev_sys == NULL) { ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: UntestablePath */ - return ARES_ENOTIMP; /* LCOV_EXCL_LINE: UntestablePath */ + return ARES_ENOTIMP; /* LCOV_EXCL_LINE: UntestablePath */ } channel->sock_state_cb = ares_event_thread_sockstate_cb; diff --git a/src/lib/ares_event_wake_pipe.c b/src/lib/ares_event_wake_pipe.c index c0aa70b5..1edd9250 100644 --- a/src/lib/ares_event_wake_pipe.c +++ b/src/lib/ares_event_wake_pipe.c @@ -69,7 +69,7 @@ static ares_pipeevent_t *ares_pipeevent_init(void) # ifdef HAVE_PIPE2 if (pipe2(p->filedes, O_NONBLOCK | O_CLOEXEC) != 0) { ares_pipeevent_destroy(p); /* LCOV_EXCL_LINE: UntestablePath */ - return NULL; /* LCOV_EXCL_LINE: UntestablePath */ + return NULL; /* LCOV_EXCL_LINE: UntestablePath */ } # else if (pipe(p->filedes) != 0) { @@ -157,7 +157,7 @@ ares_event_t *ares_pipeevent_create(ares_event_thread_t *e) ares_pipeevent_signal); if (status != ARES_SUCCESS) { ares_pipeevent_destroy(p); /* LCOV_EXCL_LINE: DefensiveCoding */ - return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } return event; diff --git a/src/lib/ares_getaddrinfo.c b/src/lib/ares_getaddrinfo.c index 51463402..e91d9e98 100644 --- a/src/lib/ares_getaddrinfo.c +++ b/src/lib/ares_getaddrinfo.c @@ -275,7 +275,7 @@ static ares_bool_t fake_addrinfo(const char *name, unsigned short port, status = ares_append_ai_node(AF_INET, port, 0, &addr4, &ai->nodes); if (status != ARES_SUCCESS) { callback(arg, (int)status, 0, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_TRUE; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_TRUE; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -289,7 +289,7 @@ static ares_bool_t fake_addrinfo(const char *name, unsigned short port, status = ares_append_ai_node(AF_INET6, port, 0, &addr6, &ai->nodes); if (status != ARES_SUCCESS) { callback(arg, (int)status, 0, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_TRUE; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_TRUE; /* LCOV_EXCL_LINE: OutOfMemory */ } } } diff --git a/src/lib/ares_gethostbyaddr.c b/src/lib/ares_gethostbyaddr.c index 9676e17e..003993b1 100644 --- a/src/lib/ares_gethostbyaddr.c +++ b/src/lib/ares_gethostbyaddr.c @@ -132,8 +132,9 @@ static void next_lookup(struct addr_query *aquery) case 'b': name = ares_dns_addr_to_ptr(&aquery->addr); if (name == NULL) { - end_aquery(aquery, ARES_ENOMEM, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ - return; /* LCOV_EXCL_LINE: OutOfMemory */ + end_aquery(aquery, ARES_ENOMEM, + NULL); /* LCOV_EXCL_LINE: OutOfMemory */ + return; /* LCOV_EXCL_LINE: OutOfMemory */ } aquery->remaining_lookups = p + 1; ares_query_dnsrec(aquery->channel, name, ARES_CLASS_IN, diff --git a/src/lib/ares_gethostbyname.c b/src/lib/ares_gethostbyname.c index 2a8ec555..33de0278 100644 --- a/src/lib/ares_gethostbyname.c +++ b/src/lib/ares_gethostbyname.c @@ -249,7 +249,7 @@ static ares_status_t ares__hostent_localhost(const char *name, int family, ai = ares_malloc_zero(sizeof(*ai)); if (ai == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__addrinfo_localhost(name, 0, &hints, ai); diff --git a/src/lib/ares_getnameinfo.c b/src/lib/ares_getnameinfo.c index 57c6ddaf..dc79ac68 100644 --- a/src/lib/ares_getnameinfo.c +++ b/src/lib/ares_getnameinfo.c @@ -81,8 +81,8 @@ static void nameinfo_callback(void *arg, int status, int timeouts, static char *lookup_service(unsigned short port, unsigned int flags, char *buf, size_t buflen); #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID -static void append_scopeid(const struct sockaddr_in6 *addr6, - unsigned int flags, char *buf, size_t buflen); +static void append_scopeid(const struct sockaddr_in6 *addr6, unsigned int flags, + char *buf, size_t buflen); #endif static char *ares_striendstr(const char *s1, const char *s2); diff --git a/src/lib/ares_init.c b/src/lib/ares_init.c index be3cfacf..2206ed27 100644 --- a/src/lib/ares_init.c +++ b/src/lib/ares_init.c @@ -197,7 +197,7 @@ static ares_status_t init_by_defaults(ares_channel_t *channel) hostname = ares_malloc(len); if (!hostname) { rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto error; /* LCOV_EXCL_LINE: OutOfMemory */ + goto error; /* LCOV_EXCL_LINE: OutOfMemory */ } do { @@ -210,7 +210,7 @@ static ares_status_t init_by_defaults(ares_channel_t *channel) p = ares_realloc(hostname, len); if (!p) { rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto error; /* LCOV_EXCL_LINE: OutOfMemory */ + goto error; /* LCOV_EXCL_LINE: OutOfMemory */ } hostname = p; continue; @@ -229,12 +229,12 @@ static ares_status_t init_by_defaults(ares_channel_t *channel) channel->domains = ares_malloc(sizeof(char *)); if (!channel->domains) { rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto error; /* LCOV_EXCL_LINE: OutOfMemory */ + goto error; /* LCOV_EXCL_LINE: OutOfMemory */ } channel->domains[0] = ares_strdup(dot + 1); if (!channel->domains[0]) { rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto error; /* LCOV_EXCL_LINE: OutOfMemory */ + goto error; /* LCOV_EXCL_LINE: OutOfMemory */ } channel->ndomains = 1; } diff --git a/src/lib/ares_math.c b/src/lib/ares_math.c index 82bb7ccc..754dcd8b 100644 --- a/src/lib/ares_math.c +++ b/src/lib/ares_math.c @@ -60,14 +60,14 @@ static ares_int64_t ares__round_up_pow2_u64(ares_int64_t n) ares_bool_t ares__is_64bit(void) { #ifdef _MSC_VER -# pragma warning( push ) -# pragma warning( disable : 4127 ) +# pragma warning(push) +# pragma warning(disable : 4127) #endif - return (sizeof(size_t) == 4)?ARES_FALSE:ARES_TRUE; + return (sizeof(size_t) == 4) ? ARES_FALSE : ARES_TRUE; #ifdef _MSC_VER -# pragma warning( pop ) +# pragma warning(pop) #endif } diff --git a/src/lib/ares_metrics.c b/src/lib/ares_metrics.c index 2250664d..e81099d3 100644 --- a/src/lib/ares_metrics.c +++ b/src/lib/ares_metrics.c @@ -101,20 +101,20 @@ /*! Minimum timeout value. Chosen due to it being approximately RTT half-way * around the world */ -#define MIN_TIMEOUT_MS 250 +#define MIN_TIMEOUT_MS 250 /*! Multiplier to apply to average latency to come up with an initial timeout */ #define AVG_TIMEOUT_MULTIPLIER 5 /*! Upper timeout bounds, only used if channel->maxtimeout not set */ -#define MAX_TIMEOUT_MS 5000 +#define MAX_TIMEOUT_MS 5000 /*! Minimum queries required to form an average */ -#define MIN_COUNT_FOR_AVERAGE 3 +#define MIN_COUNT_FOR_AVERAGE 3 -static time_t ares_metric_timestamp(ares_server_bucket_t bucket, +static time_t ares_metric_timestamp(ares_server_bucket_t bucket, const ares_timeval_t *now, - ares_bool_t is_previous) + ares_bool_t is_previous) { time_t divisor = 1; /* Silence bogus MSVC warning by setting default value */ @@ -132,7 +132,7 @@ static time_t ares_metric_timestamp(ares_server_bucket_t bucket, divisor = 24 * 60 * 60; break; case ARES_METRIC_INCEPTION: - return is_previous?0:1; + return is_previous ? 0 : 1; case ARES_METRIC_COUNT: return 0; /* Invalid! */ } @@ -150,7 +150,7 @@ static time_t ares_metric_timestamp(ares_server_bucket_t bucket, void ares_metrics_record(const struct query *query, struct server_state *server, ares_status_t status, const ares_dns_record_t *dnsrec) { - ares_timeval_t now = ares__tvnow(); + ares_timeval_t now = ares__tvnow(); ares_timeval_t tvdiff; unsigned int query_ms; ares_dns_rcode_t rcode; @@ -176,8 +176,8 @@ void ares_metrics_record(const struct query *query, struct server_state *server, } /* Place in each bucket */ - for (i=0; imetrics[i].ts) { @@ -208,12 +208,12 @@ void ares_metrics_record(const struct query *query, struct server_state *server, size_t ares_metrics_server_timeout(const struct server_state *server, const ares_timeval_t *now) { - const ares_channel_t *channel = server->channel; + const ares_channel_t *channel = server->channel; ares_server_bucket_t i; size_t timeout_ms = 0; - for (i=0; imetrics[i].prev_total_ms / server->metrics[i].prev_total_count); + timeout_ms = (size_t)(server->metrics[i].prev_total_ms / + server->metrics[i].prev_total_count); } else { /* Calculate average time for current bucket*/ - timeout_ms = (size_t)(server->metrics[i].total_ms / server->metrics[i].total_count); + timeout_ms = + (size_t)(server->metrics[i].total_ms / server->metrics[i].total_count); } /* Multiply average by constant to get timeout value */ diff --git a/src/lib/ares_options.c b/src/lib/ares_options.c index 959c4f7a..77b5238e 100644 --- a/src/lib/ares_options.c +++ b/src/lib/ares_options.c @@ -464,8 +464,8 @@ ares_status_t ares__init_by_options(ares_channel_t *channel, /* qcache_max_ttl is unsigned unlike the others */ channel->qcache_max_ttl = options->qcache_max_ttl; } else { - optmask |= ARES_OPT_QUERY_CACHE; - channel->qcache_max_ttl = 3600; + optmask |= ARES_OPT_QUERY_CACHE; + channel->qcache_max_ttl = 3600; } /* Initialize the ipv4 servers if provided */ diff --git a/src/lib/ares_parse_caa_reply.c b/src/lib/ares_parse_caa_reply.c index 42f25256..bd77cdb8 100644 --- a/src/lib/ares_parse_caa_reply.c +++ b/src/lib/ares_parse_caa_reply.c @@ -67,7 +67,7 @@ int ares_parse_caa_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* XXX: Why do we allow Chaos class? */ @@ -85,7 +85,7 @@ int ares_parse_caa_reply(const unsigned char *abuf, int alen_int, caa_curr = ares_malloc_data(ARES_DATATYPE_CAA_REPLY); if (caa_curr == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -101,7 +101,7 @@ int ares_parse_caa_reply(const unsigned char *abuf, int alen_int, (unsigned char *)ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_CAA_TAG)); if (caa_curr->property == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - break; /* LCOV_EXCL_LINE: OutOfMemory */ + break; /* LCOV_EXCL_LINE: OutOfMemory */ } /* RFC6844 says this can only be ascii, so not sure why we're recording a * length */ @@ -110,14 +110,14 @@ int ares_parse_caa_reply(const unsigned char *abuf, int alen_int, ptr = ares_dns_rr_get_bin(rr, ARES_RR_CAA_VALUE, &ptr_len); if (ptr == NULL) { status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Wants NULL termination for some reason */ caa_curr->value = ares_malloc(ptr_len + 1); if (caa_curr->value == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } memcpy(caa_curr->value, ptr, ptr_len); caa_curr->value[ptr_len] = 0; diff --git a/src/lib/ares_parse_mx_reply.c b/src/lib/ares_parse_mx_reply.c index f9e5f025..2f5f6f4c 100644 --- a/src/lib/ares_parse_mx_reply.c +++ b/src/lib/ares_parse_mx_reply.c @@ -65,7 +65,7 @@ int ares_parse_mx_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -77,7 +77,7 @@ int ares_parse_mx_reply(const unsigned char *abuf, int alen_int, mx_curr = ares_malloc_data(ARES_DATATYPE_MX_REPLY); if (mx_curr == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -93,7 +93,7 @@ int ares_parse_mx_reply(const unsigned char *abuf, int alen_int, if (mx_curr->host == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/src/lib/ares_parse_naptr_reply.c b/src/lib/ares_parse_naptr_reply.c index 51ee6f38..874da401 100644 --- a/src/lib/ares_parse_naptr_reply.c +++ b/src/lib/ares_parse_naptr_reply.c @@ -64,7 +64,7 @@ int ares_parse_naptr_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -76,7 +76,7 @@ int ares_parse_naptr_reply(const unsigned char *abuf, int alen_int, naptr_curr = ares_malloc_data(ARES_DATATYPE_NAPTR_REPLY); if (naptr_curr == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -95,27 +95,27 @@ int ares_parse_naptr_reply(const unsigned char *abuf, int alen_int, ares_dns_rr_get_str(rr, ARES_RR_NAPTR_FLAGS)); if (naptr_curr->flags == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* XXX: Why is this unsigned char * ? */ naptr_curr->service = (unsigned char *)ares_strdup( ares_dns_rr_get_str(rr, ARES_RR_NAPTR_SERVICES)); if (naptr_curr->service == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* XXX: Why is this unsigned char * ? */ naptr_curr->regexp = (unsigned char *)ares_strdup( ares_dns_rr_get_str(rr, ARES_RR_NAPTR_REGEXP)); if (naptr_curr->regexp == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } naptr_curr->replacement = ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_NAPTR_REPLACEMENT)); if (naptr_curr->replacement == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/src/lib/ares_parse_ns_reply.c b/src/lib/ares_parse_ns_reply.c index 76235396..e26266ad 100644 --- a/src/lib/ares_parse_ns_reply.c +++ b/src/lib/ares_parse_ns_reply.c @@ -74,7 +74,7 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, hostent = ares_malloc(sizeof(*hostent)); if (hostent == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(hostent, 0, sizeof(*hostent)); @@ -82,7 +82,7 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, hostent->h_addr_list = ares_malloc(sizeof(*hostent->h_addr_list)); if (hostent->h_addr_list == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } hostent->h_addr_list[0] = NULL; hostent->h_addrtype = AF_INET; @@ -96,14 +96,14 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, hostent->h_name = ares_strdup(hostname); if (hostent->h_name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Preallocate the maximum number + 1 */ hostent->h_aliases = ares_malloc((ancount + 1) * sizeof(*hostent->h_aliases)); if (hostent->h_aliases == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(hostent->h_aliases, 0, (ancount + 1) * sizeof(*hostent->h_aliases)); @@ -114,7 +114,7 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -125,7 +125,7 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, hostname = ares_dns_rr_get_str(rr, ARES_RR_NS_NSDNAME); if (hostname == NULL) { status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } hostent->h_aliases[nscount] = ares_strdup(hostname); diff --git a/src/lib/ares_parse_ptr_reply.c b/src/lib/ares_parse_ptr_reply.c index 3f8cc122..1fdc152f 100644 --- a/src/lib/ares_parse_ptr_reply.c +++ b/src/lib/ares_parse_ptr_reply.c @@ -106,7 +106,7 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN) { @@ -118,7 +118,7 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, ptrname = ares_dns_rr_get_str(rr, ARES_RR_CNAME_CNAME); if (ptrname == NULL) { status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } } @@ -146,7 +146,7 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, hostname = ares_dns_rr_get_str(rr, ARES_RR_PTR_DNAME); if (hostname == NULL) { status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Append as an alias */ @@ -169,7 +169,7 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, hostent->h_name = ares_strdup(hostname); if (hostent->h_name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } done: diff --git a/src/lib/ares_parse_soa_reply.c b/src/lib/ares_parse_soa_reply.c index d471471a..74c7832d 100644 --- a/src/lib/ares_parse_soa_reply.c +++ b/src/lib/ares_parse_soa_reply.c @@ -63,7 +63,7 @@ int ares_parse_soa_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -75,7 +75,7 @@ int ares_parse_soa_reply(const unsigned char *abuf, int alen_int, soa = ares_malloc_data(ARES_DATATYPE_SOA_REPLY); if (soa == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } soa->serial = ares_dns_rr_get_u32(rr, ARES_RR_SOA_SERIAL); @@ -86,12 +86,12 @@ int ares_parse_soa_reply(const unsigned char *abuf, int alen_int, soa->nsname = ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_SOA_MNAME)); if (soa->nsname == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } soa->hostmaster = ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_SOA_RNAME)); if (soa->hostmaster == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } break; } diff --git a/src/lib/ares_parse_srv_reply.c b/src/lib/ares_parse_srv_reply.c index 438737b7..a016159a 100644 --- a/src/lib/ares_parse_srv_reply.c +++ b/src/lib/ares_parse_srv_reply.c @@ -65,7 +65,7 @@ int ares_parse_srv_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -77,7 +77,7 @@ int ares_parse_srv_reply(const unsigned char *abuf, int alen_int, srv_curr = ares_malloc_data(ARES_DATATYPE_SRV_REPLY); if (srv_curr == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -97,7 +97,7 @@ int ares_parse_srv_reply(const unsigned char *abuf, int alen_int, if (srv_curr->host == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/src/lib/ares_parse_txt_reply.c b/src/lib/ares_parse_txt_reply.c index 2555734c..5212a585 100644 --- a/src/lib/ares_parse_txt_reply.c +++ b/src/lib/ares_parse_txt_reply.c @@ -60,7 +60,7 @@ static int ares__parse_txt_reply(const unsigned char *abuf, size_t alen, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* XXX: Why Chaos? */ @@ -75,7 +75,7 @@ static int ares__parse_txt_reply(const unsigned char *abuf, size_t alen, ares_malloc_data(ex ? ARES_DATATYPE_TXT_EXT : ARES_DATATYPE_TXT_REPLY); if (txt_curr == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -96,7 +96,7 @@ static int ares__parse_txt_reply(const unsigned char *abuf, size_t alen, txt_curr->txt = ares_malloc(ptr_len + 1); if (txt_curr->txt == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } memcpy(txt_curr->txt, ptr, ptr_len); txt_curr->txt[ptr_len] = 0; diff --git a/src/lib/ares_parse_uri_reply.c b/src/lib/ares_parse_uri_reply.c index 5966b946..b24e7976 100644 --- a/src/lib/ares_parse_uri_reply.c +++ b/src/lib/ares_parse_uri_reply.c @@ -65,7 +65,7 @@ int ares_parse_uri_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -77,7 +77,7 @@ int ares_parse_uri_reply(const unsigned char *abuf, int alen_int, uri_curr = ares_malloc_data(ARES_DATATYPE_URI_REPLY); if (uri_curr == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ diff --git a/src/lib/ares_private.h b/src/lib/ares_private.h index 1fde90da..6966bc8d 100644 --- a/src/lib/ares_private.h +++ b/src/lib/ares_private.h @@ -189,7 +189,8 @@ typedef struct { ares_uint64_t total_count; /*!< Number of queries for bucket */ time_t prev_ts; /*!< Previous period bucket timestamp */ - ares_uint64_t prev_total_ms; /*!< Previous period bucket cumulative query time */ + ares_uint64_t + prev_total_ms; /*!< Previous period bucket cumulative query time */ ares_uint64_t prev_total_count; /*!< Previous period bucket query count */ } ares_server_metrics_t; @@ -229,7 +230,7 @@ struct server_state { struct query { /* Query ID from qbuf, for faster lookup, and current timeout */ unsigned short qid; /* host byte order */ - ares_timeval_t ts; /*!< Timestamp query was sent */ + ares_timeval_t ts; /*!< Timestamp query was sent */ ares_timeval_t timeout; ares_channel_t *channel; @@ -256,8 +257,8 @@ struct query { ares_bool_t using_tcp; ares_status_t error_status; size_t timeouts; /* number of timeouts we saw for this request */ - ares_bool_t no_retries; /* do not perform any additional retries, this is set - * when a query is to be canceled */ + ares_bool_t no_retries; /* do not perform any additional retries, this is set + * when a query is to be canceled */ }; struct apattern { @@ -437,21 +438,20 @@ ares_timeval_t ares__tvnow(void); void ares__timeval_remaining(ares_timeval_t *remaining, const ares_timeval_t *now, const ares_timeval_t *tout); -void ares__timeval_diff(ares_timeval_t *tvdiff, - const ares_timeval_t *tvstart, - const ares_timeval_t *tvstop); -ares_status_t ares__expand_name_validated(const unsigned char *encoded, - const unsigned char *abuf, - size_t alen, char **s, size_t *enclen, - ares_bool_t is_hostname); -ares_status_t ares_expand_string_ex(const unsigned char *encoded, - const unsigned char *abuf, size_t alen, - unsigned char **s, size_t *enclen); -ares_status_t ares__init_servers_state(ares_channel_t *channel); -ares_status_t ares__init_by_options(ares_channel_t *channel, - const struct ares_options *options, - int optmask); -ares_status_t ares__init_by_sysconfig(ares_channel_t *channel); +void ares__timeval_diff(ares_timeval_t *tvdiff, const ares_timeval_t *tvstart, + const ares_timeval_t *tvstop); +ares_status_t ares__expand_name_validated(const unsigned char *encoded, + const unsigned char *abuf, + size_t alen, char **s, size_t *enclen, + ares_bool_t is_hostname); +ares_status_t ares_expand_string_ex(const unsigned char *encoded, + const unsigned char *abuf, size_t alen, + unsigned char **s, size_t *enclen); +ares_status_t ares__init_servers_state(ares_channel_t *channel); +ares_status_t ares__init_by_options(ares_channel_t *channel, + const struct ares_options *options, + int optmask); +ares_status_t ares__init_by_sysconfig(ares_channel_t *channel); typedef struct { ares__llist_t *sconfig; @@ -683,8 +683,8 @@ ares_status_t ares_qcache_fetch(ares_channel_t *channel, void ares_metrics_record(const struct query *query, struct server_state *server, ares_status_t status, const ares_dns_record_t *dnsrec); -size_t ares_metrics_server_timeout(const struct server_state *server, - const ares_timeval_t *now); +size_t ares_metrics_server_timeout(const struct server_state *server, + const ares_timeval_t *now); ares_status_t ares__channel_threading_init(ares_channel_t *channel); void ares__channel_threading_destroy(ares_channel_t *channel); diff --git a/src/lib/ares_process.c b/src/lib/ares_process.c index 51360d1c..530d2f1a 100644 --- a/src/lib/ares_process.c +++ b/src/lib/ares_process.c @@ -69,13 +69,13 @@ static ares_bool_t same_questions(const ares_dns_record_t *qrec, const ares_dns_record_t *arec); static ares_bool_t same_address(const struct sockaddr *sa, const struct ares_addr *aa); -static void end_query(ares_channel_t *channel, struct server_state *server, - struct query *query, ares_status_t status, - const ares_dns_record_t *dnsrec); +static void end_query(ares_channel_t *channel, struct server_state *server, + struct query *query, ares_status_t status, + const ares_dns_record_t *dnsrec); /* Invoke the server state callback after a success or failure */ -static void invoke_server_state_cb(const struct server_state *server, - ares_bool_t success, int flags) +static void invoke_server_state_cb(const struct server_state *server, + ares_bool_t success, int flags) { const ares_channel_t *channel = server->channel; ares__buf_t *buf; @@ -94,7 +94,7 @@ static void invoke_server_state_cb(const struct server_state *server, status = ares_get_server_addr(server, buf); if (status != ARES_SUCCESS) { ares__buf_destroy(buf); /* LCOV_EXCL_LINE: OutOfMemory */ - return; /* LCOV_EXCL_LINE: OutOfMemory */ + return; /* LCOV_EXCL_LINE: OutOfMemory */ } server_string = ares__buf_finish_str(buf, NULL); @@ -945,9 +945,9 @@ static ares_status_t ares__append_tcpbuf(struct server_state *server, return ares__buf_append(server->tcp_send, query->qbuf, query->qlen); } -static size_t ares__calc_query_timeout(const struct query *query, +static size_t ares__calc_query_timeout(const struct query *query, const struct server_state *server, - const ares_timeval_t *now) + const ares_timeval_t *now) { const ares_channel_t *channel = query->channel; size_t timeout = ares_metrics_server_timeout(server, now); @@ -1253,7 +1253,6 @@ static void ares_detach_query(struct query *query) query->node_all_queries = NULL; } - static void end_query(ares_channel_t *channel, struct server_state *server, struct query *query, ares_status_t status, const ares_dns_record_t *dnsrec) diff --git a/src/lib/ares_qcache.c b/src/lib/ares_qcache.c index e03d0692..d6409a2a 100644 --- a/src/lib/ares_qcache.c +++ b/src/lib/ares_qcache.c @@ -135,7 +135,7 @@ static char *ares__qcache_calc_key(const ares_dns_record_t *dnsrec) fail: ares__buf_destroy(buf); return NULL; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } static void ares__qcache_expire(ares__qcache_t *cache, @@ -214,20 +214,20 @@ ares_status_t ares__qcache_create(ares_rand_state *rand_state, cache = ares_malloc_zero(sizeof(*cache)); if (cache == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cache->cache = ares__htable_strvp_create(NULL); if (cache->cache == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cache->expire = ares__slist_create(rand_state, ares__qcache_entry_sort_cb, ares__qcache_entry_destroy_cb); if (cache->expire == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cache->max_ttl = max_ttl; @@ -397,7 +397,7 @@ fail: ares_free(entry); } return ARES_ENOMEM; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } ares_status_t ares_qcache_fetch(ares_channel_t *channel, @@ -422,7 +422,7 @@ ares_status_t ares_qcache_fetch(ares_channel_t *channel, key = ares__qcache_calc_key(dnsrec); if (key == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } entry = ares__htable_strvp_get_direct(channel->qcache->cache, key); diff --git a/src/lib/ares_query.c b/src/lib/ares_query.c index 35214bc4..264609ae 100644 --- a/src/lib/ares_query.c +++ b/src/lib/ares_query.c @@ -94,7 +94,7 @@ static ares_status_t ares_query_int(ares_channel_t *channel, const char *name, (size_t)(channel->flags & ARES_FLAG_EDNS) ? channel->ednspsz : 0); if (status != ARES_SUCCESS) { callback(arg, status, 0, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ - return status; /* LCOV_EXCL_LINE: OutOfMemory */ + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } qquery = ares_malloc(sizeof(*qquery)); @@ -147,7 +147,7 @@ void ares_query(ares_channel_t *channel, const char *name, int dnsclass, carg = ares__dnsrec_convert_arg(callback, arg); if (carg == NULL) { callback(arg, ARES_ENOMEM, 0, NULL, 0); /* LCOV_EXCL_LINE: OutOfMemory */ - return; /* LCOV_EXCL_LINE: OutOfMemory */ + return; /* LCOV_EXCL_LINE: OutOfMemory */ } ares_query_dnsrec(channel, name, (ares_dns_class_t)dnsclass, diff --git a/src/lib/ares_rand.c b/src/lib/ares_rand.c index 962b069f..e2e6687e 100644 --- a/src/lib/ares_rand.c +++ b/src/lib/ares_rand.c @@ -229,7 +229,7 @@ ares_rand_state *ares__init_rand_state(void) if (!ares__init_rand_engine(state)) { ares_free(state); /* LCOV_EXCL_LINE: UntestablePath */ - return NULL; /* LCOV_EXCL_LINE: UntestablePath */ + return NULL; /* LCOV_EXCL_LINE: UntestablePath */ } return state; @@ -250,7 +250,7 @@ static void ares__clear_rand_state(ares_rand_state *state) break; case ARES_RAND_RC4: break; - /* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } } @@ -313,7 +313,7 @@ static void ares__rand_bytes_fetch(ares_rand_state *state, unsigned char *buf, break; #endif - /* LCOV_EXCL_START: FallbackCode */ + /* LCOV_EXCL_START: FallbackCode */ case ARES_RAND_FILE: while (1) { @@ -334,8 +334,7 @@ static void ares__rand_bytes_fetch(ares_rand_state *state, unsigned char *buf, ares_rc4_prng(&state->state.rc4, buf, len); return; - /* LCOV_EXCL_STOP */ - + /* LCOV_EXCL_STOP */ } /* If we didn't return before we got here, that means we had a critical rand diff --git a/src/lib/ares_search.c b/src/lib/ares_search.c index 7403de16..d72cbf41 100644 --- a/src/lib/ares_search.c +++ b/src/lib/ares_search.c @@ -201,7 +201,7 @@ ares_status_t ares__search_name_list(const ares_channel_t *channel, list = ares_malloc_zero(sizeof(*list) * list_len); if (list == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } list[0] = alias; alias = NULL; @@ -216,7 +216,7 @@ ares_status_t ares__search_name_list(const ares_channel_t *channel, list = ares_malloc_zero(sizeof(*list) * list_len); if (list == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } list[0] = ares_strdup(name); if (list[0] == NULL) { @@ -323,7 +323,7 @@ static ares_status_t ares_search_int(ares_channel_t *channel, squery = ares_malloc_zero(sizeof(*squery)); if (squery == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } squery->channel = channel; @@ -332,7 +332,7 @@ static ares_status_t ares_search_int(ares_channel_t *channel, squery->dnsrec = ares_dns_record_duplicate(dnsrec); if (squery->dnsrec == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } squery->callback = callback; @@ -456,7 +456,7 @@ ares_status_t ares_search_dnsrec(ares_channel_t *channel, ares_status_t status; if (channel == NULL || dnsrec == NULL || callback == NULL) { - return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__channel_lock(channel); @@ -498,7 +498,7 @@ ares_status_t ares__lookup_hostaliases(const ares_channel_t *channel, ares__llist_node_t *node; if (channel == NULL || name == NULL || alias == NULL) { - return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } *alias = NULL; @@ -521,8 +521,8 @@ ares_status_t ares__lookup_hostaliases(const ares_channel_t *channel, buf = ares__buf_create(); if (buf == NULL) { - status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_load_file(hostaliases, buf); @@ -581,8 +581,8 @@ ares_status_t ares__lookup_hostaliases(const ares_channel_t *channel, *alias = ares_strdup(fqdn); if (*alias == NULL) { - status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Good! */ diff --git a/src/lib/ares_send.c b/src/lib/ares_send.c index 800edce6..1dcfc388 100644 --- a/src/lib/ares_send.c +++ b/src/lib/ares_send.c @@ -78,7 +78,7 @@ static ares_status_t ares_send_dnsrec_int(ares_channel_t *channel, query = ares_malloc(sizeof(struct query)); if (!query) { callback(arg, ARES_ENOMEM, 0, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(query, 0, sizeof(*query)); diff --git a/src/lib/ares_strsplit.c b/src/lib/ares_strsplit.c index 432a2d6c..8b2d950a 100644 --- a/src/lib/ares_strsplit.c +++ b/src/lib/ares_strsplit.c @@ -64,7 +64,7 @@ char **ares__strsplit_duplicate(char **elms, size_t num_elm) out[i] = ares_strdup(elms[i]); if (out[i] == NULL) { ares__strsplit_free(out, num_elm); /* LCOV_EXCL_LINE: OutOfMemory */ - return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -109,7 +109,7 @@ char **ares__strsplit(const char *in, const char *delms, size_t *num_elm) out = ares_malloc_zero(cnt * sizeof(*out)); if (out == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } for (node = ares__llist_node_first(llist); node != NULL; diff --git a/src/lib/ares_sysconfig_files.c b/src/lib/ares_sysconfig_files.c index f7104300..12ff3f13 100644 --- a/src/lib/ares_sysconfig_files.c +++ b/src/lib/ares_sysconfig_files.c @@ -263,7 +263,7 @@ ares_status_t ares__parse_sortlist(struct apattern **sortlist, size_t *nsort, if (!sortlist_append(sortlist, nsort, &pat)) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/src/lib/ares_sysconfig_mac.c b/src/lib/ares_sysconfig_mac.c index 6ec499e5..e2d34d7c 100644 --- a/src/lib/ares_sysconfig_mac.c +++ b/src/lib/ares_sysconfig_mac.c @@ -80,12 +80,13 @@ static void dnsinfo_destroy(dnsinfo_t *dnsinfo) static ares_status_t dnsinfo_init(dnsinfo_t **dnsinfo_out) { - dnsinfo_t *dnsinfo = NULL; - ares_status_t status = ARES_SUCCESS; + dnsinfo_t *dnsinfo = NULL; + ares_status_t status = ARES_SUCCESS; size_t i; - const char *searchlibs[] = { + const char *searchlibs[] = { "/usr/lib/libSystem.dylib", - "/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration", + "/System/Library/Frameworks/SystemConfiguration.framework/" + "SystemConfiguration", NULL }; @@ -102,7 +103,7 @@ static ares_status_t dnsinfo_init(dnsinfo_t **dnsinfo_out) goto done; } - for (i=0; searchlibs[i] != NULL; i++) { + for (i = 0; searchlibs[i] != NULL; i++) { dnsinfo->handle = dlopen(searchlibs[i], RTLD_LAZY /* | RTLD_NOLOAD */); if (dnsinfo->handle == NULL) { /* Fail, loop */ @@ -162,7 +163,7 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, unsigned short port = 0; ares_status_t status = ARES_SUCCESS; -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 /* MacOS 10.8 */ +# if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 /* MacOS 10.8 */ /* XXX: resolver->domain is for domain-specific servers. When we implement * this support, we'll want to use this. But for now, we're going to * skip any servers which set this since we can't properly route. @@ -172,9 +173,9 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, if (resolver->domain != NULL) { return ARES_SUCCESS; } -#endif +# endif -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 /* MacOS 10.8 */ +# if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 /* MacOS 10.8 */ /* Check to see if DNS server should be used, base this on if the server is * reachable or can be reachable automatically if we send traffic that * direction. */ @@ -183,7 +184,7 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, kSCNetworkReachabilityFlagsConnectionOnTraffic))) { return ARES_SUCCESS; } -#endif +# endif /* NOTE: it doesn't look like resolver->flags is relevant */ @@ -296,8 +297,8 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, if_name = ares__if_indextoname(resolver->if_index, if_name_str, sizeof(if_name_str)); - status = ares__sconfig_append(&sysconfig->sconfig, &addr, addrport, - addrport, if_name); + status = ares__sconfig_append(&sysconfig->sconfig, &addr, addrport, + addrport, if_name); if (status != ARES_SUCCESS) { return status; } diff --git a/src/lib/ares_timeout.c b/src/lib/ares_timeout.c index ac02b972..99dc41c9 100644 --- a/src/lib/ares_timeout.c +++ b/src/lib/ares_timeout.c @@ -55,16 +55,15 @@ void ares__timeval_remaining(ares_timeval_t *remaining, } } -void ares__timeval_diff(ares_timeval_t *tvdiff, - const ares_timeval_t *tvstart, +void ares__timeval_diff(ares_timeval_t *tvdiff, const ares_timeval_t *tvstart, const ares_timeval_t *tvstop) { tvdiff->sec = tvstop->sec - tvstart->sec; if (tvstop->usec > tvstart->usec) { tvdiff->usec = tvstop->usec - tvstart->usec; } else { - tvdiff->sec -= 1; - tvdiff->usec = tvstop->usec + 1000000 - tvstart->usec; + tvdiff->sec -= 1; + tvdiff->usec = tvstop->usec + 1000000 - tvstart->usec; } } @@ -73,9 +72,9 @@ static struct timeval ares_timeval_to_struct_timeval(const ares_timeval_t *atv) struct timeval tv; #ifdef USE_WINSOCK - tv.tv_sec = (long)atv->sec; + tv.tv_sec = (long)atv->sec; #else - tv.tv_sec = (time_t)atv->sec; + tv.tv_sec = (time_t)atv->sec; #endif tv.tv_usec = (int)atv->usec; diff --git a/src/lib/ares_update_servers.c b/src/lib/ares_update_servers.c index 77ed7dd2..d1d26a44 100644 --- a/src/lib/ares_update_servers.c +++ b/src/lib/ares_update_servers.c @@ -397,7 +397,7 @@ ares_status_t ares__sconfig_append(ares__llist_t **sconfig, *sconfig = ares__llist_create(ares_free); if (*sconfig == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -423,7 +423,7 @@ ares_status_t ares__sconfig_append(ares__llist_t **sconfig, if (ares__llist_insert_last(*sconfig, s) == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_SUCCESS; @@ -613,24 +613,24 @@ static ares_status_t ares__server_create(ares_channel_t *channel, server->tcp_parser = ares__buf_create(); if (server->tcp_parser == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } server->tcp_send = ares__buf_create(); if (server->tcp_send == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } server->connections = ares__llist_create(NULL); if (server->connections == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } if (ares__slist_insert(channel->servers, server) == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ARES_SUCCESS; @@ -823,7 +823,7 @@ static ares_status_t if (ares__llist_insert_last(s, sconfig) == NULL) { ares_free(sconfig); /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -834,7 +834,7 @@ static ares_status_t fail: ares__llist_destroy(s); return ARES_ENOMEM; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } static ares_status_t ares_addr_port_node_to_server_config_llist( @@ -877,7 +877,7 @@ static ares_status_t ares_addr_port_node_to_server_config_llist( if (ares__llist_insert_last(s, sconfig) == NULL) { ares_free(sconfig); /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -888,7 +888,7 @@ static ares_status_t ares_addr_port_node_to_server_config_llist( fail: ares__llist_destroy(s); return ARES_ENOMEM; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers, @@ -929,7 +929,7 @@ ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers, fail: ares__llist_destroy(s); return ARES_ENOMEM; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } /* Write out the details of a server to a buffer */ diff --git a/src/lib/config-win32.h b/src/lib/config-win32.h index 8f7f482c..f7bdb9e8 100644 --- a/src/lib/config-win32.h +++ b/src/lib/config-win32.h @@ -212,7 +212,7 @@ # undef SEND_TYPE_ARG1 # define SEND_TYPE_ARG1 int # undef RECVFROM_TYPE_ARG1 -# define RECVFROM_TYPE_ARG1 int +# define RECVFROM_TYPE_ARG1 int # define NS_INADDRSZ 4 # define HAVE_ARPA_NAMESER_H 1 # define HAVE_ARPA_INET_H 1 @@ -356,7 +356,7 @@ #endif #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) && \ - !defined(__WATCOMC__) && !defined(WATT32) + !defined(__WATCOMC__) && !defined(WATT32) /* Define if you have if_nametoindex() */ # define HAVE_IF_NAMETOINDEX 1 /* Define if you have if_indextoname() */ diff --git a/test/ares_queryloop.c b/test/ares_queryloop.c index 5bb09011..e932e4a2 100644 --- a/test/ares_queryloop.c +++ b/test/ares_queryloop.c @@ -77,7 +77,6 @@ static void ai_callback(void *arg, int status, int timeouts, ares_freeaddrinfo(result); } - static volatile ares_bool_t is_running = ARES_TRUE; @@ -96,7 +95,7 @@ static BOOL WINAPI ctrlc_handler(_In_ DWORD dwCtrlType) #else static void ctrlc_handler(int sig) { - switch(sig) { + switch (sig) { case SIGINT: is_running = ARES_FALSE; break; @@ -132,10 +131,10 @@ int main(int argc, char *argv[]) } memset(&options, 0, sizeof(options)); - optmask |= ARES_OPT_EVENT_THREAD; - options.evsys = ARES_EVSYS_DEFAULT; - optmask |= ARES_OPT_QUERY_CACHE; - options.qcache_max_ttl = 0; + optmask |= ARES_OPT_EVENT_THREAD; + options.evsys = ARES_EVSYS_DEFAULT; + optmask |= ARES_OPT_QUERY_CACHE; + options.qcache_max_ttl = 0; status = (ares_status_t)ares_init_options(&channel, &options, optmask); if (status != ARES_SUCCESS) { @@ -153,7 +152,7 @@ int main(int argc, char *argv[]) for (count = 1; is_running == ARES_TRUE; count++) { struct ares_addrinfo_hints hints; - char *servers = ares_get_servers_csv(channel); + char *servers = ares_get_servers_csv(channel); memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC;