diff --git a/appveyor.yml b/appveyor.yml index b7236e144..aecace548 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -75,32 +75,32 @@ build_script: # examples - cd %ROOT_DIRECTORY%\examples - if defined bjam ( - b2.exe --hash openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% + b2.exe --hash openssl-version=pre1.1 warnings=all warnings-as-errors=on -j2 %compiler% address-model=%model% picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% ) # tools - cd %ROOT_DIRECTORY%\tools - if defined bjam ( - b2.exe --hash openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% + b2.exe --hash openssl-version=pre1.1 warnings=all warnings-as-errors=on -j2 %compiler% address-model=%model% picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% ) # test - cd %ROOT_DIRECTORY%\test - if defined bjam ( - b2.exe --hash openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% win-tests test_upnp test_natpmp testing.execute=off + b2.exe --hash openssl-version=pre1.1 warnings=all warnings-as-errors=on -j2 %compiler% address-model=%model% picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% win-tests test_upnp test_natpmp testing.execute=off ) # python binding - cd %ROOT_DIRECTORY%\bindings\python # we use 64 bit python builds - if defined python ( - b2.exe --hash openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% libtorrent-link=shared stage_module stage_dependencies + b2.exe --hash openssl-version=pre1.1 warnings=all warnings-as-errors=on -j2 %compiler% address-model=%model% picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% libtorrent-link=shared stage_module stage_dependencies ) # simulations - cd %ROOT_DIRECTORY%\simulation - if defined sim ( - b2.exe --hash openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=off picker-debugging=on invariant-checks=full test_debug %linkflags% %include% boost-link=default link=static crypto=built-in define=BOOST_ASIO_DISABLE_IOCP testing.execute=off + b2.exe --hash openssl-version=pre1.1 warnings=all warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=off picker-debugging=on invariant-checks=full test_debug %linkflags% %include% boost-link=default link=static crypto=built-in define=BOOST_ASIO_DISABLE_IOCP testing.execute=off ) # minimal support for cmake build @@ -115,7 +115,7 @@ build_script: test_script: - cd %ROOT_DIRECTORY%\test - if defined bjam ( - appveyor-retry b2.exe -l400 --hash openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% win-tests + appveyor-retry b2.exe -l400 --hash openssl-version=pre1.1 warnings=all warnings-as-errors=on -j2 %compiler% address-model=%model% picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% win-tests ) - cd %ROOT_DIRECTORY%\bindings\python diff --git a/bindings/python/Jamfile b/bindings/python/Jamfile index 59518f693..ac4132c1a 100644 --- a/bindings/python/Jamfile +++ b/bindings/python/Jamfile @@ -210,6 +210,9 @@ my-python-extension libtorrent @libtorrent_linking openssl:/torrent//ssl openssl:/torrent//crypto + # C4268: 'identifier' : 'const' static/global data initialized + # with compiler generated default constructor fills the object with zeros + msvc:/wd4268 : # default-build all : # usage-requirements diff --git a/bindings/python/src/converters.cpp b/bindings/python/src/converters.cpp index fbc2286dd..6be582aef 100644 --- a/bindings/python/src/converters.cpp +++ b/bindings/python/src/converters.cpp @@ -54,7 +54,7 @@ struct tuple_to_endpoint if (PyTuple_Size(x) != 2) return nullptr; extract ip(object(borrowed(PyTuple_GetItem(x, 0)))); if (!ip.check()) return nullptr; - extract port(object(borrowed(PyTuple_GetItem(x, 1)))); + extract port(object(borrowed(PyTuple_GetItem(x, 1)))); if (!port.check()) return nullptr; lt::error_code ec; lt::address::from_string(ip, ec); @@ -69,7 +69,7 @@ struct tuple_to_endpoint object o(borrowed(x)); data->convertible = new (storage) T(lt::address::from_string( - extract(o[0])), extract(o[1])); + extract(o[0])), extract(o[1])); } }; diff --git a/bindings/python/src/error_code.cpp b/bindings/python/src/error_code.cpp index 02bf56fc4..1808a84e5 100644 --- a/bindings/python/src/error_code.cpp +++ b/bindings/python/src/error_code.cpp @@ -145,14 +145,14 @@ private: boost::system::error_category const* m_cat; }; -void error_code_assign(boost::system::error_code& self, int const v, category_holder const cat) +void error_code_assign(boost::system::error_code& me, int const v, category_holder const cat) { - self.assign(v, cat.ref()); + me.assign(v, cat.ref()); } -category_holder error_code_category(boost::system::error_code const& self) +category_holder error_code_category(boost::system::error_code const& me) { - return category_holder(self.category()); + return category_holder(me.category()); } #define WRAP_CAT(name) \ diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index 72d9fc2cc..c5a972a78 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -191,9 +191,9 @@ void dict_to_announce_entry(dict d, announce_entry& ae) { ae.url = extract(d["url"]); if (d.has_key("tier")) - ae.tier = extract(d["tier"]); + ae.tier = extract(d["tier"]); if (d.has_key("fail_limit")) - ae.fail_limit = extract(d["fail_limit"]); + ae.fail_limit = extract(d["fail_limit"]); } void replace_trackers(torrent_handle& h, object trackers) diff --git a/examples/Jamfile b/examples/Jamfile index 311689a5a..312531397 100644 --- a/examples/Jamfile +++ b/examples/Jamfile @@ -15,6 +15,9 @@ project client_test darwin:-Wno-unused-command-line-argument # disable warning C4275: non DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' msvc:/wd4275 + # C4268: 'identifier' : 'const' static/global data initialized + # with compiler generated default constructor fills the object with zeros + msvc:/wd4268 : default-build static ; diff --git a/examples/bt-get2.cpp b/examples/bt-get2.cpp index aadcc8180..6853c8e72 100644 --- a/examples/bt-get2.cpp +++ b/examples/bt-get2.cpp @@ -118,8 +118,8 @@ int main(int argc, char const* argv[]) try if (auto rd = lt::alert_cast(a)) { std::ofstream of(".resume_file", std::ios_base::binary); of.unsetf(std::ios_base::skipws); - auto buf = write_resume_data_buf(rd->params); - of.write(buf.data(), buf.size()); + auto const b = write_resume_data_buf(rd->params); + of.write(b.data(), b.size()); } if (auto st = lt::alert_cast(a)) { diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 0273acd0c..993cbbc7d 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -102,7 +102,7 @@ bool sleep_and_input(int* c, lt::time_duration const sleep) std::this_thread::sleep_for(sleep / 2); } return false; -}; +} #else diff --git a/examples/print.cpp b/examples/print.cpp index cc8afe209..358e2148a 100644 --- a/examples/print.cpp +++ b/examples/print.cpp @@ -382,9 +382,9 @@ std::pair terminal_size() } #ifdef _WIN32 -void apply_ansi_code(int* attributes, bool* reverse, bool* support_chaining, int code) +void apply_ansi_code(WORD* attributes, bool* reverse, bool* support_chaining, int code) { - static const int color_table[8] = + static const WORD color_table[8] = { 0, // black FOREGROUND_RED, // red @@ -459,7 +459,7 @@ void print(char const* buf) #ifdef _WIN32 HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE); - int current_attributes = 7; + WORD current_attributes = 7; bool reverse = false; SetConsoleTextAttribute(out, current_attributes); diff --git a/simulation/Jamfile b/simulation/Jamfile index 135dbfb25..13f5eab8d 100644 --- a/simulation/Jamfile +++ b/simulation/Jamfile @@ -18,6 +18,7 @@ project utils.cpp msvc:/wd4275 msvc:/wd4005 + msvc:/wd4268 : default-build multi full diff --git a/simulation/fake_peer.hpp b/simulation/fake_peer.hpp index 23cad6d07..b740a1952 100644 --- a/simulation/fake_peer.hpp +++ b/simulation/fake_peer.hpp @@ -288,7 +288,8 @@ struct udp_server boost::system::error_code ec; m_socket.open(asio::ip::udp::v4(), ec); TEST_CHECK(!ec); - m_socket.bind(asio::ip::udp::endpoint(asio::ip::address_v4::any(), port), ec); + m_socket.bind(asio::ip::udp::endpoint(asio::ip::address_v4::any() + , static_cast(port)), ec); TEST_CHECK(!ec); m_socket.non_blocking(true); diff --git a/simulation/setup_dht.cpp b/simulation/setup_dht.cpp index e33e78463..b179ffb3f 100644 --- a/simulation/setup_dht.cpp +++ b/simulation/setup_dht.cpp @@ -152,7 +152,7 @@ struct dht_node final : lt::dht::socket_manager } bool has_quota() override { return true; } - bool send_packet(lt::aux::listen_socket_handle const& s, entry& e, udp::endpoint const& addr) override + bool send_packet(lt::aux::listen_socket_handle const&, entry& e, udp::endpoint const& addr) override { // since the simulaton is single threaded, we can get away with allocating // just a single send buffer diff --git a/simulation/test_auto_manage.cpp b/simulation/test_auto_manage.cpp index fbd1b6ba8..706411691 100644 --- a/simulation/test_auto_manage.cpp +++ b/simulation/test_auto_manage.cpp @@ -74,7 +74,7 @@ void run_test(Settings const& sett, Setup const& setup, Test const& test) // set up a timer to fire later, to verify everything we expected to happen // happened sim::timer t(sim, lt::seconds((num_torrents + 1) * 60) - , [&](boost::system::error_code const& ec) + , [&](boost::system::error_code const&) { test(*ses); diff --git a/simulation/test_checking.cpp b/simulation/test_checking.cpp index 3be86f3a6..42b8fb293 100644 --- a/simulation/test_checking.cpp +++ b/simulation/test_checking.cpp @@ -89,7 +89,7 @@ TORRENT_TEST(no_truncate_checking) std::string filename; int size = 0; run_test( - [&](lt::add_torrent_params& atp, lt::settings_pack& p) { + [&](lt::add_torrent_params& atp, lt::settings_pack&) { filename = lt::combine_path(atp.save_path, atp.ti->files().file_path(lt::file_index_t{0})); std::ofstream f(filename); // create a file that's 100 bytes larger @@ -97,7 +97,7 @@ TORRENT_TEST(no_truncate_checking) std::vector dummy(size); f.write(dummy.data(), dummy.size()); }, - [](lt::session& ses) {} + [](lt::session&) {} ); // file should not have been truncated just by checking @@ -127,7 +127,7 @@ std::shared_ptr create_multifile_torrent() TORRENT_TEST(aligned_zero_priority) { run_test( - [&](lt::add_torrent_params& atp, lt::settings_pack& p) { + [&](lt::add_torrent_params& atp, lt::settings_pack&) { atp.file_priorities.push_back(lt::download_priority_t{1}); atp.file_priorities.push_back(lt::download_priority_t{0}); atp.ti = create_multifile_torrent(); @@ -147,7 +147,7 @@ TORRENT_TEST(aligned_zero_priority_no_file) { std::string partfile; run_test( - [&](lt::add_torrent_params& atp, lt::settings_pack& p) { + [&](lt::add_torrent_params& atp, lt::settings_pack&) { atp.ti = create_multifile_torrent(); atp.save_path = "."; atp.file_priorities.push_back(lt::download_priority_t{1}); @@ -181,7 +181,7 @@ TORRENT_TEST(zero_priority_missing_partfile) { std::shared_ptr ti = create_multifile_torrent(); run_test( - [&](lt::add_torrent_params& atp, lt::settings_pack& p) { + [&](lt::add_torrent_params& atp, lt::settings_pack&) { atp.ti = ti; atp.save_path = "."; atp.file_priorities.push_back(lt::download_priority_t{1}); diff --git a/simulation/test_dht_bootstrap.cpp b/simulation/test_dht_bootstrap.cpp index 63f4cd02c..9070a6298 100644 --- a/simulation/test_dht_bootstrap.cpp +++ b/simulation/test_dht_bootstrap.cpp @@ -83,7 +83,7 @@ TORRENT_TEST(dht_bootstrap) lt::deadline_timer timer(ios); timer.expires_from_now(lt::seconds(10)); - timer.async_wait([&](lt::error_code const& ec) { + timer.async_wait([&](lt::error_code const&) { zombies.push_back(ses->abort()); node.close(); ses.reset(); diff --git a/simulation/test_dht_rate_limit.cpp b/simulation/test_dht_rate_limit.cpp index 800c76b3b..fc93f3371 100644 --- a/simulation/test_dht_rate_limit.cpp +++ b/simulation/test_dht_rate_limit.cpp @@ -73,7 +73,7 @@ struct obs : dht::dht_observer #ifndef TORRENT_DISABLE_LOGGING bool should_log(module_t) const override { return true; } - void log(dht_logger::module_t l, char const* fmt, ...) override + void log(dht_logger::module_t, char const* fmt, ...) override { va_list v; va_start(v, fmt); diff --git a/simulation/test_dht_storage.cpp b/simulation/test_dht_storage.cpp index 4dc8d0d9b..dc3cb1acf 100644 --- a/simulation/test_dht_storage.cpp +++ b/simulation/test_dht_storage.cpp @@ -199,7 +199,7 @@ TORRENT_TEST(dht_storage_infohashes_sample) sim::asio::high_resolution_timer timer(ios); timer.expires_from_now(hours(1)); // expiration of torrents - timer.async_wait([&s](boost::system::error_code const& ec) + timer.async_wait([&s](boost::system::error_code const&) { // tick here to trigger the torrents expiration s->tick(); diff --git a/simulation/test_error_handling.cpp b/simulation/test_error_handling.cpp index 815765ee8..ef320ebac 100644 --- a/simulation/test_error_handling.cpp +++ b/simulation/test_error_handling.cpp @@ -129,7 +129,7 @@ void run_test(HandleAlerts const& on_alert, Test const& test) params.save_path = save_path(1); ses[1]->async_add_torrent(params); - sim::timer t(sim, lt::seconds(60), [&](boost::system::error_code const& ec) + sim::timer t(sim, lt::seconds(60), [&](boost::system::error_code const&) { test(ses); @@ -200,7 +200,7 @@ TORRENT_TEST(error_handling) using namespace lt; run_test( [](lt::session&, lt::alert const*) {}, - [](std::shared_ptr ses[2]) {} + [](std::shared_ptr[2]) {} ); } catch (std::bad_alloc const&) diff --git a/simulation/test_file_pool.cpp b/simulation/test_file_pool.cpp index 7aec5386f..133534ef1 100644 --- a/simulation/test_file_pool.cpp +++ b/simulation/test_file_pool.cpp @@ -113,8 +113,7 @@ TORRENT_TEST(file_pool_size) atp.ti->remap_files(fs); } // on alert - , [&](lt::alert const* a, lt::session&) - {} + , [&](lt::alert const*, lt::session&) {} // terminate , [&](int ticks, lt::session& ses) -> bool { diff --git a/simulation/test_http_connection.cpp b/simulation/test_http_connection.cpp index 04e02e312..6b8f31f98 100644 --- a/simulation/test_http_connection.cpp +++ b/simulation/test_http_connection.cpp @@ -622,7 +622,7 @@ TORRENT_TEST(http_connection_ssl_proxy) int proxy_counter = 0; http_proxy.register_handler("10.0.0.2:8080" - , [&proxy_counter](std::string method, std::string req, std::map& headers) + , [&proxy_counter](std::string method, std::string req, std::map&) { proxy_counter++; TEST_EQUAL(method, "CONNECT"); @@ -631,8 +631,8 @@ TORRENT_TEST(http_connection_ssl_proxy) auto h = std::make_shared(client_ios , res - , [&client_counter](error_code const& ec, http_parser const& parser - , span, http_connection& c) + , [&client_counter](error_code const& ec, http_parser const& + , span, http_connection&) { client_counter++; TEST_EQUAL(ec, boost::asio::error::operation_not_supported); diff --git a/simulation/test_pause.cpp b/simulation/test_pause.cpp index ac1017936..a3b699b9f 100644 --- a/simulation/test_pause.cpp +++ b/simulation/test_pause.cpp @@ -118,7 +118,7 @@ TORRENT_TEST(torrent_paused_disconnect) { run_test( [](lt::session&) {}, - [](lt::session&, lt::torrent_handle h, std::array& test_peers) { + [](lt::session&, lt::torrent_handle h, std::array&) { add_fake_peers(h, 3); }, diff --git a/simulation/test_pe_crypto.cpp b/simulation/test_pe_crypto.cpp index c81585a31..3589971e3 100644 --- a/simulation/test_pe_crypto.cpp +++ b/simulation/test_pe_crypto.cpp @@ -45,7 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. using namespace lt; -char const* pe_policy(std::uint8_t policy) +char const* pe_policy(int const policy) { if (policy == settings_pack::pe_disabled) return "disabled"; else if (policy == settings_pack::pe_enabled) return "enabled"; @@ -90,9 +90,9 @@ void test_transfer(int enc_policy, int level, bool prefer_rc4) pack.set_bool(settings_pack::prefer_rc4, false); } // add torrent - , [](lt::add_torrent_params& params) {} + , [](lt::add_torrent_params&) {} // on alert - , [](lt::alert const* a, lt::session& ses) {} + , [](lt::alert const*, lt::session&) {} // terminate , [](int ticks, lt::session& ses) -> bool { @@ -176,9 +176,9 @@ TORRENT_TEST(disabled_failing) pack.set_bool(settings_pack::prefer_rc4, true); } // add torrent - , [](lt::add_torrent_params& params) {} + , [](lt::add_torrent_params&) {} // on alert - , [](lt::alert const* a, lt::session& ses) {} + , [](lt::alert const*, lt::session&) {} // terminate , [](int ticks, lt::session& ses) -> bool { diff --git a/simulation/test_session.cpp b/simulation/test_session.cpp index 0fa2a5adf..684a3c51a 100644 --- a/simulation/test_session.cpp +++ b/simulation/test_session.cpp @@ -58,9 +58,9 @@ TORRENT_TEST(seed_mode) params.flags |= torrent_flags::seed_mode; } // on alert - , [](lt::alert const* a, lt::session& ses) {} + , [](lt::alert const*, lt::session&) {} // terminate - , [](int ticks, lt::session& ses) -> bool { + , [](int ticks, lt::session&) -> bool { // we don't need to finish seeding, exit after 20 seconds return ticks > 20; }); @@ -80,9 +80,9 @@ TORRENT_TEST(ip_notifier_setting) pack.set_int(settings_pack::alert_mask, alert::all_categories); } // add torrent - , [](lt::add_torrent_params& params) {} + , [](lt::add_torrent_params&) {} // on alert - , [&s_tick, &working_count](lt::alert const* a, lt::session& ses) + , [&s_tick, &working_count](lt::alert const* a, lt::session&) { std::string const msg = a->message(); if (msg.find("received error on_ip_change:") != std::string::npos) @@ -148,13 +148,13 @@ TORRENT_TEST(add_extension_while_transfer) pack.set_int(settings_pack::alert_mask, alert::all_categories); } // add torrent - , [](lt::add_torrent_params& params) {} + , [](lt::add_torrent_params&) {} // on alert - , [&done, p](lt::alert const* a, lt::session& ses) + , [&done, p](lt::alert const* a, lt::session&) { if (a->type() == peer_connect_alert::alert_type) { - auto create_test_plugin = [p](torrent_handle const& th, void*) + auto create_test_plugin = [p](torrent_handle const&, void*) { return p; }; lt::torrent_handle th = alert_cast(a)->handle; @@ -164,7 +164,7 @@ TORRENT_TEST(add_extension_while_transfer) } } // terminate - , [&done](int ticks, lt::session& ses) -> bool + , [&done](int ticks, lt::session&) -> bool { // exit after 10 seconds return ticks > 10 || done; diff --git a/simulation/test_socks5.cpp b/simulation/test_socks5.cpp index 483522663..e30dc2fe2 100644 --- a/simulation/test_socks5.cpp +++ b/simulation/test_socks5.cpp @@ -180,11 +180,11 @@ TORRENT_TEST(udp_tracker) params.save_path = "."; ses.async_add_torrent(params); }, - [&tracker_alert](lt::session& ses, lt::alert const* alert) { + [&tracker_alert](lt::session&, lt::alert const* alert) { if (lt::alert_cast(alert)) tracker_alert = true; }, - [&](sim::simulation& sim, lt::session& ses + [&](sim::simulation& sim, lt::session& , std::shared_ptr ti) { // listen on port 8080 @@ -269,7 +269,7 @@ TORRENT_TEST(socks5_udp_retry) // run for 60 seconds.The sokcks5 retry interval is expected to be 5 seconds, // meaning there should have been 12 connection attempts - sim::timer t(sim, lt::seconds(60), [&](boost::system::error_code const& ec) + sim::timer t(sim, lt::seconds(60), [&](boost::system::error_code const&) { fprintf(stderr, "shutting down\n"); // shut down diff --git a/simulation/test_swarm.cpp b/simulation/test_swarm.cpp index e1fd547a9..f581feb78 100644 --- a/simulation/test_swarm.cpp +++ b/simulation/test_swarm.cpp @@ -110,9 +110,9 @@ TORRENT_TEST(seed_mode_suggest) params.flags |= torrent_flags::seed_mode; } // on alert - , [](lt::alert const* a, lt::session& ses) {} + , [](lt::alert const*, lt::session&) {} // terminate - , [](int ticks, lt::session& ses) -> bool + , [](int, lt::session&) -> bool { return true; }); } @@ -559,7 +559,7 @@ TORRENT_TEST(delete_partfile) // add torrent , [](lt::add_torrent_params&) {} // on alert - , [](lt::alert const* a, lt::session&) {} + , [](lt::alert const*, lt::session&) {} // terminate , [&save_path](int, lt::session& ses) -> bool { @@ -637,10 +637,10 @@ TORRENT_TEST(block_uploaded_alert) int blocks_per_piece = at->handle.torrent_file()->piece_length() / 0x4000; blocks.resize(at->handle.torrent_file()->num_pieces(), std::vector(blocks_per_piece, false)); } - else if (auto at = lt::alert_cast(a)) + else if (auto ua = lt::alert_cast(a)) { - TEST_EQUAL(blocks[static_cast(at->piece_index)][at->block_index], false); - blocks[static_cast(at->piece_index)][at->block_index] = true; + TEST_EQUAL(blocks[static_cast(ua->piece_index)][ua->block_index], false); + blocks[static_cast(ua->piece_index)][ua->block_index] = true; } } // terminate @@ -667,9 +667,9 @@ void test_settings(SettingsFun fun) // add session , fun // add torrent - , [](lt::add_torrent_params& params) {} + , [](lt::add_torrent_params&) {} // on alert - , [](lt::alert const* a, lt::session& ses) {} + , [](lt::alert const*, lt::session&) {} // terminate , [](int ticks, lt::session& ses) -> bool { diff --git a/simulation/test_tracker.cpp b/simulation/test_tracker.cpp index 1b8288fa8..f83329bd9 100644 --- a/simulation/test_tracker.cpp +++ b/simulation/test_tracker.cpp @@ -124,7 +124,7 @@ void test_interval(int interval) } } // terminate - , [&](int const ticks, lt::session& ses) -> bool { + , [&](int const ticks, lt::session&) -> bool { if (ticks > duration + 1) { ran_to_completion = true; @@ -479,7 +479,7 @@ void test_udpv6_support(char const* listen_interfaces } else if (alert_cast(a)) { - TEST_CHECK(false && "unexpected tracker error"); + TEST_ERROR("unexpected tracker error"); } } }); @@ -1003,13 +1003,13 @@ TORRENT_TEST(tracker_key_argument) { std::set keys; tracker_test( - [](lt::add_torrent_params& p, lt::session& ses) + [](lt::add_torrent_params& p, lt::session&) { p.ti = make_torrent(true); return 60; }, - [&](std::string method, std::string req - , std::map& headers) + [&](std::string, std::string req + , std::map&) { auto const pos = req.find("&key="); TEST_CHECK(pos != std::string::npos); @@ -1198,7 +1198,7 @@ TORRENT_TEST(tracker_tiers) ses[1] = std::make_shared(pack, ios1); // only monitor alerts for session 0 (the downloader) - print_alerts(*ses[0], [=](lt::session& ses, lt::alert const* a) { + print_alerts(*ses[0], [=](lt::session&, lt::alert const* a) { if (auto ta = alert_cast(a)) { ta->handle.connect_peer(lt::tcp::endpoint(peer1, 6881)); @@ -1224,7 +1224,7 @@ TORRENT_TEST(tracker_tiers) params.save_path = save_path(1); ses[1]->async_add_torrent(params); - sim::timer t(sim, lt::minutes(30), [&](boost::system::error_code const& ec) + sim::timer t(sim, lt::minutes(30), [&](boost::system::error_code const&) { TEST_CHECK(received_announce[0] != received_announce[1]); TEST_CHECK(ses[0]->get_torrents()[0].status().is_seeding); diff --git a/simulation/test_transfer.cpp b/simulation/test_transfer.cpp index 4f82610b8..080891415 100644 --- a/simulation/test_transfer.cpp +++ b/simulation/test_transfer.cpp @@ -140,7 +140,7 @@ void run_test( params.save_path = save_path(1); ses[1]->async_add_torrent(params); - sim::timer t(sim, lt::seconds(60), [&](boost::system::error_code const& ec) + sim::timer t(sim, lt::seconds(60), [&](boost::system::error_code const&) { test(ses); diff --git a/simulation/test_web_seed.cpp b/simulation/test_web_seed.cpp index 3608e747f..fc530ea19 100644 --- a/simulation/test_web_seed.cpp +++ b/simulation/test_web_seed.cpp @@ -127,7 +127,7 @@ void run_test(Setup const& setup // set up a timer to fire later, to verify everything we expected to happen // happened - sim::timer t(sim, timeout, [&](boost::system::error_code const& ec) + sim::timer t(sim, timeout, [&](boost::system::error_code const&) { std::printf("shutting down\n"); // shut down @@ -153,8 +153,8 @@ TORRENT_TEST(single_file) { ses.async_add_torrent(params); }, - [](lt::session& ses, lt::alert const* alert) {}, - [&expected](sim::simulation& sim, lt::session& ses) + [](lt::session&, lt::alert const*) {}, + [&expected](sim::simulation& sim, lt::session&) { sim::asio::io_service web_server(sim, address_v4::from_string("2.2.2.2")); // listen on port 8080 @@ -191,8 +191,8 @@ TORRENT_TEST(multi_file) { ses.async_add_torrent(params); }, - [](lt::session& ses, lt::alert const* alert) {}, - [&expected](sim::simulation& sim, lt::session& ses) + [](lt::session&, lt::alert const*) {}, + [&expected](sim::simulation& sim, lt::session&) { sim::asio::io_service web_server(sim, address_v4::from_string("2.2.2.2")); // listen on port 8080 @@ -226,9 +226,9 @@ std::string generate_content(lt::file_storage const& fs, file_index_t file std::string ret; ret.reserve(lt::aux::numeric_cast(len)); std::int64_t const file_offset = fs.file_offset(file); - int const piece_size = fs.piece_length(); + int const piece_sz = fs.piece_length(); for (std::int64_t i = offset + file_offset; i < offset + file_offset + len; ++i) - ret.push_back(((i % piece_size) % 26) + 'A'); + ret.push_back(((i % piece_sz) % 26) + 'A'); return ret; } @@ -258,11 +258,11 @@ TORRENT_TEST(unaligned_file_redirect) { ses.async_add_torrent(params); }, - [&](lt::session& ses, lt::alert const* alert) { + [&](lt::session&, lt::alert const* alert) { if (lt::alert_cast(alert)) seeding = true; }, - [&fs](sim::simulation& sim, lt::session& ses) + [&fs](sim::simulation& sim, lt::session&) { // http1 is the root web server that will just redirect requests to // other servers @@ -307,11 +307,11 @@ TORRENT_TEST(multi_file_redirect_pad_files) { ses.async_add_torrent(params); }, - [&](lt::session& ses, lt::alert const* alert) { + [&](lt::session&, lt::alert const* alert) { if (lt::alert_cast(alert)) seeding = true; }, - [&fs](sim::simulation& sim, lt::session& ses) + [&fs](sim::simulation& sim, lt::session&) { // http1 is the root web server that will just redirect requests to // other servers @@ -355,11 +355,11 @@ TORRENT_TEST(multi_file_redirect) { ses.async_add_torrent(params); }, - [&](lt::session& ses, lt::alert const* alert) { + [&](lt::session&, lt::alert const* alert) { if (lt::alert_cast(alert)) seeding = true; }, - [&fs](sim::simulation& sim, lt::session& ses) + [&fs](sim::simulation& sim, lt::session&) { // http1 is the root web server that will just redirect requests to // other servers @@ -413,12 +413,12 @@ TORRENT_TEST(multi_file_redirect_through_proxy) ses.async_add_torrent(params); }, - [&](lt::session& ses, lt::alert const* alert) { + [&](lt::session&, lt::alert const* alert) { if (lt::alert_cast(alert)) { seeding = true; } }, - [&fs](sim::simulation& sim, lt::session& ses) + [&fs](sim::simulation& sim, lt::session&) { sim::asio::io_service proxy_ios(sim, address_v4::from_string("50.50.50.50")); sim::http_proxy http_p(proxy_ios, 4445); @@ -464,11 +464,11 @@ TORRENT_TEST(multi_file_unaligned_redirect) { ses.async_add_torrent(params); }, - [&](lt::session& ses, lt::alert const* alert) { + [&](lt::session&, lt::alert const* alert) { // We don't expect to get this aslert TEST_CHECK(lt::alert_cast(alert) == nullptr); }, - [&fs](sim::simulation& sim, lt::session& ses) + [&fs](sim::simulation& sim, lt::session&) { // http1 is the root web server that will just redirect requests to // other servers @@ -507,13 +507,13 @@ TORRENT_TEST(urlseed_timeout) params.save_path = "."; ses.async_add_torrent(params); }, - [&timeout](lt::session& ses, lt::alert const* alert) { + [&timeout](lt::session&, lt::alert const* alert) { const lt::peer_disconnected_alert *pda = lt::alert_cast(alert); if (pda && pda->error == errors::timed_out_inactivity){ timeout = true; } }, - [](sim::simulation& sim, lt::session& ses) + [](sim::simulation& sim, lt::session&) { sim::asio::io_service web_server(sim, address_v4::from_string("2.2.2.2")); @@ -547,8 +547,8 @@ TORRENT_TEST(no_close_redudant_webseed) ses.apply_settings(pack); ses.async_add_torrent(params); }, - [](lt::session& ses, lt::alert const* alert) {}, - [&expected](sim::simulation& sim, lt::session& ses) + [](lt::session&, lt::alert const*) {}, + [&expected](sim::simulation& sim, lt::session&) { sim::asio::io_service web_server(sim, address_v4::from_string("2.2.2.2")); // listen on port 8080 @@ -595,8 +595,8 @@ TORRENT_TEST(web_seed_connection_limit) ses.apply_settings(pack); ses.async_add_torrent(params); }, - [](lt::session& ses, lt::alert const* alert) {}, - [&expected](sim::simulation& sim, lt::session& ses) + [](lt::session&, lt::alert const*) {}, + [&expected](sim::simulation& sim, lt::session&) { using ios = sim::asio::io_service; ios web_server1{sim, address_v4::from_string("2.2.2.1")}; diff --git a/test/Jamfile b/test/Jamfile index f6765f480..a0d87c3ed 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -53,6 +53,9 @@ project msvc:/wd4309 # C4310: cast truncates constant value msvc:/wd4310 + # C4268: 'identifier' : 'const' static/global data initialized + # with compiler generated default constructor fills the object with zeros + msvc:/wd4268 @warnings on : default-build diff --git a/tools/Jamfile b/tools/Jamfile index b8ccfaf31..087384caa 100644 --- a/tools/Jamfile +++ b/tools/Jamfile @@ -30,6 +30,9 @@ project tools multi # disable warning C4275: non DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' msvc:/wd4275 + # C4268: 'identifier' : 'const' static/global data initialized + # with compiler generated default constructor fills the object with zeros + msvc:/wd4268 @link_libtorrent : default-build static