fix some more warnings

This commit is contained in:
arvidn 2015-08-08 02:33:54 -04:00
parent 4453592c09
commit 50925d7652
15 changed files with 56 additions and 36 deletions

View File

@ -122,8 +122,8 @@ namespace libtorrent
++ret;
}
return ret;
}
}
template <class OutIt>
void write_char(OutIt& out, char c)
{

View File

@ -188,7 +188,8 @@ namespace libtorrent
{
l.unlock();
m_ios.post(boost::bind(&watermark_callback
, (std::vector<boost::shared_ptr<disk_observer> >*)NULL, slice));
, static_cast<std::vector<boost::shared_ptr<disk_observer> >*>(NULL)
, slice));
return;
}
@ -199,7 +200,8 @@ namespace libtorrent
{
l.unlock();
m_ios.post(boost::bind(&watermark_callback
, (std::vector<boost::shared_ptr<disk_observer> >*)NULL, handlers));
, static_cast<std::vector<boost::shared_ptr<disk_observer> >*>(NULL)
, handlers));
return;
}
@ -307,7 +309,7 @@ namespace libtorrent
// we need to roll back and free all the buffers
// we've already allocated
for (int j = 0; j < i; ++j)
free_buffer_impl((char*)iov[j].iov_base, l);
free_buffer_impl(static_cast<char*>(iov[j].iov_base), l);
return -1;
}
}
@ -319,7 +321,7 @@ namespace libtorrent
// TODO: perhaps we should sort the buffers here?
mutex::scoped_lock l(m_pool_mutex);
for (int i = 0; i < iov_len; ++i)
free_buffer_impl((char*)iov[i].iov_base, l);
free_buffer_impl(static_cast<char*>(iov[i].iov_base), l);
check_buffer_level(l);
}
@ -575,8 +577,8 @@ namespace libtorrent
#define MAP_NOCACHE 0
#endif
ftruncate(m_cache_fd, boost::uint64_t(m_max_use) * 0x4000);
m_cache_pool = (char*)mmap(0, boost::uint64_t(m_max_use) * 0x4000, PROT_READ | PROT_WRITE
, MAP_SHARED | MAP_NOCACHE, m_cache_fd, 0);
m_cache_pool = static_cast<char*>(mmap(0, boost::uint64_t(m_max_use) * 0x4000, PROT_READ | PROT_WRITE
, MAP_SHARED | MAP_NOCACHE, m_cache_fd, 0));
if (intptr_t(m_cache_pool) == -1)
{
ec.assign(errno, boost::system::generic_category());

View File

@ -63,7 +63,7 @@ namespace libtorrent
if (action == rename_file || action == move_storage)
free(buffer.string);
else if (action == save_resume_data)
delete (entry*)buffer.resume_data;
delete static_cast<entry*>(buffer.resume_data);
}
bool disk_io_job::completed(cached_piece_entry const* pe, int block_size)

View File

