clang-format

pull/604/head
Brad House 1 year ago
parent c433477753
commit a76c95a6d7
  1. 2
      src/lib/ares__buf.c
  2. 9
      src/lib/ares_dns_mapping.c
  3. 11
      src/lib/ares_dns_parse.c
  4. 57
      src/lib/ares_dns_record.c
  5. 18
      src/lib/ares_dns_record.h
  6. 14
      src/lib/ares_dns_write.c
  7. 3
      src/lib/ares_fds.c
  8. 5
      src/lib/ares_process.c

@ -568,7 +568,7 @@ ares_status_t ares__buf_fetch_bytes_dup(ares__buf_t *buf, size_t len,
return ARES_EBADRESP;
}
*bytes = ares_malloc(null_term?len+1:len);
*bytes = ares_malloc(null_term ? len + 1 : len);
if (*bytes == NULL) {
return ARES_ENOMEM;
}

@ -497,11 +497,10 @@ static const ares_dns_rr_key_t rr_naptr_keys[] = {
ARES_RR_NAPTR_ORDER, ARES_RR_NAPTR_PREFERENCE, ARES_RR_NAPTR_FLAGS,
ARES_RR_NAPTR_SERVICES, ARES_RR_NAPTR_REGEXP, ARES_RR_NAPTR_REPLACEMENT
};
static const ares_dns_rr_key_t rr_opt_keys[] = { ARES_RR_OPT_UDP_SIZE,
ARES_RR_OPT_EXT_RCODE,
ARES_RR_OPT_VERSION,
ARES_RR_OPT_FLAGS,
ARES_RR_OPT_OPTIONS };
static const ares_dns_rr_key_t rr_opt_keys[] = {
ARES_RR_OPT_UDP_SIZE, ARES_RR_OPT_EXT_RCODE, ARES_RR_OPT_VERSION,
ARES_RR_OPT_FLAGS, ARES_RR_OPT_OPTIONS
};
static const ares_dns_rr_key_t rr_tlsa_keys[] = { ARES_RR_TLSA_CERT_USAGE,
ARES_RR_TLSA_SELECTOR,
ARES_RR_TLSA_MATCH,

@ -503,8 +503,8 @@ static ares_status_t ares_dns_parse_rr_svcb(ares__buf_t *buf, ares_dns_rr_t *rr,
return status;
}
status = ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr,
ARES_RR_SVCB_TARGET);
status =
ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr, ARES_RR_SVCB_TARGET);
if (status != ARES_SUCCESS) {
return status;
}
@ -544,8 +544,7 @@ static ares_status_t ares_dns_parse_rr_svcb(ares__buf_t *buf, ares_dns_rr_t *rr,
}
static ares_status_t ares_dns_parse_rr_https(ares__buf_t *buf,
ares_dns_rr_t *rr,
size_t rdlength)
ares_dns_rr_t *rr, size_t rdlength)
{
ares_status_t status;
size_t orig_len = ares__buf_len(buf);
@ -555,8 +554,8 @@ static ares_status_t ares_dns_parse_rr_https(ares__buf_t *buf,
return status;
}
status = ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr,
ARES_RR_HTTPS_TARGET);
status =
ares_dns_parse_and_set_dns_name(buf, ARES_FALSE, rr, ARES_RR_HTTPS_TARGET);
if (status != ARES_SUCCESS) {
return status;
}

