fix warnings
This commit is contained in:
parent
8b56aaf09a
commit
3171245292
12
.travis.yml
12
.travis.yml
|
@ -185,7 +185,7 @@ script:
|
||||||
# libtorrent is the name of the test suite target
|
# libtorrent is the name of the test suite target
|
||||||
- cd test
|
- cd test
|
||||||
- 'if [ "$tests" == "1" ]; then
|
- 'if [ "$tests" == "1" ]; then
|
||||||
travis_retry bjam -j3 warnings-as-errors=on crypto=$crypto debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset variant=$variant libtorrent test_natpmp enum_if -l300 &&
|
travis_retry bjam -j3 warnings-as-errors=on warnings=all crypto=$crypto debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset variant=$variant libtorrent test_natpmp enum_if -l300 &&
|
||||||
if [ "$coverage" == "1" ]; then
|
if [ "$coverage" == "1" ]; then
|
||||||
codecov --root .. --gcov-exec gcov-5;
|
codecov --root .. --gcov-exec gcov-5;
|
||||||
fi;
|
fi;
|
||||||
|
@ -193,13 +193,13 @@ script:
|
||||||
|
|
||||||
- cd ../examples
|
- cd ../examples
|
||||||
- 'if [ "$examples" == "1" ]; then
|
- 'if [ "$examples" == "1" ]; then
|
||||||
bjam -j3 warnings-as-errors=on crypto=$crypto debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset variant=$variant link=shared;
|
bjam -j3 warnings-as-errors=on warnings=all crypto=$crypto debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset variant=$variant link=shared;
|
||||||
fi'
|
fi'
|
||||||
- cd ..
|
- cd ..
|
||||||
|
|
||||||
- cd tools
|
- cd tools
|
||||||
- 'if [ "$tools" == "1" ]; then
|
- 'if [ "$tools" == "1" ]; then
|
||||||
bjam -j3 warnings-as-errors=on crypto=$crypto debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset variant=$variant link=shared;
|
bjam -j3 warnings-as-errors=on warnings=all crypto=$crypto debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset variant=$variant link=shared;
|
||||||
fi'
|
fi'
|
||||||
- cd ..
|
- cd ..
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ script:
|
||||||
# on OSX we need to use the brew version of python, for reasons explained above
|
# on OSX we need to use the brew version of python, for reasons explained above
|
||||||
- cd bindings/python
|
- cd bindings/python
|
||||||
- 'if [[ "$python" == "1" ]]; then
|
- 'if [[ "$python" == "1" ]]; then
|
||||||
bjam -j3 warnings-as-errors=on crypto=$crypto debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset variant=$variant stage_module stage_dependencies libtorrent-link=shared boost-link=shared &&
|
bjam -j3 warnings-as-errors=on warnings=all crypto=$crypto debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset variant=$variant stage_module stage_dependencies libtorrent-link=shared boost-link=shared &&
|
||||||
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
|
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
|
||||||
DYLD_LIBRARY_PATH=./dependencies python2 test.py;
|
DYLD_LIBRARY_PATH=./dependencies python2 test.py;
|
||||||
else
|
else
|
||||||
|
@ -223,7 +223,7 @@ script:
|
||||||
# simulation
|
# simulation
|
||||||
- cd simulation
|
- cd simulation
|
||||||
- 'if [[ "$sim" == "1" ]]; then
|
- 'if [[ "$sim" == "1" ]]; then
|
||||||
bjam -j2 crypto=built-in warnings-as-errors=on debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset deprecated-functions=off;
|
bjam -j2 crypto=built-in warnings-as-errors=on warnings=all debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset deprecated-functions=off;
|
||||||
fi'
|
fi'
|
||||||
- cd ..
|
- cd ..
|
||||||
|
|
||||||
|
@ -252,6 +252,6 @@ script:
|
||||||
- cd test
|
- cd test
|
||||||
- 'if [[ "$arch" == "arm" ]];
|
- 'if [[ "$arch" == "arm" ]];
|
||||||
then
|
then
|
||||||
bjam arm-tests warnings-as-errors=on crypto=$crypto variant=test_arm $toolset target-os=linux link=static testing.launcher="sudo cp -R bin rootfs/; sudo chroot rootfs";
|
bjam arm-tests warnings-as-errors=on warnings=all crypto=$crypto variant=test_arm $toolset target-os=linux link=static testing.launcher="sudo cp -R bin rootfs/; sudo chroot rootfs";
|
||||||
fi'
|
fi'
|
||||||
- cd ..
|
- cd ..
|
||||||
|
|
|
@ -281,15 +281,16 @@ namespace libtorrent {
|
||||||
private:
|
private:
|
||||||
aux::allocation_slot m_name_idx;
|
aux::allocation_slot m_name_idx;
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
#if defined __clang__ && __clang_major__ > 9
|
|
||||||
|
#if defined __clang__
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wshadow-field"
|
#pragma clang diagnostic ignored "-Weverything"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string TORRENT_DEPRECATED_MEMBER name;
|
std::string TORRENT_DEPRECATED_MEMBER name;
|
||||||
|
|
||||||
#if defined __clang__ && __clang_major__ > 9
|
#if defined __clang__
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -492,11 +492,6 @@ namespace libtorrent {
|
||||||
|
|
||||||
std::array<char, 8> m_reserved_bits;
|
std::array<char, 8> m_reserved_bits;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TORRENT_USE_ASSERTS
|
|
||||||
bool m_in_constructor = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,9 +160,6 @@ namespace {
|
||||||
peer_log(peer_log_alert::info, "CONSTRUCT", "bt_peer_connection");
|
peer_log(peer_log_alert::info, "CONSTRUCT", "bt_peer_connection");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TORRENT_USE_ASSERTS
|
|
||||||
m_in_constructor = false;
|
|
||||||
#endif
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
m_reserved_bits.fill(0);
|
m_reserved_bits.fill(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -268,8 +268,16 @@ CFRef<SCDynamicStoreRef> create_dynamic_store(SCDynamicStoreCallBack callback, v
|
||||||
|
|
||||||
SCDynamicStoreContext context = {0, nullptr, nullptr, nullptr, nullptr};
|
SCDynamicStoreContext context = {0, nullptr, nullptr, nullptr, nullptr};
|
||||||
context.info = context_info;
|
context.info = context_info;
|
||||||
|
|
||||||
|
#if defined __clang__
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wold-style-cast"
|
||||||
|
#endif
|
||||||
CFRef<SCDynamicStoreRef> store{SCDynamicStoreCreate(nullptr
|
CFRef<SCDynamicStoreRef> store{SCDynamicStoreCreate(nullptr
|
||||||
, CFSTR("libtorrent.IPChangeNotifierStore"), callback, &context)};
|
, CFSTR("libtorrent.IPChangeNotifierStore"), callback, &context)};
|
||||||
|
#if defined __clang__
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
if (!store)
|
if (!store)
|
||||||
return CFRef<SCDynamicStoreRef>();
|
return CFRef<SCDynamicStoreRef>();
|
||||||
|
|
||||||
|
|
|
@ -1685,7 +1685,8 @@ namespace libtorrent {
|
||||||
<< ", " << new_piece_priority << ")" << std::endl;
|
<< ", " << new_piece_priority << ")" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TORRENT_ASSERT(new_piece_priority >= dont_download);
|
static_assert(std::is_unsigned<decltype(new_piece_priority)::underlying_type>::value
|
||||||
|
, "we need assert new_piece_priority >= dont_download");
|
||||||
TORRENT_ASSERT(new_piece_priority <= top_priority);
|
TORRENT_ASSERT(new_piece_priority <= top_priority);
|
||||||
|
|
||||||
piece_pos& p = m_piece_map[index];
|
piece_pos& p = m_piece_map[index];
|
||||||
|
|
|
@ -4872,15 +4872,18 @@ namespace libtorrent {
|
||||||
bool const was_finished = is_finished();
|
bool const was_finished = is_finished();
|
||||||
for (auto const& p : pieces)
|
for (auto const& p : pieces)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(p.second >= dont_download);
|
static_assert(std::is_unsigned<decltype(p.second)>::value
|
||||||
|
, "we need assert p.second >= dont_download");
|
||||||
TORRENT_ASSERT(p.second <= top_priority);
|
TORRENT_ASSERT(p.second <= top_priority);
|
||||||
TORRENT_ASSERT(p.first >= piece_index_t(0));
|
TORRENT_ASSERT(p.first >= piece_index_t(0));
|
||||||
TORRENT_ASSERT(p.first < m_torrent_file->end_piece());
|
TORRENT_ASSERT(p.first < m_torrent_file->end_piece());
|
||||||
|
|
||||||
if (p.first < piece_index_t(0)
|
if (p.first < piece_index_t(0)
|
||||||
|| p.first >= m_torrent_file->end_piece()
|
|| p.first >= m_torrent_file->end_piece()
|
||||||
|| p.second < dont_download || p.second > top_priority)
|
|| p.second > top_priority)
|
||||||
{
|
{
|
||||||
|
static_assert(std::is_unsigned<decltype(p.second)>::value
|
||||||
|
, "we need additional condition: p.second < dont_download");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4922,7 +4925,9 @@ namespace libtorrent {
|
||||||
bool const was_finished = is_finished();
|
bool const was_finished = is_finished();
|
||||||
for (auto prio : pieces)
|
for (auto prio : pieces)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(prio >= dont_download && prio <= top_priority);
|
static_assert(std::is_unsigned<decltype(prio)>::value
|
||||||
|
, "we need assert prio >= dont_download");
|
||||||
|
TORRENT_ASSERT(prio <= top_priority);
|
||||||
filter_updated |= m_picker->set_piece_priority(index, prio);
|
filter_updated |= m_picker->set_piece_priority(index, prio);
|
||||||
TORRENT_ASSERT(num_have() >= m_picker->num_have_filtered());
|
TORRENT_ASSERT(num_have() >= m_picker->num_have_filtered());
|
||||||
++index;
|
++index;
|
||||||
|
|
|
@ -49,14 +49,17 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// tests are expected to even test deprecated functionality. There is no point
|
// tests are expected to even test deprecated functionality. There is no point
|
||||||
// in warning about deprecated use in any of the tests.
|
// in warning about deprecated use in any of the tests.
|
||||||
|
// the unreachable code warnings are disabled since the test macros may
|
||||||
|
// sometimes have conditions that are known at compile time
|
||||||
#if defined __clang__
|
#if defined __clang__
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated"
|
#pragma clang diagnostic ignored "-Wdeprecated"
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#pragma clang diagnostic ignored "-Wunreachable-code"
|
||||||
|
|
||||||
#elif defined __GNUC__
|
#elif defined __GNUC__
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated"
|
#pragma GCC diagnostic ignored "-Wdeprecated"
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunreachable-code"
|
||||||
|
|
||||||
#elif defined _MSC_VER
|
#elif defined _MSC_VER
|
||||||
#pragma warning(disable : 4996)
|
#pragma warning(disable : 4996)
|
||||||
|
|
|
@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "libtorrent/crc32c.hpp"
|
#include "libtorrent/crc32c.hpp"
|
||||||
#include "libtorrent/aux_/cpuid.hpp"
|
#include "libtorrent/aux_/cpuid.hpp"
|
||||||
|
#include "libtorrent/aux_/byteswap.hpp"
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
#include "test.hpp"
|
#include "test.hpp"
|
||||||
|
|
||||||
|
@ -44,24 +45,24 @@ TORRENT_TEST(crc32)
|
||||||
std::uint32_t in1 = 0x5aa5feef;
|
std::uint32_t in1 = 0x5aa5feef;
|
||||||
out = crc32c_32(in1);
|
out = crc32c_32(in1);
|
||||||
|
|
||||||
TEST_EQUAL(out, htonl(0xd5b9e35e));
|
TEST_EQUAL(out, aux::host_to_network(0xd5b9e35eU));
|
||||||
|
|
||||||
std::uint64_t buf[4];
|
std::uint64_t buf[4];
|
||||||
memcpy(buf, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
memcpy(buf, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 32);
|
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 32);
|
||||||
|
|
||||||
out = crc32c(buf, 4);
|
out = crc32c(buf, 4);
|
||||||
TEST_EQUAL(out, htonl(0xaa36918a));
|
TEST_EQUAL(out, aux::host_to_network(0xaa36918aU));
|
||||||
|
|
||||||
memcpy(buf, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
|
memcpy(buf, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
|
||||||
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", 32);
|
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", 32);
|
||||||
out = crc32c(buf, 4);
|
out = crc32c(buf, 4);
|
||||||
TEST_EQUAL(out, htonl(0x43aba862));
|
TEST_EQUAL(out, aux::host_to_network(0x43aba862U));
|
||||||
|
|
||||||
memcpy(buf, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
|
memcpy(buf, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
|
||||||
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", 32);
|
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", 32);
|
||||||
out = crc32c(buf, 4);
|
out = crc32c(buf, 4);
|
||||||
TEST_EQUAL(out, htonl(0x4e79dd46));
|
TEST_EQUAL(out, aux::host_to_network(0x4e79dd46U));
|
||||||
|
|
||||||
#if TORRENT_HAS_ARM
|
#if TORRENT_HAS_ARM
|
||||||
TORRENT_ASSERT(aux::arm_crc32c_support);
|
TORRENT_ASSERT(aux::arm_crc32c_support);
|
||||||
|
|
Loading…
Reference in New Issue