fixing shorten-64-to-32 warnings, part 4

This commit is contained in:
Alden Torres 2016-12-07 08:51:11 -05:00 committed by Arvid Norberg
parent 123a6389cd
commit 7266b0b360
8 changed files with 30 additions and 30 deletions

View File

@ -161,7 +161,7 @@ namespace libtorrent
#ifdef TORRENT_USE_LIBGCRYPT
gcry_md_write(m_context, data.data(), data.size());
#elif TORRENT_USE_COMMONCRYPTO
CC_SHA1_Update(&m_context, reinterpret_cast<unsigned char const*>(data.data()), data.size());
CC_SHA1_Update(&m_context, reinterpret_cast<unsigned char const*>(data.data()), CC_LONG(data.size()));
#elif TORRENT_USE_CRYPTOAPI
if (CryptHashData(m_context, reinterpret_cast<BYTE const*>(data.data()), int(data.size()), 0) == false)
{

View File

@ -149,7 +149,7 @@ namespace libtorrent
#ifdef TORRENT_USE_LIBGCRYPT
gcry_md_write(m_context, data.data(), data.size());
#elif TORRENT_USE_COMMONCRYPTO
CC_SHA512_Update(&m_context, reinterpret_cast<unsigned char const*>(data.data()), data.size());
CC_SHA512_Update(&m_context, reinterpret_cast<unsigned char const*>(data.data()), CC_LONG(data.size()));
#elif TORRENT_USE_CRYPTOAPI_SHA_512
if (CryptHashData(m_context, reinterpret_cast<BYTE const*>(data.data()), int(data.size()), 0) == false)
{

View File

@ -330,7 +330,7 @@ restart_response:
if (m_state == read_body)
{
int incoming = recv_buffer.end() - pos;
int incoming = int(recv_buffer.end() - pos);
if (m_chunked_encoding && (m_flags & dont_parse_chunks) == 0)
{
@ -459,7 +459,7 @@ restart_response:
if (*chunk_size != 0)
{
*header_size = newline - buf.data();
*header_size = int(newline - buf.data());
// the newline alone is two bytes
TORRENT_ASSERT(newline - buf.data() > 2);
return true;
@ -487,7 +487,7 @@ restart_response:
// this means we got a blank line,
// the header is finished and the body
// starts.
*header_size = newline - buf.data();
*header_size = int(newline - buf.data());
// the newline alone is two bytes
TORRENT_ASSERT(newline - buf.data() > 2);
@ -569,7 +569,7 @@ restart_response:
std::memmove(write_ptr, buffer + i.first - offset, len);
write_ptr += len;
}
size = write_ptr - buffer;
size = int(write_ptr - buffer);
return size;
}
}

View File

@ -242,12 +242,12 @@ void lsd::on_announce(udp::endpoint const& from, char const* buf
{
// we expect it to be hexadecimal
// if it isn't, it's not our cookie anyway
std::int32_t const cookie = strtol(cookie_iter->second.c_str(), nullptr, 16);
long const cookie = strtol(cookie_iter->second.c_str(), nullptr, 16);
if (cookie == m_cookie)
{
#ifndef TORRENT_DISABLE_LOGGING
debug_log("<== LSD: ignoring packet (cookie matched our own): %x"
, cookie);
, m_cookie);
#endif
return;
}

View File

@ -133,7 +133,7 @@ void natpmp::start()
|| i->act != mapping_t::action::none)
continue;
i->act = mapping_t::action::add;
update_mapping(i - m_mappings.begin());
update_mapping(int(i - m_mappings.begin()));
}
}
@ -200,7 +200,7 @@ void natpmp::disable(error_code const& ec)
if (i->protocol == portmap_protocol::none) continue;
portmap_protocol const proto = i->protocol;
i->protocol = portmap_protocol::none;
int const index = i - m_mappings.begin();
int const index = int(i - m_mappings.begin());
m_callback.on_port_mapping(index, address(), 0, proto, ec
, aux::portmap_transport::natpmp);
}
@ -246,7 +246,7 @@ int natpmp::add_mapping(portmap_protocol const p, int const external_port
i->local_port = local_port;
i->act = mapping_t::action::add;
int const mapping_index = i - m_mappings.begin();
int const mapping_index = int(i - m_mappings.begin());
#ifndef TORRENT_DISABLE_LOGGING
if (should_log())
{
@ -290,7 +290,7 @@ void natpmp::try_next_mapping(int const i)
return;
}
update_mapping(m - m_mappings.begin());
update_mapping(int(m - m_mappings.begin()));
}
void natpmp::update_mapping(int const i)
@ -531,7 +531,7 @@ void natpmp::on_reply(error_code const& e
if (!i->map_sent) continue;
if (!i->outstanding_request) continue;
m = &*i;
index = i - m_mappings.begin();
index = int(i - m_mappings.begin());
break;
}
@ -609,7 +609,7 @@ void natpmp::update_expiration_timer()
{
if (i->protocol == portmap_protocol::none
|| i->act != mapping_t::action::none) continue;
int index = i - m_mappings.begin();
int index = int(i - m_mappings.begin());
if (i->expires < now)
{
#ifndef TORRENT_DISABLE_LOGGING

View File

@ -95,7 +95,7 @@ namespace libtorrent
// parse header
std::unique_ptr<std::uint32_t[]> header(new std::uint32_t[m_header_size]);
file::iovec_t b = {header.get(), size_t(m_header_size) };
int n = m_file.readv(0, b, ec);
int n = int(m_file.readv(0, b, ec));
if (ec) return;
// we don't have a full header. consider the file empty
@ -189,7 +189,7 @@ namespace libtorrent
l.unlock();
std::int64_t slot_offset = std::int64_t(m_header_size) + std::int64_t(slot) * m_piece_size;
return m_file.writev(slot_offset + offset, bufs, ec);
return int(m_file.writev(slot_offset + offset, bufs, ec));
}
int part_file::readv(span<file::iovec_t const> bufs
@ -214,7 +214,7 @@ namespace libtorrent
l.unlock();
std::int64_t slot_offset = std::int64_t(m_header_size) + std::int64_t(slot) * m_piece_size;
return m_file.readv(slot_offset + offset, bufs, ec);
return int(m_file.readv(slot_offset + offset, bufs, ec));
}
void part_file::open_file(int mode, error_code& ec)
@ -301,8 +301,8 @@ namespace libtorrent
{
std::unique_lock<std::mutex> l(m_mutex);
int piece = offset / m_piece_size;
int const end = ((offset + size) + m_piece_size - 1) / m_piece_size;
int piece = int(offset / m_piece_size);
int const end = int(((offset + size) + m_piece_size - 1) / m_piece_size);
std::unique_ptr<char[]> buf;
@ -311,7 +311,7 @@ namespace libtorrent
for (; piece < end; ++piece)
{
std::unordered_map<int, int>::iterator i = m_piece_map.find(piece);
int const block_to_copy = (std::min)(m_piece_size - piece_offset, size);
int const block_to_copy = int((std::min)(m_piece_size - piece_offset, size));
if (i != m_piece_map.end())
{
int const slot = i->second;

View File

@ -74,7 +74,7 @@ namespace libtorrent
// we wouldn't have to shift it later
if (end < begin + 96)
{
int const len = end - begin;
int const len = int(end - begin);
std::memmove(begin + 96 - len, begin, len);
std::memset(begin, 0, 96 - len);
}

View File

@ -988,7 +988,7 @@ namespace libtorrent
// we don't know what rate we can get from this peer. Instead of assuming
// the lowest possible rate, assume the average.
int peers_with_requests = stats_counters()[counters::num_peers_down_requests];
int peers_with_requests = int(stats_counters()[counters::num_peers_down_requests]);
// avoid division by 0
if (peers_with_requests == 0) peers_with_requests = 1;
@ -2279,7 +2279,7 @@ namespace libtorrent
int fast_idx = -1;
std::vector<int>::iterator fast_iter = std::find(m_accept_fast.begin()
, m_accept_fast.end(), r.piece);
if (fast_iter != m_accept_fast.end()) fast_idx = fast_iter - m_accept_fast.begin();
if (fast_iter != m_accept_fast.end()) fast_idx = int(fast_iter - m_accept_fast.begin());
if (!m_peer_interested)
{
@ -2484,7 +2484,7 @@ namespace libtorrent
#endif
#if TORRENT_USE_ASSERTS
span<char const> recv_buffer = m_recv_buffer.get();
int recv_pos = recv_buffer.end() - recv_buffer.begin();
int recv_pos = int(recv_buffer.end() - recv_buffer.begin());
TORRENT_ASSERT(recv_pos >= 9);
#endif
@ -2776,7 +2776,7 @@ namespace libtorrent
if (m_disconnecting) return;
m_request_time.add_sample(total_milliseconds(now - m_requested));
m_request_time.add_sample(int(total_milliseconds(now - m_requested)));
#ifndef TORRENT_DISABLE_LOGGING
if (should_log(peer_log_alert::info))
{
@ -2846,7 +2846,7 @@ namespace libtorrent
, performance_alert::too_high_disk_queue_limit);
}
m_request_time.add_sample(total_milliseconds(now - m_requested));
m_request_time.add_sample(int(total_milliseconds(now - m_requested)));
#ifndef TORRENT_DISABLE_LOGGING
if (should_log(peer_log_alert::info))
{
@ -3806,7 +3806,7 @@ namespace libtorrent
int const max = m_settings.get_int(settings_pack::max_suggest_pieces);
if (int(m_suggest_pieces.size()) > max)
{
int const to_erase = m_suggest_pieces.size() - max;
int const to_erase = int(m_suggest_pieces.size() - max);
m_suggest_pieces.erase(m_suggest_pieces.begin()
, m_suggest_pieces.begin() + to_erase);
}
@ -4501,7 +4501,7 @@ namespace libtorrent
#else
p.progress = float(p.pieces.count()) / float(p.pieces.size());
#endif
p.progress_ppm = std::uint64_t(p.pieces.count()) * 1000000 / p.pieces.size();
p.progress_ppm = int(std::uint64_t(p.pieces.count()) * 1000000 / p.pieces.size());
}
p.estimated_reciprocation_rate = m_est_reciprocation_rate;
@ -5829,7 +5829,7 @@ namespace libtorrent
// receive buffer.
TORRENT_ASSERT(int(bytes_transferred) <= m_recv_buffer.max_receive());
bool const grow_buffer = (int(bytes_transferred) == m_recv_buffer.max_receive());
account_received_bytes(bytes_transferred);
account_received_bytes(int(bytes_transferred));
if (m_extension_outstanding_bytes > 0)
m_extension_outstanding_bytes -= std::min(m_extension_outstanding_bytes, int(bytes_transferred));
@ -5887,7 +5887,7 @@ namespace libtorrent
}
else
{
account_received_bytes(bytes);
account_received_bytes(int(bytes));
bytes_transferred += bytes;
}
}