clang-format

pull/641/head
Brad House 1 year ago
parent 45698509d8
commit 6e83c28ab4
  1. 29
      src/lib/ares__threads.c
  2. 3
      src/lib/ares_cancel.c
  3. 3
      src/lib/ares_fds.c
  4. 5
      src/lib/ares_getaddrinfo.c
  5. 3
      src/lib/ares_gethostbyaddr.c
  6. 3
      src/lib/ares_gethostbyname.c
  7. 3
      src/lib/ares_getnameinfo.c
  8. 9
      src/lib/ares_init.c
  9. 3
      src/lib/ares_process.c
  10. 3
      src/lib/ares_query.c
  11. 8
      src/lib/ares_search.c
  12. 3
      src/lib/ares_send.c
  13. 12
      test/ares-test.h

@ -37,8 +37,9 @@ struct ares__thread_mutex {
static ares__thread_mutex_t *ares__thread_mutex_create(void)
{
ares__thread_mutex_t *mut = ares_malloc_zero(sizeof(*mut));
if (mut == NULL)
if (mut == NULL) {
return NULL;
}
InitializeCriticalSection(&mut->mutex);
return mut;
@ -46,23 +47,26 @@ static ares__thread_mutex_t *ares__thread_mutex_create(void)
static void ares__thread_mutex_destroy(ares__thread_mutex_t *mut)
{
if (mut == NULL)
if (mut == NULL) {
return;
}
DeleteCriticalSection(&mut->mutex);
ares_free(mut);
}
static void ares__thread_mutex_lock(ares__thread_mutex_t *mut)
{
if (mut == NULL)
if (mut == NULL) {
return;
}
EnterCriticalSection(&mut->mutex);
}
static void ares__thread_mutex_unlock(ares__thread_mutex_t *mut)
{
if (mut == NULL)
if (mut == NULL) {
return;
}
LeaveCriticalSection(&mut->mutex);
}
@ -77,8 +81,9 @@ static ares__thread_mutex_t *ares__thread_mutex_create(void)
{
pthread_mutexattr_t attr;
ares__thread_mutex_t *mut = ares_malloc_zero(sizeof(*mut));
if (mut == NULL)
if (mut == NULL) {
return NULL;
}
if (pthread_mutexattr_init(&attr) != 0) {
ares_free(mut);
@ -104,32 +109,36 @@ fail:
static void ares__thread_mutex_destroy(ares__thread_mutex_t *mut)
{
if (mut == NULL)
if (mut == NULL) {
return;
}
pthread_mutex_destroy(&mut->mutex);
ares_free(mut);
}
static void ares__thread_mutex_lock(ares__thread_mutex_t *mut)
{
if (mut == NULL)
if (mut == NULL) {
return;
}
pthread_mutex_lock(&mut->mutex);
}
static void ares__thread_mutex_unlock(ares__thread_mutex_t *mut)
{
if (mut == NULL)
if (mut == NULL) {
return;
}
pthread_mutex_unlock(&mut->mutex);
}
#endif
# endif
ares_status_t ares__channel_threading_init(ares_channel_t *channel)
{
channel->lock = ares__thread_mutex_create();
if (channel->lock == NULL)
if (channel->lock == NULL) {
return ARES_ENOMEM;
}
return ARES_SUCCESS;
}

@ -37,8 +37,9 @@
*/
void ares_cancel(ares_channel_t *channel)
{
if (channel == NULL)
if (channel == NULL) {
return;
}
ares__channel_lock(channel);

@ -37,8 +37,9 @@ int ares_fds(ares_channel_t *channel, fd_set *read_fds, fd_set *write_fds)
/* Are there any active queries? */
size_t active_queries;
if (channel == NULL || read_fds == NULL || write_fds == NULL)
if (channel == NULL || read_fds == NULL || write_fds == NULL) {
return 0;
}
ares__channel_lock(channel);

@ -673,8 +673,9 @@ void ares_getaddrinfo(ares_channel_t *channel, const char *name,
const struct ares_addrinfo_hints *hints,
ares_addrinfo_callback callback, void *arg)
{
if (channel == NULL)
if (channel == NULL) {
return;
}
ares__channel_lock(channel);
ares_getaddrinfo_int(channel, name, service, hints, callback, arg);
ares__channel_unlock(channel);
@ -764,7 +765,7 @@ static ares_bool_t as_is_first(const struct host_query *hquery)
static ares_bool_t as_is_only(const struct host_query *hquery)
{
size_t nname = ares_strlen(hquery->name);
if(hquery->channel->flags & ARES_FLAG_NOSEARCH) {
if (hquery->channel->flags & ARES_FLAG_NOSEARCH) {
return ARES_TRUE;
}
if (hquery->name != NULL && nname && hquery->name[nname - 1] == '.') {

@ -114,8 +114,9 @@ static void ares_gethostbyaddr_int(ares_channel_t *channel, const void *addr,
void ares_gethostbyaddr(ares_channel_t *channel, const void *addr, int addrlen,
int family, ares_host_callback callback, void *arg)
{
if (channel == NULL)
if (channel == NULL) {
return;
}
ares__channel_lock(channel);
ares_gethostbyaddr_int(channel, addr, addrlen, family, callback, arg);
ares__channel_unlock(channel);

@ -266,8 +266,7 @@ done:
/* I really have no idea why this is exposed as a public function, but since
* it is, we can't kill this legacy function. */
static ares_status_t ares_gethostbyname_file_int(ares_channel_t *channel,
const char *name,
int family,
const char *name, int family,
struct hostent **host)
{
const ares_hosts_entry_t *entry;

@ -190,8 +190,9 @@ void ares_getnameinfo(ares_channel_t *channel, const struct sockaddr *sa,
ares_socklen_t salen, int flags_int,
ares_nameinfo_callback callback, void *arg)
{
if (channel == NULL)
if (channel == NULL) {
return;
}
ares__channel_lock(channel);
ares_getnameinfo_int(channel, sa, salen, flags_int, callback, arg);

@ -507,8 +507,9 @@ done:
void ares_set_local_ip4(ares_channel_t *channel, unsigned int local_ip)
{
if (channel == NULL)
if (channel == NULL) {
return;
}
ares__channel_lock(channel);
channel->local_ip4 = local_ip;
ares__channel_unlock(channel);
@ -517,8 +518,9 @@ void ares_set_local_ip4(ares_channel_t *channel, unsigned int local_ip)
/* local_ip6 should be 16 bytes in length */
void ares_set_local_ip6(ares_channel_t *channel, const unsigned char *local_ip6)
{
if (channel == NULL)
if (channel == NULL) {
return;
}
ares__channel_lock(channel);
memcpy(&channel->local_ip6, local_ip6, sizeof(channel->local_ip6));
ares__channel_unlock(channel);
@ -527,8 +529,9 @@ void ares_set_local_ip6(ares_channel_t *channel, const unsigned char *local_ip6)
/* local_dev_name should be null terminated. */
void ares_set_local_dev(ares_channel_t *channel, const char *local_dev_name)
{
if (channel == NULL)
if (channel == NULL) {
return;
}
ares__channel_lock(channel);
ares_strcpy(channel->local_dev_name, local_dev_name,

@ -142,8 +142,9 @@ static void processfds(ares_channel_t *channel, fd_set *read_fds,
{
struct timeval now;
if (channel == NULL)
if (channel == NULL) {
return;
}
ares__channel_lock(channel);

@ -88,8 +88,9 @@ ares_status_t ares_query_qid(ares_channel_t *channel, const char *name,
void ares_query(ares_channel_t *channel, const char *name, int dnsclass,
int type, ares_callback callback, void *arg)
{
if (channel == NULL)
if (channel == NULL) {
return;
}
ares__channel_lock(channel);
ares_query_qid(channel, name, dnsclass, type, callback, arg, NULL);
ares__channel_unlock(channel);

@ -57,8 +57,9 @@ static void search_callback(void *arg, int status, int timeouts,
static void end_squery(struct search_query *squery, ares_status_t status,
unsigned char *abuf, size_t alen);
static void ares_search_int(ares_channel_t *channel, const char *name, int dnsclass,
int type, ares_callback callback, void *arg)
static void ares_search_int(ares_channel_t *channel, const char *name,
int dnsclass, int type, ares_callback callback,
void *arg)
{
struct search_query *squery;
char *s;
@ -160,8 +161,9 @@ static void ares_search_int(ares_channel_t *channel, const char *name, int dnscl
void ares_search(ares_channel_t *channel, const char *name, int dnsclass,
int type, ares_callback callback, void *arg)
{
if (channel == NULL)
if (channel == NULL) {
return;
}
ares__channel_lock(channel);
ares_search_int(channel, name, dnsclass, type, callback, arg);
ares__channel_unlock(channel);

@ -153,8 +153,9 @@ ares_status_t ares_send_ex(ares_channel_t *channel, const unsigned char *qbuf,
void ares_send(ares_channel_t *channel, const unsigned char *qbuf, int qlen,
ares_callback callback, void *arg)
{
if (channel == NULL)
if (channel == NULL) {
return;
}
ares__channel_lock(channel);

12
test/ares-test.h vendored

@ -246,10 +246,11 @@ public:
}
private:
void ProcessRequest(ares_socket_t fd, struct sockaddr_storage *addr, ares_socklen_t addrlen,
int qid, const std::string &name, int rrtype);
void ProcessPacket(ares_socket_t fd, struct sockaddr_storage *addr, ares_socklen_t addrlen,
byte *data, int len);
void ProcessRequest(ares_socket_t fd, struct sockaddr_storage *addr,
ares_socklen_t addrlen, int qid, const std::string &name,
int rrtype);
void ProcessPacket(ares_socket_t fd, struct sockaddr_storage *addr,
ares_socklen_t addrlen, byte *data, int len);
unsigned short udpport_;
unsigned short tcpport_;
ares_socket_t udpfd_;
@ -280,7 +281,8 @@ protected:
std::set<ares_socket_t> fds() const;
void ProcessFD(ares_socket_t fd);
static NiceMockServers BuildServers(int count, int family, unsigned short base_port);
static NiceMockServers BuildServers(int count, int family,
unsigned short base_port);
NiceMockServers servers_;
// Convenience reference to first server.

Loading…
Cancel
Save