fixed build warnings

This commit is contained in:
Arvid Norberg 2011-02-14 01:59:01 +00:00
parent 8bb71da401
commit 5864a883e6
10 changed files with 23 additions and 19 deletions

View File

@ -179,7 +179,7 @@ namespace libtorrent {
std::string tracker_announce_alert::message() const std::string tracker_announce_alert::message() const
{ {
const static char* event_str[] = {"none", "completed", "started", "stopped", "paused"}; const static char* event_str[] = {"none", "completed", "started", "stopped", "paused"};
TORRENT_ASSERT_VAL(event < sizeof(event_str)/sizeof(event_str[0]), event); TORRENT_ASSERT_VAL(event < int(sizeof(event_str)/sizeof(event_str[0])), event);
return tracker_alert::message() + " sending announce (" + event_str[event] + ")"; return tracker_alert::message() + " sending announce (" + event_str[event] + ")";
} }

View File

@ -57,9 +57,7 @@ namespace libtorrent
for (int j = 0; j < 5 && channel[j]; ++j) for (int j = 0; j < 5 && channel[j]; ++j)
{ {
if (channel[j]->throttle() == 0) continue; if (channel[j]->throttle() == 0) continue;
TORRENT_ASSERT(channel[j]->distribute_quota quota = (std::min)(int(boost::int64_t(channel[j]->distribute_quota)
< (std::numeric_limits<boost::uint64_t>::max)() / priority);
quota = (std::min)(int(boost::uint64_t(channel[j]->distribute_quota)
* priority / channel[j]->tmp), quota); * priority / channel[j]->tmp), quota);
} }
assigned += quota; assigned += quota;

View File

@ -347,6 +347,9 @@ namespace libtorrent
} }
break; break;
} }
case lazy_entry::none_t:
destruct();
break;
} }
} }

View File

@ -254,7 +254,7 @@ namespace libtorrent
"bencoded nesting depth exceeded", "bencoded nesting depth exceeded",
"bencoded item count limit exceeded", "bencoded item count limit exceeded",
}; };
if (ev < 0 || ev >= sizeof(msgs)/sizeof(msgs[0])) if (ev < 0 || ev >= int(sizeof(msgs)/sizeof(msgs[0])))
return "Unknown error"; return "Unknown error";
return msgs[ev]; return msgs[ev];
} }

View File

@ -242,7 +242,7 @@ namespace libtorrent
TORRENT_ASSERT(str != 0); TORRENT_ASSERT(str != 0);
TORRENT_ASSERT(len >= 0); TORRENT_ASSERT(len >= 0);
TORRENT_ASSERT(offset >= 0); TORRENT_ASSERT(offset >= 0);
TORRENT_ASSERT(offset < sizeof(unreserved_chars)-1); TORRENT_ASSERT(offset < int(sizeof(unreserved_chars))-1);
std::string ret; std::string ret;
for (int i = 0; i < len; ++i) for (int i = 0; i < len; ++i)

View File

