fix warnings

This commit is contained in:
arvidn 2018-03-23 23:54:17 +01:00 committed by Arvid Norberg
parent 8b56aaf09a
commit 3171245292
9 changed files with 37 additions and 26 deletions

View File

@ -185,7 +185,7 @@ script:
# libtorrent is the name of the test suite target
- cd test
- '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
codecov --root .. --gcov-exec gcov-5;
fi;
@ -193,13 +193,13 @@ script:
- cd ../examples
- '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'
- cd ..
- cd tools
- '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'
- cd ..
@ -211,7 +211,7 @@ script:
# on OSX we need to use the brew version of python, for reasons explained above
- cd bindings/python
- '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
DYLD_LIBRARY_PATH=./dependencies python2 test.py;
else
@ -223,7 +223,7 @@ script:
# simulation
- cd simulation
- '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'
- cd ..
@ -252,6 +252,6 @@ script:
- cd test
- 'if [[ "$arch" == "arm" ]];
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'
- cd ..

View File

@ -281,15 +281,16 @@ namespace libtorrent {
private:
aux::allocation_slot m_name_idx;
#ifndef TORRENT_NO_DEPRECATE
#if defined __clang__ && __clang_major__ > 9
#if defined __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshadow-field"
#pragma clang diagnostic ignored "-Weverything"
#endif
public:
std::string TORRENT_DEPRECATED_MEMBER name;
#if defined __clang__ && __clang_major__ > 9
#if defined __clang__
#pragma clang diagnostic pop
#endif
#endif

View File

@ -492,11 +492,6 @@ namespace libtorrent {
std::array<char, 8> m_reserved_bits;
#endif
#if TORRENT_USE_ASSERTS
bool m_in_constructor = true;
#endif
};
}

View File

@ -160,9 +160,6 @@ namespace {
peer_log(peer_log_alert::info, "CONSTRUCT", "bt_peer_connection");
#endif
#if TORRENT_USE_ASSERTS
m_in_constructor = false;
#endif
#ifndef TORRENT_DISABLE_EXTENSIONS
m_reserved_bits.fill(0);
#endif

View File

@ -268,8 +268,16 @@ CFRef<SCDynamicStoreRef> create_dynamic_store(SCDynamicStoreCallBack callback, v
SCDynamicStoreContext context = {0, nullptr, nullptr, nullptr, nullptr};
context.info = context_info;
#if defined __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wold-style-cast"
#endif
CFRef<SCDynamicStoreRef> store{SCDynamicStoreCreate(nullptr
, CFSTR("libtorrent.IPChangeNotifierStore"), callback, &context)};
#if defined __clang__
#pragma clang diagnostic pop
#endif
if (!store)
return CFRef<SCDynamicStoreRef>();

View File

@ -1685,7 +1685,8 @@ namespace libtorrent {
<< ", " << new_piece_priority << ")" << std::endl;
#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);
piece_pos& p = m_piece_map[index];

View File

@ -4872,15 +4872,18 @@ namespace libtorrent {
bool const was_finished = is_finished();
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.first >= piece_index_t(0));
TORRENT_ASSERT(p.first < m_torrent_file->end_piece());
if (p.first < piece_index_t(0)
|| 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;
}
@ -4922,7 +4925,9 @@ namespace libtorrent {
bool const was_finished = is_finished();
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);
TORRENT_ASSERT(num_have() >= m_picker->num_have_filtered());
++index;

View File

@ -49,14 +49,17 @@ POSSIBILITY OF SUCH DAMAGE.
// tests are expected to even test deprecated functionality. There is no point
// 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__
#pragma clang diagnostic ignored "-Wdeprecated"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wunreachable-code"
#elif defined __GNUC__
#pragma GCC diagnostic ignored "-Wdeprecated"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma GCC diagnostic ignored "-Wunreachable-code"
#elif defined _MSC_VER
#pragma warning(disable : 4996)

View File

@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/crc32c.hpp"
#include "libtorrent/aux_/cpuid.hpp"
#include "libtorrent/aux_/byteswap.hpp"
#include "libtorrent/assert.hpp"
#include "test.hpp"
@ -44,24 +45,24 @@ TORRENT_TEST(crc32)
std::uint32_t in1 = 0x5aa5feef;
out = crc32c_32(in1);
TEST_EQUAL(out, htonl(0xd5b9e35e));
TEST_EQUAL(out, aux::host_to_network(0xd5b9e35eU));
std::uint64_t buf[4];
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);
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"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", 32);
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"
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", 32);
out = crc32c(buf, 4);
TEST_EQUAL(out, htonl(0x4e79dd46));
TEST_EQUAL(out, aux::host_to_network(0x4e79dd46U));
#if TORRENT_HAS_ARM
TORRENT_ASSERT(aux::arm_crc32c_support);