clang-format

pull/630/head
Brad House 1 year ago
parent 3db69bbfeb
commit 6b408a9bc9
  1. 25
      src/lib/ares__hosts_file.c
  2. 11
      src/lib/ares__htable.c
  3. 12
      src/lib/ares__llist.c
  4. 3
      src/lib/ares__socket.c
  5. 4
      src/lib/ares_dns_write.c
  6. 12
      src/lib/ares_private.h
  7. 11
      src/lib/ares_process.c
  8. 6
      src/lib/ares_qcache.c
  9. 2
      src/lib/ares_rand.c
  10. 6
      src/lib/ares_update_servers.c
  11. 2
      src/lib/config-win32.h

@ -319,10 +319,9 @@ typedef enum {
ARES_MATCH_HOST = 2
} ares_hosts_file_match_t;
static ares_status_t ares__hosts_file_merge_entry(ares_hosts_file_t *hf,
ares_hosts_entry_t *existing,
ares_hosts_entry_t *entry,
ares_hosts_file_match_t matchtype)
static ares_status_t ares__hosts_file_merge_entry(
ares_hosts_file_t *hf, ares_hosts_entry_t *existing,
ares_hosts_entry_t *entry, ares_hosts_file_match_t matchtype)
{
ares__llist_node_t *node;
@ -357,8 +356,6 @@ static ares_status_t ares__hosts_file_merge_entry(ares_hosts_file_t *hf,
return ARES_SUCCESS;
}
static ares_hosts_file_match_t
ares__hosts_file_match(const ares_hosts_file_t *hf, ares_hosts_entry_t *entry,
ares_hosts_entry_t **match)
@ -432,8 +429,9 @@ static ares_status_t ares__hosts_file_add(ares_hosts_file_t *hosts,
node = ares__llist_node_prev(node)) {
const char *val = ares__llist_node_val(node);
if (num_hostnames == 0)
if (num_hostnames == 0) {
break;
}
num_hostnames--;
@ -939,8 +937,9 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry,
/* Cap at 100, some people use https://github.com/StevenBlack/hosts and we
* don't need 200k+ aliases */
if (naliases > 100)
if (naliases > 100) {
naliases = 100;
}
(*hostent)->h_aliases =
ares_malloc_zero((naliases + 1) * sizeof(*(*hostent)->h_aliases));
@ -962,8 +961,9 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry,
idx++;
/* Break out if artificially capped */
if (idx == naliases)
if (idx == naliases) {
break;
}
node = ares__llist_node_next(node);
}
@ -994,11 +994,12 @@ static ares_status_t
while (node != NULL) {
const char *host = ares__llist_node_val(node);
/* Cap at 100 entries. , some people use https://github.com/StevenBlack/hosts
* and we don't need 200k+ aliases */
/* Cap at 100 entries. , some people use
* https://github.com/StevenBlack/hosts and we don't need 200k+ aliases */
cnt++;
if (cnt > 100)
if (cnt > 100) {
break;
}
cname = ares__append_addrinfo_cname(&cnames);
if (cname == NULL) {

@ -185,13 +185,13 @@ static ares_bool_t ares__htable_expand(ares__htable_t *htable)
* that were recorded */
prealloc_llist_len = htable->num_collisions;
if (prealloc_llist_len) {
prealloc_llist = ares_malloc_zero(sizeof(*prealloc_llist) *
prealloc_llist_len);
prealloc_llist =
ares_malloc_zero(sizeof(*prealloc_llist) * prealloc_llist_len);
if (prealloc_llist == NULL) {
goto done;
}
}
for (i=0; i<prealloc_llist_len; i++) {
for (i = 0; i < prealloc_llist_len; i++) {
prealloc_llist[i] = ares__llist_create(htable->bucket_free);
if (prealloc_llist[i] == NULL) {
goto done;
@ -204,8 +204,9 @@ static ares_bool_t ares__htable_expand(ares__htable_t *htable)
ares__llist_node_t *node;
/* Nothing in this bucket */
if (htable->buckets[i] == NULL)
if (htable->buckets[i] == NULL) {
continue;
}
/* Fast path optimization (most likely case), there is likely only a single
* entry in both the source and destination, check for this to confirm and
@ -242,7 +243,7 @@ static ares_bool_t ares__htable_expand(ares__htable_t *htable)
if (prealloc_llist == NULL || prealloc_llist_len == 0) {
goto done;
}
buckets[idx] = prealloc_llist[prealloc_llist_len-1];
buckets[idx] = prealloc_llist[prealloc_llist_len - 1];
prealloc_llist_len--;
} else {
/* Collision occurred since the bucket wasn't empty */

@ -76,8 +76,9 @@ static void ares__llist_attach_at(ares__llist_t *list,
ares__llist_node_t *at,
ares__llist_node_t *node)
{
if (list == NULL || node == NULL)
if (list == NULL || node == NULL) {
return;
}
node->parent = list;
@ -248,8 +249,9 @@ static void ares__llist_node_detach(ares__llist_node_t *node)
{
ares__llist_t *list;
if (node == NULL)
if (node == NULL) {
return;
}
list = node->parent;
@ -338,8 +340,9 @@ void ares__llist_destroy(ares__llist_t *list)
void ares__llist_node_move_parent_last(ares__llist_node_t *node,
ares__llist_t *new_parent)
{
if (node == NULL || new_parent == NULL)
if (node == NULL || new_parent == NULL) {
return;
}
ares__llist_node_detach(node);
ares__llist_attach_at(new_parent, ARES__LLIST_INSERT_TAIL, NULL, node);
@ -348,8 +351,9 @@ void ares__llist_node_move_parent_last(ares__llist_node_t *node,
void ares__llist_node_move_parent_first(ares__llist_node_t *node,
ares__llist_t *new_parent)
{
if (node == NULL || new_parent == NULL)
if (node == NULL || new_parent == NULL) {
return;
}
ares__llist_node_detach(node);
ares__llist_attach_at(new_parent, ARES__LLIST_INSERT_HEAD, NULL, node);

@ -402,8 +402,9 @@ int ares__connect_socket(ares_channel_t *channel, ares_socket_t sockfd,
void ares__close_socket(ares_channel_t *channel, ares_socket_t s)
{
if (s == ARES_SOCKET_BAD)
if (s == ARES_SOCKET_BAD) {
return;
}
if (channel->sock_funcs && channel->sock_funcs->aclose) {
channel->sock_funcs->aclose(s, channel->sock_func_cb_data);

@ -1044,11 +1044,11 @@ done:
return status;
}
void ares_dns_record_write_ttl_decrement(ares_dns_record_t *dnsrec,
unsigned int ttl_decrement)
{
if (dnsrec == NULL)
if (dnsrec == NULL) {
return;
}
dnsrec->ttl_decrement = ttl_decrement;
}

@ -477,8 +477,7 @@ ares_status_t ares__sconfig_append(ares__llist_t **sconfig,
unsigned short tcp_port);
ares_status_t ares__sconfig_append_fromstr(ares__llist_t **sconfig,
const char *str);
ares_status_t
ares_in_addr_to_server_config_llist(const struct in_addr *servers,
ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers,
size_t nservers,
ares__llist_t **llist);
@ -569,20 +568,19 @@ ares_status_t ares__qcache_create(ares_rand_state *rand_state,
unsigned int max_ttl,
ares__qcache_t **cache_out);
void ares__qcache_flush(ares__qcache_t *cache);
ares_status_t ares_qcache_insert(ares_channel_t *channel,
struct timeval *now,
ares_status_t ares_qcache_insert(ares_channel_t *channel, struct timeval *now,
struct query *query,
ares_dns_record_t *dnsrec);
ares_status_t ares_qcache_fetch(ares_channel_t *channel, struct timeval *now,
const unsigned char *qbuf, size_t qlen,
unsigned char **abuf, size_t *alen);
# ifdef _MSC_VER
#ifdef _MSC_VER
typedef __int64 ares_int64_t;
typedef unsigned __int64 ares_uint64_t;
# else
#else
typedef long long ares_int64_t;
typedef unsigned long long ares_uint64_t;
# endif
#endif
#endif /* __ARES_PRIVATE_H */

@ -116,8 +116,9 @@ ares_bool_t ares__timedout(const struct timeval *now,
}
/* if the full seconds were identical, check the sub second parts */
return ((ares_int64_t)now->tv_usec - (ares_int64_t)check->tv_usec) >= 0 ?
ARES_TRUE : ARES_FALSE;
return ((ares_int64_t)now->tv_usec - (ares_int64_t)check->tv_usec) >= 0
? ARES_TRUE
: ARES_FALSE;
}
/* add the specific number of milliseconds to the time in the first argument */
@ -776,8 +777,9 @@ static struct server_state *ares__random_server(ares_channel_t *channel)
size_t num_servers = ares__slist_len(channel->servers);
/* Silence coverity, not possible */
if (num_servers == 0)
if (num_servers == 0) {
return NULL;
}
ares__rand_bytes(channel->rand_state, &c, 1);
@ -816,8 +818,9 @@ static size_t ares__calc_query_timeout(const struct query *query)
size_t rounds;
size_t num_servers = ares__slist_len(channel->servers);
if (num_servers == 0)
if (num_servers == 0) {
return 0;
}
/* For each trip through the entire server list, we want to double the
* retry from the last retry */

@ -308,8 +308,7 @@ done:
/* On success, takes ownership of dnsrec */
static ares_status_t ares__qcache_insert(ares__qcache_t *qcache,
ares_dns_record_t *dnsrec,
const unsigned char *qbuf,
size_t qlen,
const unsigned char *qbuf, size_t qlen,
struct timeval *now)
{
ares__qcache_entry_t *entry;
@ -422,8 +421,7 @@ done:
}
ares_status_t ares_qcache_insert(ares_channel_t *channel, struct timeval *now,
struct query *query,
ares_dns_record_t *dnsrec)
struct query *query, ares_dns_record_t *dnsrec)
{
return ares__qcache_insert(channel->qcache, dnsrec, query->qbuf, query->qlen,
now);

@ -53,8 +53,6 @@ typedef struct ares_rand_rc4 {
size_t j;
} ares_rand_rc4;
static unsigned int ares_u32_from_ptr(void *addr)
{
if (sizeof(void *) == 8) {

@ -643,8 +643,7 @@ fail:
}
static ares_status_t ares_addr_port_node_to_server_config_llist(
const struct ares_addr_port_node *servers,
ares__llist_t **llist)
const struct ares_addr_port_node *servers, ares__llist_t **llist)
{
const struct ares_addr_port_node *node;
ares__llist_t *s;
@ -695,8 +694,7 @@ fail:
return ARES_ENOMEM;
}
ares_status_t
ares_in_addr_to_server_config_llist(const struct in_addr *servers,
ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers,
size_t nservers,
ares__llist_t **llist)
{

@ -98,7 +98,7 @@
/* If we are building with OpenWatcom, we need to specify that we have
* <stdint.h>. */
#if defined(__WATCOMC__)
#define HAVE_STDINT_H
# define HAVE_STDINT_H
#endif
/* ---------------------------------------------------------------- */

Loading…
Cancel
Save