forked from premiere/premiere-libtorrent
fixing sign-conversion warnings, part 10 (#1642)
fixing sign-conversion warnings, part 10
This commit is contained in:
parent
29db3de6c0
commit
d36c598eeb
|
@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/performance_counters.hpp"
|
#include "libtorrent/performance_counters.hpp"
|
||||||
#include "libtorrent/aux_/time.hpp"
|
#include "libtorrent/aux_/time.hpp"
|
||||||
#include "libtorrent/aux_/block_cache_reference.hpp"
|
#include "libtorrent/aux_/block_cache_reference.hpp"
|
||||||
|
#include "libtorrent/aux_/numeric_cast.hpp"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
@ -620,7 +621,7 @@ cached_piece_entry* block_cache::allocate_piece(disk_io_job const* j, std::uint1
|
||||||
pe.piece = j->piece;
|
pe.piece = j->piece;
|
||||||
pe.storage = j->storage;
|
pe.storage = j->storage;
|
||||||
pe.expire = aux::time_now();
|
pe.expire = aux::time_now();
|
||||||
pe.blocks_in_piece = blocks_in_piece;
|
pe.blocks_in_piece = aux::numeric_cast<std::uint64_t>(blocks_in_piece);
|
||||||
|
|
||||||
pe.blocks.reset(new (std::nothrow) cached_block_entry[blocks_in_piece]);
|
pe.blocks.reset(new (std::nothrow) cached_block_entry[blocks_in_piece]);
|
||||||
if (!pe.blocks) return nullptr;
|
if (!pe.blocks) return nullptr;
|
||||||
|
@ -1772,7 +1773,7 @@ int block_cache::copy_from_piece(cached_piece_entry* const pe
|
||||||
- block_offset, size);
|
- block_offset, size);
|
||||||
std::memcpy(j->buffer.disk_block + buffer_offset
|
std::memcpy(j->buffer.disk_block + buffer_offset
|
||||||
, pe->blocks[block].buf + block_offset
|
, pe->blocks[block].buf + block_offset
|
||||||
, to_copy);
|
, aux::numeric_cast<std::size_t>(to_copy));
|
||||||
size -= to_copy;
|
size -= to_copy;
|
||||||
block_offset = 0;
|
block_offset = 0;
|
||||||
buffer_offset += to_copy;
|
buffer_offset += to_copy;
|
||||||
|
|
|
@ -531,7 +531,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int const pad_size = random(512);
|
int const pad_size = int(random(512));
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
peer_log(peer_log_alert::info, "ENCRYPTION", "pad size: %d", pad_size);
|
peer_log(peer_log_alert::info, "ENCRYPTION", "pad size: %d", pad_size);
|
||||||
|
@ -570,7 +570,7 @@ namespace libtorrent
|
||||||
key_t const secret_key = m_dh_key_exchange->get_secret();
|
key_t const secret_key = m_dh_key_exchange->get_secret();
|
||||||
std::array<char, dh_key_len> const secret = export_key(secret_key);
|
std::array<char, dh_key_len> const secret = export_key(secret_key);
|
||||||
|
|
||||||
int const pad_size = random(512);
|
int const pad_size = int(random(512));
|
||||||
|
|
||||||
// synchash,skeyhash,vc,crypto_provide,len(pad),pad,len(ia)
|
// synchash,skeyhash,vc,crypto_provide,len(pad),pad,len(ia)
|
||||||
char msg[20 + 20 + 8 + 4 + 2 + 512 + 2];
|
char msg[20 + 20 + 8 + 4 + 2 + 512 + 2];
|
||||||
|
@ -619,7 +619,7 @@ namespace libtorrent
|
||||||
m_dh_key_exchange.reset(); // secret should be invalid at this point
|
m_dh_key_exchange.reset(); // secret should be invalid at this point
|
||||||
|
|
||||||
// write the verification constant and crypto field
|
// write the verification constant and crypto field
|
||||||
int const encrypt_size = sizeof(msg) - 512 + pad_size - 40;
|
int const encrypt_size = int(sizeof(msg)) - 512 + pad_size - 40;
|
||||||
|
|
||||||
// this is an invalid setting, but let's just make the best of the situation
|
// this is an invalid setting, but let's just make the best of the situation
|
||||||
int const enc_level = m_settings.get_int(settings_pack::allowed_enc_level);
|
int const enc_level = m_settings.get_int(settings_pack::allowed_enc_level);
|
||||||
|
@ -634,9 +634,9 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
write_pe_vc_cryptofield(ptr, encrypt_size, crypto_provide, pad_size);
|
write_pe_vc_cryptofield(ptr, encrypt_size, crypto_provide, pad_size);
|
||||||
span<char> vec(ptr, encrypt_size);
|
span<char> vec(ptr, aux::numeric_cast<std::size_t>(encrypt_size));
|
||||||
m_rc4->encrypt(vec);
|
m_rc4->encrypt(vec);
|
||||||
send_buffer(msg, sizeof(msg) - 512 + pad_size);
|
send_buffer(msg, int(sizeof(msg)) - 512 + pad_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::write_pe4_sync(int crypto_select)
|
void bt_peer_connection::write_pe4_sync(int crypto_select)
|
||||||
|
@ -649,13 +649,13 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(crypto_select == 0x02 || crypto_select == 0x01);
|
TORRENT_ASSERT(crypto_select == 0x02 || crypto_select == 0x01);
|
||||||
TORRENT_ASSERT(!m_sent_handshake);
|
TORRENT_ASSERT(!m_sent_handshake);
|
||||||
|
|
||||||
int const pad_size = random(512);
|
int const pad_size = int(random(512));
|
||||||
|
|
||||||
int const buf_size = 8 + 4 + 2 + pad_size;
|
int const buf_size = 8 + 4 + 2 + pad_size;
|
||||||
char msg[512 + 8 + 4 + 2];
|
char msg[512 + 8 + 4 + 2];
|
||||||
write_pe_vc_cryptofield(msg, sizeof(msg), crypto_select, pad_size);
|
write_pe_vc_cryptofield(msg, sizeof(msg), crypto_select, pad_size);
|
||||||
|
|
||||||
span<char> vec(msg, buf_size);
|
span<char> vec(msg, aux::numeric_cast<std::size_t>(buf_size));
|
||||||
m_rc4->encrypt(vec);
|
m_rc4->encrypt(vec);
|
||||||
send_buffer(msg, buf_size);
|
send_buffer(msg, buf_size);
|
||||||
|
|
||||||
|
@ -1335,7 +1335,7 @@ namespace libtorrent
|
||||||
span<char const> recv_buffer = m_recv_buffer.get();
|
span<char const> recv_buffer = m_recv_buffer.get();
|
||||||
|
|
||||||
const char* ptr = recv_buffer.begin() + 1;
|
const char* ptr = recv_buffer.begin() + 1;
|
||||||
piece_index_t const piece(detail::read_uint32(ptr));
|
piece_index_t const piece(detail::read_int32(ptr));
|
||||||
incoming_suggest(piece);
|
incoming_suggest(piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1726,7 +1726,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
piece_index_t const piece(aux::read_uint32(recv_buffer));
|
piece_index_t const piece(aux::numeric_cast<int>(aux::read_uint32(recv_buffer)));
|
||||||
incoming_dont_have(piece);
|
incoming_dont_have(piece);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2142,7 +2142,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::memset(ptr, 0, packet_size - 5);
|
std::memset(ptr, 0, aux::numeric_cast<std::size_t>(packet_size - 5));
|
||||||
piece_picker const& p = t->picker();
|
piece_picker const& p = t->picker();
|
||||||
int mask = 0x80;
|
int mask = 0x80;
|
||||||
for (piece_index_t i(0); i < piece_index_t(num_pieces); ++i)
|
for (piece_index_t i(0); i < piece_index_t(num_pieces); ++i)
|
||||||
|
@ -2452,7 +2452,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// back-patch the length field
|
// back-patch the length field
|
||||||
char* ptr2 = msg;
|
char* ptr2 = msg;
|
||||||
detail::write_int32(int(r.length + 1 + 4 + 4 + 4 + piece_list_buf.size())
|
detail::write_int32(r.length + 1 + 4 + 4 + 4 + int(piece_list_buf.size())
|
||||||
, ptr2);
|
, ptr2);
|
||||||
|
|
||||||
send_buffer(msg, 17);
|
send_buffer(msg, 17);
|
||||||
|
@ -2502,9 +2502,9 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
int const consumed = m_enc_handler.decrypt(m_recv_buffer, bytes_transferred);
|
int const consumed = m_enc_handler.decrypt(m_recv_buffer, bytes_transferred);
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
if (consumed + bytes_transferred > 0)
|
if (consumed + int(bytes_transferred) > 0)
|
||||||
peer_log(peer_log_alert::incoming_message, "ENCRYPTION"
|
peer_log(peer_log_alert::incoming_message, "ENCRYPTION"
|
||||||
, "decrypted block s = %d", int(consumed + bytes_transferred));
|
, "decrypted block s = %d", consumed + int(bytes_transferred));
|
||||||
#endif
|
#endif
|
||||||
if (bytes_transferred == SIZE_MAX)
|
if (bytes_transferred == SIZE_MAX)
|
||||||
{
|
{
|
||||||
|
@ -2529,9 +2529,9 @@ namespace libtorrent
|
||||||
std::int64_t cur_payload_dl = m_statistics.last_payload_downloaded();
|
std::int64_t cur_payload_dl = m_statistics.last_payload_downloaded();
|
||||||
std::int64_t cur_protocol_dl = m_statistics.last_protocol_downloaded();
|
std::int64_t cur_protocol_dl = m_statistics.last_protocol_downloaded();
|
||||||
#endif
|
#endif
|
||||||
on_receive_impl(sub_transferred);
|
|
||||||
bytes_transferred -= sub_transferred;
|
|
||||||
TORRENT_ASSERT(sub_transferred > 0);
|
TORRENT_ASSERT(sub_transferred > 0);
|
||||||
|
on_receive_impl(std::size_t(sub_transferred));
|
||||||
|
bytes_transferred -= std::size_t(sub_transferred);
|
||||||
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
TORRENT_ASSERT(m_statistics.last_payload_downloaded() - cur_payload_dl >= 0);
|
TORRENT_ASSERT(m_statistics.last_payload_downloaded() - cur_payload_dl >= 0);
|
||||||
|
@ -2692,10 +2692,13 @@ namespace libtorrent
|
||||||
m_state = state_t::read_pe_skey_vc;
|
m_state = state_t::read_pe_skey_vc;
|
||||||
// skey,vc - 28 bytes
|
// skey,vc - 28 bytes
|
||||||
m_sync_hash.reset();
|
m_sync_hash.reset();
|
||||||
int transferred_used = int(bytes_processed - int(recv_buffer.size()) + bytes_transferred);
|
int const transferred_used = bytes_processed
|
||||||
|
- aux::numeric_cast<int>(recv_buffer.size())
|
||||||
|
+ aux::numeric_cast<int>(bytes_transferred);
|
||||||
|
TORRENT_ASSERT(transferred_used >= 0);
|
||||||
TORRENT_ASSERT(transferred_used <= int(bytes_transferred));
|
TORRENT_ASSERT(transferred_used <= int(bytes_transferred));
|
||||||
received_bytes(0, transferred_used);
|
received_bytes(0, transferred_used);
|
||||||
bytes_transferred -= transferred_used;
|
bytes_transferred -= std::size_t(transferred_used);
|
||||||
m_recv_buffer.cut(bytes_processed, 28);
|
m_recv_buffer.cut(bytes_processed, 28);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2827,10 +2830,13 @@ namespace libtorrent
|
||||||
, "sync point (verification constant) found at offset %d"
|
, "sync point (verification constant) found at offset %d"
|
||||||
, m_sync_bytes_read + bytes_processed - 8);
|
, m_sync_bytes_read + bytes_processed - 8);
|
||||||
#endif
|
#endif
|
||||||
int transferred_used = int(bytes_processed - int(recv_buffer.size()) + bytes_transferred);
|
int const transferred_used = bytes_processed
|
||||||
|
- aux::numeric_cast<int>(recv_buffer.size())
|
||||||
|
+ aux::numeric_cast<int>(bytes_transferred);
|
||||||
|
TORRENT_ASSERT(transferred_used >= 0);
|
||||||
TORRENT_ASSERT(transferred_used <= int(bytes_transferred));
|
TORRENT_ASSERT(transferred_used <= int(bytes_transferred));
|
||||||
received_bytes(0, transferred_used);
|
received_bytes(0, transferred_used);
|
||||||
bytes_transferred -= transferred_used;
|
bytes_transferred -= std::size_t(transferred_used);
|
||||||
|
|
||||||
m_recv_buffer.cut(bytes_processed, 4 + 2);
|
m_recv_buffer.cut(bytes_processed, 4 + 2);
|
||||||
|
|
||||||
|
@ -2967,7 +2973,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (!is_outgoing())
|
if (!is_outgoing())
|
||||||
{
|
{
|
||||||
recv_buffer = recv_buffer.subspan(pad_size);
|
recv_buffer = recv_buffer.subspan(aux::numeric_cast<std::size_t>(pad_size));
|
||||||
int len_ia = aux::read_int16(recv_buffer);
|
int len_ia = aux::read_int16(recv_buffer);
|
||||||
|
|
||||||
if (len_ia < 0)
|
if (len_ia < 0)
|
||||||
|
@ -3052,7 +3058,7 @@ namespace libtorrent
|
||||||
if (m_rc4_encrypted)
|
if (m_rc4_encrypted)
|
||||||
{
|
{
|
||||||
span<char> const remaining = m_recv_buffer.mutable_buffer()
|
span<char> const remaining = m_recv_buffer.mutable_buffer()
|
||||||
.subspan(m_recv_buffer.packet_size());
|
.subspan(aux::numeric_cast<std::size_t>(m_recv_buffer.packet_size()));
|
||||||
rc4_decrypt(remaining);
|
rc4_decrypt(remaining);
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
|
@ -3182,9 +3188,9 @@ namespace libtorrent
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
std::string extensions;
|
std::string extensions;
|
||||||
extensions.resize(8 * 8);
|
extensions.resize(8 * 8);
|
||||||
for (int i=0; i < 8; ++i)
|
for (std::size_t i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
for (int j=0; j < 8; ++j)
|
for (std::size_t j = 0; j < 8; ++j)
|
||||||
{
|
{
|
||||||
if (recv_buffer[i] & (0x80 >> j)) extensions[i * 8 + j] = '1';
|
if (recv_buffer[i] & (0x80 >> j)) extensions[i * 8 + j] = '1';
|
||||||
else extensions[i * 8 + j] = '0';
|
else extensions[i * 8 + j] = '0';
|
||||||
|
@ -3283,7 +3289,7 @@ namespace libtorrent
|
||||||
hex_pid[40] = 0;
|
hex_pid[40] = 0;
|
||||||
char ascii_pid[21];
|
char ascii_pid[21];
|
||||||
ascii_pid[20] = 0;
|
ascii_pid[20] = 0;
|
||||||
for (int i = 0; i != 20; ++i)
|
for (std::size_t i = 0; i != 20; ++i)
|
||||||
{
|
{
|
||||||
if (is_print(recv_buffer[i])) ascii_pid[i] = recv_buffer[i];
|
if (is_print(recv_buffer[i])) ascii_pid[i] = recv_buffer[i];
|
||||||
else ascii_pid[i] = '.';
|
else ascii_pid[i] = '.';
|
||||||
|
@ -3420,7 +3426,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(bytes_transferred <= 5);
|
TORRENT_ASSERT(bytes_transferred <= 5);
|
||||||
int used_bytes = int(recv_buffer.size()) > 4 ? int(bytes_transferred) - 1: int(bytes_transferred);
|
int used_bytes = int(recv_buffer.size()) > 4 ? int(bytes_transferred) - 1: int(bytes_transferred);
|
||||||
received_bytes(0, used_bytes);
|
received_bytes(0, used_bytes);
|
||||||
bytes_transferred -= used_bytes;
|
bytes_transferred -= aux::numeric_cast<std::size_t>(used_bytes);
|
||||||
if (int(recv_buffer.size()) < 4) return;
|
if (int(recv_buffer.size()) < 4) return;
|
||||||
|
|
||||||
TORRENT_ASSERT(bytes_transferred <= 1);
|
TORRENT_ASSERT(bytes_transferred <= 1);
|
||||||
|
|
|
@ -583,9 +583,9 @@ namespace libtorrent
|
||||||
int piece_size = pe->storage->files()->piece_size(pe->piece);
|
int piece_size = pe->storage->files()->piece_size(pe->piece);
|
||||||
TORRENT_PIECE_ASSERT(piece_size > 0, pe);
|
TORRENT_PIECE_ASSERT(piece_size > 0, pe);
|
||||||
|
|
||||||
int iov_len = 0;
|
std::size_t iov_len = 0;
|
||||||
// the blocks we're flushing
|
// the blocks we're flushing
|
||||||
int num_flushing = 0;
|
std::size_t num_flushing = 0;
|
||||||
|
|
||||||
#if DEBUG_DISK_THREAD
|
#if DEBUG_DISK_THREAD
|
||||||
DLOG("build_iov: piece: %d [", int(pe->piece));
|
DLOG("build_iov: piece: %d [", int(pe->piece));
|
||||||
|
@ -618,7 +618,7 @@ namespace libtorrent
|
||||||
|
|
||||||
flushing[num_flushing++] = i + block_base_index;
|
flushing[num_flushing++] = i + block_base_index;
|
||||||
iov[iov_len].iov_base = pe->blocks[i].buf;
|
iov[iov_len].iov_base = pe->blocks[i].buf;
|
||||||
iov[iov_len].iov_len = std::min(block_size, size_left);
|
iov[iov_len].iov_len = aux::numeric_cast<std::size_t>(std::min(block_size, size_left));
|
||||||
++iov_len;
|
++iov_len;
|
||||||
pe->blocks[i].pending = true;
|
pe->blocks[i].pending = true;
|
||||||
|
|
||||||
|
@ -627,7 +627,7 @@ namespace libtorrent
|
||||||
DLOG("]\n");
|
DLOG("]\n");
|
||||||
|
|
||||||
TORRENT_PIECE_ASSERT(iov_len == num_flushing, pe);
|
TORRENT_PIECE_ASSERT(iov_len == num_flushing, pe);
|
||||||
return iov_len;
|
return aux::numeric_cast<int>(iov_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
// does the actual writing to disk
|
// does the actual writing to disk
|
||||||
|
@ -656,13 +656,14 @@ namespace libtorrent
|
||||||
|
|
||||||
// issue the actual write operation
|
// issue the actual write operation
|
||||||
auto iov_start = iov;
|
auto iov_start = iov;
|
||||||
int flushing_start = 0;
|
std::size_t flushing_start = 0;
|
||||||
piece_index_t const piece = pe->piece;
|
piece_index_t const piece = pe->piece;
|
||||||
int const blocks_in_piece = pe->blocks_in_piece;
|
int const blocks_in_piece = pe->blocks_in_piece;
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
for (int i = 1; i <= num_blocks; ++i)
|
std::size_t const n_blocks = aux::numeric_cast<std::size_t>(num_blocks);
|
||||||
|
for (std::size_t i = 1; i <= n_blocks; ++i)
|
||||||
{
|
{
|
||||||
if (i < num_blocks && flushing[i] == flushing[i - 1] + 1) continue;
|
if (i < n_blocks && flushing[i] == flushing[i - 1] + 1) continue;
|
||||||
int const ret = pe->storage->writev(
|
int const ret = pe->storage->writev(
|
||||||
iov_start.first(i - flushing_start)
|
iov_start.first(i - flushing_start)
|
||||||
, piece_index_t(static_cast<int>(piece) + flushing[flushing_start] / blocks_in_piece)
|
, piece_index_t(static_cast<int>(piece) + flushing[flushing_start] / blocks_in_piece)
|
||||||
|
@ -919,7 +920,7 @@ namespace libtorrent
|
||||||
DLOG("try_flush_write_blocks: %d\n", num);
|
DLOG("try_flush_write_blocks: %d\n", num);
|
||||||
|
|
||||||
list_iterator<cached_piece_entry> range = m_disk_cache.write_lru_pieces();
|
list_iterator<cached_piece_entry> range = m_disk_cache.write_lru_pieces();
|
||||||
std::vector<std::pair<storage_interface*, piece_index_t>> pieces;
|
aux::vector<std::pair<storage_interface*, piece_index_t>> pieces;
|
||||||
pieces.reserve(m_disk_cache.num_write_lru_pieces());
|
pieces.reserve(m_disk_cache.num_write_lru_pieces());
|
||||||
|
|
||||||
for (list_iterator<cached_piece_entry> p = range; p.get() && num > 0; p.next())
|
for (list_iterator<cached_piece_entry> p = range; p.get() && num > 0; p.next())
|
||||||
|
@ -1283,8 +1284,8 @@ namespace libtorrent
|
||||||
|
|
||||||
// if this is the last piece, adjust the size of the
|
// if this is the last piece, adjust the size of the
|
||||||
// last buffer to match up
|
// last buffer to match up
|
||||||
iov[iov_len - 1].iov_len = std::min(int(piece_size - adjusted_offset)
|
iov[iov_len - 1].iov_len = aux::numeric_cast<std::size_t>(std::min(int(piece_size - adjusted_offset)
|
||||||
- (iov_len - 1) * block_size, block_size);
|
- (iov_len - 1) * block_size, block_size));
|
||||||
TORRENT_ASSERT(iov[iov_len - 1].iov_len > 0);
|
TORRENT_ASSERT(iov[iov_len - 1].iov_len > 0);
|
||||||
|
|
||||||
// at this point, all the buffers are allocated and iov is initialized
|
// at this point, all the buffers are allocated and iov is initialized
|
||||||
|
@ -1665,7 +1666,7 @@ namespace libtorrent
|
||||||
bool exceeded = false;
|
bool exceeded = false;
|
||||||
disk_buffer_holder buffer(*this, m_disk_cache.allocate_buffer(exceeded, o, "receive buffer"));
|
disk_buffer_holder buffer(*this, m_disk_cache.allocate_buffer(exceeded, o, "receive buffer"));
|
||||||
if (!buffer) aux::throw_ex<std::bad_alloc>();
|
if (!buffer) aux::throw_ex<std::bad_alloc>();
|
||||||
std::memcpy(buffer.get(), buf, r.length);
|
std::memcpy(buffer.get(), buf, aux::numeric_cast<std::size_t>(r.length));
|
||||||
|
|
||||||
disk_io_job* j = allocate_job(disk_io_job::write);
|
disk_io_job* j = allocate_job(disk_io_job::write);
|
||||||
j->storage = m_torrents[storage]->shared_from_this();
|
j->storage = m_torrents[storage]->shared_from_this();
|
||||||
|
@ -2154,7 +2155,7 @@ namespace libtorrent
|
||||||
|
|
||||||
time_point const start_time = clock_type::now();
|
time_point const start_time = clock_type::now();
|
||||||
|
|
||||||
iov.iov_len = std::min(block_size, piece_size - offset);
|
iov.iov_len = aux::numeric_cast<std::size_t>(std::min(block_size, piece_size - offset));
|
||||||
ret = j->storage->readv(iov, j->piece
|
ret = j->storage->readv(iov, j->piece
|
||||||
, offset, file_flags, j->error);
|
, offset, file_flags, j->error);
|
||||||
if (ret < 0) break;
|
if (ret < 0) break;
|
||||||
|
@ -2307,7 +2308,7 @@ namespace libtorrent
|
||||||
for (int i = offset / block_size; i < blocks_in_piece; ++i)
|
for (int i = offset / block_size; i < blocks_in_piece; ++i)
|
||||||
{
|
{
|
||||||
iovec_t iov;
|
iovec_t iov;
|
||||||
iov.iov_len = std::min(block_size, piece_size - offset);
|
iov.iov_len = aux::numeric_cast<std::size_t>(std::min(block_size, piece_size - offset));
|
||||||
|
|
||||||
if (next_locked_block < num_locked_blocks
|
if (next_locked_block < num_locked_blocks
|
||||||
&& locked_blocks[next_locked_block] == i)
|
&& locked_blocks[next_locked_block] == i)
|
||||||
|
@ -2576,9 +2577,9 @@ namespace libtorrent
|
||||||
? cached_piece_info::volatile_read_cache
|
? cached_piece_info::volatile_read_cache
|
||||||
: cached_piece_info::read_cache;
|
: cached_piece_info::read_cache;
|
||||||
int blocks_in_piece = i->blocks_in_piece;
|
int blocks_in_piece = i->blocks_in_piece;
|
||||||
info.blocks.resize(blocks_in_piece);
|
info.blocks.resize(aux::numeric_cast<std::size_t>(blocks_in_piece));
|
||||||
for (int b = 0; b < blocks_in_piece; ++b)
|
for (int b = 0; b < blocks_in_piece; ++b)
|
||||||
info.blocks[b] = i->blocks[b].buf != nullptr;
|
info.blocks[std::size_t(b)] = i->blocks[b].buf != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
@ -2663,7 +2664,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
std::shared_ptr<storage_interface> storage = m_torrents[st];
|
std::shared_ptr<storage_interface> storage = m_torrents[st];
|
||||||
TORRENT_ASSERT(storage);
|
TORRENT_ASSERT(storage);
|
||||||
ret->pieces.reserve(storage->num_pieces());
|
ret->pieces.reserve(aux::numeric_cast<std::size_t>(storage->num_pieces()));
|
||||||
|
|
||||||
for (auto pe : storage->cached_pieces())
|
for (auto pe : storage->cached_pieces())
|
||||||
{
|
{
|
||||||
|
@ -2678,7 +2679,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret->pieces.reserve(m_disk_cache.num_pieces());
|
ret->pieces.reserve(aux::numeric_cast<std::size_t>(m_disk_cache.num_pieces()));
|
||||||
|
|
||||||
auto range = m_disk_cache.all_pieces();
|
auto range = m_disk_cache.all_pieces();
|
||||||
for (auto i = range.first; i != range.second; ++i)
|
for (auto i = range.first; i != range.second; ++i)
|
||||||
|
|
Loading…
Reference in New Issue