forked from premiere/premiere-libtorrent
enable /W4 warnings for msvc
This commit is contained in:
parent
63df1a26b6
commit
22b596945e
12
Jamfile
12
Jamfile
|
@ -265,19 +265,11 @@ rule warnings ( properties * )
|
||||||
|
|
||||||
if <toolset>msvc in $(properties)
|
if <toolset>msvc in $(properties)
|
||||||
{
|
{
|
||||||
# disable warning C4503: decorated name length exceeded, name was truncated
|
# on msvc this resolves to /W4
|
||||||
result += <cflags>/wd4503 ;
|
result += <warnings>all ;
|
||||||
|
|
||||||
# enable these warnings again, once the other ones are dealt with
|
# enable these warnings again, once the other ones are dealt with
|
||||||
|
|
||||||
# disable warning C4389: signed/unsigned mismatch
|
|
||||||
result += <cflags>/wd4389 ;
|
|
||||||
result += <cflags>/wd4245 ;
|
|
||||||
result += <cflags>/wd4018 ;
|
|
||||||
# disable warning C4244: 'argument' : conversion from 'int' to 'unsigned short', possible loss of data
|
|
||||||
result += <cflags>/wd4244 ;
|
|
||||||
# disable warning C4512: assignment operator could not be generated
|
|
||||||
result += <cflags>/wd4512 ;
|
|
||||||
# disable warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
|
# disable warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
|
||||||
result += <cflags>/wd4251 ;
|
result += <cflags>/wd4251 ;
|
||||||
# disable warning C4275: non DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'
|
# disable warning C4275: non DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'
|
||||||
|
|
|
@ -1978,7 +1978,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
dht_mutable_item_alert(aux::stack_allocator& alloc
|
dht_mutable_item_alert(aux::stack_allocator& alloc
|
||||||
, std::array<char, 32> k, std::array<char, 64> sig
|
, std::array<char, 32> k, std::array<char, 64> sig
|
||||||
, std::uint64_t sequence, string_view s, entry const& i, bool a);
|
, std::int64_t sequence, string_view s, entry const& i, bool a);
|
||||||
|
|
||||||
TORRENT_DEFINE_ALERT_PRIO(dht_mutable_item_alert, 75)
|
TORRENT_DEFINE_ALERT_PRIO(dht_mutable_item_alert, 75)
|
||||||
|
|
||||||
|
@ -1996,7 +1996,7 @@ namespace libtorrent
|
||||||
std::array<char, 64> const signature;
|
std::array<char, 64> const signature;
|
||||||
|
|
||||||
// the sequence number of this item
|
// the sequence number of this item
|
||||||
std::uint64_t const seq;
|
std::int64_t const seq;
|
||||||
|
|
||||||
// the salt, if any, used to lookup and store this item. If no
|
// the salt, if any, used to lookup and store this item. If no
|
||||||
// salt was used, this is an empty string
|
// salt was used, this is an empty string
|
||||||
|
@ -2018,7 +2018,7 @@ namespace libtorrent
|
||||||
dht_put_alert(aux::stack_allocator& alloc, std::array<char, 32> key
|
dht_put_alert(aux::stack_allocator& alloc, std::array<char, 32> key
|
||||||
, std::array<char, 64> sig
|
, std::array<char, 64> sig
|
||||||
, std::string s
|
, std::string s
|
||||||
, std::uint64_t sequence_number
|
, std::int64_t sequence_number
|
||||||
, int n);
|
, int n);
|
||||||
|
|
||||||
TORRENT_DEFINE_ALERT(dht_put_alert, 76)
|
TORRENT_DEFINE_ALERT(dht_put_alert, 76)
|
||||||
|
@ -2035,7 +2035,7 @@ namespace libtorrent
|
||||||
std::array<char, 32> const public_key;
|
std::array<char, 32> const public_key;
|
||||||
std::array<char, 64> const signature;
|
std::array<char, 64> const signature;
|
||||||
std::string const salt;
|
std::string const salt;
|
||||||
std::uint64_t const seq;
|
std::int64_t const seq;
|
||||||
|
|
||||||
// DHT put operation usually writes item to k nodes, maybe the node
|
// DHT put operation usually writes item to k nodes, maybe the node
|
||||||
// is stale so no response, or the node doesn't support 'put', or the
|
// is stale so no response, or the node doesn't support 'put', or the
|
||||||
|
|
|
@ -41,4 +41,3 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -93,4 +93,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#pragma warning(disable : 4005)
|
#pragma warning(disable : 4005)
|
||||||
// expression before comma has no effect; expected expression with side-effect
|
// expression before comma has no effect; expected expression with side-effect
|
||||||
#pragma warning(disable : 4548)
|
#pragma warning(disable : 4548)
|
||||||
|
// 'conversion' conversion from 'type1' to 'type2', possible loss of data
|
||||||
|
#pragma warning(disable : 4244)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -147,8 +147,8 @@ enum utp_extensions_t
|
||||||
|
|
||||||
struct utp_header
|
struct utp_header
|
||||||
{
|
{
|
||||||
unsigned char type_ver;
|
std::uint8_t type_ver;
|
||||||
unsigned char extension;
|
std::uint8_t extension;
|
||||||
be_uint16 connection_id;
|
be_uint16 connection_id;
|
||||||
be_uint32 timestamp_microseconds;
|
be_uint32 timestamp_microseconds;
|
||||||
be_uint32 timestamp_difference_microseconds;
|
be_uint32 timestamp_difference_microseconds;
|
||||||
|
|
|
@ -1564,7 +1564,7 @@ namespace libtorrent {
|
||||||
dht_mutable_item_alert::dht_mutable_item_alert(aux::stack_allocator&
|
dht_mutable_item_alert::dht_mutable_item_alert(aux::stack_allocator&
|
||||||
, std::array<char, 32> k
|
, std::array<char, 32> k
|
||||||
, std::array<char, 64> sig
|
, std::array<char, 64> sig
|
||||||
, std::uint64_t sequence
|
, std::int64_t sequence
|
||||||
, string_view s
|
, string_view s
|
||||||
, entry const& i
|
, entry const& i
|
||||||
, bool a)
|
, bool a)
|
||||||
|
@ -1596,7 +1596,7 @@ namespace libtorrent {
|
||||||
, std::array<char, 32> key
|
, std::array<char, 32> key
|
||||||
, std::array<char, 64> sig
|
, std::array<char, 64> sig
|
||||||
, std::string s
|
, std::string s
|
||||||
, std::uint64_t sequence_number
|
, std::int64_t sequence_number
|
||||||
, int n)
|
, int n)
|
||||||
: target(nullptr)
|
: target(nullptr)
|
||||||
, public_key(key)
|
, public_key(key)
|
||||||
|
@ -1969,15 +1969,14 @@ namespace libtorrent {
|
||||||
, m_num_peers(int(peers.size()))
|
, m_num_peers(int(peers.size()))
|
||||||
{
|
{
|
||||||
std::size_t total_size = peers.size(); // num bytes for sizes
|
std::size_t total_size = peers.size(); // num bytes for sizes
|
||||||
for (int i = 0; i < m_num_peers; i++) {
|
for (auto const& endp : peers) {
|
||||||
total_size += peers[i].size();
|
total_size += endp.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_peers_idx = alloc.allocate(int(total_size));
|
m_peers_idx = alloc.allocate(int(total_size));
|
||||||
|
|
||||||
char *ptr = alloc.ptr(m_peers_idx);
|
char *ptr = alloc.ptr(m_peers_idx);
|
||||||
for (int i = 0; i < m_num_peers; i++) {
|
for (auto const& endp : peers) {
|
||||||
tcp::endpoint const& endp = peers[i];
|
|
||||||
std::size_t const size = endp.size();
|
std::size_t const size = endp.size();
|
||||||
TORRENT_ASSERT(size < 0x100);
|
TORRENT_ASSERT(size < 0x100);
|
||||||
detail::write_uint8(size, ptr);
|
detail::write_uint8(size, ptr);
|
||||||
|
@ -2083,7 +2082,7 @@ namespace libtorrent {
|
||||||
std::vector<piece_block> ret(m_num_blocks);
|
std::vector<piece_block> ret(m_num_blocks);
|
||||||
|
|
||||||
char const* start = m_alloc.get().ptr(m_array_idx);
|
char const* start = m_alloc.get().ptr(m_array_idx);
|
||||||
std::memcpy(&ret[0], start, m_num_blocks * sizeof(piece_block));
|
std::memcpy(ret.data(), start, m_num_blocks * sizeof(piece_block));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2124,11 +2123,11 @@ namespace libtorrent {
|
||||||
|
|
||||||
std::vector<piece_block> b = blocks();
|
std::vector<piece_block> b = blocks();
|
||||||
|
|
||||||
for (int i = 0; i < int(b.size()); ++i)
|
for (auto const& p : b)
|
||||||
{
|
{
|
||||||
char buf[50];
|
char buf[50];
|
||||||
std::snprintf(buf, sizeof(buf), "(%d,%d) "
|
std::snprintf(buf, sizeof(buf), "(%d,%d) "
|
||||||
, b[i].piece_index, b[i].block_index);
|
, p.piece_index, p.block_index);
|
||||||
ret += buf;
|
ret += buf;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -244,7 +244,7 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth
|
||||||
if (has_line)
|
if (has_line)
|
||||||
{
|
{
|
||||||
ret = std::snprintf(out, len, " %s:%d"
|
ret = std::snprintf(out, len, " %s:%d"
|
||||||
, line.FileName, line.LineNumber);
|
, line.FileName, int(line.LineNumber));
|
||||||
out += ret; len -= ret; if (len <= 0) break;
|
out += ret; len -= ret; if (len <= 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -554,7 +554,7 @@ void block_cache::try_evict_one_volatile()
|
||||||
// some blocks are pinned in this piece, skip it
|
// some blocks are pinned in this piece, skip it
|
||||||
if (pe->pinned > 0) continue;
|
if (pe->pinned > 0) continue;
|
||||||
|
|
||||||
TORRENT_ALLOCA(to_delete, char*, pe->blocks_in_piece);
|
TORRENT_ALLOCA(to_delete, char*, std::size_t(pe->blocks_in_piece));
|
||||||
int num_to_delete = 0;
|
int num_to_delete = 0;
|
||||||
|
|
||||||
// go through the blocks and evict the ones that are not dirty and not
|
// go through the blocks and evict the ones that are not dirty and not
|
||||||
|
@ -861,7 +861,7 @@ bool block_cache::evict_piece(cached_piece_entry* pe, tailqueue<disk_io_job>& jo
|
||||||
|
|
||||||
TORRENT_PIECE_ASSERT(pe->in_use, pe);
|
TORRENT_PIECE_ASSERT(pe->in_use, pe);
|
||||||
|
|
||||||
TORRENT_ALLOCA(to_delete, char*, pe->blocks_in_piece);
|
TORRENT_ALLOCA(to_delete, char*, std::size_t(pe->blocks_in_piece));
|
||||||
int num_to_delete = 0;
|
int num_to_delete = 0;
|
||||||
for (int i = 0; i < pe->blocks_in_piece; ++i)
|
for (int i = 0; i < pe->blocks_in_piece; ++i)
|
||||||
{
|
{
|
||||||
|
@ -1347,7 +1347,7 @@ bool block_cache::inc_block_refcount(cached_piece_entry* pe, int block, int reas
|
||||||
case ref_reading: ++pe->blocks[block].reading_count; break;
|
case ref_reading: ++pe->blocks[block].reading_count; break;
|
||||||
case ref_flushing: ++pe->blocks[block].flushing_count; break;
|
case ref_flushing: ++pe->blocks[block].flushing_count; break;
|
||||||
};
|
};
|
||||||
TORRENT_ASSERT(pe->blocks[block].refcount >= pe->blocks[block].hashing_count
|
TORRENT_ASSERT(int(pe->blocks[block].refcount) >= pe->blocks[block].hashing_count
|
||||||
+ pe->blocks[block].reading_count + pe->blocks[block].flushing_count);
|
+ pe->blocks[block].reading_count + pe->blocks[block].flushing_count);
|
||||||
#else
|
#else
|
||||||
TORRENT_UNUSED(reason);
|
TORRENT_UNUSED(reason);
|
||||||
|
@ -1380,7 +1380,7 @@ void block_cache::dec_block_refcount(cached_piece_entry* pe, int block, int reas
|
||||||
case ref_reading: --pe->blocks[block].reading_count; break;
|
case ref_reading: --pe->blocks[block].reading_count; break;
|
||||||
case ref_flushing: --pe->blocks[block].flushing_count; break;
|
case ref_flushing: --pe->blocks[block].flushing_count; break;
|
||||||
};
|
};
|
||||||
TORRENT_PIECE_ASSERT(pe->blocks[block].refcount >= pe->blocks[block].hashing_count
|
TORRENT_PIECE_ASSERT(int(pe->blocks[block].refcount) >= pe->blocks[block].hashing_count
|
||||||
+ pe->blocks[block].reading_count + pe->blocks[block].flushing_count, pe);
|
+ pe->blocks[block].reading_count + pe->blocks[block].flushing_count, pe);
|
||||||
#else
|
#else
|
||||||
TORRENT_UNUSED(reason);
|
TORRENT_UNUSED(reason);
|
||||||
|
@ -1393,7 +1393,7 @@ void block_cache::abort_dirty(cached_piece_entry* pe)
|
||||||
|
|
||||||
TORRENT_PIECE_ASSERT(pe->in_use, pe);
|
TORRENT_PIECE_ASSERT(pe->in_use, pe);
|
||||||
|
|
||||||
TORRENT_ALLOCA(to_delete, char*, pe->blocks_in_piece);
|
TORRENT_ALLOCA(to_delete, char*, std::size_t(pe->blocks_in_piece));
|
||||||
int num_to_delete = 0;
|
int num_to_delete = 0;
|
||||||
for (int i = 0; i < pe->blocks_in_piece; ++i)
|
for (int i = 0; i < pe->blocks_in_piece; ++i)
|
||||||
{
|
{
|
||||||
|
@ -1432,7 +1432,7 @@ void block_cache::free_piece(cached_piece_entry* pe)
|
||||||
|
|
||||||
// build a vector of all the buffers we need to free
|
// build a vector of all the buffers we need to free
|
||||||
// and free them all in one go
|
// and free them all in one go
|
||||||
TORRENT_ALLOCA(to_delete, char*, pe->blocks_in_piece);
|
TORRENT_ALLOCA(to_delete, char*, std::size_t(pe->blocks_in_piece));
|
||||||
int num_to_delete = 0;
|
int num_to_delete = 0;
|
||||||
int removed_clean = 0;
|
int removed_clean = 0;
|
||||||
for (int i = 0; i < pe->blocks_in_piece; ++i)
|
for (int i = 0; i < pe->blocks_in_piece; ++i)
|
||||||
|
@ -1664,7 +1664,7 @@ void block_cache::check_invariant() const
|
||||||
if (p.blocks[k].pending) ++num_pending;
|
if (p.blocks[k].pending) ++num_pending;
|
||||||
if (p.blocks[k].refcount > 0) ++num_pinned;
|
if (p.blocks[k].refcount > 0) ++num_pinned;
|
||||||
|
|
||||||
TORRENT_PIECE_ASSERT(p.blocks[k].refcount >=
|
TORRENT_PIECE_ASSERT(int(p.blocks[k].refcount) >=
|
||||||
p.blocks[k].hashing_count
|
p.blocks[k].hashing_count
|
||||||
+ p.blocks[k].reading_count
|
+ p.blocks[k].reading_count
|
||||||
+ p.blocks[k].flushing_count, &p);
|
+ p.blocks[k].flushing_count, &p);
|
||||||
|
@ -1846,7 +1846,7 @@ cached_piece_entry* block_cache::find_piece(storage_interface* st, int piece)
|
||||||
for (tailqueue_iterator<const disk_io_job> j = i->jobs.iterate(); j.get(); j.next())
|
for (tailqueue_iterator<const disk_io_job> j = i->jobs.iterate(); j.get(); j.next())
|
||||||
{
|
{
|
||||||
disk_io_job const* job = static_cast<disk_io_job const*>(j.get());
|
disk_io_job const* job = static_cast<disk_io_job const*>(j.get());
|
||||||
TORRENT_PIECE_ASSERT(job->piece == piece, &*i);
|
TORRENT_PIECE_ASSERT(int(job->piece) == piece, &*i);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,7 @@ namespace libtorrent
|
||||||
// round offset up to include the last block, which might
|
// round offset up to include the last block, which might
|
||||||
// have an odd size
|
// have an odd size
|
||||||
int const block_size = m_disk_cache.block_size();
|
int const block_size = m_disk_cache.block_size();
|
||||||
int end = p->hashing_done ? p->blocks_in_piece : (p->hash->offset + block_size - 1) / block_size;
|
int end = p->hashing_done ? int(p->blocks_in_piece) : (p->hash->offset + block_size - 1) / block_size;
|
||||||
|
|
||||||
// nothing has been hashed yet, don't flush anything
|
// nothing has been hashed yet, don't flush anything
|
||||||
if (end == 0 && !p->need_readback) return 0;
|
if (end == 0 && !p->need_readback) return 0;
|
||||||
|
@ -344,7 +344,7 @@ namespace libtorrent
|
||||||
// if the cache line size is larger than a whole piece, hold
|
// if the cache line size is larger than a whole piece, hold
|
||||||
// off flushing this piece until enough adjacent pieces are
|
// off flushing this piece until enough adjacent pieces are
|
||||||
// full as well.
|
// full as well.
|
||||||
int cont_pieces = cont_block / p->blocks_in_piece;
|
int cont_pieces = int(cont_block / p->blocks_in_piece);
|
||||||
|
|
||||||
// at this point, we may enforce flushing full cache stripes even when
|
// at this point, we may enforce flushing full cache stripes even when
|
||||||
// they span multiple pieces. This won't necessarily work in the general
|
// they span multiple pieces. This won't necessarily work in the general
|
||||||
|
@ -361,7 +361,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
// piece range
|
// piece range
|
||||||
int range_start = (p->piece / cont_pieces) * cont_pieces;
|
int range_start = int((p->piece / cont_pieces) * cont_pieces);
|
||||||
int range_end = (std::min)(range_start + cont_pieces, p->storage->files()->num_pieces());
|
int range_end = (std::min)(range_start + cont_pieces, p->storage->files()->num_pieces());
|
||||||
|
|
||||||
// look through all the pieces in this range to see if
|
// look through all the pieces in this range to see if
|
||||||
|
@ -442,7 +442,7 @@ namespace libtorrent
|
||||||
// we keep the indices in the iovec_offset array
|
// we keep the indices in the iovec_offset array
|
||||||
|
|
||||||
cont_pieces = range_end - range_start;
|
cont_pieces = range_end - range_start;
|
||||||
int blocks_to_flush = p->blocks_in_piece * cont_pieces;
|
int blocks_to_flush = int(p->blocks_in_piece * cont_pieces);
|
||||||
TORRENT_ALLOCA(iov, file::iovec_t, blocks_to_flush);
|
TORRENT_ALLOCA(iov, file::iovec_t, blocks_to_flush);
|
||||||
TORRENT_ALLOCA(flushing, int, blocks_to_flush);
|
TORRENT_ALLOCA(flushing, int, blocks_to_flush);
|
||||||
// this is the offset into iov and flushing for each piece
|
// this is the offset into iov and flushing for each piece
|
||||||
|
@ -463,7 +463,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
refcount_pieces[i] = 0;
|
refcount_pieces[i] = 0;
|
||||||
iovec_offset[i] = iov_len;
|
iovec_offset[i] = iov_len;
|
||||||
block_start += p->blocks_in_piece;
|
block_start += int(p->blocks_in_piece);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ namespace libtorrent
|
||||||
iov_len += build_iovec(pe, 0, p->blocks_in_piece
|
iov_len += build_iovec(pe, 0, p->blocks_in_piece
|
||||||
, iov.subspan(iov_len), flushing.subspan(iov_len), block_start);
|
, iov.subspan(iov_len), flushing.subspan(iov_len), block_start);
|
||||||
|
|
||||||
block_start += p->blocks_in_piece;
|
block_start += int(p->blocks_in_piece);
|
||||||
}
|
}
|
||||||
iovec_offset[cont_pieces] = iov_len;
|
iovec_offset[cont_pieces] = iov_len;
|
||||||
|
|
||||||
|
@ -514,7 +514,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
DLOG("iovec_flushed: piece %d gone!\n", range_start + i);
|
DLOG("iovec_flushed: piece %d gone!\n", range_start + i);
|
||||||
TORRENT_PIECE_ASSERT(refcount_pieces[i] == 0, pe);
|
TORRENT_PIECE_ASSERT(refcount_pieces[i] == 0, pe);
|
||||||
block_start += p->blocks_in_piece;
|
block_start += int(p->blocks_in_piece);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (refcount_pieces[i])
|
if (refcount_pieces[i])
|
||||||
|
@ -526,7 +526,7 @@ namespace libtorrent
|
||||||
const int block_diff = iovec_offset[i+1] - iovec_offset[i];
|
const int block_diff = iovec_offset[i+1] - iovec_offset[i];
|
||||||
iovec_flushed(pe, flushing.subspan(iovec_offset[i]).data(), block_diff
|
iovec_flushed(pe, flushing.subspan(iovec_offset[i]).data(), block_diff
|
||||||
, block_start, error, completed_jobs);
|
, block_start, error, completed_jobs);
|
||||||
block_start += p->blocks_in_piece;
|
block_start += int(p->blocks_in_piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the cache is under high pressure, we need to evict
|
// if the cache is under high pressure, we need to evict
|
||||||
|
@ -740,8 +740,8 @@ namespace libtorrent
|
||||||
TORRENT_PIECE_ASSERT(start >= 0, pe);
|
TORRENT_PIECE_ASSERT(start >= 0, pe);
|
||||||
TORRENT_PIECE_ASSERT(start < end, pe);
|
TORRENT_PIECE_ASSERT(start < end, pe);
|
||||||
|
|
||||||
TORRENT_ALLOCA(iov, file::iovec_t, pe->blocks_in_piece);
|
TORRENT_ALLOCA(iov, file::iovec_t, std::size_t(pe->blocks_in_piece));
|
||||||
TORRENT_ALLOCA(flushing, int, pe->blocks_in_piece);
|
TORRENT_ALLOCA(flushing, int, std::size_t(pe->blocks_in_piece));
|
||||||
int iov_len = build_iovec(pe, start, end, iov, flushing, 0);
|
int iov_len = build_iovec(pe, start, end, iov, flushing, 0);
|
||||||
if (iov_len == 0) return 0;
|
if (iov_len == 0) return 0;
|
||||||
|
|
||||||
|
@ -2191,9 +2191,9 @@ namespace libtorrent
|
||||||
|
|
||||||
if (pe == nullptr)
|
if (pe == nullptr)
|
||||||
{
|
{
|
||||||
std::uint16_t const cache_state = (j->flags & disk_interface::volatile_read)
|
std::uint16_t const cache_state = std::uint16_t((j->flags & disk_interface::volatile_read)
|
||||||
? cached_piece_entry::volatile_read_lru
|
? cached_piece_entry::volatile_read_lru
|
||||||
: cached_piece_entry::read_lru1;
|
: cached_piece_entry::read_lru1);
|
||||||
pe = m_disk_cache.allocate_piece(j, cache_state);
|
pe = m_disk_cache.allocate_piece(j, cache_state);
|
||||||
}
|
}
|
||||||
if (pe == nullptr)
|
if (pe == nullptr)
|
||||||
|
@ -3389,7 +3389,7 @@ namespace libtorrent
|
||||||
j->call_callback();
|
j->call_callback();
|
||||||
to_delete[cnt++] = j;
|
to_delete[cnt++] = j;
|
||||||
j = next;
|
j = next;
|
||||||
if (cnt == to_delete.size())
|
if (cnt == int(to_delete.size()))
|
||||||
{
|
{
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
free_jobs(to_delete.data(), int(to_delete.size()));
|
free_jobs(to_delete.data(), int(to_delete.size()));
|
||||||
|
|
|
@ -1009,7 +1009,7 @@ namespace libtorrent
|
||||||
*write_cur++ = *read_cur++;
|
*write_cur++ = *read_cur++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int element_len = read_cur - last_read_sep;
|
int element_len = int(read_cur - last_read_sep);
|
||||||
if (element_len == 1 && std::memcmp(last_read_sep, ".", 1) == 0)
|
if (element_len == 1 && std::memcmp(last_read_sep, ".", 1) == 0)
|
||||||
{
|
{
|
||||||
--write_cur;
|
--write_cur;
|
||||||
|
@ -1305,7 +1305,7 @@ namespace libtorrent
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ret = -1;
|
DWORD ret;
|
||||||
if (GetOverlappedResult(file, &ol, &ret, false) == 0)
|
if (GetOverlappedResult(file, &ol, &ret, false) == 0)
|
||||||
{
|
{
|
||||||
DWORD last_error = GetLastError();
|
DWORD last_error = GetLastError();
|
||||||
|
@ -1854,7 +1854,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
||||||
#if TORRENT_USE_PREADV
|
#if TORRENT_USE_PREADV
|
||||||
TORRENT_UNUSED(flags);
|
TORRENT_UNUSED(flags);
|
||||||
|
|
||||||
int ret = iov(&::preadv, native_handle(), file_offset, bufs, ec);
|
std::int64_t ret = iov(&::preadv, native_handle(), file_offset, bufs, ec);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// there's no point in coalescing single buffer writes
|
// there's no point in coalescing single buffer writes
|
||||||
|
@ -1910,7 +1910,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
||||||
#if TORRENT_USE_PREADV
|
#if TORRENT_USE_PREADV
|
||||||
TORRENT_UNUSED(flags);
|
TORRENT_UNUSED(flags);
|
||||||
|
|
||||||
int ret = iov(&::pwritev, native_handle(), file_offset, bufs, ec);
|
std::int64_t ret = iov(&::pwritev, native_handle(), file_offset, bufs, ec);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// there's no point in coalescing single buffer writes
|
// there's no point in coalescing single buffer writes
|
||||||
|
|
|
@ -348,7 +348,7 @@ restart_response:
|
||||||
incoming -= int(payload);
|
incoming -= int(payload);
|
||||||
}
|
}
|
||||||
auto const buf = span<char const>(recv_buffer)
|
auto const buf = span<char const>(recv_buffer)
|
||||||
.subspan(m_cur_chunk_end);
|
.subspan(std::size_t(m_cur_chunk_end));
|
||||||
std::int64_t chunk_size;
|
std::int64_t chunk_size;
|
||||||
int header_size;
|
int header_size;
|
||||||
if (parse_chunk_header(buf, &chunk_size, &header_size))
|
if (parse_chunk_header(buf, &chunk_size, &header_size))
|
||||||
|
@ -525,7 +525,7 @@ restart_response:
|
||||||
? (std::min)(m_chunked_ranges.back().second - m_body_start_pos, received)
|
? (std::min)(m_chunked_ranges.back().second - m_body_start_pos, received)
|
||||||
: m_content_length < 0 ? received : (std::min)(m_content_length, received);
|
: m_content_length < 0 ? received : (std::min)(m_content_length, received);
|
||||||
|
|
||||||
return m_recv_buffer.subspan(m_body_start_pos, body_length);
|
return m_recv_buffer.subspan(m_body_start_pos, std::size_t(body_length));
|
||||||
}
|
}
|
||||||
|
|
||||||
void http_parser::reset()
|
void http_parser::reset()
|
||||||
|
|
|
@ -359,7 +359,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
int header_size = 0;
|
int header_size = 0;
|
||||||
std::int64_t chunk_size = 0;
|
std::int64_t chunk_size = 0;
|
||||||
span<char const> chunk_start(recv_buffer.begin() + m_chunk_pos, int(recv_buffer.size()) - m_chunk_pos);
|
span<char const> chunk_start(recv_buffer.begin() + m_chunk_pos, std::size_t(int(recv_buffer.size()) - m_chunk_pos));
|
||||||
TORRENT_ASSERT(chunk_start[0] == '\r'
|
TORRENT_ASSERT(chunk_start[0] == '\r'
|
||||||
|| aux::is_hex(chunk_start[0]));
|
|| aux::is_hex(chunk_start[0]));
|
||||||
bool ret = m_parser.parse_chunk_header(chunk_start, &chunk_size, &header_size);
|
bool ret = m_parser.parse_chunk_header(chunk_start, &chunk_size, &header_size);
|
||||||
|
|
|
@ -526,7 +526,7 @@ namespace
|
||||||
return e.added + minutes(int(announce_interval * 3 / 2)) < now;
|
return e.added + minutes(int(announce_interval * 3 / 2)) < now;
|
||||||
});
|
});
|
||||||
|
|
||||||
m_counters.peers -= std::distance(new_end, peers.end());
|
m_counters.peers -= std::int32_t(std::distance(new_end, peers.end()));
|
||||||
peers.erase(new_end, peers.end());
|
peers.erase(new_end, peers.end());
|
||||||
// if we're using less than 1/4 of the capacity free up the excess
|
// if we're using less than 1/4 of the capacity free up the excess
|
||||||
if (!peers.empty() && peers.capacity() / peers.size() >= 4u)
|
if (!peers.empty() && peers.capacity() / peers.size() >= 4u)
|
||||||
|
|
|
@ -594,8 +594,8 @@ namespace libtorrent { namespace dht
|
||||||
m_last_tick = now;
|
m_last_tick = now;
|
||||||
|
|
||||||
// add any new quota we've accrued since last time
|
// add any new quota we've accrued since last time
|
||||||
m_send_quota += std::uint64_t(m_settings.upload_rate_limit)
|
m_send_quota += int(std::uint64_t(m_settings.upload_rate_limit)
|
||||||
* total_microseconds(delta) / 1000000;
|
* total_microseconds(delta) / 1000000);
|
||||||
|
|
||||||
// allow 3 seconds worth of burst
|
// allow 3 seconds worth of burst
|
||||||
if (m_send_quota > 3 * m_settings.upload_rate_limit)
|
if (m_send_quota > 3 * m_settings.upload_rate_limit)
|
||||||
|
|
|
@ -252,7 +252,7 @@ namespace libtorrent
|
||||||
lazy_entry* lazy_entry::dict_append(char const* name)
|
lazy_entry* lazy_entry::dict_append(char const* name)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m_type == dict_t);
|
TORRENT_ASSERT(m_type == dict_t);
|
||||||
TORRENT_ASSERT(m_size <= this->capacity());
|
TORRENT_ASSERT(int(m_size) <= this->capacity());
|
||||||
if (m_data.dict == nullptr)
|
if (m_data.dict == nullptr)
|
||||||
{
|
{
|
||||||
int capacity = lazy_entry_dict_init;
|
int capacity = lazy_entry_dict_init;
|
||||||
|
@ -260,7 +260,7 @@ namespace libtorrent
|
||||||
if (m_data.dict == nullptr) return nullptr;
|
if (m_data.dict == nullptr) return nullptr;
|
||||||
m_data.dict[0].val.m_len = capacity;
|
m_data.dict[0].val.m_len = capacity;
|
||||||
}
|
}
|
||||||
else if (m_size == this->capacity())
|
else if (int(m_size) == this->capacity())
|
||||||
{
|
{
|
||||||
int capacity = this->capacity() * lazy_entry_grow_factor / 100;
|
int capacity = this->capacity() * lazy_entry_grow_factor / 100;
|
||||||
lazy_dict_entry* tmp = new (std::nothrow) lazy_dict_entry[capacity+1];
|
lazy_dict_entry* tmp = new (std::nothrow) lazy_dict_entry[capacity+1];
|
||||||
|
@ -273,7 +273,7 @@ namespace libtorrent
|
||||||
m_data.dict[0].val.m_len = capacity;
|
m_data.dict[0].val.m_len = capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
TORRENT_ASSERT(m_size < this->capacity());
|
TORRENT_ASSERT(int(m_size) < this->capacity());
|
||||||
lazy_dict_entry& ret = m_data.dict[1+m_size++];
|
lazy_dict_entry& ret = m_data.dict[1+m_size++];
|
||||||
ret.name = name;
|
ret.name = name;
|
||||||
return &ret.val;
|
return &ret.val;
|
||||||
|
@ -421,7 +421,7 @@ namespace libtorrent
|
||||||
lazy_entry* lazy_entry::list_append()
|
lazy_entry* lazy_entry::list_append()
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m_type == list_t);
|
TORRENT_ASSERT(m_type == list_t);
|
||||||
TORRENT_ASSERT(m_size <= this->capacity());
|
TORRENT_ASSERT(int(m_size) <= this->capacity());
|
||||||
if (m_data.start == nullptr)
|
if (m_data.start == nullptr)
|
||||||
{
|
{
|
||||||
int capacity = lazy_entry_list_init;
|
int capacity = lazy_entry_list_init;
|
||||||
|
@ -429,7 +429,7 @@ namespace libtorrent
|
||||||
if (m_data.list == nullptr) return nullptr;
|
if (m_data.list == nullptr) return nullptr;
|
||||||
m_data.list[0].m_len = capacity;
|
m_data.list[0].m_len = capacity;
|
||||||
}
|
}
|
||||||
else if (m_size == this->capacity())
|
else if (int(m_size) == this->capacity())
|
||||||
{
|
{
|
||||||
int capacity = this->capacity() * lazy_entry_grow_factor / 100;
|
int capacity = this->capacity() * lazy_entry_grow_factor / 100;
|
||||||
lazy_entry* tmp = new (std::nothrow) lazy_entry[capacity+1];
|
lazy_entry* tmp = new (std::nothrow) lazy_entry[capacity+1];
|
||||||
|
@ -442,7 +442,7 @@ namespace libtorrent
|
||||||
m_data.list[0].m_len = capacity;
|
m_data.list[0].m_len = capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
TORRENT_ASSERT(m_size < this->capacity());
|
TORRENT_ASSERT(int(m_size) < this->capacity());
|
||||||
return &m_data.list[1 + (m_size++)];
|
return &m_data.list[1 + (m_size++)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -327,7 +327,7 @@ namespace libtorrent
|
||||||
l.unlock();
|
l.unlock();
|
||||||
|
|
||||||
file::iovec_t v = {buf.get(), std::size_t(block_to_copy)};
|
file::iovec_t v = {buf.get(), std::size_t(block_to_copy)};
|
||||||
v.iov_len = m_file.readv(slot_offset + piece_offset, v, ec);
|
v.iov_len = std::size_t(m_file.readv(slot_offset + piece_offset, v, ec));
|
||||||
TORRENT_ASSERT(!ec);
|
TORRENT_ASSERT(!ec);
|
||||||
if (ec || v.iov_len == 0) return;
|
if (ec || v.iov_len == 0) return;
|
||||||
|
|
||||||
|
|
|
@ -337,7 +337,7 @@ namespace libtorrent
|
||||||
int erase_candidate = -1;
|
int erase_candidate = -1;
|
||||||
int force_erase_candidate = -1;
|
int force_erase_candidate = -1;
|
||||||
|
|
||||||
if (m_finished != state->is_finished)
|
if (bool(m_finished) != state->is_finished)
|
||||||
recalculate_connect_candidates(state);
|
recalculate_connect_candidates(state);
|
||||||
|
|
||||||
int round_robin = random(std::uint32_t(m_peers.size()-1));
|
int round_robin = random(std::uint32_t(m_peers.size()-1));
|
||||||
|
@ -476,7 +476,7 @@ namespace libtorrent
|
||||||
|
|
||||||
int erase_candidate = -1;
|
int erase_candidate = -1;
|
||||||
|
|
||||||
if (m_finished != state->is_finished)
|
if (bool(m_finished) != state->is_finished)
|
||||||
recalculate_connect_candidates(state);
|
recalculate_connect_candidates(state);
|
||||||
|
|
||||||
external_ip const& external = state->ip;
|
external_ip const& external = state->ip;
|
||||||
|
@ -1144,7 +1144,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
if (m_finished != state->is_finished)
|
if (bool(m_finished) != state->is_finished)
|
||||||
recalculate_connect_candidates(state);
|
recalculate_connect_candidates(state);
|
||||||
|
|
||||||
// clear out any peers from the cache that no longer
|
// clear out any peers from the cache that no longer
|
||||||
|
@ -1174,7 +1174,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(p->connectable);
|
TORRENT_ASSERT(p->connectable);
|
||||||
|
|
||||||
// this should hold because find_connect_candidates should have done this
|
// this should hold because find_connect_candidates should have done this
|
||||||
TORRENT_ASSERT(m_finished == state->is_finished);
|
TORRENT_ASSERT(bool(m_finished) == state->is_finished);
|
||||||
|
|
||||||
TORRENT_ASSERT(is_connect_candidate(*p));
|
TORRENT_ASSERT(is_connect_candidate(*p));
|
||||||
return p;
|
return p;
|
||||||
|
@ -1390,4 +1390,3 @@ namespace libtorrent
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -414,7 +414,7 @@ namespace libtorrent
|
||||||
for (int i = 0; i < num_pieces; ++i)
|
for (int i = 0; i < num_pieces; ++i)
|
||||||
{
|
{
|
||||||
bool h = have[i];
|
bool h = have[i];
|
||||||
TORRENT_ASSERT(m_piece_map[std::size_t(i)].have_peers.count(p) == (h ? 1 : 0));
|
TORRENT_ASSERT(int(m_piece_map[i].have_peers.count(p)) == (h ? 1 : 0));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
TORRENT_UNUSED(have);
|
TORRENT_UNUSED(have);
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace libtorrent
|
||||||
std::int64_t sz = m_stat_cache[i].file_size;
|
std::int64_t sz = m_stat_cache[i].file_size;
|
||||||
if (sz < not_in_cache)
|
if (sz < not_in_cache)
|
||||||
{
|
{
|
||||||
ec = m_errors[-sz + file_error];
|
ec = m_errors[std::size_t(-sz + file_error)];
|
||||||
return file_error;
|
return file_error;
|
||||||
}
|
}
|
||||||
else if (sz == not_in_cache)
|
else if (sz == not_in_cache)
|
||||||
|
|
|
@ -35,10 +35,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
enum
|
constexpr std::uint32_t TIME_MASK = 0xffffffff;
|
||||||
{
|
|
||||||
TIME_MASK = 0xffffffff
|
|
||||||
};
|
|
||||||
// defined in utp_stream.cpp
|
// defined in utp_stream.cpp
|
||||||
bool compare_less_wrap(std::uint32_t lhs, std::uint32_t rhs
|
bool compare_less_wrap(std::uint32_t lhs, std::uint32_t rhs
|
||||||
, std::uint32_t mask);
|
, std::uint32_t mask);
|
||||||
|
|
|
@ -631,7 +631,7 @@ namespace libtorrent
|
||||||
: url(url_)
|
: url(url_)
|
||||||
, auth(auth_)
|
, auth(auth_)
|
||||||
, extra_headers(extra_headers_)
|
, extra_headers(extra_headers_)
|
||||||
, type(type_)
|
, type(std::uint8_t(type_))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1066,7 +1066,7 @@ size_t utp_stream::read_some(bool clear_buffers)
|
||||||
m_impl->m_receive_buffer_size -= to_copy;
|
m_impl->m_receive_buffer_size -= to_copy;
|
||||||
TORRENT_ASSERT(m_impl->m_read_buffer_size >= to_copy);
|
TORRENT_ASSERT(m_impl->m_read_buffer_size >= to_copy);
|
||||||
m_impl->m_read_buffer_size -= to_copy;
|
m_impl->m_read_buffer_size -= to_copy;
|
||||||
p->header_size += to_copy;
|
p->header_size += std::uint16_t(to_copy);
|
||||||
if (target->len == 0) target = m_impl->m_read_buffer.erase(target);
|
if (target->len == 0) target = m_impl->m_read_buffer.erase(target);
|
||||||
|
|
||||||
m_impl->check_receive_buffers();
|
m_impl->check_receive_buffers();
|
||||||
|
@ -1670,8 +1670,8 @@ void utp_socket_impl::remove_sack_header(packet* p)
|
||||||
TORRENT_ASSERT(p->size >= p->header_size);
|
TORRENT_ASSERT(p->size >= p->header_size);
|
||||||
TORRENT_ASSERT(p->header_size >= sizeof(utp_header) + sack_size + 2);
|
TORRENT_ASSERT(p->header_size >= sizeof(utp_header) + sack_size + 2);
|
||||||
memmove(ptr, ptr + sack_size + 2, p->size - p->header_size);
|
memmove(ptr, ptr + sack_size + 2, p->size - p->header_size);
|
||||||
p->header_size -= sack_size + 2;
|
p->header_size -= std::uint16_t(sack_size + 2);
|
||||||
p->size -= sack_size + 2;
|
p->size -= std::uint16_t(sack_size + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct holder
|
struct holder
|
||||||
|
@ -1884,8 +1884,8 @@ bool utp_socket_impl::send_pkt(int const flags)
|
||||||
h = reinterpret_cast<utp_header*>(ptr);
|
h = reinterpret_cast<utp_header*>(ptr);
|
||||||
ptr += sizeof(utp_header);
|
ptr += sizeof(utp_header);
|
||||||
|
|
||||||
h->extension = sack ? utp_sack
|
h->extension = std::uint8_t(sack ? utp_sack
|
||||||
: close_reason ? utp_close_reason : utp_no_extension;
|
: close_reason ? utp_close_reason : utp_no_extension);
|
||||||
h->connection_id = m_send_id;
|
h->connection_id = m_send_id;
|
||||||
// seq_nr is ignored for ST_STATE packets, so it doesn't
|
// seq_nr is ignored for ST_STATE packets, so it doesn't
|
||||||
// matter that we say this is a sequence number we haven't
|
// matter that we say this is a sequence number we haven't
|
||||||
|
@ -1925,7 +1925,7 @@ bool utp_socket_impl::send_pkt(int const flags)
|
||||||
, m_write_buffer_size);
|
, m_write_buffer_size);
|
||||||
|
|
||||||
write_payload(p->buf + p->size, size_left);
|
write_payload(p->buf + p->size, size_left);
|
||||||
p->size += size_left;
|
p->size += std::uint16_t(size_left);
|
||||||
|
|
||||||
UTP_LOGV("%8p: NAGLE appending %d bytes to nagle packet. new size: %d allocated: %d\n"
|
UTP_LOGV("%8p: NAGLE appending %d bytes to nagle packet. new size: %d allocated: %d\n"
|
||||||
, static_cast<void*>(this), size_left, p->size, p->allocated);
|
, static_cast<void*>(this), size_left, p->size, p->allocated);
|
||||||
|
@ -1951,7 +1951,7 @@ bool utp_socket_impl::send_pkt(int const flags)
|
||||||
|
|
||||||
if (sack)
|
if (sack)
|
||||||
{
|
{
|
||||||
*ptr++ = close_reason ? utp_close_reason : utp_no_extension;
|
*ptr++ = std::uint8_t(close_reason ? utp_close_reason : utp_no_extension);
|
||||||
*ptr++ = std::uint8_t(sack); // bytes for SACK bitfield
|
*ptr++ = std::uint8_t(sack); // bytes for SACK bitfield
|
||||||
write_sack(ptr, sack);
|
write_sack(ptr, sack);
|
||||||
ptr += sack;
|
ptr += sack;
|
||||||
|
@ -2428,7 +2428,7 @@ void utp_socket_impl::incoming(std::uint8_t const* buf, int size, packet* p
|
||||||
if (target->len == 0) m_read_buffer.erase(m_read_buffer.begin());
|
if (target->len == 0) m_read_buffer.erase(m_read_buffer.begin());
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
p->header_size += to_copy;
|
p->header_size += std::uint16_t(to_copy);
|
||||||
TORRENT_ASSERT(p->header_size <= p->size);
|
TORRENT_ASSERT(p->header_size <= p->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -914,7 +914,7 @@ void web_peer_connection::on_receive(error_code const& error
|
||||||
TORRENT_ASSERT(chunk_size != 0
|
TORRENT_ASSERT(chunk_size != 0
|
||||||
|| int(chunk_start.size()) <= header_size || chunk_start[header_size] == 'H');
|
|| int(chunk_start.size()) <= header_size || chunk_start[header_size] == 'H');
|
||||||
TORRENT_ASSERT(m_body_start + m_chunk_pos < INT_MAX);
|
TORRENT_ASSERT(m_body_start + m_chunk_pos < INT_MAX);
|
||||||
m_chunk_pos += chunk_size;
|
m_chunk_pos += int(chunk_size);
|
||||||
recv_buffer = recv_buffer.subspan(header_size);
|
recv_buffer = recv_buffer.subspan(header_size);
|
||||||
|
|
||||||
// a chunk size of zero means the request is complete. Make sure the
|
// a chunk size of zero means the request is complete. Make sure the
|
||||||
|
|
Loading…
Reference in New Issue