clang-format

pull/797/head
Brad House 5 months ago
parent c2b91beaef
commit bbcb1a2bdf
  1. 3
      src/lib/ares__hosts_file.c
  2. 6
      src/lib/ares__iface_ips.c
  3. 14
      src/lib/ares_dns_mapping.c
  4. 41
      src/lib/ares_event_configchg.c
  5. 3
      src/lib/ares_gethostbyaddr.c
  6. 4
      src/lib/ares_getnameinfo.c
  7. 6
      src/lib/ares_metrics.c
  8. 6
      src/lib/ares_private.h
  9. 1
      src/lib/ares_process.c
  10. 1
      src/lib/ares_rand.c
  11. 3
      src/lib/ares_sysconfig_mac.c
  12. 3
      src/lib/ares_timeout.c
  13. 1
      test/ares_queryloop.c

@ -617,7 +617,8 @@ static ares_bool_t ares__hosts_expired(const char *filename,
/* Expire every 60s if we can't get a time */ /* Expire every 60s if we can't get a time */
if (mod_ts == 0) { if (mod_ts == 0) {
mod_ts = time(NULL) - 60; /* LCOV_EXCL_LINE: only on systems without stat() */ mod_ts =
time(NULL) - 60; /* LCOV_EXCL_LINE: only on systems without stat() */
} }
/* If filenames are different, its expired */ /* If filenames are different, its expired */

@ -529,8 +529,9 @@ static ares_status_t ares__iface_ips_enumerate(ares__iface_ips_t *ips,
unsigned int ares__if_nametoindex(const char *name) unsigned int ares__if_nametoindex(const char *name)
{ {
#ifdef HAVE_IF_NAMETOINDEX #ifdef HAVE_IF_NAMETOINDEX
if (name == NULL) if (name == NULL) {
return 0; return 0;
}
return if_nametoindex(name); return if_nametoindex(name);
#else #else
ares_status_t status; ares_status_t status;
@ -538,8 +539,9 @@ unsigned int ares__if_nametoindex(const char *name)
size_t i; size_t i;
unsigned int index = 0; unsigned int index = 0;
if (name == NULL) if (name == NULL) {
return 0; return 0;
}
status = status =
ares__iface_ips(&ips, ARES_IFACE_IP_V6 | ARES_IFACE_IP_LINKLOCAL, name); ares__iface_ips(&ips, ARES_IFACE_IP_V6 | ARES_IFACE_IP_LINKLOCAL, name);

@ -548,15 +548,11 @@ static const ares_dns_rr_key_t rr_hinfo_keys[] = { ARES_RR_HINFO_CPU,
ARES_RR_HINFO_OS }; ARES_RR_HINFO_OS };
static const ares_dns_rr_key_t rr_mx_keys[] = { ARES_RR_MX_PREFERENCE, static const ares_dns_rr_key_t rr_mx_keys[] = { ARES_RR_MX_PREFERENCE,
ARES_RR_MX_EXCHANGE }; ARES_RR_MX_EXCHANGE };
static const ares_dns_rr_key_t rr_sig_keys[] = { ARES_RR_SIG_TYPE_COVERED, static const ares_dns_rr_key_t rr_sig_keys[] = {
ARES_RR_SIG_ALGORITHM, ARES_RR_SIG_TYPE_COVERED, ARES_RR_SIG_ALGORITHM, ARES_RR_SIG_LABELS,
ARES_RR_SIG_LABELS, ARES_RR_SIG_ORIGINAL_TTL, ARES_RR_SIG_EXPIRATION, ARES_RR_SIG_INCEPTION,
ARES_RR_SIG_ORIGINAL_TTL, ARES_RR_SIG_KEY_TAG, ARES_RR_SIG_SIGNERS_NAME, ARES_RR_SIG_SIGNATURE
ARES_RR_SIG_EXPIRATION, };
ARES_RR_SIG_INCEPTION,
ARES_RR_SIG_KEY_TAG,
ARES_RR_SIG_SIGNERS_NAME,
ARES_RR_SIG_SIGNATURE };
static const ares_dns_rr_key_t rr_txt_keys[] = { ARES_RR_TXT_DATA }; static const ares_dns_rr_key_t rr_txt_keys[] = { ARES_RR_TXT_DATA };
static const ares_dns_rr_key_t rr_aaaa_keys[] = { ARES_RR_AAAA_ADDR }; static const ares_dns_rr_key_t rr_aaaa_keys[] = { ARES_RR_AAAA_ADDR };
static const ares_dns_rr_key_t rr_srv_keys[] = { static const ares_dns_rr_key_t rr_srv_keys[] = {

@ -250,25 +250,22 @@ static void ares_event_configchg_ip_cb(PVOID CallerContext,
} }
# endif # endif
static ares_bool_t ares_event_configchg_regnotify(ares_event_configchg_t *configchg) static ares_bool_t
ares_event_configchg_regnotify(ares_event_configchg_t *configchg)
{ {
# if defined(__WATCOMC__) && !defined(REG_NOTIFY_THREAD_AGNOSTIC) # if defined(__WATCOMC__) && !defined(REG_NOTIFY_THREAD_AGNOSTIC)
# define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000L # define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000L
# endif # endif
DWORD flags = DWORD flags = REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_LAST_SET |
REG_NOTIFY_CHANGE_NAME|REG_NOTIFY_CHANGE_LAST_SET|REG_NOTIFY_THREAD_AGNOSTIC; REG_NOTIFY_THREAD_AGNOSTIC;
if (RegNotifyChangeKeyValue(configchg->regip4, TRUE, if (RegNotifyChangeKeyValue(configchg->regip4, TRUE, flags,
flags, configchg->regip4_event, TRUE) != ERROR_SUCCESS) {
configchg->regip4_event,
TRUE) != ERROR_SUCCESS) {
return ARES_FALSE; return ARES_FALSE;
} }
if (RegNotifyChangeKeyValue(configchg->regip6, TRUE, if (RegNotifyChangeKeyValue(configchg->regip6, TRUE, flags,
flags, configchg->regip6_event, TRUE) != ERROR_SUCCESS) {
configchg->regip6_event,
TRUE) != ERROR_SUCCESS) {
return ARES_FALSE; return ARES_FALSE;
} }
@ -318,14 +315,16 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
/* Monitor HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Interfaces /* Monitor HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Interfaces
* and HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces * and HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces
* for changes via RegNotifyChangeKeyValue() */ * for changes via RegNotifyChangeKeyValue() */
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, if (RegOpenKeyEx(
"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", HKEY_LOCAL_MACHINE,
0, KEY_NOTIFY, &c->regip4) != ERROR_SUCCESS) { "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", 0,
KEY_NOTIFY, &c->regip4) != ERROR_SUCCESS) {
status = ARES_ESERVFAIL; status = ARES_ESERVFAIL;
goto done; goto done;
} }
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, if (RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Services\\Tcpip6\\Parameters\\Interfaces", "SYSTEM\\CurrentControlSet\\Services\\Tcpip6\\Parameters\\Interfaces",
0, KEY_NOTIFY, &c->regip6) != ERROR_SUCCESS) { 0, KEY_NOTIFY, &c->regip6) != ERROR_SUCCESS) {
status = ARES_ESERVFAIL; status = ARES_ESERVFAIL;
@ -345,13 +344,15 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
} }
if (!RegisterWaitForSingleObject(&c->regip4_wait, c->regip4_event, if (!RegisterWaitForSingleObject(&c->regip4_wait, c->regip4_event,
ares_event_configchg_reg_cb, c, INFINITE, WT_EXECUTEDEFAULT)) { ares_event_configchg_reg_cb, c, INFINITE,
WT_EXECUTEDEFAULT)) {
status = ARES_ESERVFAIL; status = ARES_ESERVFAIL;
goto done; goto done;
} }
if (!RegisterWaitForSingleObject(&c->regip6_wait, c->regip6_event, if (!RegisterWaitForSingleObject(&c->regip6_wait, c->regip6_event,
ares_event_configchg_reg_cb, c, INFINITE, WT_EXECUTEDEFAULT)) { ares_event_configchg_reg_cb, c, INFINITE,
WT_EXECUTEDEFAULT)) {
status = ARES_ESERVFAIL; status = ARES_ESERVFAIL;
goto done; goto done;
} }
@ -454,7 +455,8 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
size_t i; size_t i;
const char *searchlibs[] = { const char *searchlibs[] = {
"/usr/lib/libSystem.dylib", "/usr/lib/libSystem.dylib",
"/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration", "/System/Library/Frameworks/SystemConfiguration.framework/"
"SystemConfiguration",
NULL NULL
}; };
@ -471,7 +473,8 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
continue; continue;
} }
pdns_configuration_notify_key = dlsym(handle, "dns_configuration_notify_key"); pdns_configuration_notify_key =
dlsym(handle, "dns_configuration_notify_key");
if (pdns_configuration_notify_key != NULL) { if (pdns_configuration_notify_key != NULL) {
break; break;
} }

