diff --git a/include/libtorrent/disk_io_job.hpp b/include/libtorrent/disk_io_job.hpp index df12b4c58..2f576fd89 100644 --- a/include/libtorrent/disk_io_job.hpp +++ b/include/libtorrent/disk_io_job.hpp @@ -53,7 +53,7 @@ namespace libtorrent class piece_manager; struct cached_piece_entry; struct bdecode_node; - struct torrent_info; + class torrent_info; struct block_cache_reference { diff --git a/include/libtorrent/identify_client.hpp b/include/libtorrent/identify_client.hpp index c16f8944b..575d89701 100644 --- a/include/libtorrent/identify_client.hpp +++ b/include/libtorrent/identify_client.hpp @@ -53,15 +53,16 @@ namespace libtorrent // This function can can be used to extract a string describing a client // version from its peer-id. It will recognize most clients that have this // kind of identification in the peer-id. - TORRENT_DEPRECATED_EXPORT std::string identify_client(const peer_id& p) - TORRENT_DEPRECATED; + TORRENT_DEPRECATED_EXPORT TORRENT_DEPRECATED + std::string identify_client(const peer_id& p); // Returns an optional fingerprint if any can be identified from the peer // id. This can be used to automate the identification of clients. It will // not be able to identify peers with non- standard encodings. Only Azureus // style, Shadow's style and Mainline style. - TORRENT_DEPRECATED_EXPORT boost::optional - client_fingerprint(peer_id const& p) TORRENT_DEPRECATED; + TORRENT_DEPRECATED_EXPORT TORRENT_DEPRECATED + boost::optional + client_fingerprint(peer_id const& p); } diff --git a/include/libtorrent/kademlia/node.hpp b/include/libtorrent/kademlia/node.hpp index 75791856e..d5761ea36 100644 --- a/include/libtorrent/kademlia/node.hpp +++ b/include/libtorrent/kademlia/node.hpp @@ -176,12 +176,12 @@ public: struct count_peers { - int& count; - count_peers(int& c): count(c) {} + int* count; + count_peers(int* c): count(c) {} void operator()(std::pair const& t) { - count += t.second.peers.size(); + *count += t.second.peers.size(); } }; @@ -218,7 +218,7 @@ public: int num_peers() const { int ret = 0; - std::for_each(m_map.begin(), m_map.end(), count_peers(ret)); + std::for_each(m_map.begin(), m_map.end(), count_peers(&ret)); return ret; } diff --git a/test/main.cpp b/test/main.cpp index ff1da30e0..cbb165d32 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -49,6 +49,11 @@ POSSIBILITY OF SUCH DAMAGE. #ifdef WIN32 #include // fot SetErrorMode +#include // for _dup and _dup2 + +#define dup _dup +#define dup2 _dup2 + #endif using namespace libtorrent; diff --git a/test/test_auto_unchoke.cpp b/test/test_auto_unchoke.cpp index 16951ef5b..3134b04c7 100644 --- a/test/test_auto_unchoke.cpp +++ b/test/test_auto_unchoke.cpp @@ -149,7 +149,5 @@ TORRENT_TEST(auto_unchoke) remove_all("./tmp1_unchoke", ec); remove_all("./tmp2_unchoke", ec); remove_all("./tmp3_unchoke", ec); - - return 0; } diff --git a/test/test_checking.cpp b/test/test_checking.cpp index 7150405c7..53180e685 100644 --- a/test/test_checking.cpp +++ b/test/test_checking.cpp @@ -282,7 +282,5 @@ TORRENT_TEST(checking) test_checking(read_only_files); test_checking(incomplete_files); test_checking(corrupt_files); - - return 0; } diff --git a/test/test_fast_extension.cpp b/test/test_fast_extension.cpp index 56eec299a..a1614a35d 100644 --- a/test/test_fast_extension.cpp +++ b/test/test_fast_extension.cpp @@ -795,7 +795,5 @@ TORRENT_TEST(fast_extension) test_multiple_have_all(); test_dont_have(); test_invalid_metadata_requests(); - - return 0; } diff --git a/test/test_http_connection.cpp b/test/test_http_connection.cpp index 013613304..c4a82eedc 100644 --- a/test/test_http_connection.cpp +++ b/test/test_http_connection.cpp @@ -244,6 +244,5 @@ TORRENT_TEST(http_parser) stop_web_server(); std::remove("test_file"); - return 0; } diff --git a/test/test_lsd.cpp b/test/test_lsd.cpp index 66415d0e9..be1a4458a 100644 --- a/test/test_lsd.cpp +++ b/test/test_lsd.cpp @@ -109,8 +109,6 @@ TORRENT_TEST(lsd) remove_all("./tmp1_lsd", ec); remove_all("./tmp2_lsd", ec); remove_all("./tmp3_lsd", ec); - - return 0; } diff --git a/test/test_metadata_extension.cpp b/test/test_metadata_extension.cpp index 81ca6b28d..4b61cc656 100644 --- a/test/test_metadata_extension.cpp +++ b/test/test_metadata_extension.cpp @@ -232,7 +232,5 @@ TORRENT_TEST(metadata_extension) remove_all("tmp2", ec); #endif // TORRENT_NO_DEPRECATE - - return 0; } diff --git a/test/test_pe_crypto.cpp b/test/test_pe_crypto.cpp index 65a990efc..64a254f14 100644 --- a/test/test_pe_crypto.cpp +++ b/test/test_pe_crypto.cpp @@ -252,7 +252,5 @@ TORRENT_TEST(test_pe_crypto) #else fprintf(stderr, "PE test not run because it's disabled\n"); #endif - - return 0; } diff --git a/test/test_peer_classes.cpp b/test/test_peer_classes.cpp index 60d13e3f1..d81d3ec84 100644 --- a/test/test_peer_classes.cpp +++ b/test/test_peer_classes.cpp @@ -112,6 +112,5 @@ TORRENT_TEST(peer_class) pool.decref(id1); TEST_CHECK(pool.at(id2) == NULL); TEST_CHECK(pool.at(id1) == NULL); - return 0; } diff --git a/test/test_pex.cpp b/test/test_pex.cpp index 4fc32dbc7..23820f533 100644 --- a/test/test_pex.cpp +++ b/test/test_pex.cpp @@ -160,11 +160,9 @@ TORRENT_TEST(pex) remove_all("tmp1_pex", ec); remove_all("tmp2_pex", ec); remove_all("tmp3_pex", ec); - - return 0; } #else -TORRENT_TEST(pex) { return 0; } +TORRENT_TEST(pex) {} #endif // TORRENT_DISABLE_EXTENSIONS diff --git a/test/test_primitives.cpp b/test/test_primitives.cpp index c839f515f..ea63602f3 100644 --- a/test/test_primitives.cpp +++ b/test/test_primitives.cpp @@ -270,6 +270,5 @@ TORRENT_TEST(primitives) // test endpoint_to_bytes TEST_EQUAL(endpoint_to_bytes(udp::endpoint(address_v4::from_string("10.11.12.13"), 8080)), "\x0a\x0b\x0c\x0d\x1f\x90"); TEST_EQUAL(endpoint_to_bytes(udp::endpoint(address_v4::from_string("16.5.127.1"), 12345)), "\x10\x05\x7f\x01\x30\x39"); - return 0; } diff --git a/test/test_priority.cpp b/test/test_priority.cpp index 656c27fc6..6ede7d42e 100644 --- a/test/test_priority.cpp +++ b/test/test_priority.cpp @@ -424,8 +424,6 @@ TORRENT_TEST(priority) // we have to clear them, session doesn't really support being destructed // as a global destructor (for silly reasons) sp.clear(); - - return 0; } diff --git a/test/test_privacy.cpp b/test/test_privacy.cpp index ef892e360..62e28f324 100644 --- a/test/test_privacy.cpp +++ b/test/test_privacy.cpp @@ -268,6 +268,5 @@ TORRENT_TEST(privacy) pr[11] = test_proxy(settings_pack::http, force_proxy_mode | expect_udp_reject); pr[12] = test_proxy(settings_pack::http_pw, force_proxy_mode | expect_udp_reject); pr[13] = test_proxy(settings_pack::i2p_proxy, force_proxy_mode); - return 0; } diff --git a/test/test_read_piece.cpp b/test/test_read_piece.cpp index 37122eeb5..51f691f86 100644 --- a/test/test_read_piece.cpp +++ b/test/test_read_piece.cpp @@ -138,6 +138,5 @@ TORRENT_TEST(read_piece) test_read_piece(0); test_read_piece(seed_mode); test_read_piece(time_critical); - return 0; } diff --git a/test/test_recheck.cpp b/test/test_recheck.cpp index 51b404096..cb7777513 100644 --- a/test/test_recheck.cpp +++ b/test/test_recheck.cpp @@ -63,7 +63,7 @@ void wait_for_complete(lt::session& ses, torrent_handle h) if (st.progress_ppm == 1000000) return; test_sleep(500); } - TEST_CHECK(false); + TEST_ERROR("torrent did not finish"); } TORRENT_TEST(recheck) @@ -98,6 +98,4 @@ TORRENT_TEST(recheck) st1 = tor1.status(); TEST_CHECK(st1.progress_ppm <= 1000000); wait_for_complete(ses1, tor1); - - return 0; } diff --git a/test/test_remap_files.cpp b/test/test_remap_files.cpp index 277e4d99b..13298d2aa 100644 --- a/test/test_remap_files.cpp +++ b/test/test_remap_files.cpp @@ -520,7 +520,5 @@ TORRENT_TEST(remap_files) remove_all("tmp2_remap2", ec); remove_all("tmp1_remap3", ec); remove_all("tmp2_remap3", ec); - - return 0; } diff --git a/test/test_resume.cpp b/test/test_resume.cpp index 41b797b73..918537834 100644 --- a/test/test_resume.cpp +++ b/test/test_resume.cpp @@ -340,7 +340,6 @@ TORRENT_TEST(resume) // TODO: test all other resume flags here too. This would require returning // more than just the torrent_status from test_resume_flags. Also http seeds // and trackers for instance - return 0; } diff --git a/test/test_session.cpp b/test/test_session.cpp index f46594a91..145a468f0 100644 --- a/test/test_session.cpp +++ b/test/test_session.cpp @@ -86,6 +86,5 @@ TORRENT_TEST(session) // for the asynchronous call to set the alert // mask completes, before it goes on to destruct // the session object - return 0; } diff --git a/test/test_ssl.cpp b/test/test_ssl.cpp index 9f20cdd45..baad4b756 100644 --- a/test/test_ssl.cpp +++ b/test/test_ssl.cpp @@ -596,7 +596,6 @@ TORRENT_TEST(ssl) remove_all("tmp2_ssl", ec); #endif // TORRENT_USE_OPENSSL - return 0; } diff --git a/test/test_stat_cache.cpp b/test/test_stat_cache.cpp index 3c5bb5e40..2e6117252 100644 --- a/test/test_stat_cache.cpp +++ b/test/test_stat_cache.cpp @@ -76,6 +76,5 @@ TORRENT_TEST(stat_cache) TEST_CHECK(sc.get_filesize(14) == stat_cache::not_in_cache); TEST_CHECK(sc.get_filesize(15) == 1000); TEST_CHECK(sc.get_filetime(15) == 3000); - return 0; } diff --git a/test/test_storage.cpp b/test/test_storage.cpp index 0640960d9..57d710b65 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -838,7 +838,7 @@ void free_iov(file::iovec_t* iov, int num_bufs) } } -void test_iovec_copy_bufs() +TORRENT_TEST(iovec_copy_bufs) { file::iovec_t iov1[10]; file::iovec_t iov2[10]; @@ -869,7 +869,7 @@ void test_iovec_copy_bufs() free_iov(iov1, 10); } -void test_iovec_clear_bufs() +TORRENT_TEST(iovec_clear_bufs) { file::iovec_t iov[10]; alloc_iov(iov, 10); @@ -887,7 +887,7 @@ void test_iovec_clear_bufs() free_iov(iov, 10); } -void test_iovec_bufs_size() +TORRENT_TEST(iovec_bufs_size) { file::iovec_t iov[10]; @@ -903,7 +903,7 @@ void test_iovec_bufs_size() } } -void test_iovec_advance_bufs() +TORRENT_TEST(iovec_advance_bufs) { file::iovec_t iov1[10]; file::iovec_t iov2[10]; @@ -936,13 +936,6 @@ void test_iovec_advance_bufs() TORRENT_TEST(storage) { - test_iovec_copy_bufs(); - test_iovec_clear_bufs(); - test_iovec_advance_bufs(); - test_iovec_bufs_size(); - - return 0; - // initialize test pieces for (char* p = piece0, *end(piece0 + piece_size); p < end; ++p) *p = random_byte(); @@ -974,7 +967,5 @@ TORRENT_TEST(storage) std::for_each(test_paths.begin(), test_paths.end(), boost::bind(&run_test, _1, true)); std::for_each(test_paths.begin(), test_paths.end(), boost::bind(&run_test, _1, false)); - - return 0; } diff --git a/test/test_super_seeding.cpp b/test/test_super_seeding.cpp index dabc8c41f..3aa5b6a50 100644 --- a/test/test_super_seeding.cpp +++ b/test/test_super_seeding.cpp @@ -39,8 +39,6 @@ TORRENT_TEST(super_seeding) // with strict super seeding test_swarm(super_seeding | strict_super_seeding); - - return 0; } diff --git a/test/test_swarm.cpp b/test/test_swarm.cpp index ed6ce7ea6..4b8a985d0 100644 --- a/test/test_swarm.cpp +++ b/test/test_swarm.cpp @@ -44,7 +44,5 @@ TORRENT_TEST(swarm) // test explicit cache test_swarm(suggest | explicit_cache); - - return 0; } diff --git a/test/test_time_critical.cpp b/test/test_time_critical.cpp index 9b52092c6..80e52e021 100644 --- a/test/test_time_critical.cpp +++ b/test/test_time_critical.cpp @@ -36,8 +36,6 @@ TORRENT_TEST(time_crititcal) { // with time critical pieces test_swarm(time_critical); - - return 0; } diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index adf4214b1..b2877885c 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -264,8 +264,6 @@ TORRENT_TEST(torrent) TEST_EQUAL(int(sum), fs.piece_size(idx)); } } - - return 0; } diff --git a/test/test_tracker.cpp b/test/test_tracker.cpp index d6b239806..e3ea73dc1 100644 --- a/test/test_tracker.cpp +++ b/test/test_tracker.cpp @@ -394,7 +394,5 @@ TORRENT_TEST(traccker) fprintf(stderr, "stop_web_server\n"); stop_web_server(); fprintf(stderr, "done\n"); - - return 0; } diff --git a/test/test_trackers_extension.cpp b/test/test_trackers_extension.cpp index 6be2eaa6e..b8e976e4d 100644 --- a/test/test_trackers_extension.cpp +++ b/test/test_trackers_extension.cpp @@ -129,11 +129,9 @@ TORRENT_TEST(trackers_extension) // this allows shutting down the sessions in parallel p1 = ses1.abort(); p2 = ses2.abort(); - - return 0; } #else -TORRENT_TEST(trackers_extension) { return 0; } +TORRENT_TEST(trackers_extension) { } #endif // TORRENT_DISABLE_EXTENSIONS diff --git a/test/test_url_seed.cpp b/test/test_url_seed.cpp index c4edb5cae..6defb0603 100644 --- a/test/test_url_seed.cpp +++ b/test/test_url_seed.cpp @@ -48,7 +48,6 @@ TORRENT_TEST(url_seed) run_http_suite(proxy, "http", 1, 0, 0, keepalive); } run_http_suite(proxy, "http", 1, 0, 0, 1, 1); - return 0; } diff --git a/test/test_utf8.cpp b/test/test_utf8.cpp index abb77325a..a308f3e7e 100644 --- a/test/test_utf8.cpp +++ b/test/test_utf8.cpp @@ -251,6 +251,5 @@ TORRENT_TEST(utf8) TEST_EQUAL(ret, conversion_ok); TEST_EQUAL(utf8, identity); - return 0; } diff --git a/test/test_utp.cpp b/test/test_utp.cpp index bcfc6d2a8..dab5424a2 100644 --- a/test/test_utp.cpp +++ b/test/test_utp.cpp @@ -137,7 +137,5 @@ TORRENT_TEST(utp) error_code ec; remove_all("./tmp1_utp", ec); remove_all("./tmp2_utp", ec); - - return 0; } diff --git a/test/test_web_seed.cpp b/test/test_web_seed.cpp index d001abd2a..362584013 100644 --- a/test/test_web_seed.cpp +++ b/test/test_web_seed.cpp @@ -44,6 +44,5 @@ TORRENT_TEST(web_seed) run_http_suite(proxy, "https", false); #endif run_http_suite(proxy, "http", false); - return 0; } diff --git a/test/test_web_seed_ban.cpp b/test/test_web_seed_ban.cpp index 32a47667c..006b534bd 100644 --- a/test/test_web_seed_ban.cpp +++ b/test/test_web_seed_ban.cpp @@ -40,7 +40,6 @@ const int proxy = libtorrent::settings_pack::none; TORRENT_TEST(web_seed_ban) { - int ret = 0; for (int url_seed = 0; url_seed < 2; ++url_seed) { #ifdef TORRENT_USE_OPENSSL @@ -48,6 +47,5 @@ TORRENT_TEST(web_seed_ban) #endif run_http_suite(proxy, "http", url_seed, 0, 1); } - return ret; } diff --git a/test/test_web_seed_chunked.cpp b/test/test_web_seed_chunked.cpp index 07a4a926f..3c418c3c6 100644 --- a/test/test_web_seed_chunked.cpp +++ b/test/test_web_seed_chunked.cpp @@ -40,7 +40,6 @@ const int proxy = libtorrent::settings_pack::none; TORRENT_TEST(web_seed_chunked) { - int ret = 0; for (int url_seed = 0; url_seed < 2; ++url_seed) { #ifdef TORRENT_USE_OPENSSL @@ -48,6 +47,5 @@ TORRENT_TEST(web_seed_chunked) #endif run_http_suite(proxy, "http", url_seed, 1, 0); } - return ret; } diff --git a/test/test_web_seed_http.cpp b/test/test_web_seed_http.cpp index 084463ed2..f33c829c3 100644 --- a/test/test_web_seed_http.cpp +++ b/test/test_web_seed_http.cpp @@ -40,7 +40,6 @@ const int proxy = libtorrent::settings_pack::http; TORRENT_TEST(web_seed_http) { - int ret = 0; for (int url_seed = 0; url_seed < 2; ++url_seed) { #ifdef TORRENT_USE_OPENSSL @@ -48,6 +47,5 @@ TORRENT_TEST(web_seed_http) #endif run_http_suite(proxy, "http", url_seed); } - return ret; } diff --git a/test/test_web_seed_http_pw.cpp b/test/test_web_seed_http_pw.cpp index 61838d0ed..9805e9733 100644 --- a/test/test_web_seed_http_pw.cpp +++ b/test/test_web_seed_http_pw.cpp @@ -40,7 +40,6 @@ const int proxy = libtorrent::settings_pack::http_pw; TORRENT_TEST(web_seed_http_pw) { - int ret = 0; for (int url_seed = 0; url_seed < 2; ++url_seed) { #ifdef TORRENT_USE_OPENSSL @@ -48,6 +47,5 @@ TORRENT_TEST(web_seed_http_pw) #endif run_http_suite(proxy, "http", url_seed); } - return ret; } diff --git a/test/test_web_seed_redirect.cpp b/test/test_web_seed_redirect.cpp index 1d0b3da82..e65890436 100644 --- a/test/test_web_seed_redirect.cpp +++ b/test/test_web_seed_redirect.cpp @@ -53,7 +53,8 @@ TORRENT_TEST(web_seed_redirect) { fprintf(stderr, "failed to create file \"test_file\": (%d) %s\n" , ec.value(), ec.message().c_str()); - return 1; + TEST_ERROR("failed to create file"); + return; } file::iovec_t b = { random_data, size_t(16000)}; f.writev(0, &b, 1, ec); @@ -76,8 +77,8 @@ TORRENT_TEST(web_seed_redirect) { fprintf(stderr, "error creating hashes for test torrent: %s\n" , ec.message().c_str()); - TEST_CHECK(false); - return 0; + TEST_ERROR("failed to create hashes"); + return; } std::vector buf; @@ -91,14 +92,13 @@ TORRENT_TEST(web_seed_redirect) settings.set_int(settings_pack::max_queued_disk_bytes, 256 * 1024); settings.set_int(settings_pack::alert_mask, ~(alert::progress_notification | alert::stats_notification)); ses.apply_settings(settings); - + // disable keep-alive because otherwise the test will choke on seeing // the disconnect (from the redirect) test_transfer(ses, torrent_file, 0, 0, "http", true, false, false, false); } stop_web_server(); - return 0; } diff --git a/test/test_web_seed_socks4.cpp b/test/test_web_seed_socks4.cpp index 25472615c..3db731f11 100644 --- a/test/test_web_seed_socks4.cpp +++ b/test/test_web_seed_socks4.cpp @@ -40,7 +40,6 @@ const int proxy = libtorrent::settings_pack::socks4; TORRENT_TEST(web_seed_socks4) { - int ret = 0; for (int url_seed = 0; url_seed < 2; ++url_seed) { #ifdef TORRENT_USE_OPENSSL @@ -48,6 +47,5 @@ TORRENT_TEST(web_seed_socks4) #endif run_http_suite(proxy, "http", url_seed); } - return ret; } diff --git a/test/test_web_seed_socks5.cpp b/test/test_web_seed_socks5.cpp index 709acb6a3..d46a71a5e 100644 --- a/test/test_web_seed_socks5.cpp +++ b/test/test_web_seed_socks5.cpp @@ -40,7 +40,6 @@ const int proxy = libtorrent::settings_pack::socks5; TORRENT_TEST(web_seed_socks5) { - int ret = 0; for (int url_seed = 0; url_seed < 2; ++url_seed) { #ifdef TORRENT_USE_OPENSSL @@ -48,6 +47,5 @@ TORRENT_TEST(web_seed_socks5) #endif run_http_suite(proxy, "http", url_seed); } - return ret; } diff --git a/test/test_web_seed_socks5_pw.cpp b/test/test_web_seed_socks5_pw.cpp index 4361f7718..267938051 100644 --- a/test/test_web_seed_socks5_pw.cpp +++ b/test/test_web_seed_socks5_pw.cpp @@ -40,7 +40,6 @@ const int proxy = libtorrent::settings_pack::socks5_pw; TORRENT_TEST(web_seed_socks5_pw) { - int ret = 0; for (int url_seed = 0; url_seed < 2; ++url_seed) { #ifdef TORRENT_USE_OPENSSL @@ -48,6 +47,5 @@ TORRENT_TEST(web_seed_socks5_pw) #endif run_http_suite(proxy, "http", url_seed); } - return ret; }