SonarCloud: fix codesmells

pull/600/head
Brad House 1 year ago
parent 35c1300078
commit 80d940cd3d
  1. 4
      src/lib/ares_dns_name.c
  2. 27
      src/lib/ares_dns_write.c
  3. 4
      src/lib/ares_process.c

@ -175,7 +175,7 @@ static ares__buf_t *ares_dns_labels_add(ares_dns_labels_t *labels)
return labels->label[labels->num - 1];
}
static ares__buf_t *ares_dns_labels_get_last(ares_dns_labels_t *labels)
static const ares__buf_t *ares_dns_labels_get_last(const ares_dns_labels_t *labels)
{
if (labels == NULL || labels->num == 0) {
return NULL;
@ -271,7 +271,7 @@ static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels,
if (*name != '\0') {
status =
ares__buf_append(namebuf, (unsigned char *)name, ares_strlen(name));
ares__buf_append(namebuf, (const unsigned char *)name, ares_strlen(name));
if (status != ARES_SUCCESS) {
goto done;
}

@ -208,7 +208,7 @@ static ares_status_t ares_dns_write_rr_str(ares__buf_t *buf,
}
/* Write string */
return ares__buf_append(buf, (unsigned char *)str, len);
return ares__buf_append(buf, (const unsigned char *)str, len);
}
static ares_status_t ares_dns_write_rr_binstrs(ares__buf_t *buf,
@ -242,7 +242,7 @@ static ares_status_t ares_dns_write_rr_binstrs(ares__buf_t *buf,
/* String */
if (len) {
status = ares__buf_append(buf, (unsigned char *)ptr, len);
status = ares__buf_append(buf, (const unsigned char *)ptr, len);
if (status != ARES_SUCCESS) {
return status;
}
@ -297,7 +297,7 @@ static ares_status_t ares_dns_write_rr_a(ares__buf_t *buf,
return ARES_EFORMERR;
}
return ares__buf_append(buf, (unsigned char *)&addr, sizeof(*addr));
return ares__buf_append(buf, (const unsigned char *)addr, sizeof(*addr));
}
static ares_status_t ares_dns_write_rr_ns(ares__buf_t *buf,
@ -427,7 +427,7 @@ static ares_status_t ares_dns_write_rr_aaaa(ares__buf_t *buf,
return ARES_EFORMERR;
}
return ares__buf_append(buf, (unsigned char *)&addr, sizeof(*addr));
return ares__buf_append(buf, (const unsigned char *)addr, sizeof(*addr));
}
static ares_status_t ares_dns_write_rr_srv(ares__buf_t *buf,
@ -573,7 +573,8 @@ static ares_status_t ares_dns_write_rr_uri(ares__buf_t *buf,
return ARES_EFORMERR;
}
return ares__buf_append(buf, (unsigned char *)target, ares_strlen(target));
return ares__buf_append(buf, (const unsigned char *)target,
ares_strlen(target));
}
static ares_status_t ares_dns_write_rr_caa(ares__buf_t *buf,
@ -660,14 +661,14 @@ static ares_status_t ares_dns_write_rr(ares_dns_record_t *dnsrec,
size_t i;
for (i = 0; i < ares_dns_record_rr_cnt(dnsrec, section); i++) {
ares_dns_rr_t *rr;
ares_dns_rec_type_t type;
ares_bool_t allow_compress;
ares__llist_t **namelistptr = NULL;
size_t pos_len;
ares_status_t status;
size_t rdlength;
size_t end_length;
const ares_dns_rr_t *rr;
ares_dns_rec_type_t type;
ares_bool_t allow_compress;
ares__llist_t **namelistptr = NULL;
size_t pos_len;
ares_status_t status;
size_t rdlength;
size_t end_length;
rr = ares_dns_record_rr_get(dnsrec, section, i);
if (rr == NULL) {

@ -568,7 +568,7 @@ static ares_status_t rewrite_without_edns(ares_dns_record_t *qdnsrec,
/* Find and remove the OPT RR record */
for (i = 0; i < ares_dns_record_rr_cnt(qdnsrec, ARES_SECTION_ADDITIONAL);
i++) {
ares_dns_rr_t *rr;
const ares_dns_rr_t *rr;
rr = ares_dns_record_rr_get(qdnsrec, ARES_SECTION_ADDITIONAL, i);
if (ares_dns_rr_get_type(rr) == ARES_REC_TYPE_OPT) {
ares_dns_record_rr_del(qdnsrec, ARES_SECTION_ADDITIONAL, i);
@ -786,7 +786,7 @@ static struct server_state *ares__random_server(ares_channel_t *channel)
}
static ares_status_t ares__append_tcpbuf(struct server_state *server,
struct query *query)
const struct query *query)
{
ares_status_t status;

Loading…
Cancel
Save