fix more warnings and bare_bones build

This commit is contained in:
Arvid Norberg 2015-04-22 00:59:35 +00:00
parent 0b063de9ff
commit 3664c7c137
9 changed files with 35 additions and 9 deletions

View File

@ -59,7 +59,10 @@ extern char const* libtorrent_assert_log;
TORRENT_EXPORT void assert_print(char const* fmt, ...);
TORRENT_NO_RETURN TORRENT_EXPORT void assert_fail(const char* expr, int line
#if TORRENT_USE_ASSERTS || defined TORRENT_ASIO_DEBUGGING
TORRENT_NO_RETURN
#endif
TORRENT_EXPORT void assert_fail(const char* expr, int line
, char const* file, char const* function, char const* val, int kind = 0);
#define TORRENT_ASSERT_PRECOND(x) \

View File

@ -309,13 +309,13 @@ namespace libtorrent
const int b = (bits + 31) / 32;
if (m_buf)
{
m_buf = (boost::uint32_t*)std::realloc(m_buf-1, (b+1) * 4);
m_buf = static_cast<boost::uint32_t*>(std::realloc(m_buf-1, (b+1) * 4));
m_buf = m_buf + 1;
m_buf[-1] = bits;
}
else if (bits > 0)
{
m_buf = (boost::uint32_t*)std::malloc((b+1) * 4);
m_buf = static_cast<boost::uint32_t*>(std::malloc((b+1) * 4));
m_buf = m_buf + 1;
m_buf[-1] = bits;
}

View File

@ -171,8 +171,9 @@ public:
void resize(std::size_t n)
{
TORRENT_ASSERT(n < 0xffffffffu);
reserve(n);
m_size = n;
m_size = boost::uint32_t(n);
}
void insert(char* point, char const* first, char const* last)
@ -214,9 +215,10 @@ public:
{
if (n <= capacity()) return;
TORRENT_ASSERT(n > 0);
TORRENT_ASSERT(n < 0xffffffffu);
m_begin = (char*)std::realloc(m_begin, n);
m_capacity = n;
m_begin = static_cast<char*>(std::realloc(m_begin, n));
m_capacity = boost::uint32_t(n);
}
bool empty() const { return m_size == 0; }

View File

@ -47,6 +47,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/peer_id.hpp"
#include "libtorrent/tracker_manager.hpp"
#include "libtorrent/i2p_stream.hpp"
#include "libtorrent/error_code.hpp"
namespace libtorrent
{
@ -54,6 +55,9 @@ namespace libtorrent
struct http_connection;
class entry;
class http_parser;
struct bdecode_node;
struct peer_entry;
namespace aux { struct session_settings; }
class TORRENT_EXTRA_EXPORT http_tracker_connection

View File

@ -1269,6 +1269,7 @@ namespace libtorrent
friend void* asio_handler_allocate(
std::size_t size, allocating_handler<Handler, Size>* ctx)
{
TORRENT_UNUSED(size);
TORRENT_ASSERT(size <= Size);
#ifdef TORRENT_DEBUG
TORRENT_ASSERT(!ctx->storage.used);
@ -1278,8 +1279,14 @@ namespace libtorrent
}
friend void asio_handler_deallocate(
void*, std::size_t, allocating_handler<Handler, Size>* ctx)
void* ptr, std::size_t size, allocating_handler<Handler, Size>* ctx)
{
TORRENT_UNUSED(ptr);
TORRENT_UNUSED(size);
TORRENT_UNUSED(ctx);
TORRENT_ASSERT(size <= Size);
TORRENT_ASSERT(ptr == &ctx->storage.bytes);
#ifdef TORRENT_DEBUG
ctx->storage.used = false;
#endif

View File

@ -271,6 +271,7 @@ namespace libtorrent
template <class S>
void instantiate(io_service& ios, void* userdata = 0)
{
TORRENT_UNUSED(ios);
TORRENT_ASSERT(&ios == &m_io_service);
construct(socket_type_int_impl<S>::value, userdata);
}

View File

@ -297,7 +297,7 @@ TORRENT_NO_RETURN TORRENT_EXPORT void assert_fail(char const* expr, int line
#else
TORRENT_EXPORT void assert_print(char const*, ...) {}
TORRENT_NO_RETURN TORRENT_EXPORT void assert_fail(char const*, int, char const*
TORRENT_EXPORT void assert_fail(char const*, int, char const*
, char const*, char const*, int) {}
#endif

View File

@ -1323,6 +1323,8 @@ bool block_cache::inc_block_refcount(cached_piece_entry* pe, int block, int reas
};
TORRENT_ASSERT(pe->blocks[block].refcount >= pe->blocks[block].hashing_count
+ pe->blocks[block].reading_count + pe->blocks[block].flushing_count);
#else
TORRENT_UNUSED(reason);
#endif
return true;
}
@ -1381,6 +1383,8 @@ void block_cache::dec_block_refcount(cached_piece_entry* pe, int block, int reas
};
TORRENT_PIECE_ASSERT(pe->blocks[block].refcount >= pe->blocks[block].hashing_count
+ pe->blocks[block].reading_count + pe->blocks[block].flushing_count, pe);
#else
TORRENT_UNUSED(reason);
#endif
}
@ -1675,13 +1679,16 @@ void block_cache::check_invariant() const
}
#endif
// TODO: 2 turn these return values into enums
// returns
// -1: block not in cache
// -2: out of memory
int block_cache::copy_from_piece(cached_piece_entry* pe, disk_io_job* j, bool expect_no_fail)
int block_cache::copy_from_piece(cached_piece_entry* pe, disk_io_job* j
, bool expect_no_fail)
{
INVARIANT_CHECK;
TORRENT_UNUSED(expect_no_fail);
TORRENT_PIECE_ASSERT(j->buffer == 0, pe);
TORRENT_PIECE_ASSERT(pe->in_use, pe);

View File

@ -2427,6 +2427,8 @@ namespace libtorrent
send_buffer(msg, sizeof(msg));
stats_counters().inc_stats_counter(counters::num_outgoing_extended);
#else
TORRENT_UNUSED(index);
#endif
}