fixed more warnings

This commit is contained in:
arvidn 2015-08-07 00:30:29 -04:00
parent a91e7ce25d
commit 97571b4ad4
3 changed files with 43 additions and 42 deletions

View File

@ -179,7 +179,7 @@ namespace libtorrent
iothread->async_hash(storage.get(), *piece_counter iothread->async_hash(storage.get(), *piece_counter
, disk_io_job::sequential_access , disk_io_job::sequential_access
, boost::bind(&on_hash, _1, t, storage, iothread , boost::bind(&on_hash, _1, t, storage, iothread
, piece_counter, completed_piece, f, ec), (void*)0); , piece_counter, completed_piece, f, ec), NULL);
++(*piece_counter); ++(*piece_counter);
} }
else else
@ -276,7 +276,7 @@ namespace libtorrent
storage_interface* storage_impl = default_storage_constructor(params); storage_interface* storage_impl = default_storage_constructor(params);
boost::shared_ptr<piece_manager> storage = boost::make_shared<piece_manager>( boost::shared_ptr<piece_manager> storage = boost::make_shared<piece_manager>(
storage_impl, dummy, (file_storage*)&t.files()); storage_impl, dummy, const_cast<file_storage*>(&t.files()));
settings_pack sett; settings_pack sett;
sett.set_int(settings_pack::cache_size, 0); sett.set_int(settings_pack::cache_size, 0);
@ -295,7 +295,7 @@ namespace libtorrent
{ {
disk_thread.async_hash(storage.get(), i, disk_io_job::sequential_access disk_thread.async_hash(storage.get(), i, disk_io_job::sequential_access
, boost::bind(&on_hash, _1, &t, storage, &disk_thread , boost::bind(&on_hash, _1, &t, storage, &disk_thread
, &piece_counter, &completed_piece, &f, &ec), (void*)0); , &piece_counter, &completed_piece, &f, &ec), NULL);
++piece_counter; ++piece_counter;
if (piece_counter >= t.num_pieces()) break; if (piece_counter >= t.num_pieces()) break;
} }
@ -576,12 +576,14 @@ namespace libtorrent
TORRENT_ASSERT(has_parent_path(m_files.file_path(i))); TORRENT_ASSERT(has_parent_path(m_files.file_path(i)));
{
std::string split = split_path(m_files.file_path(i)); std::string split = split_path(m_files.file_path(i));
TORRENT_ASSERT(split.c_str() == m_files.name()); TORRENT_ASSERT(split.c_str() == m_files.name());
for (char const* e = next_path_element(split.c_str()); for (char const* e = next_path_element(split.c_str());
e != 0; e = next_path_element(e)) e != 0; e = next_path_element(e))
path_e.list().push_back(entry(e)); path_e.list().push_back(entry(e));
}
int flags = m_files.file_flags(i); int flags = m_files.file_flags(i);
if (flags != 0) if (flags != 0)
@ -634,8 +636,8 @@ namespace libtorrent
for (int i = level_start; i < level_start + level_size; i += 2, ++parent) for (int i = level_start; i < level_start + level_size; i += 2, ++parent)
{ {
hasher h; hasher h;
h.update((char const*)&m_merkle_tree[i][0], 20); h.update(m_merkle_tree[i].data(), 20);
h.update((char const*)&m_merkle_tree[i+1][0], 20); h.update(m_merkle_tree[i+1].data(), 20);
m_merkle_tree[parent] = h.final(); m_merkle_tree[parent] = h.final();
} }
level_start = merkle_get_parent(level_start); level_start = merkle_get_parent(level_start);
@ -643,7 +645,7 @@ namespace libtorrent
} }
TORRENT_ASSERT(level_size == 1); TORRENT_ASSERT(level_size == 1);
std::string& p = info["root hash"].string(); std::string& p = info["root hash"].string();
p.assign((char const*)&m_merkle_tree[0][0], 20); p.assign(m_merkle_tree[0].data(), 20);
} }
else else
{ {
@ -652,7 +654,7 @@ namespace libtorrent
for (std::vector<sha1_hash>::const_iterator i = m_piece_hash.begin(); for (std::vector<sha1_hash>::const_iterator i = m_piece_hash.begin();
i != m_piece_hash.end(); ++i) i != m_piece_hash.end(); ++i)
{ {
p.append((char*)i->begin(), sha1_hash::size); p.append(i->data(), sha1_hash::size);
} }
} }
@ -661,7 +663,6 @@ namespace libtorrent
m_info_hash = hasher(&buf[0], buf.size()).final(); m_info_hash = hasher(&buf[0], buf.size()).final();
return dict; return dict;
} }
void create_torrent::add_tracker(std::string const& url, int tier) void create_torrent::add_tracker(std::string const& url, int tier)
@ -690,14 +691,14 @@ namespace libtorrent
void create_torrent::set_hash(int index, sha1_hash const& h) void create_torrent::set_hash(int index, sha1_hash const& h)
{ {
TORRENT_ASSERT(index >= 0); TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < (int)m_piece_hash.size()); TORRENT_ASSERT(index < int(m_piece_hash.size()));
m_piece_hash[index] = h; m_piece_hash[index] = h;
} }
void create_torrent::set_file_hash(int index, sha1_hash const& h) void create_torrent::set_file_hash(int index, sha1_hash const& h)
{ {
TORRENT_ASSERT(index >= 0); TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < (int)m_files.num_files()); TORRENT_ASSERT(index < int(m_files.num_files()));
if (m_filehashes.empty()) m_filehashes.resize(m_files.num_files()); if (m_filehashes.empty()) m_filehashes.resize(m_files.num_files());
m_filehashes[index] = h; m_filehashes[index] = h;
} }

View File

