From 5a23d04143a63d91115e66fab6b03ba17efc5511 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 18 Feb 2012 08:23:48 +0000 Subject: [PATCH] fix some clang warnings --- include/libtorrent/bt_peer_connection.hpp | 3 ++- src/bt_peer_connection.cpp | 5 ++++- src/logger.cpp | 4 ++-- src/sha1.cpp | 4 ++++ src/torrent.cpp | 12 ++++++------ test/setup_transfer.cpp | 1 - test/test_bdecode_performance.cpp | 2 +- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index e1f41d626..c3c1897f7 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -294,7 +294,8 @@ public: // is true, otherwise it passes the call to the // peer_connection functions of the same names virtual void append_const_send_buffer(char const* buffer, int size); - void send_buffer(char const* buf, int size, int flags = 0); + virtual void send_buffer(char const* begin, int size, int flags = 0 + , void (*fun)(char*, int, void*) = 0, void* userdata = 0); template void append_send_buffer(char* buffer, int size, Destructor const& destructor) { diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index feea2bbd6..c28a3df09 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -668,8 +668,11 @@ namespace libtorrent rc4->encrypt(buf, len); } - void bt_peer_connection::send_buffer(char const* buf, int size, int flags) + void bt_peer_connection::send_buffer(char const* buf, int size, int flags + , void (*f)(char*, int, void*), void* ud) { + TORRENT_ASSERT(f == 0); + TORRENT_ASSERT(ud == 0); TORRENT_ASSERT(buf); TORRENT_ASSERT(size > 0); diff --git a/src/logger.cpp b/src/logger.cpp index 55f844230..31b7b122d 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -140,7 +140,7 @@ namespace return false; } - virtual bool on_bitfield(std::vector const& bitfield) + virtual bool on_bitfield(bitfield const& bitfield_) { log_timestamp(); m_file << "<== BITFIELD\n"; @@ -157,7 +157,7 @@ namespace return false; } - virtual bool on_piece(peer_request const& r, char const*) + virtual bool on_piece(peer_request const& r, disk_buffer_holder& data) { log_timestamp(); m_file << "<== PIECE [ piece: " << r.piece << " | s: " << r.start diff --git a/src/sha1.cpp b/src/sha1.cpp index e9d90006e..e5b668691 100644 --- a/src/sha1.cpp +++ b/src/sha1.cpp @@ -127,6 +127,7 @@ namespace a = b = c = d = e = 0; } +#ifdef VERBOSE void SHAPrintContext(SHA_CTX *context, char *msg) { using namespace std; @@ -139,6 +140,7 @@ namespace , (unsigned int)context->state[3] , (unsigned int)context->state[4]); } +#endif template void internal_update(SHA_CTX* context, u8 const* data, u32 len) @@ -172,11 +174,13 @@ namespace #endif } +#if !defined __BIG_ENDIAN__ && !defined __LITTLE_ENDIAN__ bool is_big_endian() { u32 test = 1; return *reinterpret_cast(&test) == 0; } +#endif } // SHA1Init - Initialize new context diff --git a/src/torrent.cpp b/src/torrent.cpp index 9aebcc689..65d5cb2d2 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -394,14 +394,14 @@ namespace libtorrent , m_need_save_resume_data(true) , m_seeding_time(0) , m_time_scaler(0) - , m_max_uploads(~0) + , m_max_uploads((1<<24)-1) , m_deficit_counter(0) , m_num_uploads(0) , m_block_size_shift(root2(block_size)) , m_has_incoming(false) , m_files_checked(false) , m_queued_for_checking(false) - , m_max_connections(~0) + , m_max_connections((1<<24)-1) , m_padding(0) , m_complete(0xffffff) , m_priority(0) @@ -6452,7 +6452,7 @@ namespace libtorrent { TORRENT_ASSERT(m_ses.is_network_thread()); TORRENT_ASSERT(limit >= -1); - if (limit <= 0) limit = (std::numeric_limits::max)(); + if (limit <= 0) limit = (1<<24)-1; if (m_max_uploads != limit) state_updated(); m_max_uploads = limit; } @@ -6461,7 +6461,7 @@ namespace libtorrent { TORRENT_ASSERT(m_ses.is_network_thread()); TORRENT_ASSERT(limit >= -1); - if (limit <= 0) limit = (std::numeric_limits::max)(); + if (limit <= 0) limit = (1<<24)-1; if (m_max_connections != limit) state_updated(); m_max_connections = limit; @@ -8176,9 +8176,9 @@ namespace libtorrent } st->num_uploads = m_num_uploads; - st->uploads_limit = m_max_uploads; + st->uploads_limit = m_max_uploads == (1<<24)-1 ? -1 : m_max_uploads; st->num_connections = int(m_connections.size()); - st->connections_limit = m_max_connections; + st->connections_limit = m_max_connections == (1<<24)-1 ? -1 : m_max_connections; // if we don't have any metadata, stop here st->queue_position = queue_position(); diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 3441ac155..80ec4518f 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -335,7 +335,6 @@ setup_transfer(session* ses1, session* ses2, session* ses3 // they should not use the same save dir, because the // file pool will complain if two torrents are trying to // use the same files - sha1_hash info_hash = t->info_hash(); add_torrent_params param; param.paused = false; param.auto_managed = false; diff --git a/test/test_bdecode_performance.cpp b/test/test_bdecode_performance.cpp index b726bdd77..6b34bb8c5 100644 --- a/test/test_bdecode_performance.cpp +++ b/test/test_bdecode_performance.cpp @@ -18,7 +18,7 @@ int test_main() char b[] = "d1:ai12453e1:b3:aaa1:c3:bbbe"; lazy_entry e; error_code ec; - int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec); + lazy_bdecode(b, b + sizeof(b)-1, e, ec); } ptime stop(time_now());