fix some warnings

This commit is contained in:
arvidn 2015-08-13 23:52:25 -04:00
parent 54e483647c
commit 16bb2de6ed
9 changed files with 50 additions and 50 deletions

View File

@ -114,11 +114,11 @@ typedef uint8_t UTF8;
typedef unsigned char Boolean; /* 0 or 1 */
/* Some fundamental constants */
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
#define UNI_MAX_BMP (UTF32)0x0000FFFF
#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
#define UNI_REPLACEMENT_CHAR UTF32(0x0000FFFD)
#define UNI_MAX_BMP UTF32(0x0000FFFF)
#define UNI_MAX_UTF16 UTF32(0x0010FFFF)
#define UNI_MAX_UTF32 UTF32(0x7FFFFFFF)
#define UNI_MAX_LEGAL_UTF32 UTF32(0x0010FFFF)
typedef enum {
conversionOK, /* conversion successful */

View File

@ -237,15 +237,15 @@ namespace libtorrent { namespace
if (need_encoding(e.url.c_str(), e.url.size())) continue;
// ignore invalid URLs
error_code ec;
error_code err;
std::string protocol;
std::string auth;
std::string hostname;
int port;
std::string path;
boost::tie(protocol, auth, hostname, port, path)
= parse_url_components(e.url, ec);
if (ec) continue;
= parse_url_components(e.url, err);
if (err) continue;
// ignore unknown protocols
if (protocol != "udp" && protocol != "http" && protocol != "https")
@ -273,7 +273,8 @@ namespace libtorrent { namespace
virtual void tick()
{
if (!m_message_index) return; // no handshake yet
// no handshake yet
if (!m_message_index) return;
if (++m_2_minutes <= 120) return;
m_2_minutes = 0;

View File

@ -4668,8 +4668,8 @@ retry:
{
torrent_info::nodes_t const& nodes = params.ti->nodes();
std::for_each(nodes.begin(), nodes.end(), boost::bind(
(void(dht::dht_tracker::*)(std::pair<std::string, int> const&))
&dht::dht_tracker::add_node
static_cast<void(dht::dht_tracker::*)(std::pair<std::string, int> const&)>(
&dht::dht_tracker::add_node)
, boost::ref(m_dht), _1));
}
#endif
@ -6515,7 +6515,7 @@ retry:
char buf[1024];
vsnprintf(buf, sizeof(buf), fmt, v);
va_end(v);
m_alerts.emplace_alert<dht_log_alert>((dht_log_alert::dht_module_t)m, buf);
m_alerts.emplace_alert<dht_log_alert>(static_cast<dht_log_alert::dht_module_t>(m), buf);
}
void session_impl::log_packet(message_direction_t dir, char const* pkt, int len

View File

@ -149,7 +149,7 @@ namespace libtorrent
size += bufs->iov_len;
if (size >= bytes)
{
((char*&)bufs->iov_base) += bufs->iov_len - (size - bytes);
reinterpret_cast<char*&>(bufs->iov_base) += bufs->iov_len - (size - bytes);
bufs->iov_len = size - bytes;
return;
}
@ -720,7 +720,7 @@ namespace libtorrent
TORRENT_ASSERT(slot >= 0);
TORRENT_ASSERT(slot < files().num_pieces());
boost::int64_t file_offset = (boost::int64_t)slot * files().piece_length();
boost::int64_t file_offset = boost::int64_t(slot) * files().piece_length();
int file_index = 0;
for (;;)
@ -1064,8 +1064,8 @@ namespace libtorrent
else
{
// ignore errors when removing
error_code e;
remove_all(old_path, e);
error_code ignore;
remove_all(old_path, ignore);
}
break;
}
@ -1270,8 +1270,8 @@ namespace libtorrent
write_access_log(adjusted_offset, handle->file_id(), op_start | flags, clock_type::now());
#endif
bytes_transferred = (int)((*handle).*op.op)(adjusted_offset
, tmp_bufs, num_tmp_bufs, e, op.mode);
bytes_transferred = int(((*handle).*op.op)(adjusted_offset
, tmp_bufs, num_tmp_bufs, e, op.mode));
// we either get an error or 0 or more bytes read
TORRENT_ASSERT(e || bytes_transferred >= 0);
@ -1431,6 +1431,7 @@ namespace libtorrent
storage_interface* disabled_storage_constructor(storage_params const& params)
{
TORRENT_UNUSED(params);
return new disabled_storage;
}

View File

@ -8380,7 +8380,7 @@ namespace libtorrent
TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < int(m_trackers.size()));
if (index >= (int)m_trackers.size()) return -1;
if (index >= int(m_trackers.size())) return -1;
while (index > 0 && m_trackers[index].tier == m_trackers[index-1].tier)
{
@ -8399,7 +8399,7 @@ namespace libtorrent
TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < int(m_trackers.size()));
if (index >= (int)m_trackers.size()) return -1;
if (index >= int(m_trackers.size())) return -1;
while (index < int(m_trackers.size()) - 1 && m_trackers[index].tier == m_trackers[index + 1].tier)
{
@ -11318,7 +11318,6 @@ namespace libtorrent
return;
}
int num_files = m_torrent_file->num_files();
// if this is the first time the client asks for file progress.
// allocate it and make sure it's up to date
@ -11454,7 +11453,7 @@ namespace libtorrent
if (m_ses.alerts().should_post<state_changed_alert>())
{
m_ses.alerts().emplace_alert<state_changed_alert>(get_handle()
, s, (torrent_status::state_t)m_state);
, s, static_cast<torrent_status::state_t>(m_state));
}
if (s == torrent_status::finished
@ -11600,7 +11599,7 @@ namespace libtorrent
st->time_since_download = m_last_download == (std::numeric_limits<boost::int16_t>::min)() ? -1
: clamped_subtract(m_ses.session_time(), m_last_download);
st->storage_mode = (storage_mode_t)m_storage_mode;
st->storage_mode = static_cast<storage_mode_t>(m_storage_mode);
st->num_complete = (m_complete == 0xffffff) ? -1 : m_complete;
st->num_incomplete = (m_incomplete == 0xffffff) ? -1 : m_incomplete;
@ -11680,7 +11679,7 @@ namespace libtorrent
st->need_save_resume = need_save_resume_data();
st->ip_filter_applies = m_apply_ip_filter;
st->state = (torrent_status::state_t)m_state;
st->state = static_cast<torrent_status::state_t>(m_state);
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
if (st->state == torrent_status::finished

View File

@ -588,7 +588,7 @@ namespace libtorrent
ec = errors::metadata_too_large;
return -2;
}
v.resize((unsigned int)s);
v.resize(std::size_t(s));
if (s == 0) return 0;
file::iovec_t b = {&v[0], size_t(s) };
boost::int64_t read = f.readv(0, &b, 1, ec);
@ -1266,8 +1266,8 @@ namespace libtorrent
if (name.empty()) name = to_hex(m_info_hash.to_string());
// extract file list
bdecode_node i = info.dict_find_list("files");
if (!i)
bdecode_node files_node = info.dict_find_list("files");
if (!files_node)
{
// if there's no list of files, there has to be a length
// field.
@ -1278,7 +1278,7 @@ namespace libtorrent
}
else
{
if (!extract_files(i, files, name, info_ptr_diff, ec))
if (!extract_files(files_node, files, name, info_ptr_diff, ec))
return false;
m_multifile = true;
}
@ -1521,13 +1521,13 @@ namespace libtorrent
#endif // TORRENT_DISABLE_MUTABLE_TORRENTS
// extract the url of the tracker
bdecode_node i = torrent_file.dict_find_list("announce-list");
if (i)
bdecode_node announce_node = torrent_file.dict_find_list("announce-list");
if (announce_node)
{
m_urls.reserve(i.list_size());
for (int j = 0, end(i.list_size()); j < end; ++j)
m_urls.reserve(announce_node.list_size());
for (int j = 0, end(announce_node.list_size()); j < end; ++j)
{
bdecode_node tier = i.list_at(j);
bdecode_node tier = announce_node.list_at(j);
if (tier.type() != bdecode_node::list_t) continue;
for (int k = 0, end(tier.list_size()); k < end; ++k)
{
@ -1563,7 +1563,6 @@ namespace libtorrent
}
}
if (m_urls.empty())
{
announce_entry e(torrent_file.dict_find_string_value("announce"));

View File

@ -59,7 +59,7 @@ namespace libtorrent
switch(type)
{
case torrent_peer_allocator_interface::ipv4_peer_type:
p = (torrent_peer*)m_ipv4_peer_pool.malloc();
p = static_cast<torrent_peer*>(m_ipv4_peer_pool.malloc());
if (p == NULL) return NULL;
m_ipv4_peer_pool.set_next_size(500);
m_total_bytes += sizeof(libtorrent::ipv4_peer);
@ -69,7 +69,7 @@ namespace libtorrent
break;
#if TORRENT_USE_IPV6
case torrent_peer_allocator_interface::ipv6_peer_type:
p = (torrent_peer*)m_ipv6_peer_pool.malloc();
p = static_cast<torrent_peer*>(m_ipv6_peer_pool.malloc());
if (p == NULL) return NULL;
m_ipv6_peer_pool.set_next_size(500);
m_total_bytes += sizeof(libtorrent::ipv6_peer);
@ -80,7 +80,7 @@ namespace libtorrent
#endif
#if TORRENT_USE_I2P
case torrent_peer_allocator_interface::i2p_peer_type:
p = (torrent_peer*)m_i2p_peer_pool.malloc();
p = static_cast<torrent_peer*>(m_i2p_peer_pool.malloc());
if (p == NULL) return NULL;
m_i2p_peer_pool.set_next_size(500);
m_total_bytes += sizeof(libtorrent::i2p_peer);
@ -98,7 +98,7 @@ namespace libtorrent
#if TORRENT_USE_IPV6
if (p->is_v6_addr)
{
TORRENT_ASSERT(m_ipv6_peer_pool.is_from((libtorrent::ipv6_peer*)p));
TORRENT_ASSERT(m_ipv6_peer_pool.is_from(static_cast<libtorrent::ipv6_peer*>(p)));
static_cast<libtorrent::ipv6_peer*>(p)->~ipv6_peer();
m_ipv6_peer_pool.free(p);
TORRENT_ASSERT(m_live_bytes >= sizeof(ipv6_peer));
@ -111,7 +111,7 @@ namespace libtorrent
#if TORRENT_USE_I2P
if (p->is_i2p_addr)
{
TORRENT_ASSERT(m_i2p_peer_pool.is_from((libtorrent::i2p_peer*)p));
TORRENT_ASSERT(m_i2p_peer_pool.is_from(static_cast<libtorrent::i2p_peer*>(p)));
static_cast<libtorrent::i2p_peer*>(p)->~i2p_peer();
m_i2p_peer_pool.free(p);
TORRENT_ASSERT(m_live_bytes >= sizeof(i2p_peer));
@ -121,7 +121,7 @@ namespace libtorrent
return;
}
#endif
TORRENT_ASSERT(m_ipv4_peer_pool.is_from((libtorrent::ipv4_peer*)p));
TORRENT_ASSERT(m_ipv4_peer_pool.is_from(static_cast<libtorrent::ipv4_peer*>(p)));
static_cast<libtorrent::ipv4_peer*>(p)->~ipv4_peer();
m_ipv4_peer_pool.free(p);
TORRENT_ASSERT(m_live_bytes >= sizeof(ipv4_peer));

View File

@ -94,7 +94,7 @@ udp_socket::udp_socket(io_service& ios)
m_buf_size = 2048;
m_new_buf_size = m_buf_size;
m_buf = (char*)malloc(m_buf_size);
m_buf = static_cast<char*>(malloc(m_buf_size));
}
udp_socket::~udp_socket()
@ -281,14 +281,14 @@ void udp_socket::on_read(error_code const& ec, udp::socket* s)
for (;;)
{
error_code ec;
error_code err;
udp::endpoint ep;
size_t bytes_transferred = s->receive_from(boost::asio::buffer(m_buf, m_buf_size), ep, 0, ec);
size_t bytes_transferred = s->receive_from(boost::asio::buffer(m_buf, m_buf_size), ep, 0, err);
// TODO: it would be nice to detect this on posix systems also
#ifdef TORRENT_WINDOWS
if ((ec == error_code(ERROR_MORE_DATA, system_category())
|| ec == error_code(WSAEMSGSIZE, system_category()))
if ((err == error_code(ERROR_MORE_DATA, system_category())
|| err == error_code(WSAEMSGSIZE, system_category()))
&& m_buf_size < 65536)
{
// if this function fails to allocate memory, m_buf_size
@ -299,8 +299,8 @@ void udp_socket::on_read(error_code const& ec, udp::socket* s)
}
#endif
if (ec == boost::asio::error::would_block || ec == boost::asio::error::try_again) break;
on_read_impl(ep, ec, bytes_transferred);
if (err == boost::asio::error::would_block || err == boost::asio::error::try_again) break;
on_read_impl(ep, err, bytes_transferred);
}
call_drained_handler();
setup_read(s);
@ -1279,7 +1279,7 @@ void udp_socket::connect2(error_code const& e)
else
{
// in this case we need to read more data from the socket
TORRENT_ASSERT(false && "not implemented yet!");
TORRENT_ASSERT(false);
drain_queue();
return;
}

View File

@ -527,7 +527,7 @@ namespace libtorrent
if (cb)
{
char hex_ih[41];
to_hex((char const*)&tracker_req().info_hash[0], 20, hex_ih);
to_hex(tracker_req().info_hash.data(), 20, hex_ih);
cb->debug_log("==> UDP_TRACKER_CONNECT [ to: %s ih: %s]"
, m_hostname.empty()
? print_endpoint(m_target).c_str()
@ -757,7 +757,7 @@ namespace libtorrent
if (cb)
{
char hex_ih[41];
to_hex((char const*)&req.info_hash[0], 20, hex_ih);
to_hex(req.info_hash.data(), 20, hex_ih);
cb->debug_log("==> UDP_TRACKER_ANNOUNCE [%s]", hex_ih);
}
#endif