merged fixes of warnings from RC_1_0

This commit is contained in:
Arvid Norberg 2014-07-04 23:40:31 +00:00
parent 6cce06fbd6
commit 6c6fe4dfe2
38 changed files with 90 additions and 77 deletions

View File

@ -661,8 +661,6 @@ local usage-requirements =
<toolset>gcc:<cflags>-fno-strict-aliasing <toolset>gcc:<cflags>-fno-strict-aliasing
<toolset>gcc:<cflags>-Wno-missing-braces <toolset>gcc:<cflags>-Wno-missing-braces
# assert on integer overflow # assert on integer overflow
<toolset>clang:<cflags>-Wno-invalid-offsetof
<toolset>clang-darwin:<cflags>-Wno-invalid-offsetof
<boost>system:<cxxflags>$(CXXFLAGS) <boost>system:<cxxflags>$(CXXFLAGS)
<boost>system:<linkflags>$(LDFLAGS) <boost>system:<linkflags>$(LDFLAGS)
# this works around a bug in asio in boost-1.39 # this works around a bug in asio in boost-1.39

View File

@ -12,7 +12,7 @@ enum
ed25519_public_key_size = 32, ed25519_public_key_size = 32,
ed25519_signature_size = 64, ed25519_signature_size = 64,
ed25519_scalar_size = 32, ed25519_scalar_size = 32,
ed25519_shared_secret_size = 32, ed25519_shared_secret_size = 32
}; };
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1498,3 +1498,4 @@ void fe_tobytes(unsigned char *s, const fe h) {
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#endif // _MSC_VER #endif // _MSC_VER

View File

@ -1389,3 +1389,4 @@ static ge_precomp base[32][8] = {
}, },
}, },
}; };

View File

@ -10,3 +10,4 @@ void sc_reduce(unsigned char *s);
void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b, const unsigned char *c); void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b, const unsigned char *c);
#endif #endif

View File

@ -38,3 +38,4 @@ int ed25519_create_seed(unsigned char *seed) {
} }
#endif #endif

View File

@ -19,3 +19,4 @@ int sha512_update(sha512_context * md, const unsigned char *in, size_t inlen);
int sha512(const unsigned char *message, size_t message_len, unsigned char *out); int sha512(const unsigned char *message, size_t message_len, unsigned char *out);
#endif #endif

View File

@ -692,7 +692,7 @@ namespace libtorrent
TORRENT_DEFINE_ALERT(peer_connect_alert); TORRENT_DEFINE_ALERT(peer_connect_alert);
const static int static_category = alert::debug_notification; const static int static_category = alert::debug_notification;
virtual std::string message() const;; virtual std::string message() const;
int socket_type; int socket_type;
}; };

View File

@ -105,7 +105,7 @@ namespace libtorrent
// recommend_msg = 5, // recommend_msg = 5,
// comment_msg = 6, // comment_msg = 6,
dont_have_msg = 7, dont_have_msg = 7,
share_mode_msg = 8, share_mode_msg = 8
}; };
~bt_peer_connection(); ~bt_peer_connection();

View File

@ -59,12 +59,8 @@ POSSIBILITY OF SUCH DAMAGE.
build, to automatically apply these defines build, to automatically apply these defines
#endif #endif
#if !defined _MSC_VER || _MSC_VER >= 1600 // some parts pulled out of stdint.h
// to avoid C99 or C++11 dependency
#include <stdint.h> // for INT64_MAX et.al.
#else
#if !defined INT64_MAX #if !defined INT64_MAX
#define INT64_MAX 0x7fffffffffffffffLL #define INT64_MAX 0x7fffffffffffffffLL
#endif #endif
@ -75,8 +71,6 @@ POSSIBILITY OF SUCH DAMAGE.
#define INT16_MIN -32768 #define INT16_MIN -32768
#endif #endif
#endif
#ifndef _MSC_VER #ifndef _MSC_VER
#ifndef __STDC_FORMAT_MACROS #ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS 1 #define __STDC_FORMAT_MACROS 1

View File

