fixed sign implicit conversion warnings in new enum_net code (#3107)

This commit is contained in:
Alden Torres 2018-06-16 09:19:02 -04:00 committed by Arvid Norberg
parent 5530793c75
commit dfe47aa2a9
1 changed files with 12 additions and 14 deletions

View File

@ -174,21 +174,20 @@ namespace {
}
#if TORRENT_USE_GETIPFORWARDTABLE || TORRENT_USE_NETLINK
address build_netmask(int bits, int family)
address build_netmask(int bits, int const family)
{
if (family == AF_INET)
{
using bytes_t = boost::asio::ip::address_v4::bytes_type;
bytes_t b;
std::memset(&b[0], 0xff, b.size());
for (int i = int(b.size()) - 1; i > 0; --i)
address_v4::bytes_type b;
b.fill(0xff);
for (int i = int(b.size()) - 1; i >= 0; --i)
{
if (bits < 8)
{
b[i] <<= bits;
b[std::size_t(i)] <<= bits;
break;
}
b[i] = 0;
b[std::size_t(i)] = 0;
bits -= 8;
}
return address_v4(b);
@ -196,17 +195,16 @@ namespace {
#if TORRENT_USE_IPV6
else if (family == AF_INET6)
{
using bytes_t = boost::asio::ip::address_v6::bytes_type;
bytes_t b;
std::memset(&b[0], 0xff, b.size());
for (int i = int(b.size()) - 1; i > 0; --i)
address_v6::bytes_type b;
b.fill(0xff);
for (int i = int(b.size()) - 1; i >= 0; --i)
{
if (bits < 8)
{
b[i] <<= bits;
b[std::size_t(i)] <<= bits;
break;
}
b[i] = 0;
b[std::size_t(i)] = 0;
bits -= 8;
}
return address_v6(b);
@ -358,7 +356,7 @@ namespace {
if (rt_info->gateway.is_v6() && rt_info->gateway.to_v6().is_link_local())
{
address_v6 gateway6 = rt_info->gateway.to_v6();
gateway6.scope_id(if_index);
gateway6.scope_id(std::uint32_t(if_index));
rt_info->gateway = gateway6;
}
#endif