From 7dad0db4a5f26dc4328f1be203b007761f93c088 Mon Sep 17 00:00:00 2001 From: arvidn Date: Tue, 20 Mar 2018 09:12:47 +0100 Subject: [PATCH] fix warnings in bdecode and disk_io_job --- include/libtorrent/bdecode.hpp | 10 +++++++--- src/disk_io_job.cpp | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/libtorrent/bdecode.hpp b/include/libtorrent/bdecode.hpp index 2ddc85a51..1342f4dce 100644 --- a/include/libtorrent/bdecode.hpp +++ b/include/libtorrent/bdecode.hpp @@ -164,7 +164,7 @@ struct bdecode_token { // the node with type 'end' is a logical node, pointing to the end // of the bencoded buffer. - enum type_t + enum type_t : std::uint8_t { none, dict, list, string, integer, end }; enum limits_t @@ -182,7 +182,9 @@ struct bdecode_token { TORRENT_ASSERT(off >= 0); TORRENT_ASSERT(off <= max_offset); - TORRENT_ASSERT(t >= 0 && t <= end); + TORRENT_ASSERT(t <= end); + static_assert(std::is_unsigned::type>::value + , "we need to assert t >= 0 here"); } bdecode_token(std::ptrdiff_t off, std::uint32_t next @@ -198,7 +200,9 @@ struct bdecode_token TORRENT_ASSERT(next <= max_next_item); // the string has 2 implied header bytes, to allow for longer prefixes TORRENT_ASSERT(header_size < 8 || (type == string && header_size < 10)); - TORRENT_ASSERT(t >= 0 && t <= end); + TORRENT_ASSERT(t <= end); + static_assert(std::is_unsigned::type>::value + , "we need to assert t >= 0 here"); } int start_offset() const { TORRENT_ASSERT(type == string); return int(header) + 2; } diff --git a/src/disk_io_job.cpp b/src/disk_io_job.cpp index 9f5eb9342..1ddbe3b5a 100644 --- a/src/disk_io_job.cpp +++ b/src/disk_io_job.cpp @@ -34,7 +34,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/block_cache.hpp" // for cached_piece_entry #include "libtorrent/disk_buffer_holder.hpp" +#include "libtorrent/aux_/disable_warnings_push.hpp" #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" namespace libtorrent {