@ -116,7 +116,7 @@ private:
boost::function<void()> on_timeout; boost::function<void()> on_timeout;
ptime expires; ptime expires;
time_duration timeout; time_duration timeout;
boost::uint32_t ticket; boost::int32_t ticket;
bool connecting; bool connecting;
boost::uint8_t priority; boost::uint8_t priority;
}; };

View File

@ -465,7 +465,7 @@ namespace libtorrent
// this file is a symlink. The symlink target is // this file is a symlink. The symlink target is
// specified in a separate field // specified in a separate field
flag_symlink = 8, flag_symlink = 8
}; };
// returns a bitmask of flags from file_flags_t that apply // returns a bitmask of flags from file_flags_t that apply

View File

@ -364,7 +364,7 @@ namespace libtorrent
web_seed = 1, web_seed = 1,
// HTTP connection using the `BEP 17`_ protocol // HTTP connection using the `BEP 17`_ protocol
http_seed = 2, http_seed = 2
}; };
// the kind of connection this peer uses. See connection_type_t. // the kind of connection this peer uses. See connection_type_t.

View File

@ -95,7 +95,7 @@ namespace libtorrent
enum enum
{ {
// the limits of the download queue size // the limits of the download queue size
min_request_queue = 2, min_request_queue = 2
}; };
// calculate the priority of a peer based on its address. One of the // calculate the priority of a peer based on its address. One of the

View File

@ -271,7 +271,7 @@ namespace libtorrent
aux::session_impl& m_ses; aux::session_impl& m_ses;
}; };
}; }
#endif #endif

View File

@ -522,7 +522,7 @@ namespace libtorrent
{ {
public: public:
disabled_storage(int piece_size) : m_piece_size(piece_size) {} disabled_storage(int piece_size) : m_piece_size(piece_size) {}
void set_file_priority(std::vector<boost::uint8_t> const& prio) {} void set_file_priority(std::vector<boost::uint8_t> const&) {}
bool has_any_file() { return false; } bool has_any_file() { return false; }
bool rename_file(int, std::string const&) { return false; } bool rename_file(int, std::string const&) { return false; }
bool release_files() { return false; } bool release_files() { return false; }
@ -561,7 +561,7 @@ namespace libtorrent
// if any file exist in the target, take those files instead // if any file exist in the target, take those files instead
// of the ones we may have in the source. // of the ones we may have in the source.
dont_replace, dont_replace
}; };
struct disk_io_thread; struct disk_io_thread;
@ -651,7 +651,7 @@ namespace libtorrent
need_full_check = -1, need_full_check = -1,
fatal_disk_error = -2, fatal_disk_error = -2,
disk_check_aborted = -3, disk_check_aborted = -3,
file_exist = -4, file_exist = -4
}; };
storage_interface* get_storage_impl() { return m_storage.get(); } storage_interface* get_storage_impl() { return m_storage.get(); }

View File

@ -315,7 +315,7 @@ namespace libtorrent
query_name = 64, query_name = 64,
// includes ``save_path``, the path to the directory the files of the // includes ``save_path``, the path to the directory the files of the
// torrent are saved to. // torrent are saved to.
query_save_path = 128, query_save_path = 128
}; };
// ``status()`` will return a structure with information about the status // ``status()`` will return a structure with information about the status

View File

@ -110,7 +110,7 @@ namespace libtorrent
invalid_pkts_in, invalid_pkts_in,
redundant_pkts_in, redundant_pkts_in,
num_counters, num_counters
}; };
// used to keep stats of uTP events // used to keep stats of uTP events

View File

