From 5864a883e6dfbf26e1833f0c5020d4da8fd62207 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 14 Feb 2011 01:59:01 +0000 Subject: [PATCH] fixed build warnings --- src/alert.cpp | 2 +- src/bandwidth_queue_entry.cpp | 4 +--- src/entry.cpp | 3 +++ src/error_code.cpp | 2 +- src/escape_string.cpp | 2 +- src/file.cpp | 4 ++-- src/file_storage.cpp | 18 +++++++++--------- src/http_connection.cpp | 2 +- src/lazy_bdecode.cpp | 3 +++ src/pe_crypto.cpp | 2 +- 10 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/alert.cpp b/src/alert.cpp index 82d41b7f8..32bea58ba 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -179,7 +179,7 @@ namespace libtorrent { std::string tracker_announce_alert::message() const { 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] + ")"; } diff --git a/src/bandwidth_queue_entry.cpp b/src/bandwidth_queue_entry.cpp index d95b219d6..c13a564a9 100644 --- a/src/bandwidth_queue_entry.cpp +++ b/src/bandwidth_queue_entry.cpp @@ -57,9 +57,7 @@ namespace libtorrent for (int j = 0; j < 5 && channel[j]; ++j) { if (channel[j]->throttle() == 0) continue; - TORRENT_ASSERT(channel[j]->distribute_quota - < (std::numeric_limits::max)() / priority); - quota = (std::min)(int(boost::uint64_t(channel[j]->distribute_quota) + quota = (std::min)(int(boost::int64_t(channel[j]->distribute_quota) * priority / channel[j]->tmp), quota); } assigned += quota; diff --git a/src/entry.cpp b/src/entry.cpp index 20f7f3888..47251f0b9 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -347,6 +347,9 @@ namespace libtorrent } break; } + case lazy_entry::none_t: + destruct(); + break; } } diff --git a/src/error_code.cpp b/src/error_code.cpp index 6d3efee11..d7099bdce 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -254,7 +254,7 @@ namespace libtorrent "bencoded nesting depth 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 msgs[ev]; } diff --git a/src/escape_string.cpp b/src/escape_string.cpp index c80598334..e1deb79d2 100644 --- a/src/escape_string.cpp +++ b/src/escape_string.cpp @@ -242,7 +242,7 @@ namespace libtorrent TORRENT_ASSERT(str != 0); TORRENT_ASSERT(len >= 0); TORRENT_ASSERT(offset >= 0); - TORRENT_ASSERT(offset < sizeof(unreserved_chars)-1); + TORRENT_ASSERT(offset < int(sizeof(unreserved_chars))-1); std::string ret; for (int i = 0; i < len; ++i) diff --git a/src/file.cpp b/src/file.cpp index 17fb1ff7d..8f1c4d304 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -309,7 +309,7 @@ namespace libtorrent ec.assign(errno, boost::system::get_generic_category()); break; } - if (num_read < sizeof(buffer)) break; + if (num_read < int(sizeof(buffer))) break; } close(infd); close(outfd); @@ -441,7 +441,7 @@ namespace libtorrent #endif 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 \) // ignore it diff --git a/src/file_storage.cpp b/src/file_storage.cpp index f2f08e90f..580d9cd03 100644 --- a/src/file_storage.cpp +++ b/src/file_storage.cpp @@ -374,7 +374,7 @@ namespace libtorrent sha1_hash file_storage::hash(internal_file_entry const& fe) const { 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]); } @@ -387,29 +387,29 @@ namespace libtorrent time_t file_storage::mtime(internal_file_entry const& fe) const { 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]; } int file_storage::file_index(internal_file_entry const& fe) const { 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; } void file_storage::set_file_base(internal_file_entry const& fe, size_type off) { int index = &fe - &m_files[0]; - TORRENT_ASSERT(index >= 0 && index < m_files.size()); - if (m_file_base.size() <= index) m_file_base.resize(index); + TORRENT_ASSERT(index >= 0 && index < int(m_files.size())); + if (int(m_file_base.size()) <= index) m_file_base.resize(index); m_file_base[index] = off; } size_type file_storage::file_base(internal_file_entry const& fe) const { 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]; } @@ -424,7 +424,7 @@ namespace libtorrent if (!m_mtime.empty()) { time_t mtime = 0; - if (m_mtime.size() > index) + if (int(m_mtime.size()) > index) { mtime = m_mtime[index]; m_mtime.erase(m_mtime.begin() + index); @@ -434,7 +434,7 @@ namespace libtorrent if (!m_file_hashes.empty()) { char const* fh = 0; - if (m_file_hashes.size() > index) + if (int(m_file_hashes.size()) > index) { fh = m_file_hashes[index]; m_file_hashes.erase(m_file_hashes.begin() + index); @@ -444,7 +444,7 @@ namespace libtorrent if (!m_file_base.empty()) { size_type base = 0; - if (m_file_base.size() > index) + if (int(m_file_base.size()) > index) { base = m_file_base[index]; m_file_base.erase(m_file_base.begin() + index); diff --git a/src/http_connection.cpp b/src/http_connection.cpp index 0ad809327..2d346f84d 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -252,7 +252,7 @@ void http_connection::start(std::string const& hostname, std::string const& port #ifdef TORRENT_USE_OPENSSL if (m_ssl) userdata = &m_ssl_ctx; #endif - bool ret = instantiate_connection(m_resolver.get_io_service() + instantiate_connection(m_resolver.get_io_service() , proxy ? *proxy : null_proxy, m_sock, userdata); if (m_bind_addr != address_v4::any()) diff --git a/src/lazy_bdecode.cpp b/src/lazy_bdecode.cpp index acf2bc323..71acf3c40 100644 --- a/src/lazy_bdecode.cpp +++ b/src/lazy_bdecode.cpp @@ -464,6 +464,9 @@ namespace libtorrent line_len += 2; } break; + case lazy_entry::none_t: + line_len += 4; + break; } if (line_len > limit) return -1; diff --git a/src/pe_crypto.cpp b/src/pe_crypto.cpp index de558d195..f1545d97e 100644 --- a/src/pe_crypto.cpp +++ b/src/pe_crypto.cpp @@ -144,7 +144,7 @@ get_out: if (prime) BN_free(prime); #elif defined TORRENT_USE_TOMMATH // 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(); mp_int prime;