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
|
||||
<library>/torrent//torrent
|
||||
<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
|
||||
<toolset>msvc:<cflags>/wd4373
|
||||
<conditional>@warnings
|
||||
: # default-build
|
||||
<threading>multi
|
||||
<asserts>on
|
||||
|
@ -22,8 +21,7 @@ exe enum_if : enum_if.cpp
|
|||
: # requirements
|
||||
<library>/torrent//torrent
|
||||
<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
|
||||
<toolset>msvc:<cflags>/wd4373
|
||||
<conditional>@warnings
|
||||
: # default-build
|
||||
<threading>multi
|
||||
<asserts>on
|
||||
|
@ -80,13 +78,13 @@ project
|
|||
<export-extra>on
|
||||
<library>libtorrent_test
|
||||
<library>/torrent//torrent
|
||||
<toolset>darwin:<cflags>-Wno-unused-command-line-argument
|
||||
# disable warning C4275: non DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'
|
||||
<toolset>msvc:<cflags>/wd4275
|
||||
# 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>/wd4373
|
||||
<toolset>msvc:<cflags>/wd4503
|
||||
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
|
||||
# C4127: conditional expression is constant
|
||||
<toolset>msvc:<cflags>/wd4127
|
||||
# C4309: 'conversion' : truncation of constant value
|
||||
<toolset>msvc:<cflags>/wd4309
|
||||
# C4310: cast truncates constant value
|
||||
<toolset>msvc:<cflags>/wd4310
|
||||
<conditional>@warnings
|
||||
<export-extra>on
|
||||
: default-build
|
||||
<threading>multi
|
||||
|
|
|
@ -642,10 +642,11 @@ dht::key_desc_t const sample_infohashes_desc[] = {
|
|||
|
||||
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);
|
||||
int cursor = 0;
|
||||
|
||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
||||
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||
, "kademlia routing table state\n"
|
||||
"bucket_size: %d\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());
|
||||
i != end; ++i, ++idx)
|
||||
{
|
||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
||||
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||
, "%2d: ", idx);
|
||||
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)
|
||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor, "-");
|
||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor, "\n");
|
||||
cursor += std::snprintf(BUFFER_CURSOR_POS, "-");
|
||||
cursor += std::snprintf(BUFFER_CURSOR_POS, "\n");
|
||||
|
||||
if (cursor > int(buf.size()) - 500) buf.resize(buf.size() * 3 / 2);
|
||||
}
|
||||
|
||||
time_point now = aux::time_now();
|
||||
|
||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
||||
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||
, "\nnodes:");
|
||||
|
||||
int bucket_index = 0;
|
||||
for (auto i = table.buckets().begin(), end(table.buckets().end());
|
||||
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"
|
||||
, bucket_index, int(i->live_nodes.size())
|
||||
, int(i->replacements.size()));
|
||||
|
@ -712,23 +713,23 @@ void print_state(std::ostream& os, routing_table const& table)
|
|||
node_id id = j->id;
|
||||
id <<= id_shift;
|
||||
|
||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
||||
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||
, " prefix: %2x id: %s"
|
||||
, ((id[0] & top_mask) >> mask_shift)
|
||||
, aux::to_hex(j->id).c_str());
|
||||
|
||||
if (j->rtt == 0xffff)
|
||||
{
|
||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
||||
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||
, " rtt: ");
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
||||
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||
, " rtt: %4d", j->rtt);
|
||||
}
|
||||
|
||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
||||
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||
, " fail: %4d ping: %d dist: %3d"
|
||||
, j->fail_count()
|
||||
, j->pinged()
|
||||
|
@ -736,22 +737,22 @@ void print_state(std::ostream& os, routing_table const& table)
|
|||
|
||||
if (j->last_queried == min_time())
|
||||
{
|
||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
||||
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||
, " query: ");
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
||||
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||
, " 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());
|
||||
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");
|
||||
bucket_index = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
||||
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||
, "%2d mask: %2x: [", bucket_index, (top_mask >> mask_shift));
|
||||
|
||||
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" : " "));
|
||||
}
|
||||
cursor += std::snprintf(&buf[cursor], buf.size() - cursor
|
||||
cursor += std::snprintf(BUFFER_CURSOR_POS
|
||||
, "]\n");
|
||||
if (cursor > int(buf.size()) - 500) buf.resize(buf.size() * 3 / 2);
|
||||
}
|
||||
buf[cursor] = '\0';
|
||||
buf[std::size_t(cursor)] = '\0';
|
||||
os << &buf[0];
|
||||
#undef BUFFER_CURSOR_POS
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
|
@ -475,8 +475,6 @@ TORRENT_TEST(unc_tests)
|
|||
std::string long_file_name2 { long_file_name1 };
|
||||
long_file_name2.back() = '2';
|
||||
|
||||
error_code ec;
|
||||
|
||||
lt::create_directory(long_component_name, ec);
|
||||
TEST_EQUAL(ec, error_code());
|
||||
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());
|
||||
if (r.empty()) return;
|
||||
|
||||
error_code ec;
|
||||
if (sizeof(r.front().first) == sizeof(address_v4))
|
||||
{
|
||||
TEST_CHECK(r.front().first == addr("0.0.0.0"));
|
||||
|
|
|
@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/natpmp.hpp"
|
||||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/socket_io.hpp"
|
||||
#include "libtorrent/aux_/numeric_cast.hpp"
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
@ -43,10 +44,12 @@ namespace
|
|||
{
|
||||
struct natpmp_callback : aux::portmap_callback
|
||||
{
|
||||
virtual ~natpmp_callback() = default;
|
||||
|
||||
void on_port_mapping(port_mapping_t const mapping
|
||||
, address const& ip, int port
|
||||
, portmap_protocol const protocol, error_code const& err
|
||||
, portmap_transport const transport) override
|
||||
, portmap_transport) override
|
||||
{
|
||||
std::cout
|
||||
<< "mapping: " << mapping
|
||||
|
@ -56,12 +59,12 @@ namespace
|
|||
<< ", error: \"" << err.message() << "\"\n";
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -86,9 +89,9 @@ int main(int argc, char* argv[])
|
|||
deadline_timer timer(ios);
|
||||
|
||||
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])
|
||||
, tcp::endpoint({}, atoi(argv[2])));
|
||||
, tcp::endpoint({}, aux::numeric_cast<std::uint16_t>(atoi(argv[2]))));
|
||||
|
||||
error_code ec;
|
||||
timer.expires_from_now(seconds(2), ec);
|
||||
|
|
|
@ -33,7 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "test.hpp"
|
||||
#include "libtorrent/packet_buffer.hpp"
|
||||
#include "libtorrent/packet_pool.hpp"
|
||||
#include "libtorrent/aux_/numeric_cast.hpp"
|
||||
|
||||
using lt::packet_buffer;
|
||||
using lt::packet_ptr;
|
||||
|
@ -45,7 +44,7 @@ namespace {
|
|||
packet_ptr make_pkt(packet_pool& pool, int const val)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -289,6 +289,7 @@ done:
|
|||
|
||||
std::cout << "re-adding" << std::endl;
|
||||
add_torrent_params p;
|
||||
TORRENT_UNUSED(test_deprecated);
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
if (test_deprecated)
|
||||
{
|
||||
|
|
|
@ -155,7 +155,7 @@ torrent_handle test_resume_flags(lt::session& ses
|
|||
|
||||
add_torrent_params p;
|
||||
std::vector<char> rd = generate_resume_data(ti.get(), resume_file_prio);
|
||||
|
||||
TORRENT_UNUSED(test_deprecated);
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
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);
|
||||
|
||||
std::vector<char> resume_data = write_resume_data_buf(ra->params);
|
||||
|
||||
TORRENT_UNUSED(test_deprecated);
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
if (test_deprecated)
|
||||
{
|
||||
|
@ -856,7 +856,7 @@ void test_zero_file_prio(bool test_deprecated = false)
|
|||
|
||||
std::vector<char> resume_data;
|
||||
bencode(back_inserter(resume_data), rd);
|
||||
|
||||
TORRENT_UNUSED(test_deprecated);
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
if (test_deprecated)
|
||||
{
|
||||
|
|
|
@ -703,6 +703,7 @@ void test_fastresume(bool const test_deprecated)
|
|||
bencode(std::back_inserter(resume_data), resume);
|
||||
|
||||
add_torrent_params p;
|
||||
TORRENT_UNUSED(test_deprecated);
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
if (test_deprecated)
|
||||
{
|
||||
|
@ -888,7 +889,7 @@ void test_rename_file_fastresume(bool test_deprecated)
|
|||
add_torrent_params p;
|
||||
std::vector<char> resume_data;
|
||||
bencode(std::back_inserter(resume_data), resume_ent);
|
||||
|
||||
TORRENT_UNUSED(test_deprecated);
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
if (test_deprecated)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue