SonarCloud: fix 31 character identifier max

We recently turned on a feature of SonarCloud to notify when the
ISO C limit of 31 character identifiers had been exceeded.  This
commit fixes all non-public instances of such violations.

Authored-By: Brad House (@bradh352)
pull/871/head
Brad House 3 months ago
parent db9c8e9ad2
commit 4c86bf3e9d
  1. 4
      src/lib/ares__hosts_file.c
  2. 2
      src/lib/ares_options.c
  3. 10
      src/lib/ares_private.h
  4. 6
      src/lib/ares_process.c
  5. 4
      src/lib/ares_qcache.c
  6. 19
      src/lib/ares_update_servers.c
  7. 2
      src/lib/dsa/ares__htable.c
  8. 8
      src/lib/dsa/ares__llist.c
  9. 4
      src/lib/event/ares_event_thread.c
  10. 4
      src/lib/include/ares__buf.h
  11. 8
      src/lib/include/ares__llist.h
  12. 2
      src/lib/record/ares_dns_mapping.c
  13. 2
      src/lib/record/ares_dns_multistring.c
  14. 5
      src/lib/record/ares_dns_multistring.h
  15. 2
      src/lib/record/ares_dns_parse.c
  16. 36
      src/lib/record/ares_dns_private.h
  17. 2
      src/lib/record/ares_dns_record.c
  18. 6
      src/lib/record/ares_dns_write.c
  19. 2
      src/lib/str/ares__buf.c
  20. 2
      test/ares-test-internal.cc

@ -245,7 +245,7 @@ static ares_status_t ares__hosts_file_merge_entry(
continue;
}
ares__llist_node_move_parent_last(node, existing->ips);
ares__llist_node_mvparent_last(node, existing->ips);
}
}
@ -258,7 +258,7 @@ static ares_status_t ares__hosts_file_merge_entry(
continue;
}
ares__llist_node_move_parent_last(node, existing->hosts);
ares__llist_node_mvparent_last(node, existing->hosts);
}
ares__hosts_entry_destroy(entry);

