fix warnings in bdecode and disk_io_job

This commit is contained in:
arvidn 2018-03-20 09:12:47 +01:00 committed by Arvid Norberg
parent 61ae2c834b
commit 7dad0db4a5
2 changed files with 9 additions and 3 deletions

View File

@ -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<std::underlying_type<bdecode_token::type_t>::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<std::underlying_type<bdecode_token::type_t>::type>::value
, "we need to assert t >= 0 here");
}
int start_offset() const { TORRENT_ASSERT(type == string); return int(header) + 2; }

View File

@ -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 <boost/variant/get.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace libtorrent {