From 3f862d8eb14009ac4d5be9fd0ac3cfa7dd1716cf Mon Sep 17 00:00:00 2001 From: Brad House Date: Sat, 2 Dec 2023 09:07:27 -0500 Subject: [PATCH] clang-format --- src/lib/ares__buf.c | 23 ++++++++++------------- src/lib/ares__buf.h | 21 +++++++++------------ src/lib/ares_sysconfig.c | 13 ++++++++----- src/lib/ares_sysconfig_files.c | 3 ++- src/lib/ares_update_servers.c | 26 +++++++++++++++----------- 5 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/lib/ares__buf.c b/src/lib/ares__buf.c index 31c3372f..ce42c12d 100644 --- a/src/lib/ares__buf.c +++ b/src/lib/ares__buf.c @@ -722,15 +722,14 @@ done: return i; } -size_t ares__buf_consume_until_charset(ares__buf_t *buf, - const unsigned char *charset, - size_t len, +size_t ares__buf_consume_until_charset(ares__buf_t *buf, + const unsigned char *charset, size_t len, ares_bool_t require_charset) { size_t remaining_len = 0; const unsigned char *ptr = ares__buf_fetch(buf, &remaining_len); size_t i; - ares_bool_t found = ARES_FALSE; + ares_bool_t found = ARES_FALSE; if (ptr == NULL || charset == NULL || len == 0) { return 0; @@ -747,8 +746,9 @@ size_t ares__buf_consume_until_charset(ares__buf_t *buf, } done: - if (require_charset && !found) + if (require_charset && !found) { return 0; + } if (i > 0) { ares__buf_consume(buf, i); @@ -756,9 +756,7 @@ done: return i; } - -size_t ares__buf_consume_charset(ares__buf_t *buf, - const unsigned char *charset, +size_t ares__buf_consume_charset(ares__buf_t *buf, const unsigned char *charset, size_t len) { size_t remaining_len = 0; @@ -770,15 +768,16 @@ size_t ares__buf_consume_charset(ares__buf_t *buf, } for (i = 0; i < remaining_len; i++) { - size_t j; + size_t j; for (j = 0; j < len; j++) { if (ptr[i] == charset[j]) { break; } } /* Not found */ - if (j == len) + if (j == len) { break; + } } if (i > 0) { @@ -787,7 +786,6 @@ size_t ares__buf_consume_charset(ares__buf_t *buf, return i; } - static void ares__buf_destroy_cb(void *arg) { ares__buf_destroy(arg); @@ -823,7 +821,7 @@ ares_status_t ares__buf_split(ares__buf_t *buf, const unsigned char *delims, } if (len != 0 || flags & ARES_BUF_SPLIT_ALLOW_BLANK) { - const unsigned char *ptr = ares__buf_tag_fetch(buf, &len); + const unsigned char *ptr = ares__buf_tag_fetch(buf, &len); ares__buf_t *data; /* Since we don't allow const buffers of 0 length, and user wants 0-length @@ -864,7 +862,6 @@ done: return status; } - ares_bool_t ares__buf_begins_with(const ares__buf_t *buf, const unsigned char *data, size_t data_len) { diff --git a/src/lib/ares__buf.h b/src/lib/ares__buf.h index 4537c687..4e6a8971 100644 --- a/src/lib/ares__buf.h +++ b/src/lib/ares__buf.h @@ -384,10 +384,9 @@ size_t ares__buf_consume_nonwhitespace(ares__buf_t *buf); * 0 if not found. * \return number of characters consumed */ -size_t ares__buf_consume_until_charset(ares__buf_t *buf, - const unsigned char *charset, - size_t len, - ares_bool_t require_charset); +size_t ares__buf_consume_until_charset(ares__buf_t *buf, + const unsigned char *charset, size_t len, + ares_bool_t require_charset); /*! Consume while the characters match the characters in the provided set. @@ -397,8 +396,7 @@ size_t ares__buf_consume_until_charset(ares__buf_t *buf, * \param[in] len length of character set * \return number of characters consumed */ -size_t ares__buf_consume_charset(ares__buf_t *buf, - const unsigned char *charset, +size_t ares__buf_consume_charset(ares__buf_t *buf, const unsigned char *charset, size_t len); @@ -412,10 +410,9 @@ size_t ares__buf_consume_charset(ares__buf_t *buf, */ size_t ares__buf_consume_line(ares__buf_t *buf, ares_bool_t include_linefeed); - typedef enum { /*! No flags */ - ARES_BUF_SPLIT_NONE = 0, + ARES_BUF_SPLIT_NONE = 0, /*! The delimiter will be the first character in the buffer, except the * first buffer since the start doesn't have a delimiter */ @@ -423,7 +420,7 @@ typedef enum { /*! Allow blank sections, by default blank sections are not emitted. If using * ARES_BUF_SPLIT_DONT_CONSUME_DELIMS, the delimiter is not counted as part * of the section */ - ARES_BUF_SPLIT_ALLOW_BLANK = 1 << 1 + ARES_BUF_SPLIT_ALLOW_BLANK = 1 << 1 } ares__buf_split_t; /*! Split the provided buffer into multiple sub-buffers stored in the variable @@ -454,8 +451,8 @@ ares_status_t ares__buf_split(ares__buf_t *buf, const unsigned char *delims, * \param[in] data_len Length of data to compare. * \return ARES_TRUE on match, ARES_FALSE otherwise. */ -ares_bool_t ares__buf_begins_with(const ares__buf_t *buf, - const unsigned char *data, size_t data_len); +ares_bool_t ares__buf_begins_with(const ares__buf_t *buf, + const unsigned char *data, size_t data_len); /*! Size of unprocessed remaining data length @@ -463,7 +460,7 @@ ares_bool_t ares__buf_begins_with(const ares__buf_t *buf, * \param[in] buf Initialized buffer object * \return length remaining */ -size_t ares__buf_len(const ares__buf_t *buf); +size_t ares__buf_len(const ares__buf_t *buf); /*! Retrieve a pointer to the currently unprocessed data. Generally this isn't * recommended to be used in practice. The returned pointer may be invalidated diff --git a/src/lib/ares_sysconfig.c b/src/lib/ares_sysconfig.c index ea72455d..da329da2 100644 --- a/src/lib/ares_sysconfig.c +++ b/src/lib/ares_sysconfig.c @@ -713,7 +713,8 @@ static ares_status_t ares__init_sysconfig_riscos(ares_sysconfig_t *sysconfig) if (space) { *space = '\0'; } - status = ares__sconfig_append_fromstr(&sysconfig->sconfig, pos, ARES_TRUE); + status = + ares__sconfig_append_fromstr(&sysconfig->sconfig, pos, ARES_TRUE); if (status != ARES_SUCCESS) { break; } @@ -770,8 +771,8 @@ static ares_status_t ares__init_sysconfig_android(ares_sysconfig_t *sysconfig) dns_servers = ares_get_android_server_list(MAX_DNS_PROPERTIES, &num_servers); if (dns_servers != NULL) { for (i = 0; i < num_servers; i++) { - status = - ares__sconfig_append_fromstr(&sysconfig->sconfig, dns_servers[i], ARES_TRUE); + status = ares__sconfig_append_fromstr(&sysconfig->sconfig, dns_servers[i], + ARES_TRUE); if (status != ARES_SUCCESS) { return status; } @@ -802,7 +803,8 @@ static ares_status_t ares__init_sysconfig_android(ares_sysconfig_t *sysconfig) if (__system_property_get(propname, propvalue) < 1) { break; } - status = ares__sconfig_append_fromstr(&sysconfig->sconfig, propvalue, ARES_TRUE); + status = + ares__sconfig_append_fromstr(&sysconfig->sconfig, propvalue, ARES_TRUE); if (status != ARES_SUCCESS) { return status; } @@ -854,7 +856,8 @@ static ares_status_t ares__init_sysconfig_libresolv(ares_sysconfig_t *sysconfig) snprintf(ipaddr_port, sizeof(ipaddr_port), "%s", ipaddr); } - status = ares__sconfig_append_fromstr(&sysconfig->sconfig, ipaddr_port, ARES_TRUE); + status = + ares__sconfig_append_fromstr(&sysconfig->sconfig, ipaddr_port, ARES_TRUE); if (status != ARES_SUCCESS) { goto done; } diff --git a/src/lib/ares_sysconfig_files.c b/src/lib/ares_sysconfig_files.c index 5207e62a..f384611e 100644 --- a/src/lib/ares_sysconfig_files.c +++ b/src/lib/ares_sysconfig_files.c @@ -516,7 +516,8 @@ ares_status_t ares__init_sysconfig_files(const ares_channel_t *channel, } else if ((p = try_config(line, "search", ';'))) { status = config_search(sysconfig, p); } else if ((p = try_config(line, "nameserver", ';'))) { - status = ares__sconfig_append_fromstr(&sysconfig->sconfig, p, ARES_TRUE); + status = + ares__sconfig_append_fromstr(&sysconfig->sconfig, p, ARES_TRUE); } else if ((p = try_config(line, "sortlist", ';'))) { status = ares__parse_sortlist(&sysconfig->sortlist, &sysconfig->nsortlist, p); diff --git a/src/lib/ares_update_servers.c b/src/lib/ares_update_servers.c index 5a463836..550dc70e 100644 --- a/src/lib/ares_update_servers.c +++ b/src/lib/ares_update_servers.c @@ -155,9 +155,8 @@ static ares_bool_t ares_server_blacklisted(const struct ares_addr *addr) * Returns an error code on failure, else ARES_SUCCESS */ -static ares_status_t parse_dnsaddrport(ares__buf_t *buf, - struct ares_addr *host, - unsigned short *port) +static ares_status_t parse_dnsaddrport(ares__buf_t *buf, struct ares_addr *host, + unsigned short *port) { ares_status_t status; char ipaddr[INET6_ADDRSTRLEN] = ""; @@ -177,7 +176,8 @@ static ares_status_t parse_dnsaddrport(ares__buf_t *buf, ares__buf_tag(buf); /* Consume until ] */ - if (ares__buf_consume_until_charset(buf, (const unsigned char *)"]", 1, ARES_TRUE) == 0) { + if (ares__buf_consume_until_charset(buf, (const unsigned char *)"]", 1, + ARES_TRUE) == 0) { return ARES_EBADSTR; } @@ -195,19 +195,22 @@ static ares_status_t parse_dnsaddrport(ares__buf_t *buf, * otherwise treat as ipv6 */ ares__buf_tag(buf); - offset = ares__buf_consume_until_charset(buf, (const unsigned char *)".", 1, ARES_TRUE); + offset = ares__buf_consume_until_charset(buf, (const unsigned char *)".", 1, + ARES_TRUE); ares__buf_tag_rollback(buf); ares__buf_tag(buf); if (offset > 0 && offset < 4) { /* IPv4 */ - if (ares__buf_consume_charset(buf, (const unsigned char *)"0123456789.", 11) == 0) { + if (ares__buf_consume_charset(buf, (const unsigned char *)"0123456789.", + 11) == 0) { return ARES_EBADSTR; } } else { /* IPv6 */ const unsigned char ipv6_charset[] = "ABCDEFabcdef0123456789.:"; - if (ares__buf_consume_charset(buf, ipv6_charset, sizeof(ipv6_charset)) == 0) { + if (ares__buf_consume_charset(buf, ipv6_charset, sizeof(ipv6_charset)) == + 0) { return ARES_EBADSTR; } } @@ -234,7 +237,8 @@ static ares_status_t parse_dnsaddrport(ares__buf_t *buf, ares__buf_tag(buf); /* Read numbers */ - if (ares__buf_consume_charset(buf, (const unsigned char *)"0123456789", 10) == 0) { + if (ares__buf_consume_charset(buf, (const unsigned char *)"0123456789", + 10) == 0) { return ARES_EBADSTR; } @@ -346,9 +350,9 @@ ares_status_t ares__sconfig_append_fromstr(ares__llist_t **sconfig, for (node = ares__llist_node_first(list); node != NULL; node = ares__llist_node_next(node)) { - ares__buf_t *entry = ares__llist_node_val(node); - struct ares_addr host; - unsigned short port; + ares__buf_t *entry = ares__llist_node_val(node); + struct ares_addr host; + unsigned short port; status = parse_dnsaddrport(entry, &host, &port); if (status != ARES_SUCCESS) {