fixing warnings in tests code, part10, final
This commit is contained in:
parent
c5d62cf1ca
commit
2d3e394226
20
test/Jamfile
20
test/Jamfile
|
@ -7,8 +7,7 @@ exe test_natpmp : test_natpmp.cpp
|
||||||
: # requirements
|
: # requirements
|
||||||
<library>/torrent//torrent
|
<library>/torrent//torrent
|
||||||
<export-extra>on
|
<export-extra>on
|
||||||
# disable warning C4373: virtual function overrides, previous versions of the compiler did not override when parameters only differed by const/volatile qualifiers
|
<conditional>@warnings
|
||||||
<toolset>msvc:<cflags>/wd4373
|
|
||||||
: # default-build
|
: # default-build
|
||||||
<threading>multi
|
<threading>multi
|
||||||
<asserts>on
|
<asserts>on
|
||||||
|
@ -22,8 +21,7 @@ exe enum_if : enum_if.cpp
|
||||||
: # requirements
|
: # requirements
|
||||||
<library>/torrent//torrent
|
<library>/torrent//torrent
|
||||||
<export-extra>on
|
<export-extra>on
|
||||||
# disable warning C4373: virtual function overrides, previous versions of the compiler did not override when parameters only differed by const/volatile qualifiers
|
<conditional>@warnings
|
||||||
<toolset>msvc:<cflags>/wd4373
|
|
||||||
: # default-build
|
: # default-build
|
||||||
<threading>multi
|
<threading>multi
|
||||||
<asserts>on
|
<asserts>on
|
||||||
|
@ -80,13 +78,13 @@ project
|
||||||
<export-extra>on
|
<export-extra>on
|
||||||
<library>libtorrent_test
|
<library>libtorrent_test
|
||||||
<library>/torrent//torrent
|
<library>/torrent//torrent
|
||||||
<toolset>darwin:<cflags>-Wno-unused-command-line-argument
|
# C4127: conditional expression is constant
|
||||||
# disable warning C4275: non DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'
|
<toolset>msvc:<cflags>/wd4127
|
||||||
<toolset>msvc:<cflags>/wd4275
|
# C4309: 'conversion' : truncation of constant value
|
||||||
# disable warning C4373: virtual function overrides, previous versions of the compiler did not override when parameters only differed by const/volatile qualifiers
|
<toolset>msvc:<cflags>/wd4309
|
||||||
<toolset>msvc:<cflags>/wd4373
|
# C4310: cast truncates constant value
|
||||||
<toolset>msvc:<cflags>/wd4503
|
<toolset>msvc:<cflags>/wd4310
|
||||||
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
|
<conditional>@warnings
|
||||||
<export-extra>on
|
<export-extra>on
|
||||||
: default-build
|
: default-build
|
||||||
<threading>multi
|
<threading>multi
|
||||||
|
|
|
@ -642,10 +642,11 @@ dht::key_desc_t const sample_infohashes_desc[] = {
|
||||||
|
|
||||||
void print_state(std::ostream& os, routing_table const& table)
|
void print_state(std::ostream& os, routing_table const& table)
|
||||||
{
|
{
|
||||||
|
#define BUFFER_CURSOR_POS &buf[std::size_t(cursor)], buf.size() - std::size_t(cursor)
|
||||||
std::vector<char> buf(2048);
|
std::vector<char> buf(2048);
|
||||||
int cursor = 0;
|
int cursor = 0;
|
||||||
|
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, "kademlia routing table state\n"
|
, "kademlia routing table state\n"
|
||||||
"bucket_size: %d\n"
|
"bucket_size: %d\n"
|
||||||
"global node count: %" PRId64 "\n"
|
"global node count: %" PRId64 "\n"
|
||||||
|
@ -661,27 +662,27 @@ void print_state(std::ostream& os, routing_table const& table)
|
||||||
for (auto i = table.buckets().begin(), end(table.buckets().end());
|
for (auto i = table.buckets().begin(), end(table.buckets().end());
|
||||||
i != end; ++i, ++idx)
|
i != end; ++i, ++idx)
|
||||||
{
|
{
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, "%2d: ", idx);
|
, "%2d: ", idx);
|
||||||
for (int k = 0; k < int(i->live_nodes.size()); ++k)
|
for (int k = 0; k < int(i->live_nodes.size()); ++k)
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor, "#");
|
cursor += std::snprintf(BUFFER_CURSOR_POS, "#");
|
||||||
for (int k = 0; k < int(i->replacements.size()); ++k)
|
for (int k = 0; k < int(i->replacements.size()); ++k)
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor, "-");
|
cursor += std::snprintf(BUFFER_CURSOR_POS, "-");
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor, "\n");
|
cursor += std::snprintf(BUFFER_CURSOR_POS, "\n");
|
||||||
|
|
||||||
if (cursor > int(buf.size()) - 500) buf.resize(buf.size() * 3 / 2);
|
if (cursor > int(buf.size()) - 500) buf.resize(buf.size() * 3 / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
time_point now = aux::time_now();
|
time_point now = aux::time_now();
|
||||||
|
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, "\nnodes:");
|
, "\nnodes:");
|
||||||
|
|
||||||
int bucket_index = 0;
|
int bucket_index = 0;
|
||||||
for (auto i = table.buckets().begin(), end(table.buckets().end());
|
for (auto i = table.buckets().begin(), end(table.buckets().end());
|
||||||
i != end; ++i, ++bucket_index)
|
i != end; ++i, ++bucket_index)
|
||||||
{
|
{
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, "\n=== BUCKET == %d == %d|%d ==== \n"
|
, "\n=== BUCKET == %d == %d|%d ==== \n"
|
||||||
, bucket_index, int(i->live_nodes.size())
|
, bucket_index, int(i->live_nodes.size())
|
||||||
, int(i->replacements.size()));
|
, int(i->replacements.size()));
|
||||||
|
@ -712,23 +713,23 @@ void print_state(std::ostream& os, routing_table const& table)
|
||||||
node_id id = j->id;
|
node_id id = j->id;
|
||||||
id <<= id_shift;
|
id <<= id_shift;
|
||||||
|
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, " prefix: %2x id: %s"
|
, " prefix: %2x id: %s"
|
||||||
, ((id[0] & top_mask) >> mask_shift)
|
, ((id[0] & top_mask) >> mask_shift)
|
||||||
, aux::to_hex(j->id).c_str());
|
, aux::to_hex(j->id).c_str());
|
||||||
|
|
||||||
if (j->rtt == 0xffff)
|
if (j->rtt == 0xffff)
|
||||||
{
|
{
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, " rtt: ");
|
, " rtt: ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, " rtt: %4d", j->rtt);
|
, " rtt: %4d", j->rtt);
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, " fail: %4d ping: %d dist: %3d"
|
, " fail: %4d ping: %d dist: %3d"
|
||||||
, j->fail_count()
|
, j->fail_count()
|
||||||
, j->pinged()
|
, j->pinged()
|
||||||
|
@ -736,22 +737,22 @@ void print_state(std::ostream& os, routing_table const& table)
|
||||||
|
|
||||||
if (j->last_queried == min_time())
|
if (j->last_queried == min_time())
|
||||||
{
|
{
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, " query: ");
|
, " query: ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, " query: %3d", int(total_seconds(now - j->last_queried)));
|
, " query: %3d", int(total_seconds(now - j->last_queried)));
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, " ip: %s\n", print_endpoint(j->ep()).c_str());
|
, " ip: %s\n", print_endpoint(j->ep()).c_str());
|
||||||
if (cursor > int(buf.size()) - 500) buf.resize(buf.size() * 3 / 2);
|
if (cursor > int(buf.size()) - 500) buf.resize(buf.size() * 3 / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, "\nnode spread per bucket:\n");
|
, "\nnode spread per bucket:\n");
|
||||||
bucket_index = 0;
|
bucket_index = 0;
|
||||||
for (auto i = table.buckets().begin(), end(table.buckets().end());
|
for (auto i = table.buckets().begin(), end(table.buckets().end());
|
||||||
|
@ -796,20 +797,21 @@ void print_state(std::ostream& os, routing_table const& table)
|
||||||
sub_buckets[b] = true;
|
sub_buckets[b] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, "%2d mask: %2x: [", bucket_index, (top_mask >> mask_shift));
|
, "%2d mask: %2x: [", bucket_index, (top_mask >> mask_shift));
|
||||||
|
|
||||||
for (int j = 0; j < bucket_size_limit; ++j)
|
for (int j = 0; j < bucket_size_limit; ++j)
|
||||||
{
|
{
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, (sub_buckets[j] ? "X" : " "));
|
, (sub_buckets[j] ? "X" : " "));
|
||||||
}
|
}
|
||||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||||
, "]\n");
|
, "]\n");
|
||||||
if (cursor > int(buf.size()) - 500) buf.resize(buf.size() * 3 / 2);
|
if (cursor > int(buf.size()) - 500) buf.resize(buf.size() * 3 / 2);
|
||||||
}
|
}
|
||||||
buf[cursor] = '\0';
|
buf[std::size_t(cursor)] = '\0';
|
||||||
os << &buf[0];
|
os << &buf[0];
|
||||||
|
#undef BUFFER_CURSOR_POS
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
|
@ -475,8 +475,6 @@ TORRENT_TEST(unc_tests)
|
||||||
std::string long_file_name2 { long_file_name1 };
|
std::string long_file_name2 { long_file_name1 };
|
||||||
long_file_name2.back() = '2';
|
long_file_name2.back() = '2';
|
||||||
|
|
||||||
error_code ec;
|
|
||||||
|
|
||||||
lt::create_directory(long_component_name, ec);
|
lt::create_directory(long_component_name, ec);
|
||||||
TEST_EQUAL(ec, error_code());
|
TEST_EQUAL(ec, error_code());
|
||||||
TEST_CHECK(lt::exists(long_component_name));
|
TEST_CHECK(lt::exists(long_component_name));
|
||||||
|
|
|
@ -66,7 +66,6 @@ void test_rules_invariant(std::vector<ip_range<T>> const& r, ip_filter const& f)
|
||||||
TEST_CHECK(!r.empty());
|
TEST_CHECK(!r.empty());
|
||||||
if (r.empty()) return;
|
if (r.empty()) return;
|
||||||
|
|
||||||
error_code ec;
|
|
||||||
if (sizeof(r.front().first) == sizeof(address_v4))
|
if (sizeof(r.front().first) == sizeof(address_v4))
|
||||||
{
|
{
|
||||||
TEST_CHECK(r.front().first == addr("0.0.0.0"));
|
TEST_CHECK(r.front().first == addr("0.0.0.0"));
|
||||||
|
|
|
@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/natpmp.hpp"
|
#include "libtorrent/natpmp.hpp"
|
||||||
#include "libtorrent/socket.hpp"
|
#include "libtorrent/socket.hpp"
|
||||||
#include "libtorrent/socket_io.hpp"
|
#include "libtorrent/socket_io.hpp"
|
||||||
|
#include "libtorrent/aux_/numeric_cast.hpp"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -43,10 +44,12 @@ namespace
|
||||||
{
|
{
|
||||||
struct natpmp_callback : aux::portmap_callback
|
struct natpmp_callback : aux::portmap_callback
|
||||||
{
|
{
|
||||||
|
virtual ~natpmp_callback() = default;
|
||||||
|
|
||||||
void on_port_mapping(port_mapping_t const mapping
|
void on_port_mapping(port_mapping_t const mapping
|
||||||
, address const& ip, int port
|
, address const& ip, int port
|
||||||
, portmap_protocol const protocol, error_code const& err
|
, portmap_protocol const protocol, error_code const& err
|
||||||
, portmap_transport const transport) override
|
, portmap_transport) override
|
||||||
{
|
{
|
||||||
std::cout
|
std::cout
|
||||||
<< "mapping: " << mapping
|
<< "mapping: " << mapping
|
||||||
|
@ -56,12 +59,12 @@ namespace
|
||||||
<< ", error: \"" << err.message() << "\"\n";
|
<< ", error: \"" << err.message() << "\"\n";
|
||||||
}
|
}
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
virtual bool should_log_portmap(portmap_transport transport) const override
|
virtual bool should_log_portmap(portmap_transport) const override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void log_portmap(portmap_transport transport, char const* msg) const override
|
virtual void log_portmap(portmap_transport, char const* msg) const override
|
||||||
{
|
{
|
||||||
std::cout << msg << std::endl;
|
std::cout << msg << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -86,9 +89,9 @@ int main(int argc, char* argv[])
|
||||||
deadline_timer timer(ios);
|
deadline_timer timer(ios);
|
||||||
|
|
||||||
auto const tcp_map = natpmp_handler->add_mapping(portmap_protocol::tcp
|
auto const tcp_map = natpmp_handler->add_mapping(portmap_protocol::tcp
|
||||||
, atoi(argv[1]), tcp::endpoint({}, atoi(argv[1])));
|
, atoi(argv[1]), tcp::endpoint({}, aux::numeric_cast<std::uint16_t>(atoi(argv[1]))));
|
||||||
natpmp_handler->add_mapping(portmap_protocol::udp, atoi(argv[2])
|
natpmp_handler->add_mapping(portmap_protocol::udp, atoi(argv[2])
|
||||||
, tcp::endpoint({}, atoi(argv[2])));
|
, tcp::endpoint({}, aux::numeric_cast<std::uint16_t>(atoi(argv[2]))));
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
timer.expires_from_now(seconds(2), ec);
|
timer.expires_from_now(seconds(2), ec);
|
||||||
|
|
|
@ -33,7 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "test.hpp"
|
#include "test.hpp"
|
||||||
#include "libtorrent/packet_buffer.hpp"
|
#include "libtorrent/packet_buffer.hpp"
|
||||||
#include "libtorrent/packet_pool.hpp"
|
#include "libtorrent/packet_pool.hpp"
|
||||||
#include "libtorrent/aux_/numeric_cast.hpp"
|
|
||||||
|
|
||||||
using lt::packet_buffer;
|
using lt::packet_buffer;
|
||||||
using lt::packet_ptr;
|
using lt::packet_ptr;
|
||||||
|
@ -45,7 +44,7 @@ namespace {
|
||||||
packet_ptr make_pkt(packet_pool& pool, int const val)
|
packet_ptr make_pkt(packet_pool& pool, int const val)
|
||||||
{
|
{
|
||||||
packet_ptr ret = pool.acquire(20);
|
packet_ptr ret = pool.acquire(20);
|
||||||
*reinterpret_cast<std::uint8_t*>(ret->buf) = val;
|
*reinterpret_cast<std::uint8_t*>(ret->buf) = std::uint8_t(val);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -289,6 +289,7 @@ done:
|
||||||
|
|
||||||
std::cout << "re-adding" << std::endl;
|
std::cout << "re-adding" << std::endl;
|
||||||
add_torrent_params p;
|
add_torrent_params p;
|
||||||
|
TORRENT_UNUSED(test_deprecated);
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
if (test_deprecated)
|
if (test_deprecated)
|
||||||
{
|
{
|
||||||
|
|
|
@ -155,7 +155,7 @@ torrent_handle test_resume_flags(lt::session& ses
|
||||||
|
|
||||||
add_torrent_params p;
|
add_torrent_params p;
|
||||||
std::vector<char> rd = generate_resume_data(ti.get(), resume_file_prio);
|
std::vector<char> rd = generate_resume_data(ti.get(), resume_file_prio);
|
||||||
|
TORRENT_UNUSED(test_deprecated);
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
if (test_deprecated)
|
if (test_deprecated)
|
||||||
{
|
{
|
||||||
|
@ -249,7 +249,7 @@ void test_piece_priorities(bool test_deprecated = false)
|
||||||
TEST_EQUAL(prios[std::size_t(ti->num_pieces() - 1)], 0_pri);
|
TEST_EQUAL(prios[std::size_t(ti->num_pieces() - 1)], 0_pri);
|
||||||
|
|
||||||
std::vector<char> resume_data = write_resume_data_buf(ra->params);
|
std::vector<char> resume_data = write_resume_data_buf(ra->params);
|
||||||
|
TORRENT_UNUSED(test_deprecated);
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
if (test_deprecated)
|
if (test_deprecated)
|
||||||
{
|
{
|
||||||
|
@ -856,7 +856,7 @@ void test_zero_file_prio(bool test_deprecated = false)
|
||||||
|
|
||||||
std::vector<char> resume_data;
|
std::vector<char> resume_data;
|
||||||
bencode(back_inserter(resume_data), rd);
|
bencode(back_inserter(resume_data), rd);
|
||||||
|
TORRENT_UNUSED(test_deprecated);
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
if (test_deprecated)
|
if (test_deprecated)
|
||||||
{
|
{
|
||||||
|
|
|
@ -703,6 +703,7 @@ void test_fastresume(bool const test_deprecated)
|
||||||
bencode(std::back_inserter(resume_data), resume);
|
bencode(std::back_inserter(resume_data), resume);
|
||||||
|
|
||||||
add_torrent_params p;
|
add_torrent_params p;
|
||||||
|
TORRENT_UNUSED(test_deprecated);
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
if (test_deprecated)
|
if (test_deprecated)
|
||||||
{
|
{
|
||||||
|
@ -888,7 +889,7 @@ void test_rename_file_fastresume(bool test_deprecated)
|
||||||
add_torrent_params p;
|
add_torrent_params p;
|
||||||
std::vector<char> resume_data;
|
std::vector<char> resume_data;
|
||||||
bencode(std::back_inserter(resume_data), resume_ent);
|
bencode(std::back_inserter(resume_data), resume_ent);
|
||||||
|
TORRENT_UNUSED(test_deprecated);
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
if (test_deprecated)
|
if (test_deprecated)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue