clang-format

pull/617/head
Brad House 1 year ago
parent b2ea0cd6b2
commit 4e73f1055e
  1. 1
      include/ares.h
  2. 15
      src/lib/ares__buf.c
  3. 8
      src/lib/ares_dns_mapping.c
  4. 9
      src/lib/ares_dns_parse.c
  5. 32
      src/lib/ares_dns_record.c
  6. 6
      src/lib/ares_math.c
  7. 3
      src/lib/ares_private.h
  8. 13
      src/lib/ares_process.c
  9. 1
      src/lib/ares_query.c
  10. 1
      src/lib/ares_send.c
  11. 8
      src/lib/ares_strsplit.c
  12. 31
      src/tools/adig.c
  13. 3
      src/tools/ares_getopt.c

@ -519,7 +519,6 @@ struct ares_addr {
} addr;
};
struct ares_addrttl {
struct in_addr ipaddr;
int ttl;

@ -838,7 +838,6 @@ ares_status_t ares__buf_parse_dns_str(ares__buf_t *buf, size_t remaining_len,
&len, allow_multiple);
}
ares_status_t ares__buf_append_num_dec(ares__buf_t *buf, size_t num, size_t len)
{
size_t i;
@ -850,16 +849,17 @@ ares_status_t ares__buf_append_num_dec(ares__buf_t *buf, size_t num, size_t len)
mod = ares__pow(10, len);
for (i=len; i>0; i--) {
for (i = len; i > 0; i--) {
size_t digit = (num % mod);
ares_status_t status;
mod /= 10;
digit /= mod;
status = ares__buf_append_byte(buf, '0' + (unsigned char)(digit & 0xFF));
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
}
return ARES_SUCCESS;
}
@ -887,8 +887,7 @@ static ares_status_t ares__buf_append_str(ares__buf_t *buf, const char *str)
return ares__buf_append(buf, (const unsigned char *)str, ares_strlen(str));
}
static ares_status_t ares__buf_hexdump_line(ares__buf_t *buf,
size_t idx,
static ares_status_t ares__buf_hexdump_line(ares__buf_t *buf, size_t idx,
const unsigned char *data,
size_t len)
{
@ -933,8 +932,7 @@ static ares_status_t ares__buf_hexdump_line(ares__buf_t *buf,
if (i >= len) {
break;
}
status =
ares__buf_append_byte(buf, ares__isprint(data[i]) ? data[i] : '.');
status = ares__buf_append_byte(buf, ares__isprint(data[i]) ? data[i] : '.');
if (status != ARES_SUCCESS) {
return status;
}
@ -952,9 +950,10 @@ ares_status_t ares__buf_hexdump(ares__buf_t *buf, const unsigned char *data,
for (i = 0; i < len; i += 16) {
ares_status_t status;
status = ares__buf_hexdump_line(buf, i, data + i, len - i);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
return status;
}
}
return ARES_SUCCESS;
}

@ -503,10 +503,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_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_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,

@ -62,12 +62,9 @@ static ares_status_t ares_dns_parse_and_set_dns_name(ares__buf_t *buf,
return ARES_SUCCESS;
}
static ares_status_t ares_dns_parse_and_set_dns_str(ares__buf_t *buf,
size_t max_len,
ares_bool_t allow_multiple,
ares_dns_rr_t *rr,
ares_dns_rr_key_t key,
ares_bool_t blank_allowed)
static ares_status_t ares_dns_parse_and_set_dns_str(
ares__buf_t *buf, size_t max_len, ares_bool_t allow_multiple,
ares_dns_rr_t *rr, ares_dns_rr_key_t key, ares_bool_t blank_allowed)
{
ares_status_t status;
char *str = NULL;

@ -499,7 +499,8 @@ ares_dns_rr_t *ares_dns_record_rr_get(ares_dns_record_t *dnsrec,
return &rr_ptr[idx];
}
static const ares_dns_rr_t *ares_dns_record_rr_get_const(const ares_dns_record_t *dnsrec,
static const ares_dns_rr_t *
ares_dns_record_rr_get_const(const ares_dns_record_t *dnsrec,
ares_dns_section_t sect, size_t idx)
{
return ares_dns_record_rr_get((void *)((size_t)dnsrec), sect, idx);
@ -1236,12 +1237,14 @@ char *ares_dns_addr_to_ptr(const struct ares_addr *addr)
ares_status_t status;
static const unsigned char hexbytes[] = "0123456789abcdef";
if (addr->family != AF_INET && addr->family != AF_INET6)
if (addr->family != AF_INET && addr->family != AF_INET6) {
goto fail;
}
buf = ares__buf_create();
if (buf == NULL)
if (buf == NULL) {
goto fail;
}
if (addr->family == AF_INET) {
ptr = (const unsigned char *)&addr->addr.addr4;
@ -1251,39 +1254,44 @@ char *ares_dns_addr_to_ptr(const struct ares_addr *addr)
ptr_len = 16;
}
for (i=ptr_len; i>0; i--) {
for (i = ptr_len; i > 0; i--) {
if (addr->family == AF_INET) {
status = ares__buf_append_num_dec(buf, (size_t)ptr[i-1], 0);
status = ares__buf_append_num_dec(buf, (size_t)ptr[i - 1], 0);
} else {
unsigned char c;
c = ptr[i-1] & 0xF;
c = ptr[i - 1] & 0xF;
status = ares__buf_append_byte(buf, hexbytes[c]);
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
goto fail;
}
status = ares__buf_append_byte(buf, '.');
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
goto fail;
}
c = (ptr[i-1] >> 4) & 0xF;
c = (ptr[i - 1] >> 4) & 0xF;
status = ares__buf_append_byte(buf, hexbytes[c]);
}
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
goto fail;
}
status = ares__buf_append_byte(buf, '.');
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
goto fail;
}
}
if (addr->family == AF_INET) {
status = ares__buf_append(buf, (const unsigned char *)"in-addr.arpa", 12);
} else {
status = ares__buf_append(buf, (const unsigned char *)"ip6.arpa", 8);
}
if (status != ARES_SUCCESS)
if (status != ARES_SUCCESS) {
goto fail;
}
return ares__buf_finish_str(buf, NULL);

@ -92,8 +92,9 @@ size_t ares__count_digits(size_t n)
for (digits = 0; n > 0; digits++) {
n /= 10;
}
if (digits == 0)
if (digits == 0) {
digits = 1;
}
return digits;
}
@ -105,8 +106,9 @@ size_t ares__count_hexdigits(size_t n)
for (digits = 0; n > 0; digits++) {
n /= 16;
}
if (digits == 0)
if (digits == 0) {
digits = 1;
}
return digits;
}