@ -586,7 +586,7 @@ namespace libtorrent
{
// currently, only swapping entries of the same type or where one
// of the entries is uninitialized is supported.
TORRENT_ASSERT(false && "not implemented");
TORRENT_ASSERT(false);
}
}
@ -605,7 +605,7 @@ namespace libtorrent
{
case int_t:
out += libtorrent::to_string(integer()).elems;
out += "\n";
out += "\n";
break;
case string_t:
{

View File

@ -1620,7 +1620,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
int buf_size = bufs_size(bufs, num_bufs);
// this is page aligned since it's used in APIs which
// are likely to require that (depending on OS)
char* buf = (char*)page_aligned_allocator::malloc(buf_size);
char* buf = static_cast<char*>(page_aligned_allocator::malloc(buf_size));
if (!buf) return false;
tmp->iov_base = buf;
tmp->iov_len = buf_size;
@ -1642,7 +1642,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
// operation
int buf_size = 0;
for (int i = 0; i < num_bufs; ++i) buf_size += bufs[i].iov_len;
char* buf = (char*)page_aligned_allocator::malloc(buf_size);
char* buf = static_cast<char*>(page_aligned_allocator::malloc(buf_size));
if (!buf) return false;
gather_copy(bufs, num_bufs, buf);
tmp->iov_base = buf;
@ -1786,7 +1786,8 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
#endif
if (flags & file::coalesce_buffers)
coalesce_read_buffers_end(bufs, num_bufs, (char*)tmp.iov_base, !ec);
coalesce_read_buffers_end(bufs, num_bufs
, static_cast<char*>(tmp.iov_base), !ec);
#endif
return ret;

View File

@ -280,7 +280,7 @@ namespace libtorrent
if (string_len >= name_is_owned) string_len = name_is_owned - 1;
// free the current string, before assigning the new one
if (name_len == name_is_owned) free((void*)name);
if (name_len == name_is_owned) free(const_cast<char*>(name));
if (n == NULL)
{
TORRENT_ASSERT(borrow_string == false);
@ -429,7 +429,7 @@ namespace libtorrent
// find the file iterator and file offset
internal_file_entry target;
target.offset = piece * (boost::int64_t)m_piece_length + offset;
target.offset = piece * boost::int64_t(m_piece_length) + offset;
TORRENT_ASSERT_PRECOND(boost::int64_t(target.offset + size) <= m_total_size);
TORRENT_ASSERT(!compare_file_offset(target, m_files.front()));
@ -458,7 +458,7 @@ namespace libtorrent
file_offset += f.size;
ret.push_back(f);
}
TORRENT_ASSERT(size >= 0);
}
return ret;

View File

@ -138,7 +138,7 @@ void http_connection::get(std::string const& url, time_duration timeout, int pri
if (ec)
{
m_timer.get_io_service().post(boost::bind(&http_connection::callback
, me, ec, (char*)0, 0));
, me, ec, static_cast<char*>(NULL), 0));
return;
}
@ -150,7 +150,7 @@ void http_connection::get(std::string const& url, time_duration timeout, int pri
{
error_code ec(errors::unsupported_url_protocol);
m_timer.get_io_service().post(boost::bind(&http_connection::callback
, me, ec, (char*)0, 0));
, me, ec, static_cast<char*>(NULL), 0));
return;
}
@ -158,7 +158,7 @@ void http_connection::get(std::string const& url, time_duration timeout, int pri
bool ssl = false;
if (protocol == "https") ssl = true;
char request[4096];
char* end = request + sizeof(request);
char* ptr = request;
@ -199,7 +199,7 @@ void http_connection::get(std::string const& url, time_duration timeout, int pri
if (!m_user_agent.empty())
APPEND_FMT1("User-Agent: %s\r\n", m_user_agent.c_str());
if (m_bottled)
APPEND_FMT("Accept-Encoding: gzip\r\n");
@ -258,7 +258,7 @@ void http_connection::start(std::string const& hostname, int port
if (ec)
{
m_timer.get_io_service().post(boost::bind(&http_connection::callback
, me, ec, (char*)0, 0));
, me, ec, static_cast<char*>(NULL), 0));
return;
}
@ -298,7 +298,7 @@ void http_connection::start(std::string const& hostname, int port
if (is_i2p && i2p_conn->proxy().type != settings_pack::i2p_proxy)
{
m_timer.get_io_service().post(boost::bind(&http_connection::callback
, me, error_code(errors::no_i2p_router, get_libtorrent_category()), (char*)0, 0));
, me, error_code(errors::no_i2p_router, get_libtorrent_category()), static_cast<char*>(NULL), 0));
return;
}
#endif
@ -354,7 +354,7 @@ void http_connection::start(std::string const& hostname, int port
if (ec)
{
m_timer.get_io_service().post(boost::bind(&http_connection::callback
, me, ec, (char*)0, 0));
, me, ec, static_cast<char*>(NULL), 0));
return;
}
}
@ -363,7 +363,7 @@ void http_connection::start(std::string const& hostname, int port
if (ec)
{
m_timer.get_io_service().post(boost::bind(&http_connection::callback
, me, ec, (char*)0, 0));
, me, ec, static_cast<char*>(NULL), 0));
return;
}

View File

