From 57769bab118f5f8ef309c8ebfb0f25ced8a71921 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 25 Jun 2012 14:17:51 +0000 Subject: [PATCH] fix some compiler warnings --- src/bt_peer_connection.cpp | 2 +- src/connection_queue.cpp | 1 + src/gzip.cpp | 2 +- src/i2p_stream.cpp | 8 ++++---- src/kademlia/routing_table.cpp | 6 +++--- src/peer_connection.cpp | 3 --- src/session.cpp | 3 +++ src/torrent_info.cpp | 5 ++++- src/utp_stream.cpp | 14 +++++++------- src/web_peer_connection.cpp | 3 --- 10 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 9b458e0b0..9dbfa45ee 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -756,7 +756,7 @@ namespace libtorrent // peer id memcpy(ptr, &m_ses.get_peer_id()[0], 20); - ptr += 20; +// ptr += 20; #ifdef TORRENT_VERBOSE_LOGGING peer_log("==> HANDSHAKE [ ih: %s ]", to_hex(ih.to_string()).c_str()); diff --git a/src/connection_queue.cpp b/src/connection_queue.cpp index 6b89ce7fd..34f031944 100644 --- a/src/connection_queue.cpp +++ b/src/connection_queue.cpp @@ -90,6 +90,7 @@ namespace libtorrent m_queue.push_front(entry()); e = &m_queue.front(); break; + default: return; } e->priority = priority; diff --git a/src/gzip.cpp b/src/gzip.cpp index b4ea1bc8c..d8a278283 100644 --- a/src/gzip.cpp +++ b/src/gzip.cpp @@ -123,7 +123,7 @@ namespace libtorrent if (size < 2) return -1; size -= 2; - buffer += 2; +// buffer += 2; } return total_size - size; diff --git a/src/i2p_stream.cpp b/src/i2p_stream.cpp index 2c2f07f23..32e184e72 100644 --- a/src/i2p_stream.cpp +++ b/src/i2p_stream.cpp @@ -293,8 +293,8 @@ namespace libtorrent if (ptr == 0 || expect2 == 0 || strcmp(expect2, ptr)) { handle_error(invalid_response, h); return; } int result = 0; - char const* message = 0; - float version = 3.0f; +// char const* message = 0; +// float version = 3.0f; for(;;) { @@ -324,11 +324,11 @@ namespace libtorrent } else if (strcmp("MESSAGE", name) == 0) { - message = ptr; +// message = ptr; } else if (strcmp("VERSION", name) == 0) { - version = float(atof(ptr)); +// version = float(atof(ptr)); } else if (strcmp("VALUE", name) == 0) { diff --git a/src/kademlia/routing_table.cpp b/src/kademlia/routing_table.cpp index 1e0b17bc7..c9f9561c5 100644 --- a/src/kademlia/routing_table.cpp +++ b/src/kademlia/routing_table.cpp @@ -379,7 +379,7 @@ bool routing_table::add_node(node_entry const& e) break; } if (!done) - { + { for (bucket_t::iterator i = rb.begin(), end(rb.end()); i != end; ++i) { @@ -388,7 +388,7 @@ bool routing_table::add_node(node_entry const& e) TORRENT_LOG(table) << "node ID changed, deleting old entry: " << i->id << " " << i->addr; #endif - rb.erase(i); + rb.erase(i); done = true; break; } @@ -398,7 +398,7 @@ bool routing_table::add_node(node_entry const& e) } } - table_t::iterator i = find_bucket(e.id); + table_t::iterator i = find_bucket(e.id); bucket_t& b = i->live_nodes; bucket_t& rb = i->replacements; diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 15a9be909..51743439c 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -3746,9 +3746,6 @@ namespace libtorrent } p.estimated_reciprocation_rate = m_est_reciprocation_rate; - int upload_capacity = m_ses.settings().upload_rate_limit; - if (upload_capacity == 0) - upload_capacity = (std::max)(20000, m_ses.m_peak_up_rate + 10000); error_code ec; p.local_endpoint = get_socket()->local_endpoint(ec); diff --git a/src/session.cpp b/src/session.cpp index e47e6dfad..089701c1e 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -514,6 +514,9 @@ namespace libtorrent error_code ec; int ret = lazy_bdecode(&buf[0], &buf[0] + buf.size(), e, ec); TORRENT_ASSERT(ret == 0); +#ifndef BOOST_NO_EXCEPTIONS + if (ret != 0) throw libtorrent_exception(ec); +#endif TORRENT_SYNC_CALL1(load_state, &e); } diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index ecc92fb38..5bb231b96 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -545,6 +545,9 @@ 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); +#ifndef BOOST_NO_EXCEPTIONS + if (ret != 0) throw libtorrent_exception(ec); +#endif TORRENT_ASSERT(ret == 0); ptrdiff_t offset = m_info_section.get() - t.m_info_section.get(); @@ -591,7 +594,7 @@ namespace libtorrent if (tmp.size() == 0 || lazy_bdecode(&tmp[0], &tmp[0] + tmp.size(), e, ec) != 0) { #ifndef BOOST_NO_EXCEPTIONS - throw invalid_torrent_file(errors::invalid_bencoding); + throw invalid_torrent_file(ec); #endif return; } diff --git a/src/utp_stream.cpp b/src/utp_stream.cpp index 5b94f187d..2f80fc40e 100644 --- a/src/utp_stream.cpp +++ b/src/utp_stream.cpp @@ -2677,15 +2677,15 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size // within reasonable bounds. The one-way delay is never // higher than the round-trip time. - // it's impossible for delay to be more than the RTT, so make - // sure to clamp it as a sanity check - if (delay > min_rtt) delay = min_rtt; - - // only use the minimum from the last 3 delay measurements - delay = *std::min_element(m_delay_sample_hist, m_delay_sample_hist + num_delay_hist); - if (sample && acked_bytes && prev_bytes_in_flight) { + // it's impossible for delay to be more than the RTT, so make + // sure to clamp it as a sanity check + if (delay > min_rtt) delay = min_rtt; + + // only use the minimum from the last 3 delay measurements + delay = *std::min_element(m_delay_sample_hist, m_delay_sample_hist + num_delay_hist); + do_ledbat(acked_bytes, delay, prev_bytes_in_flight, receive_time); m_send_delay = delay; } diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index b54865e62..9362c8248 100644 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -771,9 +771,6 @@ namespace libtorrent if (!m_requests.empty()) { - range_overlaps_request = in_range.start + in_range.length - > m_requests.front().start + int(m_piece.size()); - if (in_range.start + in_range.length < m_requests.front().start + m_requests.front().length && (m_received_body + recv_buffer.left() >= range_end - range_start)) {