@ -245,7 +245,7 @@ static ares_status_t ares__init_options_servers(ares_channel_t *channel,
ares__llist_t *slist = NULL;
ares_status_t status;
status = ares_in_addr_to_server_config_llist(servers, nservers, &slist);
status = ares_in_addr_to_sconfig_llist(servers, nservers, &slist);
if (status != ARES_SUCCESS) {
return status; /* LCOV_EXCL_LINE: OutOfMemory */
}

@ -674,11 +674,11 @@ ares_status_t ares__sconfig_append(ares__llist_t **sconfig,
ares_status_t ares__sconfig_append_fromstr(ares__llist_t **sconfig,
const char *str,
ares_bool_t ignore_invalid);
ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers,
size_t nservers,
ares__llist_t **llist);
ares_status_t ares_get_server_addr(const ares_server_t *server,
ares__buf_t *buf);
ares_status_t ares_in_addr_to_sconfig_llist(const struct in_addr *servers,
size_t nservers,
ares__llist_t **llist);
ares_status_t ares_get_server_addr(const ares_server_t *server,
ares__buf_t *buf);
struct ares_hosts_entry;
typedef struct ares_hosts_entry ares_hosts_entry_t;

@ -64,7 +64,7 @@ static void end_query(ares_channel_t *channel, ares_server_t *server,
ares_query_t *query, ares_status_t status,
const ares_dns_record_t *dnsrec);
static void ares__query_disassociate_from_conn(ares_query_t *query)
static void ares__query_remove_from_conn(ares_query_t *query)
{
/* If its not part of a connection, it can't be tracked for timeouts either */
ares__slist_node_destroy(query->node_queries_by_timeout);
@ -791,7 +791,7 @@ ares_status_t ares__requeue_query(ares_query_t *query,
ares_channel_t *channel = query->channel;
size_t max_tries = ares__slist_len(channel->servers) * channel->tries;
ares__query_disassociate_from_conn(query);
ares__query_remove_from_conn(query);
if (status != ARES_SUCCESS) {
query->error_status = status;
@ -1208,7 +1208,7 @@ done:
static void ares_detach_query(ares_query_t *query)
{
/* Remove the query from all the lists in which it is linked */
ares__query_disassociate_from_conn(query);
ares__query_remove_from_conn(query);
ares__htable_szvp_remove(query->channel->queries_by_qid, query->qid);
ares__llist_node_destroy(query->node_all_queries);
query->node_all_queries = NULL;

@ -412,8 +412,8 @@ ares_status_t ares_qcache_fetch(ares_channel_t *channel,
goto done;
}
ares_dns_record_write_ttl_decrement(
entry->dnsrec, (unsigned int)(now->sec - entry->insert_ts));
ares_dns_record_ttl_decrement(entry->dnsrec,
(unsigned int)(now->sec - entry->insert_ts));
*dnsrec_resp = entry->dnsrec;

@ -769,8 +769,8 @@ done:
}
static ares_status_t
ares_addr_node_to_server_config_llist(const struct ares_addr_node *servers,
ares__llist_t **llist)
ares_addr_node_to_sconfig_llist(const struct ares_addr_node *servers,
ares__llist_t **llist)
{
const struct ares_addr_node *node;
ares__llist_t *s;
@ -820,8 +820,9 @@ fail:
/* LCOV_EXCL_STOP */
}
static ares_status_t ares_addr_port_node_to_server_config_llist(
const struct ares_addr_port_node *servers, ares__llist_t **llist)
static ares_status_t
ares_addrpnode_to_sconfig_llist(const struct ares_addr_port_node *servers,
ares__llist_t **llist)
{
const struct ares_addr_port_node *node;
ares__llist_t *s;
@ -874,9 +875,9 @@ fail:
/* LCOV_EXCL_STOP */
}
ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers,
size_t nservers,
ares__llist_t **llist)
ares_status_t ares_in_addr_to_sconfig_llist(const struct in_addr *servers,
size_t nservers,
ares__llist_t **llist)
{
size_t i;
ares__llist_t *s;
@ -1093,7 +1094,7 @@ int ares_set_servers(ares_channel_t *channel,
return ARES_ENODATA;
}
status = ares_addr_node_to_server_config_llist(servers, &slist);
status = ares_addr_node_to_sconfig_llist(servers, &slist);
if (status != ARES_SUCCESS) {
return (int)status;
}
@ -1117,7 +1118,7 @@ int ares_set_servers_ports(ares_channel_t *channel,
return ARES_ENODATA;
}
status = ares_addr_port_node_to_server_config_llist(servers, &slist);
status = ares_addrpnode_to_sconfig_llist(servers, &slist);
if (status != ARES_SUCCESS) {
return (int)status;
}

@ -282,7 +282,7 @@ static ares_bool_t ares__htable_expand(ares__htable_t *htable)
htable->num_collisions++;
}
ares__llist_node_move_parent_first(node, buckets[idx]);
ares__llist_node_mvparent_first(node, buckets[idx]);
}
/* Abandoned bucket, destroy */

@ -363,8 +363,8 @@ void ares__llist_destroy(ares__llist_t *list)
ares_free(list);
}
void ares__llist_node_move_parent_last(ares__llist_node_t *node,
ares__llist_t *new_parent)
void ares__llist_node_mvparent_last(ares__llist_node_t *node,
ares__llist_t *new_parent)
{
if (node == NULL || new_parent == NULL) {
return; /* LCOV_EXCL_LINE: DefensiveCoding */
@ -374,8 +374,8 @@ void ares__llist_node_move_parent_last(ares__llist_node_t *node,
ares__llist_attach_at(new_parent, ARES__LLIST_INSERT_TAIL, NULL, node);
}
void ares__llist_node_move_parent_first(ares__llist_node_t *node,
ares__llist_t *new_parent)
void ares__llist_node_mvparent_first(ares__llist_node_t *node,
ares__llist_t *new_parent)
{
if (node == NULL || new_parent == NULL) {
return; /* LCOV_EXCL_LINE: DefensiveCoding */

@ -216,7 +216,7 @@ static void ares_event_thread_sockstate_cb(void *data, ares_socket_t socket_fd,
NULL, NULL, NULL);
}
static void ares_event_thread_notifywrite_cb(void *data)
static void notifywrite_cb(void *data)
{
ares_event_thread_t *e = data;
@ -508,7 +508,7 @@ ares_status_t ares_event_thread_init(ares_channel_t *channel)
channel->sock_state_cb = ares_event_thread_sockstate_cb;
channel->sock_state_cb_data = e;
channel->notify_pending_write_cb = ares_event_thread_notifywrite_cb;
channel->notify_pending_write_cb = notifywrite_cb;
channel->notify_pending_write_cb_data = e;
if (!e->ev_sys->init(e)) {

@ -440,9 +440,9 @@ typedef enum {
* incompatible with ARES_BUF_SPLIT_LTRIM since the delimiter is always
* the first character.
*/
ARES_BUF_SPLIT_DONT_CONSUME_DELIMS = 1 << 0,
ARES_BUF_SPLIT_KEEP_DELIMS = 1 << 0,
/*! 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
* ARES_BUF_SPLIT_KEEP_DELIMS, the delimiter is not counted as part
* of the section */
ARES_BUF_SPLIT_ALLOW_BLANK = 1 << 1,
/*! Remove duplicate entries */

@ -226,8 +226,8 @@ CARES_EXTERN void ares__llist_destroy(ares__llist_t *list);
* \param[in] node node to move
* \param[in] new_parent new list
*/
CARES_EXTERN void ares__llist_node_move_parent_last(ares__llist_node_t *node,
ares__llist_t *new_parent);
CARES_EXTERN void ares__llist_node_mvparent_last(ares__llist_node_t *node,
ares__llist_t *new_parent);
/*! Detach node from the current list and re-attach it to the new list as the
* first entry.
@ -235,8 +235,8 @@ CARES_EXTERN void ares__llist_node_move_parent_last(ares__llist_node_t *node,
* \param[in] node node to move
* \param[in] new_parent new list
*/
CARES_EXTERN void ares__llist_node_move_parent_first(ares__llist_node_t *node,
ares__llist_t *new_parent);
CARES_EXTERN void ares__llist_node_mvparent_first(ares__llist_node_t *node,
ares__llist_t *new_parent);
/*! @} */
#endif /* __ARES__LLIST_H */

@ -111,7 +111,7 @@ ares_bool_t ares_dns_rec_type_isvalid(ares_dns_rec_type_t type,
return is_query ? ARES_TRUE : ARES_FALSE;
}
ares_bool_t ares_dns_rec_type_allow_name_compression(ares_dns_rec_type_t type)
ares_bool_t ares_dns_rec_allow_name_comp(ares_dns_rec_type_t type)
{
/* Only record types defined in RFC1035 allow name compression within the
* RDATA. Otherwise nameservers that don't understand an RR may not be

@ -181,7 +181,7 @@ const unsigned char *
}
const unsigned char *
ares__dns_multistring_get_combined(ares__dns_multistring_t *strs, size_t *len)
ares__dns_multistring_combined(ares__dns_multistring_t *strs, size_t *len)
{
ares__buf_t *buf = NULL;
size_t i;

@ -45,9 +45,8 @@ size_t ares__dns_multistring_cnt(const ares__dns_multistring_t *strs);
const unsigned char *
ares__dns_multistring_get(const ares__dns_multistring_t *strs, size_t idx,
size_t *len);
const unsigned char *
ares__dns_multistring_get_combined(ares__dns_multistring_t *strs,
size_t *len);
const unsigned char *
ares__dns_multistring_combined(ares__dns_multistring_t *strs, size_t *len);
/*! Parse an array of character strings as defined in RFC1035, as binary,
* however, for convenience this does guarantee a NULL terminator (that is

@ -1140,7 +1140,7 @@ static ares_status_t ares_dns_parse_rr(ares__buf_t *buf, unsigned int flags,
type = ARES_REC_TYPE_RAW_RR;
}
namecomp = ares_dns_rec_type_allow_name_compression(type);
namecomp = ares_dns_rec_allow_name_comp(type);
if (sect == ARES_SECTION_ANSWER &&
(flags &
(namecomp ? ARES_DNS_PARSE_AN_BASE_RAW : ARES_DNS_PARSE_AN_EXT_RAW))) {

@ -26,18 +26,18 @@
#ifndef __ARES_DNS_PRIVATE_H
#define __ARES_DNS_PRIVATE_H
ares_status_t ares_dns_record_duplicate_ex(ares_dns_record_t **dest,
const ares_dns_record_t *src);
ares_bool_t ares_dns_rec_type_allow_name_compression(ares_dns_rec_type_t type);
ares_bool_t ares_dns_opcode_isvalid(ares_dns_opcode_t opcode);
ares_bool_t ares_dns_rcode_isvalid(ares_dns_rcode_t rcode);
ares_bool_t ares_dns_flags_arevalid(unsigned short flags);
ares_bool_t ares_dns_rec_type_isvalid(ares_dns_rec_type_t type,
ares_bool_t is_query);
ares_bool_t ares_dns_class_isvalid(ares_dns_class_t qclass,
ares_dns_rec_type_t type,
ares_bool_t is_query);
ares_bool_t ares_dns_section_isvalid(ares_dns_section_t sect);
ares_status_t ares_dns_record_duplicate_ex(ares_dns_record_t **dest,
const ares_dns_record_t *src);
ares_bool_t ares_dns_rec_allow_name_comp(ares_dns_rec_type_t type);
ares_bool_t ares_dns_opcode_isvalid(ares_dns_opcode_t opcode);
ares_bool_t ares_dns_rcode_isvalid(ares_dns_rcode_t rcode);
ares_bool_t ares_dns_flags_arevalid(unsigned short flags);
ares_bool_t ares_dns_rec_type_isvalid(ares_dns_rec_type_t type,
ares_bool_t is_query);
ares_bool_t ares_dns_class_isvalid(ares_dns_class_t qclass,
ares_dns_rec_type_t type,
ares_bool_t is_query);
ares_bool_t ares_dns_section_isvalid(ares_dns_section_t sect);
ares_status_t ares_dns_rr_set_str_own(ares_dns_rr_t *dns_rr,
ares_dns_rr_key_t key, char *val);
ares_status_t ares_dns_rr_set_bin_own(ares_dns_rr_t *dns_rr,
@ -53,16 +53,16 @@ ares_status_t ares_dns_record_rr_prealloc(ares_dns_record_t *dnsrec,
ares_dns_section_t sect, size_t cnt);
ares_dns_rr_t *ares_dns_get_opt_rr(ares_dns_record_t *rec);
const ares_dns_rr_t *ares_dns_get_opt_rr_const(const ares_dns_record_t *rec);
void ares_dns_record_write_ttl_decrement(ares_dns_record_t *dnsrec,
unsigned int ttl_decrement);
void ares_dns_record_ttl_decrement(ares_dns_record_t *dnsrec,
unsigned int ttl_decrement);
/* Same as ares_dns_write() but appends to an existing buffer object */
ares_status_t ares_dns_write_buf(const ares_dns_record_t *dnsrec,
ares__buf_t *buf);
ares_status_t ares_dns_write_buf(const ares_dns_record_t *dnsrec,
ares__buf_t *buf);
/* Same as ares_dns_write_buf(), but prepends a 16bit length */
ares_status_t ares_dns_write_buf_tcp(const ares_dns_record_t *dnsrec,
ares__buf_t *buf);
ares_status_t ares_dns_write_buf_tcp(const ares_dns_record_t *dnsrec,
ares__buf_t *buf);
/*! Create a DNS record object for a query. The arguments are the same as
* those for ares_create_query().

@ -856,7 +856,7 @@ const unsigned char *ares_dns_rr_get_bin(const ares_dns_rr_t *dns_rr,
return NULL;
}
return ares__dns_multistring_get_combined(*strs, len);
return ares__dns_multistring_combined(*strs, len);
}
/* Not a multi-string, just straight binary data */

@ -958,7 +958,7 @@ static ares_status_t ares_dns_write_rr(const ares_dns_record_t *dnsrec,
}
type = ares_dns_rr_get_type(rr);
allow_compress = ares_dns_rec_type_allow_name_compression(type);
allow_compress = ares_dns_rec_allow_name_comp(type);
if (allow_compress) {
namelistptr = namelist;
}
@ -1219,8 +1219,8 @@ ares_status_t ares_dns_write(const ares_dns_record_t *dnsrec,
return status;
}
void ares_dns_record_write_ttl_decrement(ares_dns_record_t *dnsrec,
unsigned int ttl_decrement)
void ares_dns_record_ttl_decrement(ares_dns_record_t *dnsrec,
unsigned int ttl_decrement)
{
if (dnsrec == NULL) {
return;

@ -812,7 +812,7 @@ ares_status_t ares__buf_split(ares__buf_t *buf, const unsigned char *delims,
/* No delimiter yet, just tag the start */
ares__buf_tag(buf);
} else {
if (flags & ARES_BUF_SPLIT_DONT_CONSUME_DELIMS) {
if (flags & ARES_BUF_SPLIT_KEEP_DELIMS) {
/* tag then eat delimiter so its first byte in buffer */
ares__buf_tag(buf);
ares__buf_consume(buf, 1);

@ -931,7 +931,7 @@ TEST_F(LibraryTest, DNSRecord) {
EXPECT_EQ(0, ares_dns_rr_get_ttl(NULL));
EXPECT_NE(ARES_SUCCESS, ares_dns_write(NULL, NULL, NULL));
#ifndef CARES_SYMBOL_HIDING
ares_dns_record_write_ttl_decrement(NULL, 0);
ares_dns_record_ttl_decrement(NULL, 0);
#endif
EXPECT_EQ(nullptr, ares_dns_rr_get_addr(NULL, ARES_RR_A_ADDR));
EXPECT_EQ(nullptr, ares_dns_rr_get_addr(NULL, ARES_RR_NS_NSDNAME));

Loading…
Cancel
Save