@ -132,8 +132,7 @@ libtorrent_rasterbar_la_LDFLAGS = -version-info $(INTERFACE_VERSION_INFO)
libtorrent_rasterbar_la_LIBADD = @BOOST_SYSTEM_LIB@ @OPENSSL_LIBS@ libtorrent_rasterbar_la_LIBADD = @BOOST_SYSTEM_LIB@ @OPENSSL_LIBS@
#AM_CXXFLAGS= -ftemplate-depth-100 -I$(top_srcdir)/include @DEBUGFLAGS@ @OPENSSL_INCLUDES@ #AM_CXXFLAGS= -ftemplate-depth-100 -I$(top_srcdir)/include @DEBUGFLAGS@ @OPENSSL_INCLUDES@
#AM_CPPFLAGS = -ftemplate-depth-100 -I$(top_srcdir)/include @DEBUGFLAGS@ @OPENSSL_INCLUDES@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/ed25519/src @DEBUGFLAGS@ @OPENSSL_INCLUDES@
AM_CPPFLAGS = -ftemplate-depth-100 -I$(top_srcdir)/include -I$(top_srcdir)/ed25519/src @DEBUGFLAGS@ @OPENSSL_INCLUDES@
AM_CFLAGS = -I$(top_srcdir)/ed25519/src -std=c99 AM_CFLAGS = -I$(top_srcdir)/ed25519/src -std=c99
#AM_CFLAGS= -I$(top_srcdir)/include @DEBUGFLAGS@ #AM_CFLAGS= -I$(top_srcdir)/include @DEBUGFLAGS@

View File

@ -566,7 +566,7 @@ namespace libtorrent {
}; };
int op = operation; int op = operation;
if (op < 0 || op > sizeof(operation_names)/sizeof(operation_names[0])) if (op < 0 || op > int(sizeof(operation_names)/sizeof(operation_names[0])))
op = 0; op = 0;
char msg[600]; char msg[600];

View File

@ -102,7 +102,7 @@ namespace libtorrent
// for cases where the cache size is several gigabytes) // for cases where the cache size is several gigabytes)
TORRENT_ASSERT(bytes < 0x30000000); TORRENT_ASSERT(bytes < 0x30000000);
TORRENT_ASSERT(bytes >= page_size()); TORRENT_ASSERT(int(bytes) >= page_size());
#ifdef TORRENT_DEBUG_BUFFERS #ifdef TORRENT_DEBUG_BUFFERS
int page = page_size(); int page = page_size();
int num_pages = (bytes + (page-1)) / page + 2; int num_pages = (bytes + (page-1)) / page + 2;

View File

@ -155,5 +155,5 @@ namespace libtorrent
#endif #endif
} }
}; }

View File

@ -209,7 +209,7 @@ namespace libtorrent
} }
// all entries are connecting, no need to look for new ones // all entries are connecting, no need to look for new ones
if (m_queue.size() == m_num_connecting) if (int(m_queue.size()) == m_num_connecting)
return; return;
std::list<entry>::iterator i = std::find_if(m_queue.begin() std::list<entry>::iterator i = std::find_if(m_queue.begin()
@ -245,7 +245,7 @@ namespace libtorrent
if (m_num_connecting >= m_half_open_limit if (m_num_connecting >= m_half_open_limit
&& m_half_open_limit > 0) break; && m_half_open_limit > 0) break;
if (m_num_connecting == m_queue.size()) break; if (m_num_connecting == int(m_queue.size())) break;
i = std::find_if(i, m_queue.end(), boost::bind(&entry::connecting, _1) == false); i = std::find_if(i, m_queue.end(), boost::bind(&entry::connecting, _1) == false);
} }

View File

