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

This commit is contained in:
Alden Torres 2016-12-05 08:39:53 -05:00 committed by Arvid Norberg
parent 553cff97fb
commit 0625606230
8 changed files with 44 additions and 44 deletions

View File

@ -1501,7 +1501,7 @@ namespace libtorrent
if (!ctx)
{
error_code ec(::ERR_get_error(),
error_code ec(int(::ERR_get_error()),
boost::asio::error::get_ssl_category());
set_error(ec, torrent_status::error_file_ssl_ctx);
pause();
@ -1539,7 +1539,7 @@ namespace libtorrent
X509_STORE* cert_store = X509_STORE_new();
if (!cert_store)
{
ec.assign(::ERR_get_error(),
ec.assign(int(::ERR_get_error()),
boost::asio::error::get_ssl_category());
set_error(ec, torrent_status::error_file_ssl_ctx);
pause();
@ -1559,7 +1559,7 @@ namespace libtorrent
if (!certificate)
{
ec.assign(::ERR_get_error(),
ec.assign(int(::ERR_get_error()),
boost::asio::error::get_ssl_category());
X509_STORE_free(cert_store);
set_error(ec, torrent_status::error_file_ssl_ctx);
@ -1770,7 +1770,7 @@ namespace libtorrent
// maybe this whole section should move to need_picker()
need_picker();
peer_request pr = m_torrent_file->map_file(i, 0, fs.file_size(i));
peer_request pr = m_torrent_file->map_file(i, 0, int(fs.file_size(i)));
int off = pr.start & (block_size()-1);
if (off != 0) { pr.length -= block_size() - off; pr.start += block_size() - off; }
TORRENT_ASSERT((pr.start & (block_size()-1)) == 0);
@ -2324,7 +2324,7 @@ namespace libtorrent
}
}
m_progress_ppm = std::int64_t(m_num_checked_pieces) * 1000000 / torrent_file().num_pieces();
m_progress_ppm = std::uint32_t(std::int64_t(m_num_checked_pieces) * 1000000 / torrent_file().num_pieces());
if (settings().get_bool(settings_pack::disable_hash_checks)
|| piece_hash == m_torrent_file->hash_for_piece(piece))
@ -2567,7 +2567,7 @@ namespace libtorrent
if (m_ses.alerts().should_post<dht_reply_alert>())
{
m_ses.alerts().emplace_alert<dht_reply_alert>(
get_handle(), peers.size());
get_handle(), int(peers.size()));
}
if (torrent_file().priv() || (torrent_file().is_i2p()
@ -2963,7 +2963,7 @@ namespace libtorrent
ae->fails = 0;
ae->next_announce = now + seconds(interval);
ae->min_announce = now + seconds(resp.min_interval);
int tracker_index = ae - &m_trackers[0];
int tracker_index = int(ae - &m_trackers[0]);
m_last_working_tracker = std::int8_t(prioritize_tracker(tracker_index));
if ((!resp.trackerid.empty()) && (ae->trackerid != resp.trackerid))
@ -3099,9 +3099,9 @@ namespace libtorrent
|| r.triggered_manually)
{
m_ses.alerts().emplace_alert<tracker_reply_alert>(
get_handle(), resp.peers.size() + resp.peers4.size()
get_handle(), int(resp.peers.size() + resp.peers4.size())
#if TORRENT_USE_IPV6
+ resp.peers6.size()
+ int(resp.peers6.size())
#endif
, r.url);
}
@ -3500,7 +3500,7 @@ namespace libtorrent
for (int i = 0; i < files.num_files(); ++i)
{
if (!files.pad_file_at(i)) continue;
peer_request p = files.map_file(i, 0, files.file_size(i));
peer_request p = files.map_file(i, 0, int(files.file_size(i)));
for (int j = p.piece; p.length > 0; ++j)
{
int deduction = (std::min)(p.length, piece_size - p.start);
@ -4378,7 +4378,7 @@ namespace libtorrent
}
if (avail_vec.empty()) return -1;
return avail_vec[random(avail_vec.size() - 1)];
return avail_vec[random(std::uint32_t(avail_vec.size() - 1))];
}
void torrent::on_files_deleted(storage_error const& error) try
@ -4648,7 +4648,7 @@ namespace libtorrent
{
// update the average download time and average
// download time deviation
int dl_time = total_milliseconds(aux::time_now() - i->first_requested);
int dl_time = int(total_milliseconds(aux::time_now() - i->first_requested));
if (m_average_piece_time == 0)
{
@ -9367,7 +9367,7 @@ namespace libtorrent
return;
// now, pick one of the rarest pieces to download
int const pick = random(rarest_pieces.size() - 1);
int const pick = random(std::uint32_t(rarest_pieces.size() - 1));
bool const was_finished = is_finished();
m_picker->set_piece_priority(rarest_pieces[pick], 1);
update_gauge();
@ -9870,8 +9870,8 @@ namespace libtorrent
// of a piece since we requested the last block, allow
// one more request per block
if (m_average_piece_time > 0)
timed_out = total_milliseconds(now - i->last_requested)
/ (std::max)(int(m_average_piece_time + m_piece_time_deviation / 2), 1);
timed_out = int(total_milliseconds(now - i->last_requested)
/ (std::max)(int(m_average_piece_time + m_piece_time_deviation / 2), 1));
#if TORRENT_DEBUG_STREAMING > 0
i->timed_out = timed_out;
@ -10822,8 +10822,8 @@ namespace libtorrent
}
else
{
st->progress_ppm = st->total_wanted_done * 1000000
/ st->total_wanted;
st->progress_ppm = int(st->total_wanted_done * 1000000
/ st->total_wanted);
#if !TORRENT_NO_FPU
st->progress = st->progress_ppm / 1000000.f;
#endif
@ -10929,7 +10929,7 @@ namespace libtorrent
, retry_interval);
ae->last_error = ec;
ae->message = msg;
int tracker_index = ae - &m_trackers[0];
int tracker_index = int(ae - &m_trackers[0]);
#ifndef TORRENT_DISABLE_LOGGING
debug_log("*** increment tracker fail count [%d]", ae->fails);
#endif

View File

@ -1097,7 +1097,7 @@ namespace libtorrent
ptrdiff_t const info_ptr_diff = m_info_section.get() - section.data();
// extract piece length
int piece_length = info.dict_find_int_value("piece length", -1);
int piece_length = int(info.dict_find_int_value("piece length", -1));
if (piece_length <= 0)
{
ec = errors::torrent_missing_piece_length;

View File

@ -749,7 +749,7 @@ namespace libtorrent
address ip = address::from_string(settings.get_str(settings_pack::announce_ip).c_str(), ec);
if (!ec && ip.is_v4()) announce_ip = ip.to_v4();
}
aux::write_uint32(announce_ip.to_ulong(), out);
aux::write_uint32(std::uint32_t(announce_ip.to_ulong()), out);
aux::write_int32(req.key, out); // key
aux::write_int32(req.num_want, out); // num_want
aux::write_uint16(req.listen_port, out); // port

View File

@ -209,7 +209,7 @@ int upnp::add_mapping(portmap_protocol const p, int const external_port
mapping_it->external_port = external_port;
mapping_it->local_port = local_port;
int const mapping_index = mapping_it - m_mappings.begin();
int const mapping_index = int(mapping_it - m_mappings.begin());
for (auto const& dev : m_devices)
{
@ -766,7 +766,7 @@ void upnp::next(rootdevice& d, int i)
, [] (mapping_t const& m) { return m.act != mapping_t::action::none; });
if (j == d.mapping.end()) return;
update_map(d, j - d.mapping.begin());
update_map(d, int(j - d.mapping.begin()));
}
}
@ -1102,7 +1102,7 @@ void upnp::disable(error_code const& ec)
if (i->protocol == portmap_protocol::none) continue;
portmap_protocol const proto = i->protocol;
i->protocol = portmap_protocol::none;
m_callback.on_port_mapping(i - m_mappings.begin(), address(), 0, proto, ec
m_callback.on_port_mapping(int(i - m_mappings.begin()), address(), 0, proto, ec
, aux::portmap_transport::upnp);
}

View File

@ -211,11 +211,11 @@ namespace libtorrent { namespace
bdecode_node messages = h.dict_find_dict("m");
if (!messages) return false;
int index = messages.dict_find_int_value("ut_metadata", -1);
int index = int(messages.dict_find_int_value("ut_metadata", -1));
if (index == -1) return false;
m_message_index = index;
int metadata_size = h.dict_find_int_value("metadata_size");
int metadata_size = int(h.dict_find_int_value("metadata_size"));
if (metadata_size > 0)
m_tp.metadata_size(metadata_size);
else
@ -328,8 +328,8 @@ namespace libtorrent { namespace
m_pc.disconnect(errors::invalid_metadata_message, op_bittorrent, 2);
return true;
}
int type = type_ent->integer();
int piece = piece_ent->integer();
int type = int(type_ent->integer());
int piece = int(piece_ent->integer());
#ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log(peer_log_alert::incoming_message, "UT_METADATA"
@ -381,8 +381,8 @@ namespace libtorrent { namespace
m_sent_requests.erase(i);
entry const* total_size = msg.find_key("total_size");
m_tp.received_metadata(*this, body.begin() + len, int(body.size()) - len, piece
, (total_size && total_size->type() == entry::int_t) ? total_size->integer() : 0);
m_tp.received_metadata(*this, body.begin() + len, int(body.size() - len), piece
, (total_size && total_size->type() == entry::int_t) ? int(total_size->integer()) : 0);
maybe_send_request();
}
break;
@ -499,7 +499,7 @@ namespace libtorrent { namespace
i = m_requested_metadata.begin();
}
int piece = i - m_requested_metadata.begin();
int piece = int(i - m_requested_metadata.begin());
// don't request the same block more than once every 3 seconds
time_point now = aux::time_now();

View File

@ -2301,7 +2301,7 @@ void utp_socket_impl::experienced_loss(int const seq_nr)
// start should end before we over shoot.
if (m_slow_start)
{
m_ssthres = m_cwnd >> 16;
m_ssthres = std::int32_t(m_cwnd >> 16);
m_slow_start = false;
UTP_LOGV("%8p: experienced loss, slow_start -> 0\n", static_cast<void*>(this));
}
@ -2982,7 +2982,7 @@ bool utp_socket_impl::incoming_packet(span<std::uint8_t const> buf
// ptr points to the payload of the packet
// size is the packet size, payload is the
// number of payload bytes are in this packet
const int header_size = ptr - buf.data();
const int header_size = int(ptr - buf.data());
const int payload_size = size - header_size;
#if TORRENT_UTP_LOG
@ -3388,7 +3388,7 @@ void utp_socket_impl::do_ledbat(const int acked_bytes, const int delay
{
UTP_LOGV("%8p: off_target: %d slow_start -> 0\n"
, static_cast<void*>(this), target_delay - delay);
m_ssthres = (m_cwnd >> 16) / 2;
m_ssthres = std::int32_t((m_cwnd >> 16) / 2);
m_slow_start = false;
}

View File

@ -997,7 +997,7 @@ void web_peer_connection::on_receive(error_code const& error
done:
// now, remove all the bytes we've processed from the receive buffer
m_recv_buffer.cut(recv_buffer.data() - m_recv_buffer.get().begin()
m_recv_buffer.cut(int(recv_buffer.data() - m_recv_buffer.get().begin())
, t->block_size() + request_size_overhead);
}

View File

@ -53,7 +53,7 @@ namespace libtorrent
if (p != start)
{
token = xml_string;
const int name_len = p - start;
const int name_len = int(p - start);
callback(token, start, name_len, nullptr, 0);
}
@ -78,7 +78,7 @@ namespace libtorrent
}
token = xml_string;
const int name_len = p - start - 2;
const int name_len = int(p - start - 2);
callback(token, start, name_len, nullptr, 0);
continue;
}
@ -107,13 +107,13 @@ namespace libtorrent
{
++start;
token = xml_end_tag;
const int name_len = tag_name_end - start;
const int name_len = int(tag_name_end - start);
callback(token, start, name_len, nullptr, 0);
}
else if (*(p-1) == '/')
{
token = xml_empty_tag;
const int name_len = (std::min)(tag_name_end - start, p - start - 1);
const int name_len = int((std::min)(tag_name_end - start, p - start - 1));
callback(token, start, name_len, nullptr, 0);
tag_end = p - 1;
}
@ -121,7 +121,7 @@ namespace libtorrent
{
++start;
token = xml_declaration_tag;
const int name_len = (std::min)(tag_name_end - start, p - start - 1);
const int name_len = int((std::min)(tag_name_end - start, p - start - 1));
callback(token, start, name_len, nullptr, 0);
tag_end = p - 1;
}
@ -129,7 +129,7 @@ namespace libtorrent
{
start += 3;
token = xml_comment;
const int name_len = tag_name_end - start - 2;
const int name_len = int(tag_name_end - start - 2);
callback(token, start, name_len, nullptr, 0);
tag_end = p - 2;
continue;
@ -137,7 +137,7 @@ namespace libtorrent
else
{
token = xml_start_tag;
const int name_len = tag_name_end - start;
const int name_len = int(tag_name_end - start);
callback(token, start, name_len, nullptr, 0);
}
@ -152,7 +152,7 @@ namespace libtorrent
start = i;
// find end of attribute name
for (; i != tag_end && *i != '=' && !is_space(*i); ++i);
const int name_len = i - start;
const int name_len = int(i - start);
// look for equality sign
for (; i != tag_end && *i != '='; ++i);
@ -162,7 +162,7 @@ namespace libtorrent
if (i == tag_end)
{
token = xml_tag_content;
callback(token, start, i - start, nullptr, 0);
callback(token, start, int(i - start), nullptr, 0);
break;
}
@ -188,7 +188,7 @@ namespace libtorrent
callback(token, start, int(strlen(start)), nullptr, 0);
break;
}
const int val_len = i - val_start;
const int val_len = int(i - val_start);
token = xml_attribute;
callback(token, start, name_len, val_start, val_len);
}