fixing shorten-64-to-32 warnings, part 1
This commit is contained in:
parent
b9169609df
commit
37cbdc5b37
|
@ -172,24 +172,26 @@ struct bdecode_token
|
||||||
max_header = (1 << 3) - 1
|
max_header = (1 << 3) - 1
|
||||||
};
|
};
|
||||||
|
|
||||||
bdecode_token(std::uint32_t off, bdecode_token::type_t t)
|
bdecode_token(std::ptrdiff_t off, bdecode_token::type_t t)
|
||||||
: offset(off)
|
: offset(std::uint32_t(off))
|
||||||
, type(t)
|
, type(t)
|
||||||
, next_item(0)
|
, next_item(0)
|
||||||
, header(0)
|
, header(0)
|
||||||
{
|
{
|
||||||
|
TORRENT_ASSERT(off >= 0);
|
||||||
TORRENT_ASSERT(off <= max_offset);
|
TORRENT_ASSERT(off <= max_offset);
|
||||||
TORRENT_ASSERT(t >= 0 && t <= end);
|
TORRENT_ASSERT(t >= 0 && t <= end);
|
||||||
}
|
}
|
||||||
|
|
||||||
bdecode_token(std::uint32_t off, std::uint32_t next
|
bdecode_token(std::ptrdiff_t off, std::uint32_t next
|
||||||
, bdecode_token::type_t t, std::uint8_t header_size = 0)
|
, bdecode_token::type_t t, std::uint8_t header_size = 0)
|
||||||
: offset(off)
|
: offset(std::uint32_t(off))
|
||||||
, type(t)
|
, type(t)
|
||||||
, next_item(next)
|
, next_item(next)
|
||||||
, header(type == string ? std::uint32_t(header_size - 2) : 0)
|
, header(type == string ? std::uint32_t(header_size - 2) : 0)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(type != string || header_size >= 2);
|
TORRENT_ASSERT(type != string || header_size >= 2);
|
||||||
|
TORRENT_ASSERT(off >= 0);
|
||||||
TORRENT_ASSERT(off <= max_offset);
|
TORRENT_ASSERT(off <= max_offset);
|
||||||
TORRENT_ASSERT(next <= max_next_item);
|
TORRENT_ASSERT(next <= max_next_item);
|
||||||
// the string has 2 implied header bytes, to allow for longer prefixes
|
// the string has 2 implied header bytes, to allow for longer prefixes
|
||||||
|
|
|
@ -422,7 +422,8 @@ namespace libtorrent
|
||||||
if (err) return entry();
|
if (err) return entry();
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
template<class InIt> entry bdecode(InIt start, InIt end, int& len)
|
template<class InIt> entry bdecode(InIt start, InIt end
|
||||||
|
, typename std::iterator_traits<InIt>::difference_type& len)
|
||||||
{
|
{
|
||||||
entry e;
|
entry e;
|
||||||
bool err = false;
|
bool err = false;
|
||||||
|
|
|
@ -88,7 +88,7 @@ struct average_accumulator
|
||||||
{
|
{
|
||||||
average_accumulator() {}
|
average_accumulator() {}
|
||||||
|
|
||||||
void add_sample(int s)
|
void add_sample(std::int64_t s)
|
||||||
{
|
{
|
||||||
++m_num_samples;
|
++m_num_samples;
|
||||||
m_sample_sum += s;
|
m_sample_sum += s;
|
||||||
|
|
|
@ -377,7 +377,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void update_transaction_id(
|
void update_transaction_id(
|
||||||
std::shared_ptr<udp_tracker_connection> c
|
std::shared_ptr<udp_tracker_connection> c
|
||||||
, std::uint64_t tid);
|
, std::uint32_t tid);
|
||||||
|
|
||||||
aux::session_settings const& settings() const { return m_settings; }
|
aux::session_settings const& settings() const { return m_settings; }
|
||||||
resolver_interface& host_resolver() { return m_host_resolver; }
|
resolver_interface& host_resolver() { return m_host_resolver; }
|
||||||
|
|
|
@ -170,7 +170,7 @@ namespace libtorrent
|
||||||
// make the two surrounding pages non-readable and -writable
|
// make the two surrounding pages non-readable and -writable
|
||||||
mprotect(block - page, page, PROT_READ | PROT_WRITE);
|
mprotect(block - page, page, PROT_READ | PROT_WRITE);
|
||||||
alloc_header* h = reinterpret_cast<alloc_header*>(block - page);
|
alloc_header* h = reinterpret_cast<alloc_header*>(block - page);
|
||||||
const int num_pages = (h->size + (page-1)) / page + 2;
|
const int num_pages = int((h->size + (page-1)) / page + 2);
|
||||||
TORRENT_ASSERT(h->magic == 0x1337);
|
TORRENT_ASSERT(h->magic == 0x1337);
|
||||||
mprotect(block + (num_pages-2) * page, page, PROT_READ | PROT_WRITE);
|
mprotect(block + (num_pages-2) * page, page, PROT_READ | PROT_WRITE);
|
||||||
// std::fprintf(stderr, "free: %p head: %p tail: %p size: %d\n", block, block - page, block + h->size, int(h->size));
|
// std::fprintf(stderr, "free: %p head: %p tail: %p size: %d\n", block, block - page, block + h->size, int(h->size));
|
||||||
|
|
|
@ -72,10 +72,10 @@ namespace libtorrent
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
int announce_entry::next_announce_in() const
|
int announce_entry::next_announce_in() const
|
||||||
{ return total_seconds(next_announce - aux::time_now()); }
|
{ return int(total_seconds(next_announce - aux::time_now())); }
|
||||||
|
|
||||||
int announce_entry::min_announce_in() const
|
int announce_entry::min_announce_in() const
|
||||||
{ return total_seconds(min_announce - aux::time_now()); }
|
{ return int(total_seconds(min_announce - aux::time_now())); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void announce_entry::reset()
|
void announce_entry::reset()
|
||||||
|
@ -91,7 +91,7 @@ namespace libtorrent
|
||||||
// the exponential back-off ends up being:
|
// the exponential back-off ends up being:
|
||||||
// 7, 15, 27, 45, 95, 127, 165, ... seconds
|
// 7, 15, 27, 45, 95, 127, 165, ... seconds
|
||||||
// with the default tracker_backoff of 250
|
// with the default tracker_backoff of 250
|
||||||
int const tracker_backoff_seconds = total_seconds(tracker_backoff);
|
int const tracker_backoff_seconds = int(total_seconds(tracker_backoff));
|
||||||
int const delay = std::max(std::min(tracker_retry_delay_min + int(fails) * int(fails)
|
int const delay = std::max(std::min(tracker_retry_delay_min + int(fails) * int(fails)
|
||||||
* tracker_retry_delay_min * tracker_backoff_seconds / 100
|
* tracker_retry_delay_min * tracker_backoff_seconds / 100
|
||||||
, int(tracker_retry_delay_max)), retry_interval);
|
, int(tracker_retry_delay_max)), retry_interval);
|
||||||
|
|
|
@ -198,7 +198,7 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth
|
||||||
nullptr,
|
nullptr,
|
||||||
&SymFunctionTableAccess64,
|
&SymFunctionTableAccess64,
|
||||||
&SymGetModuleBase64,
|
&SymGetModuleBase64,
|
||||||
nullptr) && size < stack.size())
|
nullptr) && size < int(stack.size()))
|
||||||
{
|
{
|
||||||
stack[size++] = reinterpret_cast<void*>(stack_frame.AddrPC.Offset);
|
stack[size++] = reinterpret_cast<void*>(stack_frame.AddrPC.Offset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -760,7 +760,7 @@ namespace libtorrent
|
||||||
if (ret.m_tokens.size() - top > bdecode_token::max_next_item)
|
if (ret.m_tokens.size() - top > bdecode_token::max_next_item)
|
||||||
TORRENT_FAIL_BDECODE(bdecode_errors::limit_exceeded);
|
TORRENT_FAIL_BDECODE(bdecode_errors::limit_exceeded);
|
||||||
|
|
||||||
ret.m_tokens[top].next_item = ret.m_tokens.size() - top;
|
ret.m_tokens[top].next_item = std::uint32_t(ret.m_tokens.size() - top);
|
||||||
|
|
||||||
// and pop it from the stack.
|
// and pop it from the stack.
|
||||||
--sp;
|
--sp;
|
||||||
|
@ -839,7 +839,7 @@ done:
|
||||||
|
|
||||||
int const top = stack[sp].token;
|
int const top = stack[sp].token;
|
||||||
TORRENT_ASSERT(ret.m_tokens.size() - top <= bdecode_token::max_next_item);
|
TORRENT_ASSERT(ret.m_tokens.size() - top <= bdecode_token::max_next_item);
|
||||||
ret.m_tokens[top].next_item = ret.m_tokens.size() - top;
|
ret.m_tokens[top].next_item = std::uint32_t(ret.m_tokens.size() - top);
|
||||||
ret.m_tokens.push_back(bdecode_token(start - orig_start, 1, bdecode_token::end));
|
ret.m_tokens.push_back(bdecode_token(start - orig_start, 1, bdecode_token::end));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -848,7 +848,7 @@ done:
|
||||||
|
|
||||||
ret.m_token_idx = 0;
|
ret.m_token_idx = 0;
|
||||||
ret.m_buffer = orig_start;
|
ret.m_buffer = orig_start;
|
||||||
ret.m_buffer_size = start - orig_start;
|
ret.m_buffer_size = int(start - orig_start);
|
||||||
ret.m_root_tokens = &ret.m_tokens[0];
|
ret.m_root_tokens = &ret.m_tokens[0];
|
||||||
|
|
||||||
return ec ? -1 : 0;
|
return ec ? -1 : 0;
|
||||||
|
|
|
@ -658,7 +658,7 @@ namespace libtorrent
|
||||||
if (!failed)
|
if (!failed)
|
||||||
{
|
{
|
||||||
TORRENT_PIECE_ASSERT(!error, pe);
|
TORRENT_PIECE_ASSERT(!error, pe);
|
||||||
std::uint32_t write_time = total_microseconds(clock_type::now() - start_time);
|
std::int64_t write_time = total_microseconds(clock_type::now() - start_time);
|
||||||
m_write_time.add_sample(write_time / num_blocks);
|
m_write_time.add_sample(write_time / num_blocks);
|
||||||
|
|
||||||
m_stats_counters.inc_stats_counter(counters::num_blocks_written, num_blocks);
|
m_stats_counters.inc_stats_counter(counters::num_blocks_written, num_blocks);
|
||||||
|
@ -1202,10 +1202,11 @@ namespace libtorrent
|
||||||
, j->piece, j->d.io.offset, file_flags, j->error);
|
, j->piece, j->d.io.offset, file_flags, j->error);
|
||||||
|
|
||||||
TORRENT_ASSERT(ret >= 0 || j->error.ec);
|
TORRENT_ASSERT(ret >= 0 || j->error.ec);
|
||||||
|
TORRENT_UNUSED(ret);
|
||||||
|
|
||||||
if (!j->error.ec)
|
if (!j->error.ec)
|
||||||
{
|
{
|
||||||
std::uint32_t read_time = total_microseconds(clock_type::now() - start_time);
|
std::int64_t read_time = total_microseconds(clock_type::now() - start_time);
|
||||||
m_read_time.add_sample(read_time);
|
m_read_time.add_sample(read_time);
|
||||||
|
|
||||||
m_stats_counters.inc_stats_counter(counters::num_read_back);
|
m_stats_counters.inc_stats_counter(counters::num_read_back);
|
||||||
|
@ -1274,11 +1275,11 @@ namespace libtorrent
|
||||||
time_point start_time = clock_type::now();
|
time_point start_time = clock_type::now();
|
||||||
|
|
||||||
ret = j->storage->readv(iov
|
ret = j->storage->readv(iov
|
||||||
, j->piece, adjusted_offset, file_flags, j->error);
|
, j->piece, int(adjusted_offset), file_flags, j->error);
|
||||||
|
|
||||||
if (!j->error.ec)
|
if (!j->error.ec)
|
||||||
{
|
{
|
||||||
std::uint32_t const read_time = total_microseconds(clock_type::now() - start_time);
|
std::int64_t const read_time = total_microseconds(clock_type::now() - start_time);
|
||||||
m_read_time.add_sample(read_time / iov_len);
|
m_read_time.add_sample(read_time / iov_len);
|
||||||
|
|
||||||
m_stats_counters.inc_stats_counter(counters::num_blocks_read, iov_len);
|
m_stats_counters.inc_stats_counter(counters::num_blocks_read, iov_len);
|
||||||
|
@ -1441,7 +1442,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (!j->error.ec)
|
if (!j->error.ec)
|
||||||
{
|
{
|
||||||
std::uint32_t write_time = total_microseconds(clock_type::now() - start_time);
|
std::int64_t write_time = total_microseconds(clock_type::now() - start_time);
|
||||||
m_write_time.add_sample(write_time);
|
m_write_time.add_sample(write_time);
|
||||||
|
|
||||||
m_stats_counters.inc_stats_counter(counters::num_blocks_written);
|
m_stats_counters.inc_stats_counter(counters::num_blocks_written);
|
||||||
|
@ -2030,7 +2031,7 @@ namespace libtorrent
|
||||||
offset += size;
|
offset += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t hash_time = total_microseconds(clock_type::now() - start_time);
|
std::int64_t hash_time = total_microseconds(clock_type::now() - start_time);
|
||||||
|
|
||||||
l.lock();
|
l.lock();
|
||||||
|
|
||||||
|
@ -2121,7 +2122,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (!j->error.ec)
|
if (!j->error.ec)
|
||||||
{
|
{
|
||||||
std::uint32_t const read_time = total_microseconds(clock_type::now() - start_time);
|
std::int64_t const read_time = total_microseconds(clock_type::now() - start_time);
|
||||||
m_read_time.add_sample(read_time);
|
m_read_time.add_sample(read_time);
|
||||||
|
|
||||||
m_stats_counters.inc_stats_counter(counters::num_blocks_read);
|
m_stats_counters.inc_stats_counter(counters::num_blocks_read);
|
||||||
|
@ -2331,7 +2332,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (!j->error.ec)
|
if (!j->error.ec)
|
||||||
{
|
{
|
||||||
std::uint32_t read_time = total_microseconds(clock_type::now() - start_time);
|
std::int64_t read_time = total_microseconds(clock_type::now() - start_time);
|
||||||
m_read_time.add_sample(read_time);
|
m_read_time.add_sample(read_time);
|
||||||
|
|
||||||
m_stats_counters.inc_stats_counter(counters::num_read_back);
|
m_stats_counters.inc_stats_counter(counters::num_read_back);
|
||||||
|
@ -2572,41 +2573,41 @@ namespace libtorrent
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
ret->total_used_buffers = m_disk_cache.in_use();
|
ret->total_used_buffers = m_disk_cache.in_use();
|
||||||
|
|
||||||
ret->blocks_read_hit = m_stats_counters[counters::num_blocks_cache_hits];
|
ret->blocks_read_hit = int(m_stats_counters[counters::num_blocks_cache_hits]);
|
||||||
ret->blocks_read = m_stats_counters[counters::num_blocks_read];
|
ret->blocks_read = int(m_stats_counters[counters::num_blocks_read]);
|
||||||
ret->blocks_written = m_stats_counters[counters::num_blocks_written];
|
ret->blocks_written = int(m_stats_counters[counters::num_blocks_written]);
|
||||||
ret->writes = m_stats_counters[counters::num_write_ops];
|
ret->writes = int(m_stats_counters[counters::num_write_ops]);
|
||||||
ret->reads = m_stats_counters[counters::num_read_ops];
|
ret->reads = int(m_stats_counters[counters::num_read_ops]);
|
||||||
|
|
||||||
int num_read_jobs = (std::max)(std::int64_t(1)
|
int num_read_jobs = int((std::max)(std::int64_t(1)
|
||||||
, m_stats_counters[counters::num_read_ops]);
|
, m_stats_counters[counters::num_read_ops]));
|
||||||
int num_write_jobs = (std::max)(std::int64_t(1)
|
int num_write_jobs = int((std::max)(std::int64_t(1)
|
||||||
, m_stats_counters[counters::num_write_ops]);
|
, m_stats_counters[counters::num_write_ops]));
|
||||||
int num_hash_jobs = (std::max)(std::int64_t(1)
|
int num_hash_jobs = int((std::max)(std::int64_t(1)
|
||||||
, m_stats_counters[counters::num_blocks_hashed]);
|
, m_stats_counters[counters::num_blocks_hashed]));
|
||||||
|
|
||||||
ret->average_read_time = m_stats_counters[counters::disk_read_time] / num_read_jobs;
|
ret->average_read_time = int(m_stats_counters[counters::disk_read_time] / num_read_jobs);
|
||||||
ret->average_write_time = m_stats_counters[counters::disk_write_time] / num_write_jobs;
|
ret->average_write_time = int(m_stats_counters[counters::disk_write_time] / num_write_jobs);
|
||||||
ret->average_hash_time = m_stats_counters[counters::disk_hash_time] / num_hash_jobs;
|
ret->average_hash_time = int(m_stats_counters[counters::disk_hash_time] / num_hash_jobs);
|
||||||
ret->average_job_time = m_stats_counters[counters::disk_job_time]
|
ret->average_job_time = int(m_stats_counters[counters::disk_job_time]
|
||||||
/ (num_read_jobs + num_write_jobs + num_hash_jobs);
|
/ (num_read_jobs + num_write_jobs + num_hash_jobs));
|
||||||
ret->cumulative_job_time = m_stats_counters[counters::disk_job_time];
|
ret->cumulative_job_time = int(m_stats_counters[counters::disk_job_time]);
|
||||||
ret->cumulative_read_time = m_stats_counters[counters::disk_read_time];
|
ret->cumulative_read_time = int(m_stats_counters[counters::disk_read_time]);
|
||||||
ret->cumulative_write_time = m_stats_counters[counters::disk_write_time];
|
ret->cumulative_write_time = int(m_stats_counters[counters::disk_write_time]);
|
||||||
ret->cumulative_hash_time = m_stats_counters[counters::disk_hash_time];
|
ret->cumulative_hash_time = int(m_stats_counters[counters::disk_hash_time]);
|
||||||
ret->total_read_back = m_stats_counters[counters::num_read_back];
|
ret->total_read_back = int(m_stats_counters[counters::num_read_back]);
|
||||||
|
|
||||||
ret->blocked_jobs = m_stats_counters[counters::blocked_disk_jobs];
|
ret->blocked_jobs = int(m_stats_counters[counters::blocked_disk_jobs]);
|
||||||
|
|
||||||
ret->num_jobs = jobs_in_use();
|
ret->num_jobs = jobs_in_use();
|
||||||
ret->num_read_jobs = read_jobs_in_use();
|
ret->num_read_jobs = read_jobs_in_use();
|
||||||
ret->read_queue_size = read_jobs_in_use();
|
ret->read_queue_size = read_jobs_in_use();
|
||||||
ret->num_write_jobs = write_jobs_in_use();
|
ret->num_write_jobs = write_jobs_in_use();
|
||||||
ret->pending_jobs = m_stats_counters[counters::num_running_disk_jobs];
|
ret->pending_jobs = int(m_stats_counters[counters::num_running_disk_jobs]);
|
||||||
ret->num_writing_threads = m_stats_counters[counters::num_writing_threads];
|
ret->num_writing_threads = int(m_stats_counters[counters::num_writing_threads]);
|
||||||
|
|
||||||
for (int i = 0; i < disk_io_job::num_job_ids; ++i)
|
for (int i = 0; i < disk_io_job::num_job_ids; ++i)
|
||||||
ret->num_fence_jobs[i] = m_stats_counters[counters::num_fenced_read + i];
|
ret->num_fence_jobs[i] = int(m_stats_counters[counters::num_fenced_read + i]);
|
||||||
|
|
||||||
m_disk_cache.get_stats(ret);
|
m_disk_cache.get_stats(ret);
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void tracker_manager::update_transaction_id(
|
void tracker_manager::update_transaction_id(
|
||||||
std::shared_ptr<udp_tracker_connection> c
|
std::shared_ptr<udp_tracker_connection> c
|
||||||
, std::uint64_t tid)
|
, std::uint32_t tid)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
m_udp_conns.erase(c->transaction_id());
|
m_udp_conns.erase(c->transaction_id());
|
||||||
|
|
|
@ -304,7 +304,7 @@ namespace libtorrent { namespace
|
||||||
|
|
||||||
if (!m_pc.packet_finished()) return true;
|
if (!m_pc.packet_finished()) return true;
|
||||||
|
|
||||||
int len;
|
std::ptrdiff_t len;
|
||||||
entry msg = bdecode(body.begin(), body.end(), len);
|
entry msg = bdecode(body.begin(), body.end(), len);
|
||||||
if (msg.type() != entry::dictionary_t)
|
if (msg.type() != entry::dictionary_t)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue