attempt fo fix msvc warning and built tests with warnings-as-errors (#710)

fix msvc warnings and built tests with warnings-as-errors
This commit is contained in:
Arvid Norberg 2016-05-08 09:58:13 -04:00
parent 29902be3a0
commit a4beb287ee
5 changed files with 19 additions and 23 deletions

View File

@ -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

View File

@ -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<boost::uint32_t>::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<boost::uint32_t>::max());
TORRENT_ASSERT(boost::uint32_t(e - b) <= m_size);
TORRENT_ASSERT(uintptr_t(e - b) <= std::numeric_limits<boost::uint32_t>::max());
TORRENT_ASSERT(uintptr_t(e - b) <= m_size);
m_size -= boost::uint32_t(e - b);
}

View File

@ -99,6 +99,7 @@ project
<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
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
: default-build
<threading>multi
<invariant-checks>full

View File

@ -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<char> buf(buf_len);
std::vector<char> 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<mutable_buffer> 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;
}
}

View File

@ -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)