@ -309,7 +309,7 @@ namespace libtorrent
ec.assign(errno, boost::system::get_generic_category()); ec.assign(errno, boost::system::get_generic_category());
break; break;
} }
if (num_read < sizeof(buffer)) break; if (num_read < int(sizeof(buffer))) break;
} }
close(infd); close(infd);
close(outfd); close(outfd);
@ -441,7 +441,7 @@ namespace libtorrent
#endif #endif
if (sep == 0) return f; if (sep == 0) return f;
if (sep - first == f.size() - 1) if (sep - first == int(f.size()) - 1)
{ {
// if the last character is a / (or \) // if the last character is a / (or \)
// ignore it // ignore it

View File

@ -374,7 +374,7 @@ namespace libtorrent
sha1_hash file_storage::hash(internal_file_entry const& fe) const sha1_hash file_storage::hash(internal_file_entry const& fe) const
{ {
int index = &fe - &m_files[0]; int index = &fe - &m_files[0];
if (index >= m_file_hashes.size()) return sha1_hash(0); if (index >= int(m_file_hashes.size())) return sha1_hash(0);
return sha1_hash(m_file_hashes[index]); return sha1_hash(m_file_hashes[index]);
} }
@ -387,29 +387,29 @@ namespace libtorrent
time_t file_storage::mtime(internal_file_entry const& fe) const time_t file_storage::mtime(internal_file_entry const& fe) const
{ {
int index = &fe - &m_files[0]; int index = &fe - &m_files[0];
if (index >= m_mtime.size()) return 0; if (index >= int(m_mtime.size())) return 0;
return m_mtime[index]; return m_mtime[index];
} }
int file_storage::file_index(internal_file_entry const& fe) const int file_storage::file_index(internal_file_entry const& fe) const
{ {
int index = &fe - &m_files[0]; int index = &fe - &m_files[0];
TORRENT_ASSERT(index >= 0 && index < m_files.size()); TORRENT_ASSERT(index >= 0 && index < int(m_files.size()));
return index; return index;
} }
void file_storage::set_file_base(internal_file_entry const& fe, size_type off) void file_storage::set_file_base(internal_file_entry const& fe, size_type off)
{ {
int index = &fe - &m_files[0]; int index = &fe - &m_files[0];
TORRENT_ASSERT(index >= 0 && index < m_files.size()); TORRENT_ASSERT(index >= 0 && index < int(m_files.size()));
if (m_file_base.size() <= index) m_file_base.resize(index); if (int(m_file_base.size()) <= index) m_file_base.resize(index);
m_file_base[index] = off; m_file_base[index] = off;
} }
size_type file_storage::file_base(internal_file_entry const& fe) const size_type file_storage::file_base(internal_file_entry const& fe) const
{ {
int index = &fe - &m_files[0]; int index = &fe - &m_files[0];
if (index >= m_file_base.size()) return 0; if (index >= int(m_file_base.size())) return 0;
return m_file_base[index]; return m_file_base[index];
} }
@ -424,7 +424,7 @@ namespace libtorrent
if (!m_mtime.empty()) if (!m_mtime.empty())
{ {
time_t mtime = 0; time_t mtime = 0;
if (m_mtime.size() > index) if (int(m_mtime.size()) > index)
{ {
mtime = m_mtime[index]; mtime = m_mtime[index];
m_mtime.erase(m_mtime.begin() + index); m_mtime.erase(m_mtime.begin() + index);
@ -434,7 +434,7 @@ namespace libtorrent
if (!m_file_hashes.empty()) if (!m_file_hashes.empty())
{ {
char const* fh = 0; char const* fh = 0;
if (m_file_hashes.size() > index) if (int(m_file_hashes.size()) > index)
{ {
fh = m_file_hashes[index]; fh = m_file_hashes[index];
m_file_hashes.erase(m_file_hashes.begin() + index); m_file_hashes.erase(m_file_hashes.begin() + index);
@ -444,7 +444,7 @@ namespace libtorrent
if (!m_file_base.empty()) if (!m_file_base.empty())
{ {
size_type base = 0; size_type base = 0;
if (m_file_base.size() > index) if (int(m_file_base.size()) > index)
{ {
base = m_file_base[index]; base = m_file_base[index];
m_file_base.erase(m_file_base.begin() + index); m_file_base.erase(m_file_base.begin() + index);

View File

@ -252,7 +252,7 @@ void http_connection::start(std::string const& hostname, std::string const& port
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
if (m_ssl) userdata = &m_ssl_ctx; if (m_ssl) userdata = &m_ssl_ctx;
#endif #endif
bool ret = instantiate_connection(m_resolver.get_io_service() instantiate_connection(m_resolver.get_io_service()
, proxy ? *proxy : null_proxy, m_sock, userdata); , proxy ? *proxy : null_proxy, m_sock, userdata);
if (m_bind_addr != address_v4::any()) if (m_bind_addr != address_v4::any())

View File

@ -464,6 +464,9 @@ namespace libtorrent
line_len += 2; line_len += 2;
} }
break; break;
case lazy_entry::none_t:
line_len += 4;
break;
} }
if (line_len > limit) return -1; if (line_len > limit) return -1;

View File

@ -144,7 +144,7 @@ get_out:
if (prime) BN_free(prime); if (prime) BN_free(prime);
#elif defined TORRENT_USE_TOMMATH #elif defined TORRENT_USE_TOMMATH
// create local key // create local key
for (int i = 0; i < sizeof(m_dh_local_secret); ++i) for (int i = 0; i < int(sizeof(m_dh_local_secret)); ++i)
m_dh_local_secret[i] = rand(); m_dh_local_secret[i] = rand();
mp_int prime; mp_int prime;