@ -132,7 +132,8 @@ static void next_lookup(struct addr_query *aquery)
case 'b': case 'b':
name = ares_dns_addr_to_ptr(&aquery->addr); name = ares_dns_addr_to_ptr(&aquery->addr);
if (name == NULL) { if (name == NULL) {
end_aquery(aquery, ARES_ENOMEM, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ end_aquery(aquery, ARES_ENOMEM,
NULL); /* LCOV_EXCL_LINE: OutOfMemory */
return; /* LCOV_EXCL_LINE: OutOfMemory */ return; /* LCOV_EXCL_LINE: OutOfMemory */
} }
aquery->remaining_lookups = p + 1; aquery->remaining_lookups = p + 1;

@ -81,8 +81,8 @@ static void nameinfo_callback(void *arg, int status, int timeouts,
static char *lookup_service(unsigned short port, unsigned int flags, char *buf, static char *lookup_service(unsigned short port, unsigned int flags, char *buf,
size_t buflen); size_t buflen);
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
static void append_scopeid(const struct sockaddr_in6 *addr6, static void append_scopeid(const struct sockaddr_in6 *addr6, unsigned int flags,
unsigned int flags, char *buf, size_t buflen); char *buf, size_t buflen);
#endif #endif
static char *ares_striendstr(const char *s1, const char *s2); static char *ares_striendstr(const char *s1, const char *s2);

@ -227,10 +227,12 @@ size_t ares_metrics_server_timeout(const struct server_state *server,
continue; continue;
} }
/* Calculate average time for previous bucket */ /* Calculate average time for previous bucket */
timeout_ms = (size_t)(server->metrics[i].prev_total_ms / server->metrics[i].prev_total_count); timeout_ms = (size_t)(server->metrics[i].prev_total_ms /
server->metrics[i].prev_total_count);
} else { } else {
/* Calculate average time for current bucket*/ /* Calculate average time for current bucket*/
timeout_ms = (size_t)(server->metrics[i].total_ms / server->metrics[i].total_count); timeout_ms =
(size_t)(server->metrics[i].total_ms / server->metrics[i].total_count);
} }
/* Multiply average by constant to get timeout value */ /* Multiply average by constant to get timeout value */