@ -2237,7 +2237,7 @@ namespace libtorrent
if (i != idx.end()) if (i != idx.end())
{ {
TORRENT_ASSERT(i->storage); TORRENT_ASSERT(i->storage);
int ret = flush_range(const_cast<cached_piece_entry&>(*i), 0, INT_MAX, l); ret = flush_range(const_cast<cached_piece_entry&>(*i), 0, INT_MAX, l);
idx.erase(i); idx.erase(i);
if (test_error(j)) if (test_error(j))
{ {

View File

@ -309,7 +309,7 @@ namespace libtorrent
// find the file iterator and file offset // find the file iterator and file offset
internal_file_entry target; internal_file_entry target;
target.offset = piece * (size_type)m_piece_length + offset; target.offset = piece * (size_type)m_piece_length + offset;
TORRENT_ASSERT_PRECOND(target.offset + size <= m_total_size); TORRENT_ASSERT_PRECOND(size_type(target.offset + size) <= m_total_size);
TORRENT_ASSERT(!compare_file_offset(target, m_files.front())); TORRENT_ASSERT(!compare_file_offset(target, m_files.front()));
std::vector<internal_file_entry>::const_iterator file_iter = std::upper_bound( std::vector<internal_file_entry>::const_iterator file_iter = std::upper_bound(
@ -644,7 +644,7 @@ namespace libtorrent
} }
file_entry file_storage::at(file_storage::iterator i) const file_entry file_storage::at(file_storage::iterator i) const
{ return at(i - begin()); } { return at(i - m_files.begin()); }
#endif // TORRENT_NO_DEPRECATE #endif // TORRENT_NO_DEPRECATE
bool compare_file_entry_size(internal_file_entry const& fe1, internal_file_entry const& fe2) bool compare_file_entry_size(internal_file_entry const& fe1, internal_file_entry const& fe2)
@ -704,7 +704,7 @@ namespace libtorrent
} }
} }
else if (pad_file_limit >= 0 else if (pad_file_limit >= 0
&& i->size > pad_file_limit && i->size > boost::uint32_t(pad_file_limit)
&& i->pad_file == false) && i->pad_file == false)
{ {
// if we have pad files enabled, and this file is // if we have pad files enabled, and this file is
@ -722,7 +722,7 @@ namespace libtorrent
{ {
for (std::vector<internal_file_entry>::iterator j = i+1; j < m_files.end(); ++j) for (std::vector<internal_file_entry>::iterator j = i+1; j < m_files.end(); ++j)
{ {
if (j->size > pad_size) continue; if (j->size > boost::uint32_t(pad_size)) continue;
if (best_match == m_files.end() || j->size > best_match->size) if (best_match == m_files.end() || j->size > best_match->size)
best_match = j; best_match = j;
} }

View File

@ -170,7 +170,7 @@ namespace libtorrent
// case we fail // case we fail
if (ret == 1) // 1: output space exhausted before completing inflate if (ret == 1) // 1: output space exhausted before completing inflate
{ {
if (destlen == maximum_size) if (destlen == boost::uint32_t(maximum_size))
{ {
error = "inflated data too big"; error = "inflated data too big";
return true; return true;

View File

@ -511,10 +511,10 @@ namespace libtorrent
if (ip_ent) if (ip_ent)
{ {
char const* p = ip_ent->string_ptr(); char const* p = ip_ent->string_ptr();
if (ip_ent->string_length() == address_v4::bytes_type().size()) if (ip_ent->string_length() == int(address_v4::bytes_type().size()))
external_ip = detail::read_v4_address(p); external_ip = detail::read_v4_address(p);
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
else if (ip_ent->string_length() == address_v6::bytes_type().size()) else if (ip_ent->string_length() == int(address_v6::bytes_type().size()))
external_ip = detail::read_v6_address(p); external_ip = detail::read_v6_address(p);
#endif #endif
} }

View File

@ -262,7 +262,7 @@ void routing_table::print_state(std::ostream& os) const
node_id id = j->id; node_id id = j->id;
id <<= bucket_index + 1; id <<= bucket_index + 1;
int b = (id[0] & top_mask) >> mask_shift; int b = (id[0] & top_mask) >> mask_shift;
TORRENT_ASSERT(b >= 0 && b < sizeof(sub_buckets)); TORRENT_ASSERT(b >= 0 && b < int(sizeof(sub_buckets)/sizeof(sub_buckets[0])));
sub_buckets[b] = true; sub_buckets[b] = true;
} }

View File

@ -223,7 +223,7 @@ void traversal_algorithm::add_entry(node_id const& id, udp::endpoint addr, unsig
if (m_results.size() > 100) if (m_results.size() > 100)
{ {
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
for (int i = 100; i < m_results.size(); ++i) for (int i = 100; i < int(m_results.size()); ++i)
m_results[i]->m_was_abandoned = true; m_results[i]->m_was_abandoned = true;
#endif #endif
m_results.resize(100); m_results.resize(100);

View File

@ -217,7 +217,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
{ {
// we expect it to be hexadecimal // we expect it to be hexadecimal
// if it isn't, it's not our cookie anyway // if it isn't, it's not our cookie anyway
boost::uint32_t cookie = strtol(cookie_iter->second.c_str(), NULL, 16); boost::int32_t cookie = strtol(cookie_iter->second.c_str(), NULL, 16);
if (cookie == m_cookie) if (cookie == m_cookie)
{ {
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING) #if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)

View File

@ -4784,7 +4784,6 @@ namespace libtorrent
shared_ptr<torrent> t = m_torrent.lock(); shared_ptr<torrent> t = m_torrent.lock();
// we may want to request more quota at this point // we may want to request more quota at this point
int ret = 0;
bool utp = m_socket->get<utp_stream>() != 0; bool utp = m_socket->get<utp_stream>() != 0;
bool ignore_limits = m_ignore_bandwidth_limits bool ignore_limits = m_ignore_bandwidth_limits
|| (!m_ses.m_settings.rate_limit_utp && utp); || (!m_ses.m_settings.rate_limit_utp && utp);
@ -4793,7 +4792,7 @@ namespace libtorrent
// in this case, we have data to send, but no // in this case, we have data to send, but no
// bandwidth. So, we simply request bandwidth // bandwidth. So, we simply request bandwidth
// from the bandwidth manager // from the bandwidth manager
ret = request_upload_bandwidth( request_upload_bandwidth(
&m_ses.m_upload_channel &m_ses.m_upload_channel
, t ? &t->m_bandwidth_channel[upload_channel] : 0 , t ? &t->m_bandwidth_channel[upload_channel] : 0
, &m_bandwidth_channel[upload_channel] , &m_bandwidth_channel[upload_channel]
@ -4806,7 +4805,7 @@ namespace libtorrent
// instead we rate limit ourself against the special // instead we rate limit ourself against the special
// global bandwidth channel for local peers, which defaults // global bandwidth channel for local peers, which defaults
// to unthrottled // to unthrottled
ret = request_upload_bandwidth(&m_ses.m_local_upload_channel request_upload_bandwidth(&m_ses.m_local_upload_channel
, &m_bandwidth_channel[upload_channel]); , &m_bandwidth_channel[upload_channel]);
} }
@ -4929,7 +4928,6 @@ namespace libtorrent
shared_ptr<torrent> t = m_torrent.lock(); shared_ptr<torrent> t = m_torrent.lock();
// we may want to request more quota at this point // we may want to request more quota at this point
int ret = 0;
bool utp = m_socket->get<utp_stream>() != 0; bool utp = m_socket->get<utp_stream>() != 0;
bool ignore_limits = m_ignore_bandwidth_limits bool ignore_limits = m_ignore_bandwidth_limits
|| (!m_ses.m_settings.rate_limit_utp && utp); || (!m_ses.m_settings.rate_limit_utp && utp);
@ -4938,7 +4936,7 @@ namespace libtorrent
// in this case, we have outstanding data to // in this case, we have outstanding data to
// receive, but no bandwidth quota. So, we simply // receive, but no bandwidth quota. So, we simply
// request bandwidth from the bandwidth manager // request bandwidth from the bandwidth manager
ret = request_download_bandwidth( request_download_bandwidth(
&m_ses.m_download_channel &m_ses.m_download_channel
, t ? &t->m_bandwidth_channel[download_channel] : 0 , t ? &t->m_bandwidth_channel[download_channel] : 0
, &m_bandwidth_channel[download_channel] , &m_bandwidth_channel[download_channel]
@ -4951,7 +4949,7 @@ namespace libtorrent
// instead we rate limit ourself against the special // instead we rate limit ourself against the special
// global bandwidth channel for local peers, which defaults // global bandwidth channel for local peers, which defaults
// to unthrottled // to unthrottled
ret = request_download_bandwidth(&m_ses.m_local_download_channel request_download_bandwidth(&m_ses.m_local_download_channel
, &m_bandwidth_channel[download_channel]); , &m_bandwidth_channel[download_channel]);
} }
@ -5755,7 +5753,7 @@ namespace libtorrent
// if the piece is fully downloaded, we might have popped it from the // if the piece is fully downloaded, we might have popped it from the
// download queue already // download queue already
int outstanding_bytes = 0; int outstanding_bytes = 0;
bool in_download_queue = false; // bool in_download_queue = false;
int block_size = t->block_size(); int block_size = t->block_size();
piece_block last_block(ti.num_pieces()-1 piece_block last_block(ti.num_pieces()-1
, (ti.piece_size(ti.num_pieces()-1) + block_size - 1) / block_size); , (ti.piece_size(ti.num_pieces()-1) + block_size - 1) / block_size);
@ -5767,7 +5765,7 @@ namespace libtorrent
|| i->block.block_index <= last_block.block_index); || i->block.block_index <= last_block.block_index);
if (m_received_in_piece && i == m_download_queue.begin()) if (m_received_in_piece && i == m_download_queue.begin())
{ {
in_download_queue = true; // in_download_queue = true;
// this assert is not correct since block may have different sizes // this assert is not correct since block may have different sizes
// and may not be returned in the order they were requested // and may not be returned in the order they were requested
// TORRENT_ASSERT(t->to_req(i->block).length >= m_received_in_piece); // TORRENT_ASSERT(t->to_req(i->block).length >= m_received_in_piece);
@ -5911,6 +5909,7 @@ namespace libtorrent
TORRENT_ASSERT(i != end); TORRENT_ASSERT(i != end);
} }
#endif #endif
/*
if (t->has_picker() && !t->is_aborted()) if (t->has_picker() && !t->is_aborted())
{ {
// make sure that pieces that have completed the download // make sure that pieces that have completed the download
@ -5931,9 +5930,10 @@ namespace libtorrent
complete = false; complete = false;
break; break;
} }
TORRENT_ASSERT(complete);
} }
} }
*/
// extremely expensive invariant check // extremely expensive invariant check
/* /*
if (!t->is_seed()) if (!t->is_seed())

View File

@ -398,6 +398,11 @@ void feed::on_feed(error_code const& ec
m_ses.update_rss_feeds(); m_ses.update_rss_feeds();
} }
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#endif
#define TORRENT_SETTING(t, x) {#x, offsetof(feed_settings,x), t}, #define TORRENT_SETTING(t, x) {#x, offsetof(feed_settings,x), t},
bencode_map_entry feed_settings_map[] = bencode_map_entry feed_settings_map[] =
{ {
@ -439,6 +444,10 @@ void feed::on_feed(error_code const& ec
}; };
#undef TORRENT_SETTING #undef TORRENT_SETTING
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
void feed::load_state(lazy_entry const& rd) void feed::load_state(lazy_entry const& rd)
{ {
load_struct(rd, this, feed_map, sizeof(feed_map)/sizeof(feed_map[0])); load_struct(rd, this, feed_map, sizeof(feed_map)/sizeof(feed_map[0]));
@ -670,5 +679,5 @@ feed_settings feed_handle::settings() const
return ret; return ret;
} }
}; }

View File

@ -281,6 +281,11 @@ namespace aux {
} }
}; };
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#endif
#define TORRENT_SETTING(t, x) {#x, offsetof(session_settings,x), t}, #define TORRENT_SETTING(t, x) {#x, offsetof(session_settings,x), t},
bencode_map_entry session_settings_map[] = bencode_map_entry session_settings_map[] =
@ -554,6 +559,10 @@ namespace aux {
} }
#undef lenof #undef lenof
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#ifdef TORRENT_STATS #ifdef TORRENT_STATS
int session_impl::logging_allocator::allocations = 0; int session_impl::logging_allocator::allocations = 0;
int session_impl::logging_allocator::allocated_bytes = 0; int session_impl::logging_allocator::allocated_bytes = 0;
@ -4480,9 +4489,9 @@ retry:
{ {
// this is the maximum number of connections we will // this is the maximum number of connections we will
// attempt this tick // attempt this tick
int average_peers = 0; // int average_peers = 0;
if (num_downloads > 0) // if (num_downloads > 0)
average_peers = num_downloads_peers / num_downloads; // average_peers = num_downloads_peers / num_downloads;
if (m_next_connect_torrent == m_torrents.end()) if (m_next_connect_torrent == m_torrents.end())
m_next_connect_torrent = m_torrents.begin(); m_next_connect_torrent = m_torrents.begin();

View File

@ -1239,9 +1239,9 @@ ret:
// if the file has priority 0, don't allocate it // if the file has priority 0, don't allocate it
if (m_allocate_files && (op.mode & file::rw_mask) != file::read_only if (m_allocate_files && (op.mode & file::rw_mask) != file::read_only
&& (m_file_priority.size() <= file_index || m_file_priority[file_index] > 0)) && (int(m_file_priority.size()) <= file_index || m_file_priority[file_index] > 0))
{ {
TORRENT_ASSERT(m_file_created.size() == files().num_files()); TORRENT_ASSERT(int(m_file_created.size()) == files().num_files());
if (m_file_created[file_index] == false) if (m_file_created[file_index] == false)
{ {
file_handle->set_size(files().file_size(file_index), ec); file_handle->set_size(files().file_size(file_index), ec);

View File

@ -3802,7 +3802,6 @@ namespace libtorrent
--i; --i;
} }
// just in case this piece had priority 0 // just in case this piece had priority 0
int prev_prio = m_picker->piece_priority(piece);
m_picker->set_piece_priority(piece, 7); m_picker->set_piece_priority(piece, 7);
return; return;
} }
@ -3819,7 +3818,6 @@ namespace libtorrent
m_time_critical_pieces.insert(i, p); m_time_critical_pieces.insert(i, p);
// just in case this piece had priority 0 // just in case this piece had priority 0
int prev_prio = m_picker->piece_priority(piece);
m_picker->set_piece_priority(piece, 7); m_picker->set_piece_priority(piece, 7);
piece_picker::downloading_piece pi; piece_picker::downloading_piece pi;
@ -6886,7 +6884,7 @@ namespace libtorrent
{ {
TORRENT_ASSERT(total_done == 0); TORRENT_ASSERT(total_done == 0);
} }
/*
if (m_picker && !m_abort) if (m_picker && !m_abort)
{ {
// make sure that pieces that have completed the download // make sure that pieces that have completed the download
@ -6907,9 +6905,10 @@ namespace libtorrent
complete = false; complete = false;
break; break;
} }
TORRENT_ASSERT(complete);
} }
} }
*/
if (m_files_checked && valid_metadata()) if (m_files_checked && valid_metadata())
{ {
TORRENT_ASSERT(block_size() > 0); TORRENT_ASSERT(block_size() > 0);
@ -7389,7 +7388,7 @@ namespace libtorrent
boost::bind(&torrent::on_cache_flushed, shared_from_this(), _1, _2)); boost::bind(&torrent::on_cache_flushed, shared_from_this(), _1, _2));
} }
void torrent::on_cache_flushed(int ret, disk_io_job const& j) void torrent::on_cache_flushed(int /* ret */, disk_io_job const& j)
{ {
TORRENT_ASSERT(m_ses.is_network_thread()); TORRENT_ASSERT(m_ses.is_network_thread());
@ -8694,7 +8693,7 @@ namespace libtorrent
// remove the bottom 10% of peers from the candidate set. // remove the bottom 10% of peers from the candidate set.
// this is just to remove outliers that might stall downloads // this is just to remove outliers that might stall downloads
int new_size = (peers.size() * 9 + 9) / 10; int new_size = (peers.size() * 9 + 9) / 10;
TORRENT_ASSERT(new_size <= peers.size()); TORRENT_ASSERT(new_size <= int(peers.size()));
peers.resize(new_size); peers.resize(new_size);
// remember all the peers we issued requests to, so we can commit them // remember all the peers we issued requests to, so we can commit them

View File

@ -78,7 +78,7 @@ namespace libtorrent { namespace
// metadata. If the torrent is greater than 16 MiB, // metadata. If the torrent is greater than 16 MiB,
// we may hit this case (and the client requesting // we may hit this case (and the client requesting
// doesn't throttle its requests) // doesn't throttle its requests)
max_incoming_requests = 1024, max_incoming_requests = 1024
}; };
int div_round_up(int numerator, int denominator) int div_round_up(int numerator, int denominator)

View File

@ -115,7 +115,7 @@ enum
// less likely to loose the re-sent packet. Because // less likely to loose the re-sent packet. Because
// when that happens, we must time-out in order // when that happens, we must time-out in order
// to continue, which takes a long time. // to continue, which takes a long time.
sack_resend_limit = 1, sack_resend_limit = 1
}; };
// compare if lhs is less than rhs, taking wrapping // compare if lhs is less than rhs, taking wrapping

View File

@ -251,7 +251,7 @@ namespace libtorrent
m_piece.swap(m_web.restart_piece); m_piece.swap(m_web.restart_piece);
m_block_pos += m_piece.size(); m_block_pos += m_piece.size();
peer_request& front = m_requests.front(); peer_request& front = m_requests.front();
TORRENT_ASSERT(front.length > m_piece.size()); TORRENT_ASSERT(front.length > int(m_piece.size()));
#if 0 #if 0
std::cerr << this << " RESTART-DATA: data: " << m_piece.size() std::cerr << this << " RESTART-DATA: data: " << m_piece.size()
@ -387,7 +387,7 @@ namespace libtorrent
peer_request const& front_request = m_requests.front(); peer_request const& front_request = m_requests.front();
if (int(m_piece.size()) < front_request.length) return false; if (int(m_piece.size()) < front_request.length) return false;
TORRENT_ASSERT(int(m_piece.size() == front_request.length)); TORRENT_ASSERT(int(m_piece.size()) == front_request.length);
// each call to incoming_piece() may result in us becoming // each call to incoming_piece() may result in us becoming
// a seed. If we become a seed, all seeds we're connected to // a seed. If we become a seed, all seeds we're connected to
@ -868,7 +868,7 @@ namespace libtorrent
if (copy_size > m_chunk_pos && m_chunk_pos > 0) copy_size = m_chunk_pos; if (copy_size > m_chunk_pos && m_chunk_pos > 0) copy_size = m_chunk_pos;
if (copy_size > 0) if (copy_size > 0)
{ {
TORRENT_ASSERT(m_piece.size() == m_received_in_piece); TORRENT_ASSERT(int(m_piece.size()) == m_received_in_piece);
m_piece.resize(piece_size + copy_size); m_piece.resize(piece_size + copy_size);
std::memcpy(&m_piece[0] + piece_size, recv_buffer.begin, copy_size); std::memcpy(&m_piece[0] + piece_size, recv_buffer.begin, copy_size);
TORRENT_ASSERT(int(m_piece.size()) <= front_request.length); TORRENT_ASSERT(int(m_piece.size()) <= front_request.length);
@ -881,9 +881,9 @@ namespace libtorrent
m_chunk_pos -= copy_size; m_chunk_pos -= copy_size;
} }
TORRENT_ASSERT(m_received_body <= range_end - range_start); TORRENT_ASSERT(m_received_body <= range_end - range_start);
TORRENT_ASSERT(m_piece.size() <= front_request.length); TORRENT_ASSERT(int(m_piece.size()) <= front_request.length);
incoming_piece_fragment(copy_size); incoming_piece_fragment(copy_size);
TORRENT_ASSERT(m_piece.size() == m_received_in_piece); TORRENT_ASSERT(int(m_piece.size()) == m_received_in_piece);
} }
if (maybe_harvest_block()) if (maybe_harvest_block())
@ -930,14 +930,14 @@ namespace libtorrent
TORRENT_ASSERT(copy_size >= 0); TORRENT_ASSERT(copy_size >= 0);
if (copy_size > 0) if (copy_size > 0)
{ {
TORRENT_ASSERT(m_piece.size() == m_received_in_piece); TORRENT_ASSERT(int(m_piece.size()) == m_received_in_piece);
m_piece.resize(piece_size + copy_size); m_piece.resize(piece_size + copy_size);
std::memcpy(&m_piece[0] + piece_size, recv_buffer.begin, copy_size); std::memcpy(&m_piece[0] + piece_size, recv_buffer.begin, copy_size);
recv_buffer.begin += copy_size; recv_buffer.begin += copy_size;
m_received_body += copy_size; m_received_body += copy_size;
m_body_start += copy_size; m_body_start += copy_size;
incoming_piece_fragment(copy_size); incoming_piece_fragment(copy_size);
TORRENT_ASSERT(m_piece.size() == m_received_in_piece); TORRENT_ASSERT(int(m_piece.size()) == m_received_in_piece);
} }
TORRENT_ASSERT(m_received_body == range_end - range_start); TORRENT_ASSERT(m_received_body == range_end - range_start);
} }