fixed some warnings

This commit is contained in:
Arvid Norberg 2011-02-15 10:05:25 +00:00
parent d35670e53d
commit c4c1773ceb
11 changed files with 23 additions and 26 deletions

View File

@ -1572,7 +1572,10 @@ namespace libtorrent
}
#endif // F_PREALLOCATE
#if defined TORRENT_LINUX || defined TORRENT_HAS_FALLOCATE
int ret;
#endif
#if defined TORRENT_LINUX
ret = my_fallocate(m_fd, 0, 0, s);
// if we return 0, everything went fine

View File

@ -362,7 +362,7 @@ namespace libtorrent
bool ret = m_parser.parse_chunk_header(chunk_start, &chunk_size, &header_size);
if (!ret)
{
TORRENT_ASSERT(bytes_transferred >= chunk_start.left() - m_partial_chunk_header);
TORRENT_ASSERT(bytes_transferred >= size_t(chunk_start.left() - m_partial_chunk_header));
bytes_transferred -= chunk_start.left() - m_partial_chunk_header;
m_statistics.received_bytes(0, chunk_start.left() - m_partial_chunk_header);
m_partial_chunk_header = chunk_start.left();
@ -374,7 +374,7 @@ namespace libtorrent
#ifdef TORRENT_VERBOSE_LOGGING
peer_log("*** parsed chunk: %d header_size: %d", chunk_size, header_size);
#endif
TORRENT_ASSERT(bytes_transferred >= header_size - m_partial_chunk_header);
TORRENT_ASSERT(bytes_transferred >= size_t(header_size - m_partial_chunk_header));
bytes_transferred -= header_size - m_partial_chunk_header;
m_statistics.received_bytes(0, header_size - m_partial_chunk_header);
m_partial_chunk_header = 0;

View File

@ -297,7 +297,7 @@ void natpmp::try_next_mapping(int i, mutex::scoped_lock& l)
void natpmp::update_mapping(int i, mutex::scoped_lock& l)
{
if (i == m_mappings.size())
if (i == int(m_mappings.size()))
{
if (m_abort)
{

View File

@ -193,7 +193,7 @@ namespace libtorrent {
if (idx == m_first && m_size != 0)
{
++m_first;
for (int i = 0; i < m_capacity; ++i, ++m_first)
for (boost::uint32_t i = 0; i < m_capacity; ++i, ++m_first)
if (m_storage[m_first & mask]) break;
m_first &= 0xffff;
}
@ -201,7 +201,7 @@ namespace libtorrent {
if (((idx + 1) & 0xffff) == m_last && m_size != 0)
{
--m_last;
for (int i = 0; i < m_capacity; ++i, --m_last)
for (boost::uint32_t i = 0; i < m_capacity; ++i, --m_last)
if (m_storage[m_last & mask]) break;
++m_last;
m_last &= 0xffff;

View File

@ -4984,11 +4984,10 @@ namespace libtorrent
return;
}
int max_receive = 0;
int num_loops = 0;
do
{
TORRENT_ASSERT(m_recv_pos + bytes_transferred <= m_packet_size);
TORRENT_ASSERT(int(m_recv_pos + bytes_transferred) <= m_packet_size);
#ifdef TORRENT_VERBOSE_LOGGING
peer_log("<<< read %d bytes", int(bytes_transferred));
#endif
@ -5369,7 +5368,7 @@ namespace libtorrent
void peer_connection::check_invariant() const
{
TORRENT_ASSERT(m_queued_time_critical <= m_request_queue.size());
TORRENT_ASSERT(m_queued_time_critical <= int(m_request_queue.size()));
TORRENT_ASSERT(bool(m_disk_recv_buffer) == (m_disk_recv_buffer_size > 0));
@ -5400,7 +5399,6 @@ namespace libtorrent
int block_size = t->block_size();
piece_block last_block(ti.num_pieces()-1
, (ti.piece_size(ti.num_pieces()-1) + block_size - 1) / block_size);
int last_block_size = t->torrent_file().piece_size(ti.num_pieces()-1) - last_block.block_index * block_size;
for (std::vector<pending_block>::const_iterator i = m_download_queue.begin()
, end(m_download_queue.end()); i != end; ++i)
{

View File

@ -1104,7 +1104,7 @@ namespace libtorrent
// maintain sparse_regions
if (index == 0)
{
if (index == m_piece_map.size() - 1
if (index == int(m_piece_map.size()) - 1
|| m_piece_map[index + 1].have())
--m_sparse_regions;
}

View File

@ -228,7 +228,7 @@ namespace libtorrent
// also, if we already have at least one outstanding
// request, we shouldn't pick any busy pieces either
bool dont_pick_busy_blocks = (ses.m_settings.strict_end_game_mode
&& p.num_have() + p.get_download_queue().size()
&& p.num_have() + int(p.get_download_queue().size())
< t.torrent_file().num_pieces())
|| dq.size() + rq.size() > 0;
@ -1115,7 +1115,6 @@ namespace libtorrent
policy::peer* policy::add_i2p_peer(char const* destination, int src, char flags)
{
INVARIANT_CHECK;
aux::session_impl& ses = m_torrent->session();
bool found = false;
iterator iter = std::lower_bound(
@ -1206,10 +1205,6 @@ namespace libtorrent
iterator iter;
peer* p = 0;
int max_peerlist_size = m_torrent->is_paused()
?m_torrent->settings().max_paused_peerlist_size
:m_torrent->settings().max_peerlist_size;
bool found = false;
if (m_torrent->settings().allow_multiple_connections_per_ip)
{

View File

@ -650,8 +650,8 @@ namespace aux {
char tmp[300];
snprintf(tmp, sizeof(tmp), "libtorrent configuration: %s\n"
"libtorrent version: %d\n"
"libtorrent revision: %d\n\n"
"libtorrent version: %s\n"
"libtorrent revision: %s\n\n"
, TORRENT_CFG_STRING
, LIBTORRENT_VERSION
, LIBTORRENT_REVISION);
@ -988,7 +988,7 @@ namespace aux {
all_default_values def;
for (int i = 0; i < sizeof(all_settings)/sizeof(all_settings[0]); ++i)
for (int i = 0; i < int(sizeof(all_settings)/sizeof(all_settings[0])); ++i)
{
session_category const& c = all_settings[i];
if ((flags & c.flag) == 0) continue;
@ -1070,7 +1070,7 @@ namespace aux {
if (e->type() != lazy_entry::dict_t) return;
for (int i = 0; i < sizeof(all_settings)/sizeof(all_settings[0]); ++i)
for (int i = 0; i < int(sizeof(all_settings)/sizeof(all_settings[0])); ++i)
{
session_category const& c = all_settings[i];
settings = e->dict_find_dict(c.name);
@ -2964,7 +2964,7 @@ namespace aux {
m_cache_rotation_timer = m_settings.explicit_cache_interval;
torrent_map::iterator least_recently_refreshed = m_torrents.begin();
if (m_next_explicit_cache_torrent >= m_torrents.size())
if (m_next_explicit_cache_torrent >= int(m_torrents.size()))
m_next_explicit_cache_torrent = 0;
std::advance(least_recently_refreshed, m_next_explicit_cache_torrent);
@ -3528,7 +3528,6 @@ namespace aux {
{
if (!p->is_choked() && p->is_interesting())
{
policy::peer* pi = p->peer_info_struct();
if (!p->has_peer_choked())
{
// we're unchoked, we may want to lower our estimated

View File

@ -460,7 +460,7 @@ namespace libtorrent
ph.h.update((char const*)bufs[i].iov_base, small_piece_size);
*small_hash = hasher(ph.h).final();
small_hash = 0; // avoid this case again
if (bufs[i].iov_len > small_piece_size)
if (int(bufs[i].iov_len) > small_piece_size)
ph.h.update((char const*)bufs[i].iov_base + small_piece_size
, bufs[i].iov_len - small_piece_size);
}
@ -491,7 +491,7 @@ namespace libtorrent
if (small_piece_size > 0) ph.h.update((char const*)buf.iov_base, small_piece_size);
*small_hash = hasher(ph.h).final();
small_hash = 0; // avoid this case again
if (buf.iov_len > small_piece_size)
if (int(buf.iov_len) > small_piece_size)
ph.h.update((char const*)buf.iov_base + small_piece_size
, buf.iov_len - small_piece_size);
}

View File

@ -481,6 +481,7 @@ namespace libtorrent
memcpy(m_info_section.get(), t.m_info_section.get(), m_info_section_size);
int ret = lazy_bdecode(m_info_section.get(), m_info_section.get()
+ m_info_section_size, m_info_dict, ec);
TORRENT_ASSERT(ret == 0);
lazy_entry const* pieces = m_info_dict.dict_find_string("pieces");
if (pieces && pieces->string_length() == m_files.num_pieces() * 20)

View File

@ -78,7 +78,6 @@ namespace libtorrent
shared_ptr<torrent> tor = t.lock();
TORRENT_ASSERT(tor);
int blocks_per_piece = tor->torrent_file().piece_length() / tor->block_size();
// we always prefer downloading 1 MB chunks
// from web seeds
@ -266,7 +265,9 @@ namespace libtorrent
INVARIANT_CHECK;
#ifdef TORRENT_DEBUG
size_type dl_target = m_statistics.last_payload_downloaded()
TORRENT_ASSERT(m_statistics.last_payload_downloaded()
+ m_statistics.last_protocol_downloaded() + bytes_transferred < size_t(INT_MAX));
int dl_target = m_statistics.last_payload_downloaded()
+ m_statistics.last_protocol_downloaded() + bytes_transferred;
#endif