From 71ee44ae5e842df6cea246986fd79d98dbc6940e Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 17 May 2015 23:32:13 +0000 Subject: [PATCH] fix build issue, some warnings --- Jamfile | 14 +++++++------- include/libtorrent/torrent.hpp | 4 ++-- src/alert_manager.cpp | 2 +- src/kademlia/node.cpp | 2 +- src/packet_buffer.cpp | 1 + src/session.cpp | 5 +++-- test/setup_transfer.cpp | 4 ++-- test/setup_transfer.hpp | 2 +- test/test_auto_unchoke.cpp | 2 +- test/test_pe_crypto.cpp | 28 ++++++++++++++-------------- test/test_torrent.cpp | 4 ++-- test/test_utp.cpp | 2 +- test/web_seed_suite.cpp | 6 +++--- update_copyright.py | 7 +++++-- 14 files changed, 44 insertions(+), 39 deletions(-) diff --git a/Jamfile b/Jamfile index 2b9c199f0..442a5ae4c 100755 --- a/Jamfile +++ b/Jamfile @@ -717,7 +717,7 @@ ED25519_SOURCES = verify ; -local usage-requirements = +local usage-requirements = ./include ./include/libtorrent /usr/sfw/include @@ -795,10 +795,10 @@ lib torrent headers = [ path.glob-tree include/libtorrent : *.hpp ] ; package.install install - : libtorrent - on - : - : torrent - : $(headers) - ; + : libtorrent + on + : + : torrent + : $(headers) + ; diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index fce3c8098..8e199c7bd 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -418,11 +418,11 @@ namespace libtorrent aux::session_settings const& settings() const; aux::session_interface& session() { return m_ses; } - + void set_sequential_download(bool sd); bool is_sequential_download() const { return m_sequential_download || m_auto_sequential; } - + void queue_up(); void queue_down(); void set_queue_position(int p); diff --git a/src/alert_manager.cpp b/src/alert_manager.cpp index b94b61bc7..39ba6b039 100644 --- a/src/alert_manager.cpp +++ b/src/alert_manager.cpp @@ -62,7 +62,7 @@ namespace libtorrent if (!m_alerts[m_generation].empty()) return m_alerts[m_generation].front(); - + // this call can be interrupted prematurely by other signals m_condition.wait_for(lock, max_wait); if (!m_alerts[m_generation].empty()) diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index 0c71b339a..8f4f1ac6c 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -531,7 +531,7 @@ void node::send_single_refresh(udp::endpoint const& ep, int bucket node_id target = generate_secret_id() & ~mask; target |= m_id & mask; - // create a dummy traversal_algorithm + // create a dummy traversal_algorithm // this is unfortunately necessary for the observer // to free itself from the pool when it's being released boost::intrusive_ptr algo( diff --git a/src/packet_buffer.cpp b/src/packet_buffer.cpp index 37e9b7f6c..512d015fb 100644 --- a/src/packet_buffer.cpp +++ b/src/packet_buffer.cpp @@ -31,6 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. */ #include // free and calloc +#include // for bad_alloc #include "libtorrent/packet_buffer.hpp" #include "libtorrent/assert.hpp" #include "libtorrent/invariant_check.hpp" diff --git a/src/session.cpp b/src/session.cpp index d3ce7495b..0a13134ff 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -72,6 +72,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/natpmp.hpp" #include "libtorrent/upnp.hpp" #include "libtorrent/magnet_uri.hpp" +#include "libtorrent/lazy_entry.hpp" #ifdef TORRENT_PROFILE_CALLS #include @@ -876,7 +877,7 @@ namespace libtorrent std::vector buf; bencode(std::back_inserter(buf), data); sha1_hash ret = hasher(&buf[0], buf.size()).final(); - + #ifndef TORRENT_DISABLE_DHT TORRENT_ASYNC_CALL2(dht_put_item, data, ret); #endif @@ -1046,7 +1047,7 @@ namespace libtorrent apply_settings(pack); } - + proxy_settings session::i2p_proxy() const { proxy_settings ret; diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 871e6b919..4d388ba1f 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -122,12 +122,12 @@ int print_failures() return tests_failure; } -std::map get_counters(libtorrent::session& s) +std::map get_counters(libtorrent::session& s) { using namespace libtorrent; s.post_session_stats(); - std::map ret; + std::map ret; alert const* a = wait_for_alert(s, session_stats_alert::alert_type , "get_counters()"); diff --git a/test/setup_transfer.hpp b/test/setup_transfer.hpp index 1e3efca6e..a98669856 100644 --- a/test/setup_transfer.hpp +++ b/test/setup_transfer.hpp @@ -58,7 +58,7 @@ EXPORT libtorrent::address rand_v6(); EXPORT libtorrent::tcp::endpoint rand_tcp_ep(); EXPORT libtorrent::udp::endpoint rand_udp_ep(); -EXPORT std::map get_counters(libtorrent::session& s); +EXPORT std::map get_counters(libtorrent::session& s); EXPORT libtorrent::alert const* wait_for_alert( libtorrent::session& ses, int type, char const* name = ""); diff --git a/test/test_auto_unchoke.cpp b/test/test_auto_unchoke.cpp index e7c6d1f75..13983ab5d 100644 --- a/test/test_auto_unchoke.cpp +++ b/test/test_auto_unchoke.cpp @@ -94,7 +94,7 @@ void test_swarm() boost::tie(tor1, tor2, tor3) = setup_transfer(&ses1, &ses2, &ses3, true, false, true, "_unchoke"); - std::map cnt = get_counters(ses1); + std::map cnt = get_counters(ses1); fprintf(stderr, "allowed_upload_slots: %d\n", int(cnt["ses.num_unchoke_slots"])); TEST_EQUAL(cnt["ses.num_unchoke_slots"], 1); diff --git a/test/test_pe_crypto.cpp b/test/test_pe_crypto.cpp index 43a512501..a13cd6166 100644 --- a/test/test_pe_crypto.cpp +++ b/test/test_pe_crypto.cpp @@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. char const* pe_policy(boost::uint8_t policy) { using namespace libtorrent; - + if (policy == settings_pack::pe_disabled) return "disabled"; else if (policy == settings_pack::pe_enabled) return "enabled"; else if (policy == settings_pack::pe_forced) return "forced"; @@ -56,11 +56,11 @@ char const* pe_policy(boost::uint8_t policy) void display_settings(libtorrent::settings_pack const& s) { using namespace libtorrent; - + fprintf(stderr, "out_enc_policy - %s\tin_enc_policy - %s\n" , pe_policy(s.get_int(settings_pack::out_enc_policy)) , pe_policy(s.get_int(settings_pack::in_enc_policy))); - + fprintf(stderr, "enc_level - %s\t\tprefer_rc4 - %s\n" , s.get_int(settings_pack::allowed_enc_level) == settings_pack::pe_plaintext ? "plaintext" : s.get_int(settings_pack::allowed_enc_level) == settings_pack::pe_rc4 ? "rc4" @@ -85,7 +85,7 @@ void test_transfer(libtorrent::settings_pack::enc_policy policy lt::session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48800, 49000), "0.0.0.0", 0); lt::session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49800, 50000), "0.0.0.0", 0); settings_pack s; - + s.set_int(settings_pack::out_enc_policy, settings_pack::pe_enabled); s.set_int(settings_pack::in_enc_policy, settings_pack::pe_enabled); s.set_int(settings_pack::allowed_enc_level, settings_pack::pe_both); @@ -108,7 +108,7 @@ void test_transfer(libtorrent::settings_pack::enc_policy policy using boost::tuples::ignore; boost::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, 0, true, false, true - , "_pe", 16 * 1024, 0, false, 0, true); + , "_pe", 16 * 1024, 0, false, 0, true); fprintf(stderr, "waiting for transfer to complete\n"); @@ -123,7 +123,7 @@ void test_transfer(libtorrent::settings_pack::enc_policy policy } TEST_CHECK(tor2.status().is_seeding); - if (tor2.status().is_seeding) fprintf(stderr, "done\n"); + if (tor2.status().is_seeding) fprintf(stderr, "done\n"); ses1.remove_torrent(tor1); ses2.remove_torrent(tor2); @@ -146,13 +146,13 @@ void test_enc_handler(libtorrent::crypto_plugin* a, libtorrent::crypto_plugin* b #endif for (int rep = 0; rep < repcount; ++rep) { - std::size_t buf_len = rand() % (512 * 1024); + int buf_len = rand() % (512 * 1024); char* buf = new char[buf_len]; char* cmp_buf = new char[buf_len]; - + std::generate(buf, buf + buf_len, &std::rand); std::memcpy(cmp_buf, buf, buf_len); - + using namespace boost::asio; std::vector iovec; iovec.push_back(mutable_buffer(buf, buf_len)); @@ -169,7 +169,7 @@ void test_enc_handler(libtorrent::crypto_plugin* a, libtorrent::crypto_plugin* b TEST_EQUAL(consume, 0); TEST_EQUAL(produce, buf_len); TEST_EQUAL(packet_size, 0); - + iovec.push_back(mutable_buffer(buf, buf_len)); b->encrypt(iovec); TEST_CHECK(!std::equal(buf, buf + buf_len, cmp_buf)); @@ -184,7 +184,7 @@ void test_enc_handler(libtorrent::crypto_plugin* a, libtorrent::crypto_plugin* b TEST_EQUAL(consume, 0); TEST_EQUAL(produce, buf_len); TEST_EQUAL(packet_size, 0); - + delete[] buf; delete[] cmp_buf; } @@ -207,10 +207,10 @@ int test_main() for (int rep = 0; rep < repcount; ++rep) { dh_key_exchange DH1, DH2; - + DH1.compute_secret(DH2.get_local_key()); DH2.compute_secret(DH1.get_local_key()); - + TEST_CHECK(std::equal(DH1.get_secret(), DH1.get_secret() + 96, DH2.get_secret())); } @@ -231,7 +231,7 @@ int test_main() rc42.set_incoming_key(&test1_key[0], 20); rc42.set_outgoing_key(&test2_key[0], 20); test_enc_handler(&rc41, &rc42); - + #ifdef TORRENT_USE_VALGRIND const int timeout = 10; #else diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 3e91de1e6..76152fd4b 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -90,7 +90,7 @@ void test_running_torrent(boost::shared_ptr info, boost::int64_t f TEST_EQUAL(st.total_wanted, file_size * 2); TEST_EQUAL(st.total_wanted_done, 0); - TEST_EQUAL(h.file_priorities().size(), info->num_files()); + TEST_EQUAL(int(h.file_priorities().size()), info->num_files()); if (!st.is_seeding) { TEST_EQUAL(h.file_priorities()[0], 0); @@ -261,7 +261,7 @@ int test_main() for (int i = 0; i < fp.size(); ++i) sum += fp[i]; - TEST_EQUAL(sum, fs.piece_size(idx)); + TEST_EQUAL(int(sum), fs.piece_size(idx)); } } diff --git a/test/test_utp.cpp b/test/test_utp.cpp index 26234e8d1..67961db42 100644 --- a/test/test_utp.cpp +++ b/test/test_utp.cpp @@ -133,7 +133,7 @@ int test_main() using namespace libtorrent; test_transfer(); - + error_code ec; remove_all("./tmp1_utp", ec); remove_all("./tmp2_utp", ec); diff --git a/test/web_seed_suite.cpp b/test/web_seed_suite.cpp index ac70abad7..cf7f00ed0 100644 --- a/test/web_seed_suite.cpp +++ b/test/web_seed_suite.cpp @@ -105,7 +105,7 @@ void test_transfer(lt::session& ses, boost::shared_ptr torrent_fil , keepalive ? "yes" : "no"); int proxy_port = 0; - + if (proxy) { proxy_port = start_proxy(proxy); @@ -160,7 +160,7 @@ void test_transfer(lt::session& ses, boost::shared_ptr torrent_fil } peer_disconnects = 0; - std::map cnt = get_counters(ses); + std::map cnt = get_counters(ses); for (int i = 0; i < 40; ++i) { @@ -395,7 +395,7 @@ int EXPORT run_http_suite(int proxy, char const* protocol, bool test_url_seed test_transfer(ses, torrent_file, proxy, port, protocol, test_url_seed , chunked_encoding, test_ban, keepalive); - + if (test_url_seed && test_rename) { torrent_file->rename_file(0, combine_path(save_path, combine_path("torrent_dir", "renamed_test1"))); diff --git a/update_copyright.py b/update_copyright.py index 3d2c4e4c4..aa498a3a2 100644 --- a/update_copyright.py +++ b/update_copyright.py @@ -24,8 +24,11 @@ def update_file(name): f.close() open(name, 'w+').write(subst) -for i in glob.glob('src/*.cpp') + glob.glob('include/libtorrent/*.hpp') + \ - glob.glob('include/libtorrent/kademlia/*.hpp') + glob.glob('src/kademlia/*.cpp') + \ +for i in glob.glob('src/*.cpp') + \ + glob.glob('include/libtorrent/*.hpp') + \ + glob.glob('include/libtorrent/extensions/*.hpp') + \ + glob.glob('include/libtorrent/kademlia/*.hpp') + \ + glob.glob('src/kademlia/*.cpp') + \ ['COPYING', 'LICENSE']: update_file(i)