From a42f9e0c63237f9bf1fde030cce91d7735146205 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 22 Aug 2015 00:28:12 +0200 Subject: [PATCH] fix more warnings --- include/libtorrent/bt_peer_connection.hpp | 2 +- include/libtorrent/disk_io_job.hpp | 2 +- src/broadcast_socket.cpp | 1 + src/bt_peer_connection.cpp | 2 +- src/disk_io_job.cpp | 2 +- src/disk_job_pool.cpp | 4 +-- src/http_seed_connection.cpp | 2 +- src/peer_connection.cpp | 8 ++++++ src/peer_connection_handle.cpp | 11 ++++++++ src/peer_list.cpp | 2 +- src/session.cpp | 2 ++ src/session_handle.cpp | 31 +++++++++++++++++++++++ src/session_impl.cpp | 11 ++++++++ src/torrent.cpp | 10 +++++--- src/torrent_handle.cpp | 3 +++ src/udp_socket.cpp | 4 +++ src/udp_tracker_connection.cpp | 2 +- 17 files changed, 87 insertions(+), 12 deletions(-) diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index 46ac8e78f..e94960f71 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -445,7 +445,7 @@ private: char m_reserved_bits[8]; #endif -#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS +#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS bool m_in_constructor; #endif diff --git a/include/libtorrent/disk_io_job.hpp b/include/libtorrent/disk_io_job.hpp index 798c0c06c..28c2b6919 100644 --- a/include/libtorrent/disk_io_job.hpp +++ b/include/libtorrent/disk_io_job.hpp @@ -227,7 +227,7 @@ namespace libtorrent // flags controlling this job boost::uint8_t flags; -#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS +#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS bool in_use:1; // set to true when the job is added to the completion queue. diff --git a/src/broadcast_socket.cpp b/src/broadcast_socket.cpp index 4e7ca3484..ccb90a57e 100644 --- a/src/broadcast_socket.cpp +++ b/src/broadcast_socket.cpp @@ -140,6 +140,7 @@ namespace libtorrent return memcmp(&b[0], teredo_prefix, 4) == 0; } TORRENT_CATCH(std::exception&) { return false; } #else + TORRENT_UNUSED(addr); return false; #endif } diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 4a8722ee6..e9c621041 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -127,7 +127,7 @@ namespace libtorrent , m_dont_have_id(0) , m_share_mode_id(0) #endif -#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS +#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS , m_in_constructor(true) #endif { diff --git a/src/disk_io_job.cpp b/src/disk_io_job.cpp index 621f9d46e..9b6c1b4ed 100644 --- a/src/disk_io_job.cpp +++ b/src/disk_io_job.cpp @@ -43,7 +43,7 @@ namespace libtorrent , action(read) , ret(0) , flags(0) -#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS +#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS , in_use(false) , job_posted(false) , callback_called(false) diff --git a/src/disk_job_pool.cpp b/src/disk_job_pool.cpp index cbddd9967..66a186662 100644 --- a/src/disk_job_pool.cpp +++ b/src/disk_job_pool.cpp @@ -62,7 +62,7 @@ namespace libtorrent new (ptr) disk_io_job; ptr->action = static_cast(type); -#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS +#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS ptr->in_use = true; #endif return ptr; @@ -72,7 +72,7 @@ namespace libtorrent { TORRENT_ASSERT(j); if (j == 0) return; -#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS +#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS TORRENT_ASSERT(j->in_use); j->in_use = false; #endif diff --git a/src/http_seed_connection.cpp b/src/http_seed_connection.cpp index d32a30de1..2479b3a75 100644 --- a/src/http_seed_connection.cpp +++ b/src/http_seed_connection.cpp @@ -255,7 +255,7 @@ namespace libtorrent boost::tie(payload, protocol) = m_parser.incoming(recv_buffer, parse_error); received_bytes(0, protocol); bytes_transferred -= protocol; -#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS +#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS if (payload > front_request.length) payload = front_request.length; #endif diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index c68fe7338..484d02639 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -384,6 +384,8 @@ namespace libtorrent peer_log(peer_log_alert::outgoing, "BIND", "dst: %s ec: %s" , print_endpoint(bound_ip).c_str() , ec.message().c_str()); +#else + TORRENT_UNUSED(bound_ip); #endif if (ec) { @@ -1119,6 +1121,8 @@ namespace libtorrent (*i)->on_piece_pass(index); } TORRENT_CATCH(std::exception&) {} } +#else + TORRENT_UNUSED(index); #endif } @@ -2172,6 +2176,8 @@ namespace libtorrent { if (!(*i)->can_disconnect(ec)) return false; } +#else + TORRENT_UNUSED(ec); #endif return true; } @@ -3083,6 +3089,8 @@ namespace libtorrent #ifndef TORRENT_DISABLE_DHT m_ses.add_dht_node(udp::endpoint( m_remote.address(), listen_port)); +#else + TORRENT_UNUSED(listen_port); #endif } diff --git a/src/peer_connection_handle.cpp b/src/peer_connection_handle.cpp index 37b97ecd0..db27083b2 100644 --- a/src/peer_connection_handle.cpp +++ b/src/peer_connection_handle.cpp @@ -54,6 +54,8 @@ void peer_connection_handle::add_extension(boost::shared_ptr ext) boost::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->add_extension(ext); +#else + TORRENT_UNUSED(ext); #endif } @@ -64,6 +66,7 @@ peer_plugin const* peer_connection_handle::find_plugin(char const* type) TORRENT_ASSERT(pc); return pc->find_plugin(type); #else + TORRENT_UNUSED(type); return NULL; #endif } @@ -228,6 +231,10 @@ void peer_connection_handle::peer_log(peer_log_alert::direction_t direction va_start(v, fmt); pc->peer_log(direction, event, fmt, v); va_end(v); +#else + TORRENT_UNUSED(direction); + TORRENT_UNUSED(event); + TORRENT_UNUSED(fmt); #endif } @@ -304,6 +311,8 @@ void bt_peer_connection_handle::switch_send_crypto(boost::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->switch_send_crypto(crypto); +#else + TORRENT_UNUSED(crypto); #endif } @@ -313,6 +322,8 @@ void bt_peer_connection_handle::switch_recv_crypto(boost::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->switch_recv_crypto(crypto); +#else + TORRENT_UNUSED(crypto); #endif } diff --git a/src/peer_list.cpp b/src/peer_list.cpp index 4c63b444f..7e90e565d 100644 --- a/src/peer_list.cpp +++ b/src/peer_list.cpp @@ -57,7 +57,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bt_peer_connection.hpp" #endif -#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS +#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS #include "libtorrent/socket_io.hpp" // for print_endpoint #endif diff --git a/src/session.cpp b/src/session.cpp index 97eb3627f..84ca2d23f 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -380,6 +380,8 @@ namespace libtorrent add_extension(create_ut_metadata_plugin); add_extension(create_smart_ban_plugin); } +#else + TORRENT_UNUSED(flags); #endif m_impl->start_session(pack); diff --git a/src/session_handle.cpp b/src/session_handle.cpp index 280a780d7..f76bea20a 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -328,6 +328,8 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_DHT TORRENT_ASYNC_CALL1(set_dht_settings, settings); +#else + TORRENT_UNUSED(settings); #endif } @@ -353,6 +355,8 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_DHT TORRENT_ASYNC_CALL1(add_dht_node_name, node); +#else + TORRENT_UNUSED(node); #endif } @@ -360,6 +364,8 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_DHT TORRENT_ASYNC_CALL1(add_dht_router, node); +#else + TORRENT_UNUSED(node); #endif } @@ -367,6 +373,8 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_DHT TORRENT_ASYNC_CALL1(dht_get_immutable_item, target); +#else + TORRENT_UNUSED(target); #endif } @@ -375,6 +383,9 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_DHT TORRENT_ASYNC_CALL2(dht_get_mutable_item, key, salt); +#else + TORRENT_UNUSED(key); + TORRENT_UNUSED(salt); #endif } @@ -397,6 +408,10 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_DHT TORRENT_ASYNC_CALL3(dht_put_mutable_item, key, cb, salt); +#else + TORRENT_UNUSED(key); + TORRENT_UNUSED(cb); + TORRENT_UNUSED(salt); #endif } @@ -404,6 +419,8 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_DHT TORRENT_ASYNC_CALL1(dht_get_peers, info_hash); +#else + TORRENT_UNUSED(info_hash); #endif } @@ -411,6 +428,10 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_DHT TORRENT_ASYNC_CALL3(dht_announce, info_hash, port, flags); +#else + TORRENT_UNUSED(info_hash); + TORRENT_UNUSED(port); + TORRENT_UNUSED(flags); #endif } @@ -418,6 +439,10 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_DHT TORRENT_ASYNC_CALL3(dht_direct_request, ep, e, userdata); +#else + TORRENT_UNUSED(ep); + TORRENT_UNUSED(e); + TORRENT_UNUSED(userdata); #endif } @@ -435,6 +460,8 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_DHT TORRENT_ASYNC_CALL1(start_dht, startup_state); +#else + TORRENT_UNUSED(startup_state); #endif } #endif // TORRENT_NO_DEPRECATE @@ -443,6 +470,8 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_EXTENSIONS TORRENT_ASYNC_CALL1(add_extension, ext); +#else + TORRENT_UNUSED(ext); #endif } @@ -450,6 +479,8 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_EXTENSIONS TORRENT_ASYNC_CALL1(add_ses_extension, ext); +#else + TORRENT_UNUSED(ext); #endif } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 231eb2803..86a80eceb 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -697,6 +697,7 @@ namespace aux { void session_impl::save_state(entry* eptr, boost::uint32_t flags) const { TORRENT_ASSERT(is_single_thread()); + TORRENT_UNUSED(flags); // potentially unused entry& e = *eptr; @@ -2729,6 +2730,8 @@ retry: #ifndef TORRENT_DISABLE_LOGGING session_log(" CLOSING CONNECTION %s : %s" , print_endpoint(p->remote()).c_str(), ec.message().c_str()); +#else + TORRENT_UNUSED(ec); #endif TORRENT_ASSERT(p->is_disconnecting()); @@ -4089,6 +4092,9 @@ retry: return handle.native_handle(); } } +#else + TORRENT_UNUSED(pc); + TORRENT_UNUSED(info_hash); #endif return boost::shared_ptr(); } @@ -6597,6 +6603,11 @@ retry: && i->handler(request.addr, request.message, response)) return true; } +#else + TORRENT_UNUSED(query); + TORRENT_UNUSED(query_len); + TORRENT_UNUSED(request); + TORRENT_UNUSED(response); #endif return false; } diff --git a/src/torrent.cpp b/src/torrent.cpp index 15ce70713..f7782b252 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -928,7 +928,7 @@ namespace libtorrent TORRENT_ASSERT(m_abort); TORRENT_ASSERT(prev == NULL && next == NULL); -#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS +#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS for (int i = 0; i < aux::session_interface::num_torrent_lists; ++i) { if (!m_links[i].in_list()) continue; @@ -2244,6 +2244,8 @@ namespace libtorrent if (!pp) continue; if (was_introduced_by(pp, ep)) return p; } +#else + TORRENT_UNUSED(ep); #endif return NULL; } @@ -4312,6 +4314,8 @@ namespace libtorrent #ifndef TORRENT_DISABLE_LOGGING (*p)->peer_log(peer_log_alert::outgoing, "PREDICTIVE_HAVE", "piece: %d expected in %d ms" , index, milliseconds); +#else + TORRENT_UNUSED(milliseconds); #endif (*p)->announce_piece(index); } @@ -8702,7 +8706,7 @@ namespace libtorrent TORRENT_ASSERT(m_info_hash == m_torrent_file->info_hash()); } -#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS +#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS for (int i = 0; i < aux::session_interface::num_torrent_lists; ++i) { if (!m_links[i].in_list()) continue; @@ -11696,7 +11700,7 @@ namespace libtorrent st->state = static_cast(m_state); -#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS +#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS if (st->state == torrent_status::finished || st->state == torrent_status::seeding) { diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index a5cedfde5..55c040207 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -311,6 +311,9 @@ namespace libtorrent { #ifndef TORRENT_DISABLE_EXTENSIONS TORRENT_ASYNC_CALL2(add_extension, ext, userdata); +#else + TORRENT_UNUSED(ext); + TORRENT_UNUSED(userdata); #endif } diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index cc3368444..16c378729 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -243,6 +243,8 @@ void udp_socket::on_writable(error_code const& ec, udp::socket* s) if (s == &m_ipv6_sock) m_v6_write_subscribed = false; else +#else + TORRENT_UNUSED(s); #endif m_v4_write_subscribed = false; @@ -268,6 +270,8 @@ void udp_socket::on_read(error_code const& ec, udp::socket* s) --m_v6_outstanding; } else +#else + TORRENT_UNUSED(s); #endif { TORRENT_ASSERT(m_v4_outstanding > 0); diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index c6a4df240..92cbb44e6 100644 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -558,7 +558,7 @@ 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 +#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS out += 20; TORRENT_ASSERT(out - buf == sizeof(buf)); #endif