From 4c86bf3e9d91e2a84972a5bd6c35ce6eb527722f Mon Sep 17 00:00:00 2001 From: Brad House Date: Wed, 28 Aug 2024 07:19:33 -0400 Subject: [PATCH] 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) --- src/lib/ares__hosts_file.c | 4 +-- src/lib/ares_options.c | 2 +- src/lib/ares_private.h | 10 ++++---- src/lib/ares_process.c | 6 ++--- src/lib/ares_qcache.c | 4 +-- src/lib/ares_update_servers.c | 19 +++++++------- src/lib/dsa/ares__htable.c | 2 +- src/lib/dsa/ares__llist.c | 8 +++--- src/lib/event/ares_event_thread.c | 4 +-- src/lib/include/ares__buf.h | 4 +-- src/lib/include/ares__llist.h | 8 +++--- src/lib/record/ares_dns_mapping.c | 2 +- src/lib/record/ares_dns_multistring.c | 2 +- src/lib/record/ares_dns_multistring.h | 5 ++-- src/lib/record/ares_dns_parse.c | 2 +- src/lib/record/ares_dns_private.h | 36 +++++++++++++-------------- src/lib/record/ares_dns_record.c | 2 +- src/lib/record/ares_dns_write.c | 6 ++--- src/lib/str/ares__buf.c | 2 +- test/ares-test-internal.cc | 2 +- 20 files changed, 65 insertions(+), 65 deletions(-) diff --git a/src/lib/ares__hosts_file.c b/src/lib/ares__hosts_file.c index 429d96d2..c9300d26 100644 --- a/src/lib/ares__hosts_file.c +++ b/src/lib/ares__hosts_file.c @@ -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); diff --git a/src/lib/ares_options.c b/src/lib/ares_options.c index 9aeb4bad..086aca1e 100644 --- a/src/lib/ares_options.c +++ b/src/lib/ares_options.c @@ -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 */ } diff --git a/src/lib/ares_private.h b/src/lib/ares_private.h index a58c4160..21dd5414 100644 --- a/src/lib/ares_private.h +++ b/src/lib/ares_private.h @@ -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; diff --git a/src/lib/ares_process.c b/src/lib/ares_process.c index c4b31f4f..d516e2a6 100644 --- a/src/lib/ares_process.c +++ b/src/lib/ares_process.c @@ -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; diff --git a/src/lib/ares_qcache.c b/src/lib/ares_qcache.c index 9725212f..fde762d4 100644 --- a/src/lib/ares_qcache.c +++ b/src/lib/ares_qcache.c @@ -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; diff --git a/src/lib/ares_update_servers.c b/src/lib/ares_update_servers.c index 1be026bb..330051ae 100644 --- a/src/lib/ares_update_servers.c +++ b/src/lib/ares_update_servers.c @@ -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; } diff --git a/src/lib/dsa/ares__htable.c b/src/lib/dsa/ares__htable.c index ba465664..becc7414 100644 --- a/src/lib/dsa/ares__htable.c +++ b/src/lib/dsa/ares__htable.c @@ -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 */ diff --git a/src/lib/dsa/ares__llist.c b/src/lib/dsa/ares__llist.c index 96936c1a..136a7a2a 100644 --- a/src/lib/dsa/ares__llist.c +++ b/src/lib/dsa/ares__llist.c @@ -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 */ diff --git a/src/lib/event/ares_event_thread.c b/src/lib/event/ares_event_thread.c index 7441be1e..40e2c04f 100644 --- a/src/lib/event/ares_event_thread.c +++ b/src/lib/event/ares_event_thread.c @@ -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)) { diff --git a/src/lib/include/ares__buf.h b/src/lib/include/ares__buf.h index 4c1a1361..b1b020af 100644 --- a/src/lib/include/ares__buf.h +++ b/src/lib/include/ares__buf.h @@ -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 */ diff --git a/src/lib/include/ares__llist.h b/src/lib/include/ares__llist.h index 6769fb3a..19d82fe1 100644 --- a/src/lib/include/ares__llist.h +++ b/src/lib/include/ares__llist.h @@ -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 */ diff --git a/src/lib/record/ares_dns_mapping.c b/src/lib/record/ares_dns_mapping.c index b8af8a6d..5a3ec28a 100644 --- a/src/lib/record/ares_dns_mapping.c +++ b/src/lib/record/ares_dns_mapping.c @@ -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 diff --git a/src/lib/record/ares_dns_multistring.c b/src/lib/record/ares_dns_multistring.c index 8d8f7fa3..59487c17 100644 --- a/src/lib/record/ares_dns_multistring.c +++ b/src/lib/record/ares_dns_multistring.c @@ -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; diff --git a/src/lib/record/ares_dns_multistring.h b/src/lib/record/ares_dns_multistring.h index 35356aba..a9e2070a 100644 --- a/src/lib/record/ares_dns_multistring.h +++ b/src/lib/record/ares_dns_multistring.h @@ -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 diff --git a/src/lib/record/ares_dns_parse.c b/src/lib/record/ares_dns_parse.c index 81b55d14..314da14e 100644 --- a/src/lib/record/ares_dns_parse.c +++ b/src/lib/record/ares_dns_parse.c @@ -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))) { diff --git a/src/lib/record/ares_dns_private.h b/src/lib/record/ares_dns_private.h index 5b86fed5..127a110c 100644 --- a/src/lib/record/ares_dns_private.h +++ b/src/lib/record/ares_dns_private.h @@ -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(). diff --git a/src/lib/record/ares_dns_record.c b/src/lib/record/ares_dns_record.c index 14704949..ddae88cd 100644 --- a/src/lib/record/ares_dns_record.c +++ b/src/lib/record/ares_dns_record.c @@ -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 */ diff --git a/src/lib/record/ares_dns_write.c b/src/lib/record/ares_dns_write.c index 8a3addd9..690c6325 100644 --- a/src/lib/record/ares_dns_write.c +++ b/src/lib/record/ares_dns_write.c @@ -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; diff --git a/src/lib/str/ares__buf.c b/src/lib/str/ares__buf.c index 8a4b2cd7..0777ec80 100644 --- a/src/lib/str/ares__buf.c +++ b/src/lib/str/ares__buf.c @@ -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); diff --git a/test/ares-test-internal.cc b/test/ares-test-internal.cc index 403663bf..c3dc2ff1 100644 --- a/test/ares-test-internal.cc +++ b/test/ares-test-internal.cc @@ -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));