some warning fixes and cleanup
This commit is contained in:
parent
8293543862
commit
ca106ca4e0
|
@ -225,7 +225,7 @@ struct peer_conn
|
|||
}
|
||||
};
|
||||
|
||||
int main(int argc, char const* argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc < 5)
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
using namespace libtorrent;
|
||||
|
||||
int main(int argc, char const* argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc != 3 && argc != 2)
|
||||
{
|
||||
|
|
|
@ -436,7 +436,8 @@ namespace libtorrent
|
|||
{
|
||||
ifreq req;
|
||||
memset(&req, 0, sizeof(req));
|
||||
strncpy(req.ifr_name, iface.name, IF_NAMESIZE);
|
||||
// -1 to leave a null terminator
|
||||
strncpy(req.ifr_name, iface.name, IF_NAMESIZE - 1);
|
||||
if (ioctl(s, SIOCGIFMTU, &req) < 0)
|
||||
{
|
||||
continue;
|
||||
|
@ -486,7 +487,8 @@ namespace libtorrent
|
|||
|
||||
ifreq req;
|
||||
memset(&req, 0, sizeof(req));
|
||||
strncpy(req.ifr_name, item.ifr_name, IF_NAMESIZE);
|
||||
// -1 to leave a null terminator
|
||||
strncpy(req.ifr_name, item.ifr_name, IF_NAMESIZE - 1);
|
||||
if (ioctl(s, SIOCGIFMTU, &req) < 0)
|
||||
{
|
||||
ec = error_code(errno, asio::error::system_category);
|
||||
|
@ -496,7 +498,7 @@ namespace libtorrent
|
|||
iface.mtu = req.ifr_mtu;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
strncpy(req.ifr_name, item.ifr_name, IF_NAMESIZE);
|
||||
strncpy(req.ifr_name, item.ifr_name, IF_NAMESIZE - 1);
|
||||
if (ioctl(s, SIOCGIFNETMASK, &req) < 0)
|
||||
{
|
||||
#if TORRENT_USE_IPV6
|
||||
|
|
|
@ -623,6 +623,9 @@ namespace libtorrent
|
|||
: m_done(false)
|
||||
{
|
||||
ec.clear();
|
||||
memset(&m_dirent, 0, sizeof(dirent));
|
||||
m_name[0] = 0;
|
||||
|
||||
#ifdef TORRENT_WINDOWS
|
||||
// the path passed to FindFirstFile() must be
|
||||
// a pattern
|
||||
|
|
|
@ -440,7 +440,7 @@ time_duration node_impl::connection_timeout()
|
|||
++i;
|
||||
continue;
|
||||
}
|
||||
m_feeds.erase(i);
|
||||
m_feeds.erase(i++);
|
||||
}
|
||||
|
||||
// look through all peers and see if any have timed out
|
||||
|
|
|
@ -199,9 +199,9 @@ namespace libtorrent
|
|||
pos = uri.find("&tr=", pos);
|
||||
if (pos == std::string::npos) break;
|
||||
pos += 4;
|
||||
error_code ec;
|
||||
std::string url = unescape_string(uri.substr(pos, uri.find('&', pos) - pos), ec);
|
||||
if (ec) continue;
|
||||
error_code e;
|
||||
std::string url = unescape_string(uri.substr(pos, uri.find('&', pos) - pos), e);
|
||||
if (e) continue;
|
||||
announce_entry ae(url);
|
||||
ae.tier = tier++;
|
||||
ret.add_tracker(ae);
|
||||
|
|
|
@ -346,8 +346,6 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
aux::session_impl& ses = m_torrent->session();
|
||||
piece_picker* p = 0;
|
||||
if (m_torrent->has_picker()) p = &m_torrent->picker();
|
||||
|
||||
for (iterator i = m_peers.begin(); i != m_peers.end();)
|
||||
{
|
||||
|
|
|
@ -368,11 +368,12 @@ void feed::on_feed(error_code const& ec
|
|||
p.ti.reset();
|
||||
p.info_hash.clear();
|
||||
p.name = i->title.c_str();
|
||||
error_code ec;
|
||||
|
||||
error_code e;
|
||||
// #error session_impl::add_torrent doesn't support magnet links via url
|
||||
m_ses.add_torrent(p, ec);
|
||||
m_ses.add_torrent(p, e);
|
||||
|
||||
if (ec)
|
||||
if (e)
|
||||
{
|
||||
// #error alert!
|
||||
}
|
||||
|
|
|
@ -1902,7 +1902,6 @@ namespace aux {
|
|||
|
||||
if (!m_listen_sockets.empty())
|
||||
{
|
||||
error_code ec;
|
||||
tcp::endpoint local = m_listen_sockets.front().sock->local_endpoint(ec);
|
||||
if (!ec)
|
||||
{
|
||||
|
|
|
@ -362,19 +362,18 @@ namespace libtorrent
|
|||
}
|
||||
if (response != 0)
|
||||
{
|
||||
error_code e(socks_error::general_failure, socks_category);
|
||||
error_code ec(socks_error::general_failure, socks_category);
|
||||
switch (response)
|
||||
{
|
||||
case 2: e = asio::error::no_permission; break;
|
||||
case 3: e = asio::error::network_unreachable; break;
|
||||
case 4: e = asio::error::host_unreachable; break;
|
||||
case 5: e = asio::error::connection_refused; break;
|
||||
case 6: e = asio::error::timed_out; break;
|
||||
case 7: e = error_code(socks_error::command_not_supported, socks_category); break;
|
||||
case 8: e = asio::error::address_family_not_supported; break;
|
||||
case 2: ec = asio::error::no_permission; break;
|
||||
case 3: ec = asio::error::network_unreachable; break;
|
||||
case 4: ec = asio::error::host_unreachable; break;
|
||||
case 5: ec = asio::error::connection_refused; break;
|
||||
case 6: ec = asio::error::timed_out; break;
|
||||
case 7: ec = error_code(socks_error::command_not_supported, socks_category); break;
|
||||
case 8: ec = asio::error::address_family_not_supported; break;
|
||||
}
|
||||
(*h)(e);
|
||||
error_code ec;
|
||||
(*h)(ec);
|
||||
close(ec);
|
||||
return;
|
||||
}
|
||||
|
@ -466,9 +465,9 @@ namespace libtorrent
|
|||
case 92: code = socks_error::no_identd; break;
|
||||
case 93: code = socks_error::identd_error; break;
|
||||
}
|
||||
error_code e(code, socks_category);
|
||||
(*h)(e);
|
||||
close(e);
|
||||
error_code ec(code, socks_category);
|
||||
(*h)(ec);
|
||||
close(ec);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -762,6 +762,10 @@ namespace libtorrent
|
|||
int piece_size = m_torrent_file->piece_size(piece);
|
||||
int blocks_in_piece = (piece_size + block_size() - 1) / block_size();
|
||||
|
||||
// if blocks_in_piece is 0, rp will leak
|
||||
TORRENT_ASSERT(blocks_in_piece > 0);
|
||||
TORRENT_ASSERT(piece_size > 0);
|
||||
|
||||
read_piece_struct* rp = new read_piece_struct;
|
||||
rp->piece_data.reset(new (std::nothrow) char[piece_size]);
|
||||
rp->blocks_left = 0;
|
||||
|
|
|
@ -163,18 +163,18 @@ namespace libtorrent
|
|||
, boost::bind(&tcp::resolver::iterator::value_type::endpoint, _1));
|
||||
|
||||
// remove endpoints that are filtered by the IP filter
|
||||
for (std::list<tcp::endpoint>::iterator i = m_endpoints.begin();
|
||||
i != m_endpoints.end();)
|
||||
for (std::list<tcp::endpoint>::iterator k = m_endpoints.begin();
|
||||
k != m_endpoints.end();)
|
||||
{
|
||||
if (m_ses.m_ip_filter.access(i->address()) == ip_filter::blocked)
|
||||
if (m_ses.m_ip_filter.access(k->address()) == ip_filter::blocked)
|
||||
{
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
||||
if (cb) cb->debug_log("*** UDP_TRACKER [ IP blocked by filter: " + print_address(i->address()) + " ]");
|
||||
if (cb) cb->debug_log("*** UDP_TRACKER [ IP blocked by filter: " + print_address(k->address()) + " ]");
|
||||
#endif
|
||||
i = m_endpoints.erase(i);
|
||||
k = m_endpoints.erase(k);
|
||||
}
|
||||
else
|
||||
++i;
|
||||
++k;
|
||||
}
|
||||
|
||||
if (m_endpoints.empty())
|
||||
|
|
25
src/upnp.cpp
25
src/upnp.cpp
|
@ -251,12 +251,12 @@ bool upnp::get_mapping(int index, int& local_port, int& external_port, int& prot
|
|||
return true;
|
||||
}
|
||||
|
||||
void upnp::resend_request(error_code const& e)
|
||||
void upnp::resend_request(error_code const& ec)
|
||||
{
|
||||
#if defined TORRENT_ASIO_DEBUGGING
|
||||
complete_async("upnp::resend_request");
|
||||
#endif
|
||||
if (e) return;
|
||||
if (ec) return;
|
||||
|
||||
boost::intrusive_ptr<upnp> me(self());
|
||||
|
||||
|
@ -300,11 +300,10 @@ void upnp::resend_request(error_code const& e)
|
|||
d.upnp_connection->get(d.url, seconds(30), 1);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (std::exception& exc)
|
||||
{
|
||||
(void)e;
|
||||
char msg[200];
|
||||
snprintf(msg, sizeof(msg), "connection failed to: %s %s", d.url.c_str(), e.what());
|
||||
snprintf(msg, sizeof(msg), "connection failed to: %s %s", d.url.c_str(), exc.what());
|
||||
log(msg, l);
|
||||
d.disabled = true;
|
||||
}
|
||||
|
@ -563,13 +562,11 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
|
|||
d.upnp_connection->get(d.url, seconds(30), 1);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (std::exception& exc)
|
||||
{
|
||||
(void)e;
|
||||
|
||||
char msg[200];
|
||||
snprintf(msg, sizeof(msg), "connection failed to: %s %s"
|
||||
, d.url.c_str(), e.what());
|
||||
, d.url.c_str(), exc.what());
|
||||
log(msg, l);
|
||||
d.disabled = true;
|
||||
}
|
||||
|
@ -655,12 +652,12 @@ void upnp::next(rootdevice& d, int i, mutex::scoped_lock& l)
|
|||
}
|
||||
else
|
||||
{
|
||||
std::vector<mapping_t>::iterator i
|
||||
std::vector<mapping_t>::iterator j
|
||||
= std::find_if(d.mapping.begin(), d.mapping.end()
|
||||
, boost::bind(&mapping_t::action, _1) != int(mapping_t::action_none));
|
||||
if (i == d.mapping.end()) return;
|
||||
if (j == d.mapping.end()) return;
|
||||
|
||||
update_map(d, i - d.mapping.begin(), l);
|
||||
update_map(d, j - d.mapping.begin(), l);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1417,12 +1414,12 @@ void upnp::on_upnp_unmap_response(error_code const& e
|
|||
next(d, mapping, l);
|
||||
}
|
||||
|
||||
void upnp::on_expire(error_code const& e)
|
||||
void upnp::on_expire(error_code const& ec)
|
||||
{
|
||||
#if defined TORRENT_ASIO_DEBUGGING
|
||||
complete_async("upnp::on_expire");
|
||||
#endif
|
||||
if (e) return;
|
||||
if (ec) return;
|
||||
|
||||
ptime now = time_now();
|
||||
ptime next_expire = max_time();
|
||||
|
|
|
@ -303,13 +303,13 @@ namespace libtorrent
|
|||
bool header_finished = m_parser.header_finished();
|
||||
if (!header_finished)
|
||||
{
|
||||
bool error = false;
|
||||
boost::tie(payload, protocol) = m_parser.incoming(recv_buffer, error);
|
||||
bool failed = false;
|
||||
boost::tie(payload, protocol) = m_parser.incoming(recv_buffer, failed);
|
||||
m_statistics.received_bytes(0, protocol);
|
||||
TORRENT_ASSERT(int(bytes_transferred) >= protocol);
|
||||
bytes_transferred -= protocol;
|
||||
|
||||
if (error)
|
||||
if (failed)
|
||||
{
|
||||
m_statistics.received_bytes(0, bytes_transferred);
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
|
|
Loading…
Reference in New Issue