@ -277,7 +277,8 @@ struct ares_channeldata {
* failures, followed by the configuration order if failures are equal. */
ares__slist_t *servers;
/* random state to use when generating new ids and generating retry penalties */
/* random state to use when generating new ids and generating retry penalties
*/
ares_rand_state *rand_state;
/* All active queries in a single list */

@ -688,8 +688,8 @@ static ares_status_t process_answer(ares_channel_t *channel,
*/
if (!(channel->flags & ARES_FLAG_NOCHECKRESP)) {
ares_dns_rcode_t rcode = ares_dns_record_get_rcode(rdnsrec);
if (rcode == ARES_RCODE_SERVFAIL ||
rcode == ARES_RCODE_NOTIMP || rcode == ARES_RCODE_REFUSED) {
if (rcode == ARES_RCODE_SERVFAIL || rcode == ARES_RCODE_NOTIMP ||
rcode == ARES_RCODE_REFUSED) {
switch (rcode) {
case ARES_RCODE_SERVFAIL:
query->error_status = ARES_ESERVFAIL;
@ -811,8 +811,9 @@ static size_t ares__calc_query_timeout(struct query *query)
timeplus <<= rounds;
}
if (channel->maxtimeout && timeplus > channel->maxtimeout)
if (channel->maxtimeout && timeplus > channel->maxtimeout) {
timeplus = channel->maxtimeout;
}
/* Add some jitter to the retry timeout.
*
@ -820,7 +821,8 @@ static size_t ares__calc_query_timeout(struct query *query)
* simultaneously from multiple hosts and DNS server throttle these requests.
* Adding randomness allows to avoid synchronisation of retries.
*
* Value of timeplus adjusted randomly to the range [0.5 * timeplus, timeplus].
* Value of timeplus adjusted randomly to the range [0.5 * timeplus,
* timeplus].
*/
if (rounds > 0) {
unsigned short r;
@ -833,8 +835,9 @@ static size_t ares__calc_query_timeout(struct query *query)
/* We want explicitly guarantee that timeplus is greater or equal to timeout
* specified in channel options. */
if (timeplus < channel->timeout)
if (timeplus < channel->timeout) {
timeplus = channel->timeout;
}
return timeplus;
}

@ -45,7 +45,6 @@ struct qquery {
static void qcallback(void *arg, int status, int timeouts, unsigned char *abuf,
int alen);
ares_status_t ares_query_qid(ares_channel_t *channel, const char *name,
int dnsclass, int type, ares_callback callback,
void *arg, unsigned short *qid)

@ -37,7 +37,6 @@
#include "ares_dns.h"
#include "ares_private.h"
static unsigned short generate_unique_qid(ares_channel_t *channel)
{
unsigned short id;

@ -51,14 +51,16 @@ char **ares__strsplit_duplicate(char **elms, size_t num_elm)
size_t i;
char **out;
if (elms == NULL || num_elm == 0)
if (elms == NULL || num_elm == 0) {
return NULL;
}
out = ares_malloc_zero(sizeof(*elms) * num_elm);
if (out == NULL)
if (out == NULL) {
return NULL;
}
for (i=0; i<num_elm; i++) {
for (i = 0; i < num_elm; i++) {
out[i] = ares_strdup(elms[i]);
if (out[i] == NULL) {
ares__strsplit_free(out, num_elm);

@ -146,7 +146,8 @@ static void print_help(void)
" SOA, SRV, TXT, TLSA, URI, CAA, SVCB, HTTPS\n\n");
}
static ares_bool_t read_cmdline(int argc, const char **argv, adig_config_t *config)
static ares_bool_t read_cmdline(int argc, const char **argv,
adig_config_t *config)
{
ares_getopt_state_t state;
int c;
@ -193,8 +194,8 @@ static ares_bool_t read_cmdline(int argc, const char **argv, adig_config_t *conf
case 'c':
if (!ares_dns_class_fromstr(&config->qclass, state.optarg)) {
snprintf(config->error, sizeof(config->error), "unrecognized class %s",
state.optarg);
snprintf(config->error, sizeof(config->error),
"unrecognized class %s", state.optarg);
return ARES_FALSE;
}
break;
@ -213,7 +214,8 @@ static ares_bool_t read_cmdline(int argc, const char **argv, adig_config_t *conf
snprintf(config->error, sizeof(config->error), "invalid port number");
return ARES_FALSE;
}
config->options.tcp_port = (unsigned short)strtol(state.optarg, NULL, 0);
config->options.tcp_port =
(unsigned short)strtol(state.optarg, NULL, 0);
config->options.flags |= ARES_FLAG_USEVC;
config->optmask |= ARES_OPT_TCP_PORT;
break;
@ -224,17 +226,20 @@ static ares_bool_t read_cmdline(int argc, const char **argv, adig_config_t *conf
snprintf(config->error, sizeof(config->error), "invalid port number");
return ARES_FALSE;
}
config->options.udp_port = (unsigned short)strtol(state.optarg, NULL, 0);
config->options.udp_port =
(unsigned short)strtol(state.optarg, NULL, 0);
config->optmask |= ARES_OPT_UDP_PORT;
break;
case ':':
snprintf(config->error, sizeof(config->error), "%c requires an argument", state.optopt);
snprintf(config->error, sizeof(config->error),
"%c requires an argument", state.optopt);
return ARES_FALSE;
case '?':
default:
snprintf(config->error, sizeof(config->error), "unrecognized option: %c", state.optopt);
snprintf(config->error, sizeof(config->error),
"unrecognized option: %c", state.optopt);
return ARES_FALSE;
}
}
@ -296,10 +301,13 @@ static void print_question(const ares_dns_record_t *dnsrec)
ares_dns_rec_type_t qtype;
ares_dns_class_t qclass;
size_t len;
if (ares_dns_record_query_get(dnsrec, i, &name, &qtype, &qclass) != ARES_SUCCESS)
if (ares_dns_record_query_get(dnsrec, i, &name, &qtype, &qclass) !=
ARES_SUCCESS) {
return;
if (name == NULL)
}
if (name == NULL) {
return;
}
len = strlen(name);
printf(";%s.\t", name);
if (len + 1 < 24) {
@ -382,7 +390,7 @@ static void print_opt_u16_list(const unsigned char *val, size_t val_len)
/* Jumping over backwards to try to avoid odd compiler warnings */
c = (unsigned short)val[i];
u16 |= (unsigned short)((c << 8) & 0xFFFF);
c = (unsigned short)val[i+1];
c = (unsigned short)val[i + 1];
u16 |= c;
if (i != 0) {
printf(",");
@ -620,8 +628,9 @@ static void print_rr(const ares_dns_rr_t *rr)
const ares_dns_rr_key_t *keys = ares_dns_rr_get_keys(rtype, &keys_cnt);
size_t i;
if (name == NULL)
if (name == NULL) {
return;
}
len = strlen(name);

@ -101,7 +101,8 @@ int ares_getopt(ares_getopt_state_t *state, const char *ostr)
++state->optind;
}
if (state->opterr) {
(void)fprintf(stderr, "%s: illegal option -- %c\n", __FILE__, state->optopt);
(void)fprintf(stderr, "%s: illegal option -- %c\n", __FILE__,
state->optopt);
}
return BADCH;
}

Loading…
Cancel
Save