@ -97,10 +97,11 @@ static void ares__dns_options_free(ares__dns_options_t *options)
{
size_t i;
if (options == NULL)
if (options == NULL) {
return;
}
for (i=0; i<options->cnt; i++) {
for (i = 0; i < options->cnt; i++) {
ares_free(options->optval[i].val);
}
ares_free(options->optval);
@ -809,7 +810,8 @@ const unsigned char *ares_dns_rr_get_bin(const ares_dns_rr_t *dns_rr,
size_t const *bin_len = NULL;
if ((ares_dns_rr_key_datatype(key) != ARES_DATATYPE_BIN &&
ares_dns_rr_key_datatype(key) != ARES_DATATYPE_BINP) || len == NULL) {
ares_dns_rr_key_datatype(key) != ARES_DATATYPE_BINP) ||
len == NULL) {
return NULL;
}
@ -863,17 +865,17 @@ size_t ares_dns_rr_get_opt_cnt(const ares_dns_rr_t *dns_rr,
}
unsigned short ares_dns_rr_get_opt(const ares_dns_rr_t *dns_rr,
ares_dns_rr_key_t key,
size_t idx,
const unsigned char **val,
size_t *val_len)
ares_dns_rr_key_t key, size_t idx,
const unsigned char **val, size_t *val_len)
{
const ares__dns_options_t *opts;
if (val)
if (val) {
*val = NULL;
if (val_len)
}
if (val_len) {
*val_len = 0;
}
if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_OPT) {
return 65535;
@ -899,18 +901,18 @@ unsigned short ares_dns_rr_get_opt(const ares_dns_rr_t *dns_rr,
}
ares_bool_t ares_dns_rr_get_opt_byid(const ares_dns_rr_t *dns_rr,
ares_dns_rr_key_t key,
unsigned short opt,
const unsigned char **val,
size_t *val_len)
ares_dns_rr_key_t key, unsigned short opt,
const unsigned char **val, size_t *val_len)
{
const ares__dns_options_t *opts;
size_t i;
if (val)
if (val) {
*val = NULL;
if (val_len)
}
if (val_len) {
*val_len = 0;
}
if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_OPT) {
return ARES_FALSE;
@ -921,14 +923,15 @@ ares_bool_t ares_dns_rr_get_opt_byid(const ares_dns_rr_t *dns_rr,
return ARES_FALSE;
}
for (i=0; i<opts->cnt; i++) {
for (i = 0; i < opts->cnt; i++) {
if (opts->optval[i].opt == opt) {
break;
}
}
if (i >= opts->cnt)
if (i >= opts->cnt) {
return ARES_FALSE;
}
if (val) {
*val = opts->optval[i].val;
@ -1061,7 +1064,7 @@ ares_status_t ares_dns_rr_set_bin(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key,
{
ares_status_t status;
ares_dns_datatype_t datatype = ares_dns_rr_key_datatype(key);
size_t alloclen = (datatype == ARES_DATATYPE_BINP)?len+1:len;
size_t alloclen = (datatype == ARES_DATATYPE_BINP) ? len + 1 : len;
unsigned char *temp = ares_malloc(alloclen);
if (temp == NULL) {
@ -1126,12 +1129,9 @@ ares_status_t ares_dns_rr_set_str(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key,
return status;
}
ares_status_t ares_dns_rr_set_opt_own(ares_dns_rr_t *dns_rr,
ares_dns_rr_key_t key,
unsigned short opt,
unsigned char *val,
size_t val_len)
ares_dns_rr_key_t key, unsigned short opt,
unsigned char *val, size_t val_len)
{
ares__dns_options_t **options;
size_t idx;
@ -1152,10 +1152,11 @@ ares_status_t ares_dns_rr_set_opt_own(ares_dns_rr_t *dns_rr,
return ARES_ENOMEM;
}
for (idx=0; idx<(*options)->cnt; idx++) {
if ((*options)->optval[idx].opt == opt)
for (idx = 0; idx < (*options)->cnt; idx++) {
if ((*options)->optval[idx].opt == opt) {
break;
}
}
/* Duplicate entry, replace */
if (idx != (*options)->cnt) {
@ -1196,10 +1197,8 @@ done:
return ARES_SUCCESS;
}
ares_status_t ares_dns_rr_set_opt(ares_dns_rr_t *dns_rr,
ares_dns_rr_key_t key,
unsigned short opt,
const unsigned char *val,
ares_status_t ares_dns_rr_set_opt(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key,
unsigned short opt, const unsigned char *val,
size_t val_len)
{
unsigned char *temp = NULL;

@ -709,8 +709,7 @@ unsigned int ares_dns_rr_get_u32(const ares_dns_rr_t *dns_rr,
* \return pointer binary data or NULL on error
*/
const unsigned char *ares_dns_rr_get_bin(const ares_dns_rr_t *dns_rr,
ares_dns_rr_key_t key,
size_t *len);
ares_dns_rr_key_t key, size_t *len);
/*! Retrieve the number of options stored for the RR.
*
@ -734,10 +733,8 @@ size_t ares_dns_rr_get_opt_cnt(const ares_dns_rr_t *dns_rr,
* \return option key/id on success, 65535 on misuse.
*/
unsigned short ares_dns_rr_get_opt(const ares_dns_rr_t *dns_rr,
ares_dns_rr_key_t key,
size_t idx,
const unsigned char **val,
size_t *val_len);
ares_dns_rr_key_t key, size_t idx,
const unsigned char **val, size_t *val_len);
/*! Retrieve the option for the RR by the option key/id.
*
@ -752,8 +749,7 @@ unsigned short ares_dns_rr_get_opt(const ares_dns_rr_t *dns_rr,
* \return ARES_TRUE on success, ARES_FALSE on misuse.
*/
ares_bool_t ares_dns_rr_get_opt_byid(const ares_dns_rr_t *dns_rr,
ares_dns_rr_key_t key,
unsigned short opt,
ares_dns_rr_key_t key, unsigned short opt,
const unsigned char **val,
size_t *val_len);
@ -797,10 +793,8 @@ ares_status_t ares_dns_rr_set_bin_own(ares_dns_rr_t *dns_rr,
ares_dns_rr_key_t key, unsigned char *val,
size_t len);
ares_status_t ares_dns_rr_set_opt_own(ares_dns_rr_t *dns_rr,
ares_dns_rr_key_t key,
unsigned short opt,
unsigned char *val,
size_t val_len);
ares_dns_rr_key_t key, unsigned short opt,
unsigned char *val, size_t val_len);
ares_status_t ares_dns_record_rr_prealloc(ares_dns_record_t *dnsrec,
ares_dns_section_t sect, size_t cnt);

@ -543,7 +543,7 @@ static ares_status_t ares_dns_write_rr_opt(ares__buf_t *buf,
}
/* Append Options */
for (i=0; i<ares_dns_rr_get_opt_cnt(rr, ARES_RR_OPT_OPTIONS); i++) {
for (i = 0; i < ares_dns_rr_get_opt_cnt(rr, ARES_RR_OPT_OPTIONS); i++) {
unsigned short opt;
size_t val_len;
const unsigned char *val;
@ -625,14 +625,14 @@ static ares_status_t ares_dns_write_rr_svcb(ares__buf_t *buf,
}
/* TARGET */
status = ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
ARES_RR_SVCB_TARGET);
status =
ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE, ARES_RR_SVCB_TARGET);
if (status != ARES_SUCCESS) {
return status;
}
/* Append Params */
for (i=0; i<ares_dns_rr_get_opt_cnt(rr, ARES_RR_SVCB_PARAMS); i++) {
for (i = 0; i < ares_dns_rr_get_opt_cnt(rr, ARES_RR_SVCB_PARAMS); i++) {
unsigned short opt;
size_t val_len;
const unsigned char *val;
@ -676,14 +676,14 @@ static ares_status_t ares_dns_write_rr_https(ares__buf_t *buf,
}
/* TARGET */
status = ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE,
ARES_RR_HTTPS_TARGET);
status =
ares_dns_write_rr_name(buf, rr, namelist, ARES_FALSE, ARES_RR_HTTPS_TARGET);
if (status != ARES_SUCCESS) {
return status;
}
/* Append Params */
for (i=0; i<ares_dns_rr_get_opt_cnt(rr, ARES_RR_HTTPS_PARAMS); i++) {
for (i = 0; i < ares_dns_rr_get_opt_cnt(rr, ARES_RR_HTTPS_PARAMS); i++) {
unsigned short opt;
size_t val_len;
const unsigned char *val;

@ -48,8 +48,9 @@ int ares_fds(ares_channel_t *channel, fd_set *read_fds, fd_set *write_fds)
node = ares__llist_node_next(node)) {
const struct server_connection *conn = ares__llist_node_val(node);
if (!active_queries && !conn->is_tcp)
if (!active_queries && !conn->is_tcp) {
continue;
}
/* Always wait on read */
FD_SET(conn->fd, read_fds);

@ -738,8 +738,7 @@ static void handle_conn_error(struct server_connection *conn,
ares_status_t ares__requeue_query(struct query *query, struct timeval *now)
{
const ares_channel_t *channel = query->channel;
size_t max_tries = ares__slist_len(channel->servers) *
channel->tries;
size_t max_tries = ares__slist_len(channel->servers) * channel->tries;
query->try_count++;
@ -796,7 +795,6 @@ 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__retry_penalty(struct query *query)
{
const ares_channel_t *channel = query->channel;
@ -828,7 +826,6 @@ static size_t ares__retry_penalty(struct query *query)
return timeplus;
}
ares_status_t ares__send_query(struct query *query, struct timeval *now)
{
ares_channel_t *channel = query->channel;

Loading…
Cancel
Save