clang-format

pull/603/head
Brad House 1 year ago
parent 9037340ef6
commit 80fdc96f9a
  1. 13
      include/ares.h
  2. 36
      src/lib/ares__buf.c
  3. 4
      src/lib/ares__buf.h
  4. 3
      src/lib/ares__slist.c
  5. 3
      src/lib/ares__slist.h
  6. 3
      src/lib/ares_dns_name.c
  7. 2
      src/lib/ares_dns_parse.c
  8. 11
      src/lib/ares_dns_record.h
  9. 14
      src/lib/ares_dns_write.c
  10. 6
      src/lib/ares_getaddrinfo.c
  11. 2
      src/lib/ares_init.c
  12. 6
      src/lib/ares_private.h
  13. 2
      src/lib/ares_send.c
  14. 10
      test/ares-test.h

@ -317,7 +317,7 @@ struct ares_addrinfo_hints;
typedef struct ares_channeldata *ares_channel;
/* Current main channel typedef */
typedef struct ares_channeldata ares_channel_t;
typedef struct ares_channeldata ares_channel_t;
typedef void (*ares_callback)(void *arg, int status, int timeouts,
@ -359,9 +359,9 @@ CARES_EXTERN const char *ares_version(int *version);
CARES_EXTERN int ares_init(ares_channel_t **channelptr);
CARES_EXTERN int ares_init_options(ares_channel_t **channelptr,
CARES_EXTERN int ares_init_options(ares_channel_t **channelptr,
const struct ares_options *options,
int optmask);
int optmask);
CARES_EXTERN int ares_save_options(ares_channel_t *channel,
struct ares_options *options, int *optmask);
@ -703,9 +703,10 @@ struct ares_addr_port_node {
int tcp_port;
};
CARES_EXTERN int ares_set_servers(ares_channel_t *channel,
const struct ares_addr_node *servers);
CARES_EXTERN int ares_set_servers_ports(ares_channel_t *channel,
CARES_EXTERN int ares_set_servers(ares_channel_t *channel,
const struct ares_addr_node *servers);
CARES_EXTERN int
ares_set_servers_ports(ares_channel_t *channel,
const struct ares_addr_port_node *servers);
/* Incomming string format: host[:port][,host[:port]]... */

@ -836,13 +836,14 @@ ares_status_t ares__buf_parse_dns_str(ares__buf_t *buf, size_t remaining_len,
static ares_status_t ares__buf_append_num_hex(ares__buf_t *buf, size_t num,
size_t len)
{
size_t i;
size_t i;
static const unsigned char hexbytes[] = "0123456789ABCDEF";
for (i=len; i>0; i--) {
for (i = len; i > 0; i--) {
ares_status_t status;
status = ares__buf_append_byte(buf, hexbytes[(num >> ((i-1) * 4)) & 0xF]);
if (status != ARES_SUCCESS)
status = ares__buf_append_byte(buf, hexbytes[(num >> ((i - 1) * 4)) & 0xF]);
if (status != ARES_SUCCESS) {
return status;
}
}
return ARES_SUCCESS;
}
@ -858,45 +859,52 @@ ares_status_t ares__buf_hexdump(ares__buf_t *buf, const unsigned char *data,
size_t i;
ares_status_t status;
/* Each line is 16 bytes */
for (i=0; i<len; i += 16) {
for (i = 0; i < len; i += 16) {
size_t j;
/* Address */
status = ares__buf_append_num_hex(buf, i, 6);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
/* | */
status = ares__buf_append_str(buf, " | ");
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
for (j=i; j<i+16; j++) {
for (j = i; j < i + 16; j++) {
if (j >= len) {
status = ares__buf_append_str(buf, " ");
} else {
status = ares__buf_append_num_hex(buf, data[j], 2);
}
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
status = ares__buf_append_byte(buf, ' ');
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
}
/* | */
status = ares__buf_append_str(buf, " | ");
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
for (j=i; j<i+16; j++) {
for (j = i; j < i + 16; j++) {
if (j >= len) {
break;
}
status = ares__buf_append_byte(buf, ares__isprint(data[j])?data[j]:'.');
if (status != ARES_SUCCESS)
status =
ares__buf_append_byte(buf, ares__isprint(data[j]) ? data[j] : '.');
if (status != ARES_SUCCESS) {
return status;
}
}
ares__buf_append_byte(buf, '\n');

@ -152,8 +152,8 @@ void ares__buf_append_finish(ares__buf_t *buf, size_t len);
* \param[in] data_len Length of data to hexdump
* \return ARES_SUCCESS on success.
*/
ares_status_t ares__buf_hexdump(ares__buf_t *buf, const unsigned char *data,
size_t len);
ares_status_t ares__buf_hexdump(ares__buf_t *buf, const unsigned char *data,
size_t len);
/*! Clean up ares__buf_t and return allocated pointer to unprocessed data. It
* is the responsibility of the caller to ares_free() the returned buffer.

@ -318,8 +318,7 @@ void ares__slist_node_reinsert(ares__slist_node_t *node)
ares__slist_node_push(list, node);
}
ares__slist_node_t *ares__slist_node_find(ares__slist_t *list,
const void *val)
ares__slist_node_t *ares__slist_node_find(ares__slist_t *list, const void *val)
{
size_t i;
ares__slist_node_t *node = NULL;

@ -135,8 +135,7 @@ ares__slist_node_t *ares__slist_node_prev(ares__slist_node_t *node);
* \param[in] val Object to use for comparison
* \return SkipList Node Object or NULL if not found
*/
ares__slist_node_t *ares__slist_node_find(ares__slist_t *list,
const void *val);
ares__slist_node_t *ares__slist_node_find(ares__slist_t *list, const void *val);
/*! Fetch Node Value

@ -175,7 +175,8 @@ static ares__buf_t *ares_dns_labels_add(ares_dns_labels_t *labels)
return labels->label[labels->num - 1];
}
static const ares__buf_t *ares_dns_labels_get_last(const ares_dns_labels_t *labels)
static const ares__buf_t *
ares_dns_labels_get_last(const ares_dns_labels_t *labels)
{
if (labels == NULL || labels->num == 0) {
return NULL;

@ -422,7 +422,6 @@ static ares_status_t ares_dns_parse_rr_opt(ares__buf_t *buf, ares_dns_rr_t *rr,
return ARES_SUCCESS;
}
static ares_status_t ares_dns_parse_rr_tlsa(ares__buf_t *buf, ares_dns_rr_t *rr,
size_t rdlength)
{
@ -465,7 +464,6 @@ static ares_status_t ares_dns_parse_rr_tlsa(ares__buf_t *buf, ares_dns_rr_t *rr,
return ARES_SUCCESS;
}
static ares_status_t ares_dns_parse_rr_uri(ares__buf_t *buf, ares_dns_rr_t *rr,
size_t rdlength)
{

@ -52,7 +52,7 @@ typedef enum {
ARES_REC_TYPE_NAPTR = 35, /*!< RFC 3403. Naming Authority Pointer */
ARES_REC_TYPE_OPT = 41, /*!< RFC 6891. EDNS0 option (meta-RR) */
ARES_REC_TYPE_TLSA = 52, /*!< RFC 6698. DNS-Based Authentication of Named
ARES_REC_TYPE_TLSA = 52, /*!< RFC 6698. DNS-Based Authentication of Named
* Entities (DANE) Transport Layer Security
* (TLS) Protocol: TLSA */
#if 0
@ -248,13 +248,13 @@ typedef enum {
/*! TLSA Record ARES_RR_TLSA_CERT_USAGE known values */
typedef enum {
/*! Certificate Usage 0. CA Constraint. */
ARES_TLSA_USAGE_CA = 0,
ARES_TLSA_USAGE_CA = 0,
/*! Certificate Usage 1. Service Certificate Constraint. */
ARES_TLSA_USAGE_SERVICE = 1,
ARES_TLSA_USAGE_SERVICE = 1,
/*! Certificate Usage 2. Trust Anchor Assertation. */
ARES_TLSA_USAGE_TRUSTANCHOR = 2,
/*! Certificate Usage 3. Domain-issued certificate. */
ARES_TLSA_USAGE_DOMAIN = 3
ARES_TLSA_USAGE_DOMAIN = 3
} ares_tlsa_usage_t;
/*! TLSA Record ARES_RR_TLSA_SELECTOR known values */
@ -268,14 +268,13 @@ typedef enum {
/*! TLSA Record ARES_RR_TLSA_MATCH known values */
typedef enum {
/*! Exact match */
ARES_TLSA_MATCH_EXACT = 0,
ARES_TLSA_MATCH_EXACT = 0,
/*! Sha256 match */
ARES_TLSA_MATCH_SHA256 = 1,
/*! Sha512 match */
ARES_TLSA_MATCH_SHA512 = 2
} ares_tlsa_match_t;
/*! String representation of DNS Record Type
*
* \param[in] type DNS Record Type

@ -94,8 +94,8 @@ static ares_status_t ares_dns_write_header(const ares_dns_record_t *dnsrec,
}
/* RCODE */
rcode = (unsigned short)(dnsrec->rcode & 0xF);
u16 |= rcode;
rcode = (unsigned short)(dnsrec->rcode & 0xF);
u16 |= rcode;
status = ares__buf_append_be16(buf, u16);
if (status != ARES_SUCCESS) {
@ -215,11 +215,11 @@ static ares_status_t ares_dns_write_rr_binstrs(ares__buf_t *buf,
const ares_dns_rr_t *rr,
ares_dns_rr_key_t key)
{
const unsigned char *bin;
const unsigned char *ptr;
size_t bin_len;
size_t ptr_len;
ares_status_t status;
const unsigned char *bin;
const unsigned char *ptr;
size_t bin_len;
size_t ptr_len;
ares_status_t status;
bin = ares_dns_rr_get_bin(rr, key, &bin_len);
if (bin == NULL) {

@ -456,10 +456,10 @@ static void next_lookup(struct host_query *hquery, ares_status_t status)
static void terminate_retries(const struct host_query *hquery,
unsigned short qid)
{
unsigned short term_qid =
unsigned short term_qid =
(qid == hquery->qid_a) ? hquery->qid_aaaa : hquery->qid_a;
const ares_channel_t *channel = hquery->channel;
struct query *query = NULL;
const ares_channel_t *channel = hquery->channel;
struct query *query = NULL;
/* No other outstanding queries, nothing to do */
if (!hquery->remaining) {

@ -286,7 +286,7 @@ error:
return rc;
}
int ares_init_options(ares_channel_t **channelptr,
int ares_init_options(ares_channel_t **channelptr,
const struct ares_options *options, int optmask)
{
ares_channel_t *channel;

@ -497,7 +497,7 @@ ares_status_t ares__hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry,
unsigned short port,
ares_bool_t want_cnames,
struct ares_addrinfo *ai);
ares_bool_t ares__isprint(int ch);
ares_bool_t ares__isprint(int ch);
/*! Parse a compressed DNS name as defined in RFC1035 starting at the current
@ -514,8 +514,8 @@ ares_bool_t ares__isprint(int ch);
* a valid hostname or will return error.
* \return ARES_SUCCESS on success
*/
ares_status_t ares__dns_name_parse(ares__buf_t *buf, char **name,
ares_bool_t is_hostname);
ares_status_t ares__dns_name_parse(ares__buf_t *buf, char **name,
ares_bool_t is_hostname);
/*! Write the DNS name to the buffer in the DNS domain-name syntax as a
* series of labels. The maximum domain name length is 255 characters with

@ -75,7 +75,7 @@ ares_status_t ares_send_ex(ares_channel_t *channel, const unsigned char *qbuf,
query->timeout.tv_usec = 0;
memcpy(query->qbuf, qbuf, qlen);
query->qlen = qlen;
query->qlen = qlen;
/* Fill in query arguments. */
query->callback = callback;

10
test/ares-test.h vendored

@ -67,10 +67,10 @@ extern std::vector<std::pair<int, bool>> families_modes;
// Process all pending work on ares-owned file descriptors, plus
// optionally the given set-of-FDs + work function.
void ProcessWork(ares_channel_t * channel,
std::function<std::set<int>()> get_extrafds,
std::function<void(int)> process_extra);
std::set<int> NoExtraFDs();
void ProcessWork(ares_channel_t *channel,
std::function<std::set<int>()> get_extrafds,
std::function<void(int)> process_extra);
std::set<int> NoExtraFDs();
// Test fixture that ensures library initialization, and allows
// memory allocations to be failed.
@ -278,7 +278,7 @@ protected:
NiceMockServers servers_;
// Convenience reference to first server.
NiceMockServer &server_;
ares_channel_t * channel_;
ares_channel_t *channel_;
};
class MockChannelTest

Loading…
Cancel
Save