mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
src: reduce variable scope in cares_wrap.cc
PR-URL: https://github.com/nodejs/node/pull/23297 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
@@ -429,7 +429,6 @@ void cares_wrap_hostent_cpy(struct hostent* dest, struct hostent* src) {
|
||||
|
||||
/* copy `h_aliases` */
|
||||
size_t alias_count;
|
||||
size_t cur_alias_length;
|
||||
for (alias_count = 0;
|
||||
src->h_aliases[alias_count] != nullptr;
|
||||
alias_count++) {
|
||||
@@ -437,9 +436,9 @@ void cares_wrap_hostent_cpy(struct hostent* dest, struct hostent* src) {
|
||||
|
||||
dest->h_aliases = node::Malloc<char*>(alias_count + 1);
|
||||
for (size_t i = 0; i < alias_count; i++) {
|
||||
cur_alias_length = strlen(src->h_aliases[i]);
|
||||
dest->h_aliases[i] = node::Malloc(cur_alias_length + 1);
|
||||
memcpy(dest->h_aliases[i], src->h_aliases[i], cur_alias_length + 1);
|
||||
const size_t cur_alias_size = strlen(src->h_aliases[i]) + 1;
|
||||
dest->h_aliases[i] = node::Malloc(cur_alias_size);
|
||||
memcpy(dest->h_aliases[i], src->h_aliases[i], cur_alias_size);
|
||||
}
|
||||
dest->h_aliases[alias_count] = nullptr;
|
||||
|
||||
@@ -1065,7 +1064,6 @@ int ParseSoaReply(Environment* env,
|
||||
/* Can't use ares_parse_soa_reply() here which can only parse single record */
|
||||
unsigned int ancount = cares_get_16bit(buf + 6);
|
||||
unsigned char* ptr = buf + NS_HFIXEDSZ;
|
||||
int rr_type, rr_len;
|
||||
char* name;
|
||||
char* rr_name;
|
||||
long temp_len; // NOLINT(runtime/int)
|
||||
@@ -1094,8 +1092,8 @@ int ParseSoaReply(Environment* env,
|
||||
break;
|
||||
}
|
||||
|
||||
rr_type = cares_get_16bit(ptr);
|
||||
rr_len = cares_get_16bit(ptr + 8);
|
||||
const int rr_type = cares_get_16bit(ptr);
|
||||
const int rr_len = cares_get_16bit(ptr + 8);
|
||||
ptr += NS_RRFIXEDSZ;
|
||||
|
||||
/* only need SOA */
|
||||
|
||||
Reference in New Issue
Block a user