@ -189,7 +189,8 @@ typedef struct {
ares_uint64_t total_count; /*!< Number of queries for bucket */ ares_uint64_t total_count; /*!< Number of queries for bucket */
time_t prev_ts; /*!< Previous period bucket timestamp */ time_t prev_ts; /*!< Previous period bucket timestamp */
ares_uint64_t prev_total_ms; /*!< Previous period bucket cumulative query time */ ares_uint64_t
prev_total_ms; /*!< Previous period bucket cumulative query time */
ares_uint64_t prev_total_count; /*!< Previous period bucket query count */ ares_uint64_t prev_total_count; /*!< Previous period bucket query count */
} ares_server_metrics_t; } ares_server_metrics_t;
@ -437,8 +438,7 @@ ares_timeval_t ares__tvnow(void);
void ares__timeval_remaining(ares_timeval_t *remaining, void ares__timeval_remaining(ares_timeval_t *remaining,
const ares_timeval_t *now, const ares_timeval_t *now,
const ares_timeval_t *tout); const ares_timeval_t *tout);
void ares__timeval_diff(ares_timeval_t *tvdiff, void ares__timeval_diff(ares_timeval_t *tvdiff, const ares_timeval_t *tvstart,
const ares_timeval_t *tvstart,
const ares_timeval_t *tvstop); const ares_timeval_t *tvstop);
ares_status_t ares__expand_name_validated(const unsigned char *encoded, ares_status_t ares__expand_name_validated(const unsigned char *encoded,
const unsigned char *abuf, const unsigned char *abuf,

@ -1253,7 +1253,6 @@ static void ares_detach_query(struct query *query)
query->node_all_queries = NULL; query->node_all_queries = NULL;
} }
static void end_query(ares_channel_t *channel, struct server_state *server, static void end_query(ares_channel_t *channel, struct server_state *server,
struct query *query, ares_status_t status, struct query *query, ares_status_t status,
const ares_dns_record_t *dnsrec) const ares_dns_record_t *dnsrec)

@ -335,7 +335,6 @@ static void ares__rand_bytes_fetch(ares_rand_state *state, unsigned char *buf,
return; return;
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* If we didn't return before we got here, that means we had a critical rand /* If we didn't return before we got here, that means we had a critical rand

@ -85,7 +85,8 @@ static ares_status_t dnsinfo_init(dnsinfo_t **dnsinfo_out)
size_t i; size_t i;
const char *searchlibs[] = { const char *searchlibs[] = {
"/usr/lib/libSystem.dylib", "/usr/lib/libSystem.dylib",
"/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration", "/System/Library/Frameworks/SystemConfiguration.framework/"
"SystemConfiguration",
NULL NULL
}; };

@ -55,8 +55,7 @@ void ares__timeval_remaining(ares_timeval_t *remaining,
} }
} }
void ares__timeval_diff(ares_timeval_t *tvdiff, void ares__timeval_diff(ares_timeval_t *tvdiff, const ares_timeval_t *tvstart,
const ares_timeval_t *tvstart,
const ares_timeval_t *tvstop) const ares_timeval_t *tvstop)
{ {
tvdiff->sec = tvstop->sec - tvstart->sec; tvdiff->sec = tvstop->sec - tvstart->sec;

@ -77,7 +77,6 @@ static void ai_callback(void *arg, int status, int timeouts,
ares_freeaddrinfo(result); ares_freeaddrinfo(result);
} }
static volatile ares_bool_t is_running = ARES_TRUE; static volatile ares_bool_t is_running = ARES_TRUE;

Loading…
Cancel
Save