diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 144a540d5..95e1b332d 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1557,7 +1557,7 @@ int main(int argc, char* argv[]) int c = 0; while (sleep_and_input(&c, refresh_delay)) { - if (c == EOF) { c = 'q'; break; } + if (c == EOF) { break; } if (c == 27) { // escape code, read another character @@ -1566,7 +1566,7 @@ int main(int argc, char* argv[]) #else int c = getc(stdin); #endif - if (c == EOF) { c = 'q'; break; } + if (c == EOF) { break; } if (c != '[') continue; #ifdef _WIN32 c = _getch(); diff --git a/src/GeoIP.c b/src/GeoIP.c index 3b6f223d3..cb4437ee7 100644 --- a/src/GeoIP.c +++ b/src/GeoIP.c @@ -287,11 +287,11 @@ void _setup_segments(GeoIP * gi) { if (gi->databaseType == GEOIP_REGION_EDITION_REV0) { /* Region Edition, pre June 2003 */ - gi->databaseSegments = (unsigned int*)malloc(sizeof(int)); + gi->databaseSegments = (unsigned int*)malloc(sizeof(unsigned int)); gi->databaseSegments[0] = STATE_BEGIN_REV0; } else if (gi->databaseType == GEOIP_REGION_EDITION_REV1) { /* Region Edition, post June 2003 */ - gi->databaseSegments = (unsigned int*)malloc(sizeof(int)); + gi->databaseSegments = (unsigned int*)malloc(sizeof(unsigned int)); gi->databaseSegments[0] = STATE_BEGIN_REV1; } else if (gi->databaseType == GEOIP_CITY_EDITION_REV0 || gi->databaseType == GEOIP_CITY_EDITION_REV1 || @@ -299,7 +299,7 @@ void _setup_segments(GeoIP * gi) { gi->databaseType == GEOIP_ISP_EDITION || gi->databaseType == GEOIP_ASNUM_EDITION) { /* City/Org Editions have two segments, read offset of second segment */ - gi->databaseSegments = (unsigned int*)malloc(sizeof(int)); + gi->databaseSegments = (unsigned int*)malloc(sizeof(unsigned int)); gi->databaseSegments[0] = 0; fread(buf, SEGMENT_RECORD_LENGTH, 1, gi->GeoIPDatabase); for (j = 0; j < SEGMENT_RECORD_LENGTH; j++) { @@ -317,7 +317,7 @@ void _setup_segments(GeoIP * gi) { if (gi->databaseType == GEOIP_COUNTRY_EDITION || gi->databaseType == GEOIP_PROXY_EDITION || gi->databaseType == GEOIP_NETSPEED_EDITION) { - gi->databaseSegments = (unsigned int*)malloc(sizeof(int)); + gi->databaseSegments = (unsigned int*)malloc(sizeof(unsigned int)); gi->databaseSegments[0] = COUNTRY_BEGIN; } } diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index c0907cf18..73f27c29c 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -2008,7 +2008,6 @@ namespace libtorrent lazy_pieces[lazy_piece++] = i; } TORRENT_ASSERT(lazy_piece == num_lazy_pieces); - lazy_piece = 0; } const int packet_size = (num_pieces + 7) / 8 + 5; @@ -3063,7 +3062,7 @@ namespace libtorrent { TORRENT_ASSERT(m_sent_handshake); m_statistics.received_bytes(0, bytes_transferred); - bytes_transferred = 0; +// bytes_transferred = 0; if (!t) { TORRENT_ASSERT(!packet_finished()); // TODO diff --git a/src/http_parser.cpp b/src/http_parser.cpp index 9215e90ae..1c48d78f7 100644 --- a/src/http_parser.cpp +++ b/src/http_parser.cpp @@ -309,7 +309,7 @@ restart_response: { m_recv_pos += incoming; boost::get<0>(ret) += incoming; - incoming = 0; +// incoming = 0; } } else diff --git a/src/http_seed_connection.cpp b/src/http_seed_connection.cpp index 7506fa6c7..0fd86fedc 100644 --- a/src/http_seed_connection.cpp +++ b/src/http_seed_connection.cpp @@ -245,7 +245,9 @@ namespace libtorrent boost::tie(payload, protocol) = m_parser.incoming(recv_buffer, parse_error); m_statistics.received_bytes(0, protocol); bytes_transferred -= protocol; +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS if (payload > front_request.length) payload = front_request.length; +#endif if (parse_error) { diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index 6b5ea70d2..b6feaef98 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -575,6 +575,10 @@ bool verify_message(lazy_entry const* msg, key_desc_t const desc[], lazy_entry c else if (k.flags & key_desc_t::last_child) { TORRENT_ASSERT(stack_ptr > 0); + // this can happen if the specification passed + // in is unbalanced. i.e. contain more last_child + // nodes than parse_children + if (stack_ptr == 0) return false; --stack_ptr; msg = stack[stack_ptr]; } diff --git a/src/kademlia/routing_table.cpp b/src/kademlia/routing_table.cpp index 7da591a0c..f9bc312a0 100644 --- a/src/kademlia/routing_table.cpp +++ b/src/kademlia/routing_table.cpp @@ -413,12 +413,14 @@ bool routing_table::add_node(node_entry e) i != end; ++i) { if (i->addr() != e.addr() || i->port() != e.port()) continue; - #ifdef TORRENT_DHT_VERBOSE_LOGGING +#ifdef TORRENT_DHT_VERBOSE_LOGGING TORRENT_LOG(table) << "node ID changed, deleting old entry: " << i->id << " " << i->addr(); - #endif +#endif b.erase(i); +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS done = true; +#endif break; } if (!done) @@ -427,12 +429,14 @@ bool routing_table::add_node(node_entry e) i != end; ++i) { if (i->addr() != e.addr() || i->port() != e.port()) continue; - #ifdef TORRENT_DHT_VERBOSE_LOGGING +#ifdef TORRENT_DHT_VERBOSE_LOGGING TORRENT_LOG(table) << "node ID changed, deleting old entry: " << i->id << " " << i->addr(); - #endif +#endif rb.erase(i); +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS done = true; +#endif break; } } diff --git a/src/session.cpp b/src/session.cpp index 608b5541b..1060b61fc 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -540,7 +540,11 @@ namespace libtorrent bencode(std::back_inserter(buf), ses_state); lazy_entry e; error_code ec; - int ret = lazy_bdecode(&buf[0], &buf[0] + buf.size(), e, ec); +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS + int ret = +#endif + 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); diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index d01928f82..df4d41fab 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -590,7 +590,10 @@ namespace libtorrent error_code ec; m_info_section.reset(new char[m_info_section_size]); 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() +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS + int ret = +#endif + 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); diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index aee2c44f0..22380721f 100644 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -490,8 +490,10 @@ namespace libtorrent detail::write_int32(m_transaction_id, out); // transaction_id // info_hash std::copy(tracker_req().info_hash.begin(), tracker_req().info_hash.end(), out); +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS out += 20; TORRENT_ASSERT(out - buf == sizeof(buf)); +#endif error_code ec; if (!m_hostname.empty()) diff --git a/src/utp_stream.cpp b/src/utp_stream.cpp index ebc8df974..47f94cd97 100644 --- a/src/utp_stream.cpp +++ b/src/utp_stream.cpp @@ -3176,7 +3176,6 @@ void utp_socket_impl::tick(ptime const& now) , this, socket_state_names[m_state], m_read, m_read_handler ? "handler" : "no handler" , m_written, m_write_handler ? "handler" : "no handler"); #endif - bool window_opened = false; TORRENT_ASSERT(m_outbuf.at((m_acked_seq_nr + 1) & ACK_MASK) || ((m_seq_nr - m_acked_seq_nr) & ACK_MASK) <= 1);