@ -50,8 +50,8 @@ namespace libtorrent
{ {
TORRENT_ASSERT(m_ref.storage == 0 || m_ref.piece >= 0); TORRENT_ASSERT(m_ref.storage == 0 || m_ref.piece >= 0);
TORRENT_ASSERT(m_ref.storage == 0 || m_ref.block >= 0); TORRENT_ASSERT(m_ref.storage == 0 || m_ref.block >= 0);
TORRENT_ASSERT(m_ref.storage == 0 || m_ref.piece < ((piece_manager*)m_ref.storage)->files()->num_pieces()); TORRENT_ASSERT(m_ref.storage == 0 || m_ref.piece < static_cast<piece_manager*>(m_ref.storage)->files()->num_pieces());
TORRENT_ASSERT(m_ref.storage == 0 || m_ref.block <= ((piece_manager*)m_ref.storage)->files()->piece_length() / 0x4000); TORRENT_ASSERT(m_ref.storage == 0 || m_ref.block <= static_cast<piece_manager*>(m_ref.storage)->files()->piece_length() / 0x4000);
TORRENT_ASSERT(j.action != disk_io_job::save_resume_data); TORRENT_ASSERT(j.action != disk_io_job::save_resume_data);
TORRENT_ASSERT(j.action != disk_io_job::rename_file); TORRENT_ASSERT(j.action != disk_io_job::rename_file);
TORRENT_ASSERT(j.action != disk_io_job::move_storage); TORRENT_ASSERT(j.action != disk_io_job::move_storage);
@ -67,8 +67,8 @@ namespace libtorrent
TORRENT_ASSERT(m_ref.piece >= 0); TORRENT_ASSERT(m_ref.piece >= 0);
TORRENT_ASSERT(m_ref.storage != 0); TORRENT_ASSERT(m_ref.storage != 0);
TORRENT_ASSERT(m_ref.block >= 0); TORRENT_ASSERT(m_ref.block >= 0);
TORRENT_ASSERT(m_ref.piece < ((piece_manager*)m_ref.storage)->files()->num_pieces()); TORRENT_ASSERT(m_ref.piece < static_cast<piece_manager*>(m_ref.storage)->files()->num_pieces());
TORRENT_ASSERT(m_ref.block <= ((piece_manager*)m_ref.storage)->files()->piece_length() / 0x4000); TORRENT_ASSERT(m_ref.block <= static_cast<piece_manager*>(m_ref.storage)->files()->piece_length() / 0x4000);
TORRENT_ASSERT(j.action != disk_io_job::save_resume_data); TORRENT_ASSERT(j.action != disk_io_job::save_resume_data);
TORRENT_ASSERT(j.action != disk_io_job::rename_file); TORRENT_ASSERT(j.action != disk_io_job::rename_file);
TORRENT_ASSERT(j.action != disk_io_job::move_storage); TORRENT_ASSERT(j.action != disk_io_job::move_storage);

View File

@ -98,11 +98,11 @@ sha1_hash item_target_id(std::pair<char const*, int> salt
} }
bool verify_mutable_item( bool verify_mutable_item(
std::pair<char const*, int> v, std::pair<char const*, int> v
std::pair<char const*, int> salt, , std::pair<char const*, int> salt
boost::uint64_t seq, , boost::uint64_t seq
char const* pk, , char const* pk
char const* sig) , char const* sig)
{ {
#ifdef TORRENT_USE_VALGRIND #ifdef TORRENT_USE_VALGRIND
VALGRIND_CHECK_MEM_IS_DEFINED(v.first, v.second); VALGRIND_CHECK_MEM_IS_DEFINED(v.first, v.second);
@ -113,10 +113,10 @@ bool verify_mutable_item(
char str[canonical_length]; char str[canonical_length];
int len = canonical_string(v, seq, salt, str); int len = canonical_string(v, seq, salt, str);
return ed25519_verify((unsigned char const*)sig, return ed25519_verify(reinterpret_cast<unsigned char const*>(sig)
(unsigned char const*)str, , reinterpret_cast<unsigned char const*>(str)
len, , len
(unsigned char const*)pk) == 1; , reinterpret_cast<unsigned char const*>(pk)) == 1;
} }
// given the bencoded buffer ``v``, the salt (which is optional and may have // given the bencoded buffer ``v``, the salt (which is optional and may have
@ -126,12 +126,12 @@ bool verify_mutable_item(
// at least 64 bytes of available space. This space is where the signature is // at least 64 bytes of available space. This space is where the signature is
// written. // written.
void sign_mutable_item( void sign_mutable_item(
std::pair<char const*, int> v, std::pair<char const*, int> v
std::pair<char const*, int> salt, , std::pair<char const*, int> salt
boost::uint64_t seq, , boost::uint64_t seq
char const* pk, , char const* pk
char const* sk, , char const* sk
char* sig) , char* sig)
{ {
#ifdef TORRENT_USE_VALGRIND #ifdef TORRENT_USE_VALGRIND
VALGRIND_CHECK_MEM_IS_DEFINED(v.first, v.second); VALGRIND_CHECK_MEM_IS_DEFINED(v.first, v.second);
@ -142,11 +142,11 @@ void sign_mutable_item(
char str[canonical_length]; char str[canonical_length];
int len = canonical_string(v, seq, salt, str); int len = canonical_string(v, seq, salt, str);
ed25519_sign((unsigned char*)sig, ed25519_sign(reinterpret_cast<unsigned char*>(sig)
(unsigned char const*)str, , reinterpret_cast<unsigned char const*>(str)
len, , len
(unsigned char const*)pk, , reinterpret_cast<unsigned char const*>(pk)
(unsigned char const*)sk , reinterpret_cast<unsigned char const*>(sk)
); );
} }