@ -536,7 +536,7 @@ namespace libtorrent
line_len += 4;
break;
}
if (line_len > limit) return -1;
return line_len;
}
@ -552,7 +552,7 @@ namespace libtorrent
else
{
char tmp[5];
snprintf(tmp, sizeof(tmp), "\\x%02x", (unsigned char)str[i]);
snprintf(tmp, sizeof(tmp), "\\x%02x", boost::uint8_t(str[i]));
ret += tmp;
}
}

View File

@ -148,7 +148,7 @@ namespace libtorrent
char* allocate_string_copy(char const* str)
{
if (str == 0) return 0;
char* tmp = (char*)std::malloc(std::strlen(str) + 1);
char* tmp = static_cast<char*>(std::malloc(std::strlen(str) + 1));
if (tmp == 0) return 0;
std::strcpy(tmp, str);
return tmp;
@ -160,7 +160,7 @@ namespace libtorrent
int offset = uintptr_t(p) & 0x7;
// if we're already aligned, don't do anything
if (offset == 0) return p;
// offset is how far passed the last aligned address
// we are. We need to go forward to the next aligned
// one. Since aligned addresses are 8 bytes apart, add

View File

@ -1406,13 +1406,13 @@ namespace libtorrent
hasher hs;
if (sibling < n)
{
hs.update((char const*)&sibling_hash->second[0], 20);
hs.update((char const*)&h[0], 20);
hs.update(sibling_hash->second.data(), 20);
hs.update(h.data(), 20);
}
else
{
hs.update((char const*)&h[0], 20);
hs.update((char const*)&sibling_hash->second[0], 20);
hs.update(h.data(), 20);
hs.update(sibling_hash->second.data(), 20);
}
h = hs.final();
n = parent;

View File

@ -264,8 +264,8 @@ EXPORT int main(int argc, char const* argv[])
t.output = tmpfile();
int ret1 = dup2(fileno(t.output), fileno(stdout));
int ret2 = dup2(fileno(t.output), fileno(stderr));
if (ret1 < 0 /*|| ret2 < 0*/)
dup2(fileno(t.output), fileno(stderr));
if (ret1 < 0 )
{
fprintf(stderr, "failed to redirect output: (%d) %s\n"
, errno, strerror(errno));

View File

@ -44,6 +44,21 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
// tests are expected to even test deprecated functionality. There is no point
// in warning about deprecated use in any of the tests.
#if defined __clang__
#pragma clang diagnostic ignored "-Wdeprecated"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined __GNUC__
#pragma GCC diagnostic ignored "-Wdeprecated"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif defined _MSC_VER
#pragma warning(disable : 4996)
#endif
#if defined TORRENT_BUILDING_TEST_SHARED
#define EXPORT BOOST_SYMBOL_EXPORT
#elif defined TORRENT_LINK_TEST_SHARED

View File

@ -578,6 +578,7 @@ TORRENT_TEST(bencoding)
bdecode_errors::error_code_enum ec;
char const* e = parse_int(b, b + sizeof(b)-1, ':', val, ec);
TEST_CHECK(ec == bdecode_errors::overflow);
TEST_EQUAL(e, b + 18);
}
{
@ -586,6 +587,7 @@ TORRENT_TEST(bencoding)
bdecode_errors::error_code_enum ec;
char const* e = parse_int(b, b + sizeof(b)-1, ':', val, ec);
TEST_CHECK(ec == bdecode_errors::expected_colon);
TEST_EQUAL(e, b + 3);
}
{

View File

@ -59,6 +59,7 @@ struct log_t : libtorrent::dht::dht_logger
libtorrent::bdecode_node print;
libtorrent::error_code ec;
int ret = bdecode(pkt, pkt + len, print, ec, NULL, 100, 100);
TEST_EQUAL(ret, 0);
std::string msg = print_entry(print, true);
printf("%s", msg.c_str());

View File

@ -80,7 +80,6 @@ void test_rules_invariant(std::vector<ip_range<T> > const& r, ip_filter const& f
TEST_CHECK(r.back().last == IP("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
}
iterator i = r.begin();
for (iterator i(r.begin()), j(boost::next(r.begin()))
, end(r.end()); j != end; ++j, ++i)
{