Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
bradh352 committed Jun 1, 2024
1 parent 75f6a6f commit 25ad4ca
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/lib/ares__htable_vpvp.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ ares_bool_t ares__htable_vpvp_get(const ares__htable_vpvp_t *htable,
}

void *ares__htable_vpvp_get_direct(const ares__htable_vpvp_t *htable,
const void *key)
const void *key)
{
void *val = NULL;
ares__htable_vpvp_get(htable, key, &val);
return val;
}

ares_bool_t ares__htable_vpvp_remove(ares__htable_vpvp_t *htable,
const void *key)
const void *key)
{
if (htable == NULL) {
return ARES_FALSE;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ares__htable_vpvp.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void *ares__htable_vpvp_get_direct(const ares__htable_vpvp_t *htable,
* \return ARES_TRUE if found, ARES_FALSE if not
*/
ares_bool_t ares__htable_vpvp_remove(ares__htable_vpvp_t *htable,
const void *key);
const void *key);

/*! Retrieve the number of keys stored in the hash table
*
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ares__threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ ares_status_t ares_queue_wait_empty(ares_channel_t *channel, int timeout_ms)
unsigned long tms;

ares__timeval_remaining(&tv_remaining, &tv_now, &tout);
tms = (unsigned long)((tv_remaining.sec * 1000) +
(tv_remaining.usec / 1000));
tms =
(unsigned long)((tv_remaining.sec * 1000) + (tv_remaining.usec / 1000));
if (tms == 0) {
status = ARES_ETIMEOUT;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ares__timeval.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ ares_timeval_t ares__tvnow(void)
ares_timeval_t now;
ULONGLONG milliseconds = GetTickCount64();

now.sec = (ares_int64_t)milliseconds / 1000;
now.usec = (unsigned int)(milliseconds % 1000) * 1000;
now.sec = (ares_int64_t)milliseconds / 1000;
now.usec = (unsigned int)(milliseconds % 1000) * 1000;
return now;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/ares_event_configchg.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static void ares_event_configchg_cb(ares_event_thread_t *e, ares_socket_t fd,
* decrease performance. Hence, the buffer used for reading from
* the inotify file descriptor should have the same alignment as
* struct inotify_event. */
unsigned char buf[4096]
unsigned char buf[4096]
__attribute__((aligned(__alignof__(struct inotify_event))));
const struct inotify_event *event;
ssize_t len;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/ares_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ ares_bool_t ares__timedout(const ares_timeval_t *now,

/* Returns one of the normal ares status codes like ARES_SUCCESS */
ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now);
ares_status_t ares__requeue_query(struct query *query, const ares_timeval_t *now);
ares_status_t ares__requeue_query(struct query *query,
const ares_timeval_t *now);

/*! Retrieve a list of names to use for searching. The first successful
* query in the list wins. This function also uses the HOSTSALIASES file
Expand Down
32 changes: 15 additions & 17 deletions src/lib/ares_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@
#include "ares_nameser.h"
#include "ares_dns.h"

static void timeadd(ares_timeval_t *now, size_t millisecs);
static ares_bool_t try_again(int errnum);
static void write_tcp_data(ares_channel_t *channel, fd_set *write_fds,
ares_socket_t write_fd);
static void read_packets(ares_channel_t *channel, fd_set *read_fds,
ares_socket_t read_fd,
const ares_timeval_t *now);
static void process_timeouts(ares_channel_t *channel,
const ares_timeval_t *now);
static void timeadd(ares_timeval_t *now, size_t millisecs);
static ares_bool_t try_again(int errnum);
static void write_tcp_data(ares_channel_t *channel, fd_set *write_fds,
ares_socket_t write_fd);
static void read_packets(ares_channel_t *channel, fd_set *read_fds,
ares_socket_t read_fd, const ares_timeval_t *now);
static void process_timeouts(ares_channel_t *channel,
const ares_timeval_t *now);
static ares_status_t process_answer(ares_channel_t *channel,
const unsigned char *abuf, size_t alen,
struct server_connection *conn,
Expand All @@ -71,8 +70,7 @@ static ares_bool_t same_questions(const ares_dns_record_t *qrec,
static ares_bool_t same_address(const struct sockaddr *sa,
const struct ares_addr *aa);
static void end_query(ares_channel_t *channel, struct query *query,
ares_status_t status,
const ares_dns_record_t *dnsrec);
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,
Expand Down Expand Up @@ -182,7 +180,7 @@ static void timeadd(ares_timeval_t *now, size_t millisecs)
now->usec += (unsigned int)((millisecs % 1000) * 1000);

if (now->usec >= 1000000) {
now->sec += now->usec / 1000000;
now->sec += now->usec / 1000000;
now->usec %= 1000000;
}
}
Expand Down Expand Up @@ -818,7 +816,8 @@ static void handle_conn_error(struct server_connection *conn,
ares__close_connection(conn);
}

ares_status_t ares__requeue_query(struct query *query, const ares_timeval_t *now)
ares_status_t ares__requeue_query(struct query *query,
const ares_timeval_t *now)
{
ares_channel_t *channel = query->channel;
size_t max_tries = ares__slist_len(channel->servers) * channel->tries;
Expand Down Expand Up @@ -887,11 +886,10 @@ static struct server_state *ares__random_server(ares_channel_t *channel)
*/
static struct server_state *ares__failover_server(ares_channel_t *channel)
{
struct server_state *first_server =
ares__slist_first_val(channel->servers);
const struct server_state *last_server =
struct server_state *first_server = ares__slist_first_val(channel->servers);
const struct server_state *last_server =
ares__slist_last_val(channel->servers);
unsigned short r;
unsigned short r;

/* Defensive code against no servers being available on the channel. */
if (first_server == NULL) {
Expand Down
6 changes: 4 additions & 2 deletions src/lib/ares_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ ares_bool_t ares__is_hostname(const char *str)
{
size_t i;

if (str == NULL)
if (str == NULL) {
return ARES_FALSE;
}

for (i = 0; str[i] != 0; i++) {
if (!ares__is_hostnamech(str[i])) {
Expand All @@ -276,8 +277,9 @@ ares_bool_t ares__str_isprint(const char *str, size_t len)
{
size_t i;

if (str == NULL && len != 0)
if (str == NULL && len != 0) {
return ARES_FALSE;
}

for (i = 0; i < len; i++) {
if (!ares__isprint(str[i])) {
Expand Down
3 changes: 1 addition & 2 deletions src/lib/ares_sysconfig_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver,
if (search_is_duplicate(sysconfig, search)) {
continue;
}
sysconfig->domains[sysconfig->ndomains] =
ares_strdup(search);
sysconfig->domains[sysconfig->ndomains] = ares_strdup(search);
if (sysconfig->domains[sysconfig->ndomains] == NULL) {
return ARES_ENOMEM;
}
Expand Down
1 change: 0 additions & 1 deletion src/lib/ares_timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ static struct timeval ares_timeval_to_struct_timeval(const ares_timeval_t *atv)
return tv;
}


static ares_timeval_t struct_timeval_to_ares_timeval(const struct timeval *tv)
{
ares_timeval_t atv;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ares_update_servers.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ static ares_bool_t ares__servers_remove_stale(ares_channel_t *channel,
ares__llist_t *srvlist)
{
ares_bool_t stale_removed = ARES_FALSE;
ares__slist_node_t *snode = ares__slist_node_first(channel->servers);
ares__slist_node_t *snode = ares__slist_node_first(channel->servers);

while (snode != NULL) {
ares__slist_node_t *snext = ares__slist_node_next(snode);
Expand Down

0 comments on commit 25ad4ca

Please sign in to comment.