diff --git a/appveyor.yml b/appveyor.yml index 25c108f8b..2947fb307 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -99,7 +99,7 @@ build_script: # test - cd %ROOT_DIRECTORY%\test -- b2.exe --hash -j2 address-model=%model% win-tests %compiler% variant=%variant% link=shared linkflags=%linkflags% include=%include% testing.execute=off +- b2.exe --hash -j2 warnings-as-errors=on address-model=%model% win-tests %compiler% variant=%variant% link=shared linkflags=%linkflags% include=%include% testing.execute=off # python binding - cd %ROOT_DIRECTORY%\bindings\python diff --git a/include/libtorrent/buffer.hpp b/include/libtorrent/buffer.hpp index bc06d63ac..085107af2 100644 --- a/include/libtorrent/buffer.hpp +++ b/include/libtorrent/buffer.hpp @@ -127,7 +127,6 @@ public: std::memcpy(m_begin, b.begin(), b.size()); } -#if __cplusplus > 199711L buffer(buffer&& b) : m_begin(b.m_begin) , m_size(b.m_size) @@ -148,7 +147,6 @@ public: b.m_size = b.m_capacity = 0; return *this; } -#endif buffer& operator=(buffer const& b) { @@ -171,7 +169,7 @@ public: void resize(std::size_t n) { - TORRENT_ASSERT(n < 0xffffffffu); + TORRENT_ASSERT(n < std::numeric_limits::max()); reserve(n); m_size = boost::uint32_t(n); } @@ -203,8 +201,8 @@ public: } std::memmove(b, e, m_begin + m_size - e); TORRENT_ASSERT(e >= b); - TORRENT_ASSERT(e - b <= std::numeric_limits::max()); - TORRENT_ASSERT(boost::uint32_t(e - b) <= m_size); + TORRENT_ASSERT(uintptr_t(e - b) <= std::numeric_limits::max()); + TORRENT_ASSERT(uintptr_t(e - b) <= m_size); m_size -= boost::uint32_t(e - b); } diff --git a/test/Jamfile b/test/Jamfile index 7abaa29f2..bbe0e57e0 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -99,6 +99,7 @@ project darwin:-Wno-unused-command-line-argument # disable warning C4275: non DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' msvc:/wd4275 + msvc:_SCL_SECURE_NO_WARNINGS : default-build multi full diff --git a/test/test_pe_crypto.cpp b/test/test_pe_crypto.cpp index e8d126952..fa0e83e49 100644 --- a/test/test_pe_crypto.cpp +++ b/test/test_pe_crypto.cpp @@ -52,47 +52,44 @@ void test_enc_handler(libtorrent::crypto_plugin* a, libtorrent::crypto_plugin* b #endif for (int rep = 0; rep < repcount; ++rep) { - int buf_len = rand() % (512 * 1024); - char* buf = new char[buf_len]; - char* cmp_buf = new char[buf_len]; + int const buf_len = rand() % (512 * 1024); + std::vector buf(buf_len); + std::vector cmp_buf(buf_len); - std::generate(buf, buf + buf_len, &std::rand); - std::memcpy(cmp_buf, buf, buf_len); + std::generate(buf.begin(), buf.end(), &std::rand); + std::copy(buf.begin(), buf.end(), cmp_buf.begin()); using namespace boost::asio; std::vector iovec; - iovec.push_back(mutable_buffer(buf, buf_len)); + iovec.push_back(mutable_buffer(&buf[0], buf_len)); a->encrypt(iovec); - TEST_CHECK(!std::equal(buf, buf + buf_len, cmp_buf)); + TEST_CHECK(!std::equal(buf.begin(), buf.end(), cmp_buf.begin())); TEST_CHECK(iovec.empty()); int consume = 0; int produce = buf_len; int packet_size = 0; - iovec.push_back(mutable_buffer(buf, buf_len)); + iovec.push_back(mutable_buffer(&buf[0], buf_len)); b->decrypt(iovec, consume, produce, packet_size); - TEST_CHECK(std::equal(buf, buf + buf_len, cmp_buf)); + TEST_CHECK(std::equal(buf.begin(), buf.end(), cmp_buf.begin())); TEST_CHECK(iovec.empty()); TEST_EQUAL(consume, 0); TEST_EQUAL(produce, buf_len); TEST_EQUAL(packet_size, 0); - iovec.push_back(mutable_buffer(buf, buf_len)); + iovec.push_back(mutable_buffer(&buf[0], buf_len)); b->encrypt(iovec); - TEST_CHECK(!std::equal(buf, buf + buf_len, cmp_buf)); + TEST_CHECK(!std::equal(buf.begin(), buf.end(), cmp_buf.begin())); TEST_CHECK(iovec.empty()); consume = 0; produce = buf_len; packet_size = 0; - iovec.push_back(mutable_buffer(buf, buf_len)); + iovec.push_back(mutable_buffer(&buf[0], buf_len)); a->decrypt(iovec, consume, produce, packet_size); - TEST_CHECK(std::equal(buf, buf + buf_len, cmp_buf)); + TEST_CHECK(std::equal(buf.begin(), buf.end(), cmp_buf.begin())); TEST_CHECK(iovec.empty()); TEST_EQUAL(consume, 0); TEST_EQUAL(produce, buf_len); TEST_EQUAL(packet_size, 0); - - delete[] buf; - delete[] cmp_buf; } } diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 26ed23807..ce7088aa8 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -257,7 +257,7 @@ TORRENT_TEST(torrent) piece[i] = (i % 26) + 'A'; // calculate the hash for all pieces - sha1_hash ph = hasher(&piece[0], piece.size()).final(); + sha1_hash ph = hasher(&piece[0], int(piece.size())).final(); int num = t.num_pieces(); TEST_CHECK(t.num_pieces() > 0); for (int i = 0; i < num; ++i)