Fix some shadowed variable warnings (#935)

This commit is contained in:
Vincent Stumpf 2021-05-15 05:46:16 -07:00 committed by GitHub
parent 2a70c45697
commit 5cfb70c2b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2230,45 +2230,45 @@ inline socket_t create_client_socket(
time_t write_timeout_usec, const std::string &intf, Error &error) { time_t write_timeout_usec, const std::string &intf, Error &error) {
auto sock = create_socket( auto sock = create_socket(
host, port, address_family, 0, tcp_nodelay, std::move(socket_options), host, port, address_family, 0, tcp_nodelay, std::move(socket_options),
[&](socket_t sock, struct addrinfo &ai) -> bool { [&](socket_t sock2, struct addrinfo &ai) -> bool {
if (!intf.empty()) { if (!intf.empty()) {
#ifdef USE_IF2IP #ifdef USE_IF2IP
auto ip = if2ip(intf); auto ip = if2ip(intf);
if (ip.empty()) { ip = intf; } if (ip.empty()) { ip = intf; }
if (!bind_ip_address(sock, ip.c_str())) { if (!bind_ip_address(sock2, ip.c_str())) {
error = Error::BindIPAddress; error = Error::BindIPAddress;
return false; return false;
} }
#endif #endif
} }
set_nonblocking(sock, true); set_nonblocking(sock2, true);
auto ret = auto ret =
::connect(sock, ai.ai_addr, static_cast<socklen_t>(ai.ai_addrlen)); ::connect(sock2, ai.ai_addr, static_cast<socklen_t>(ai.ai_addrlen));
if (ret < 0) { if (ret < 0) {
if (is_connection_error() || if (is_connection_error() ||
!wait_until_socket_is_ready(sock, connection_timeout_sec, !wait_until_socket_is_ready(sock2, connection_timeout_sec,
connection_timeout_usec)) { connection_timeout_usec)) {
error = Error::Connection; error = Error::Connection;
return false; return false;
} }
} }
set_nonblocking(sock, false); set_nonblocking(sock2, false);
{ {
timeval tv; timeval tv;
tv.tv_sec = static_cast<long>(read_timeout_sec); tv.tv_sec = static_cast<long>(read_timeout_sec);
tv.tv_usec = static_cast<decltype(tv.tv_usec)>(read_timeout_usec); tv.tv_usec = static_cast<decltype(tv.tv_usec)>(read_timeout_usec);
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)); setsockopt(sock2, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv));
} }
{ {
timeval tv; timeval tv;
tv.tv_sec = static_cast<long>(write_timeout_sec); tv.tv_sec = static_cast<long>(write_timeout_sec);
tv.tv_usec = static_cast<decltype(tv.tv_usec)>(write_timeout_usec); tv.tv_usec = static_cast<decltype(tv.tv_usec)>(write_timeout_usec);
setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(tv)); setsockopt(sock2, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(tv));
} }
error = Error::Success; error = Error::Success;
@ -2946,8 +2946,8 @@ bool prepare_content_receiver(T &x, int &status,
ContentReceiverWithProgress out = [&](const char *buf, size_t n, ContentReceiverWithProgress out = [&](const char *buf, size_t n,
uint64_t off, uint64_t len) { uint64_t off, uint64_t len) {
return decompressor->decompress(buf, n, return decompressor->decompress(buf, n,
[&](const char *buf, size_t n) { [&](const char *buf2, size_t n2) {
return receiver(buf, n, off, len); return receiver(buf2, n2, off, len);
}); });
}; };
return callback(std::move(out)); return callback(std::move(out));