fix some more coverity issues and add more todo comments
This commit is contained in:
parent
8fdacf9534
commit
f90537c52d
|
@ -4,7 +4,8 @@
|
||||||
#include <algorithm> // for std::max
|
#include <algorithm> // for std::max
|
||||||
|
|
||||||
session_view::session_view()
|
session_view::session_view()
|
||||||
: m_print_utp_stats(false)
|
: m_position(0)
|
||||||
|
, m_print_utp_stats(false)
|
||||||
{
|
{
|
||||||
using libtorrent::find_metric_idx;
|
using libtorrent::find_metric_idx;
|
||||||
|
|
||||||
|
|
|
@ -1143,7 +1143,8 @@ namespace libtorrent
|
||||||
// shutting down. This list is just here to keep them alive during
|
// shutting down. This list is just here to keep them alive during
|
||||||
// whe shutting down process
|
// whe shutting down process
|
||||||
std::list<boost::shared_ptr<tracker_logger> > m_tracker_loggers;
|
std::list<boost::shared_ptr<tracker_logger> > m_tracker_loggers;
|
||||||
|
#endif
|
||||||
|
#ifdef TORRENT_REQUEST_LOGGING
|
||||||
FILE* m_request_logger;
|
FILE* m_request_logger;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#include <boost/preprocessor/cat.hpp>
|
||||||
#include <boost/preprocessor/stringize.hpp>
|
#include <boost/preprocessor/stringize.hpp>
|
||||||
|
|
||||||
|
// TODO: 2 instead of using a dummy function to cause link errors when
|
||||||
|
// incompatible build configurations are used, make the namespace name
|
||||||
|
// depend on the configuration, and have a using declaration in the headers
|
||||||
|
// to pull it into libtorrent.
|
||||||
#if TORRENT_USE_IPV6
|
#if TORRENT_USE_IPV6
|
||||||
#define TORRENT_CFG_IPV6 ipv6_
|
#define TORRENT_CFG_IPV6 ipv6_
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -111,8 +111,9 @@ namespace libtorrent
|
||||||
{ return m_buf == 0? 0: &disk_buffer_holder::release; }
|
{ return m_buf == 0? 0: &disk_buffer_holder::release; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// explicitly disallow assignment, to silence msvc warning
|
// non-copyable
|
||||||
disk_buffer_holder& operator=(disk_buffer_holder const&);
|
disk_buffer_holder& operator=(disk_buffer_holder const&);
|
||||||
|
disk_buffer_holder(disk_buffer_holder const*);
|
||||||
|
|
||||||
buffer_allocator_interface& m_allocator;
|
buffer_allocator_interface& m_allocator;
|
||||||
char* m_buf;
|
char* m_buf;
|
||||||
|
|
|
@ -70,8 +70,7 @@ namespace libtorrent
|
||||||
io_service& ios
|
io_service& ios
|
||||||
, tracker_manager& man
|
, tracker_manager& man
|
||||||
, tracker_request const& req
|
, tracker_request const& req
|
||||||
, boost::weak_ptr<request_callback> c
|
, boost::weak_ptr<request_callback> c);
|
||||||
);
|
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void close();
|
void close();
|
||||||
|
|
|
@ -45,12 +45,13 @@ namespace libtorrent
|
||||||
|
|
||||||
struct socket_job
|
struct socket_job
|
||||||
{
|
{
|
||||||
socket_job() : vec(NULL), recv_buf(NULL), buf_size(0) {}
|
socket_job() : vec(NULL), recv_buf(NULL), buf_size(0), type(none) {}
|
||||||
|
|
||||||
enum job_type_t
|
enum job_type_t
|
||||||
{
|
{
|
||||||
read_job = 0,
|
read_job = 0,
|
||||||
write_job
|
write_job,
|
||||||
|
none
|
||||||
};
|
};
|
||||||
|
|
||||||
job_type_t type;
|
job_type_t type;
|
||||||
|
|
|
@ -121,12 +121,9 @@ namespace libtorrent
|
||||||
struct TORRENT_EXTRA_EXPORT rc4_handler : crypto_plugin
|
struct TORRENT_EXTRA_EXPORT rc4_handler : crypto_plugin
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Input longkeys must be 20 bytes
|
rc4_handler();
|
||||||
rc4_handler()
|
|
||||||
: m_encrypt(false)
|
|
||||||
, m_decrypt(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
// Input keys must be 20 bytes
|
||||||
void set_incoming_key(unsigned char const* key, int len);
|
void set_incoming_key(unsigned char const* key, int len);
|
||||||
void set_outgoing_key(unsigned char const* key, int len);
|
void set_outgoing_key(unsigned char const* key, int len);
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,6 @@ namespace libtorrent
|
||||||
, int flags = start_default_features | add_default_plugins)
|
, int flags = start_default_features | add_default_plugins)
|
||||||
{
|
{
|
||||||
TORRENT_CFG();
|
TORRENT_CFG();
|
||||||
init();
|
|
||||||
start(flags, pack);
|
start(flags, pack);
|
||||||
}
|
}
|
||||||
session(fingerprint const& print = fingerprint("LT"
|
session(fingerprint const& print = fingerprint("LT"
|
||||||
|
@ -196,6 +195,9 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_CFG();
|
TORRENT_CFG();
|
||||||
settings_pack pack;
|
settings_pack pack;
|
||||||
|
// TODO: 2 the two second constructors here should probably
|
||||||
|
// be deprecated in favor of the more generic one that just
|
||||||
|
// takes a settings_pack and a string
|
||||||
pack.set_int(settings_pack::alert_mask, alert_mask);
|
pack.set_int(settings_pack::alert_mask, alert_mask);
|
||||||
pack.set_str(settings_pack::peer_fingerprint, print.to_string());
|
pack.set_str(settings_pack::peer_fingerprint, print.to_string());
|
||||||
if ((flags & start_default_features) == 0)
|
if ((flags & start_default_features) == 0)
|
||||||
|
@ -206,7 +208,6 @@ namespace libtorrent
|
||||||
pack.set_bool(settings_pack::enable_dht, false);
|
pack.set_bool(settings_pack::enable_dht, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
|
||||||
start(flags, pack);
|
start(flags, pack);
|
||||||
}
|
}
|
||||||
session(fingerprint const& print
|
session(fingerprint const& print
|
||||||
|
@ -234,7 +235,6 @@ namespace libtorrent
|
||||||
pack.set_bool(settings_pack::enable_lsd, false);
|
pack.set_bool(settings_pack::enable_lsd, false);
|
||||||
pack.set_bool(settings_pack::enable_dht, false);
|
pack.set_bool(settings_pack::enable_dht, false);
|
||||||
}
|
}
|
||||||
init();
|
|
||||||
start(flags, pack);
|
start(flags, pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,7 +1218,6 @@ namespace libtorrent
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void init();
|
|
||||||
void start(int flags, settings_pack const& pack);
|
void start(int flags, settings_pack const& pack);
|
||||||
|
|
||||||
// data shared between the main thread
|
// data shared between the main thread
|
||||||
|
|
|
@ -41,6 +41,8 @@ namespace libtorrent
|
||||||
: m_allocator(alloc), m_buf(buf)
|
: m_allocator(alloc), m_buf(buf)
|
||||||
{
|
{
|
||||||
m_ref.storage = 0;
|
m_ref.storage = 0;
|
||||||
|
m_ref.piece = -1;
|
||||||
|
m_ref.block = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
disk_buffer_holder::disk_buffer_holder(buffer_allocator_interface& alloc, disk_io_job const& j)
|
disk_buffer_holder::disk_buffer_holder(buffer_allocator_interface& alloc, disk_io_job const& j)
|
||||||
|
|
|
@ -74,6 +74,9 @@ namespace libtorrent
|
||||||
, boost::weak_ptr<request_callback> c)
|
, boost::weak_ptr<request_callback> c)
|
||||||
: tracker_connection(man, req, ios, c)
|
: tracker_connection(man, req, ios, c)
|
||||||
, m_man(man)
|
, m_man(man)
|
||||||
|
#if TORRENT_USE_I2P
|
||||||
|
, m_i2p_conn(NULL)
|
||||||
|
#endif
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void http_tracker_connection::start()
|
void http_tracker_connection::start()
|
||||||
|
|
|
@ -92,7 +92,8 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
i2p_connection::i2p_connection(io_service& ios)
|
i2p_connection::i2p_connection(io_service& ios)
|
||||||
: m_state(sam_idle)
|
: m_port(0)
|
||||||
|
, m_state(sam_idle)
|
||||||
, m_io_service(ios)
|
, m_io_service(ios)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -264,6 +264,16 @@ namespace libtorrent
|
||||||
recv_buffer.crypto_reset(packet_size);
|
recv_buffer.crypto_reset(packet_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc4_handler::rc4_handler()
|
||||||
|
: m_encrypt(false)
|
||||||
|
, m_decrypt(false)
|
||||||
|
{
|
||||||
|
m_rc4_incoming.x = 0;
|
||||||
|
m_rc4_incoming.y = 0;
|
||||||
|
m_rc4_outgoing.x = 0;
|
||||||
|
m_rc4_outgoing.y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void rc4_handler::set_incoming_key(unsigned char const* key, int len)
|
void rc4_handler::set_incoming_key(unsigned char const* key, int len)
|
||||||
{
|
{
|
||||||
m_decrypt = true;
|
m_decrypt = true;
|
||||||
|
|
|
@ -388,7 +388,7 @@ namespace libtorrent
|
||||||
{ throw; }
|
{ throw; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void session::init()
|
void session::start(int flags, settings_pack const& pack)
|
||||||
{
|
{
|
||||||
#if defined _MSC_VER && defined TORRENT_DEBUG
|
#if defined _MSC_VER && defined TORRENT_DEBUG
|
||||||
// workaround for microsofts
|
// workaround for microsofts
|
||||||
|
@ -398,10 +398,6 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_impl.reset(new session_impl());
|
m_impl.reset(new session_impl());
|
||||||
}
|
|
||||||
|
|
||||||
void session::start(int flags, settings_pack const& pack)
|
|
||||||
{
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
if (flags & add_default_plugins)
|
if (flags & add_default_plugins)
|
||||||
{
|
{
|
||||||
|
|
|
@ -357,6 +357,9 @@ namespace aux {
|
||||||
#else
|
#else
|
||||||
, m_upload_rate(peer_connection::upload_channel)
|
, m_upload_rate(peer_connection::upload_channel)
|
||||||
#endif
|
#endif
|
||||||
|
, m_global_class(0)
|
||||||
|
, m_tcp_peer_class(0)
|
||||||
|
, m_local_peer_class(0)
|
||||||
, m_tracker_manager(m_udp_socket, m_stats_counters, m_host_resolver
|
, m_tracker_manager(m_udp_socket, m_stats_counters, m_host_resolver
|
||||||
, m_ip_filter, m_settings
|
, m_ip_filter, m_settings
|
||||||
#if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
|
#if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
|
||||||
|
@ -392,6 +395,7 @@ namespace aux {
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
, m_next_rss_update(min_time())
|
, m_next_rss_update(min_time())
|
||||||
#endif
|
#endif
|
||||||
|
, m_next_port(0)
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
, m_dht_announce_timer(m_io_service)
|
, m_dht_announce_timer(m_io_service)
|
||||||
, m_dht_interval_update_torrents(0)
|
, m_dht_interval_update_torrents(0)
|
||||||
|
@ -410,7 +414,10 @@ namespace aux {
|
||||||
, m_timer(m_io_service)
|
, m_timer(m_io_service)
|
||||||
, m_lsd_announce_timer(m_io_service)
|
, m_lsd_announce_timer(m_io_service)
|
||||||
, m_host_resolver(m_io_service)
|
, m_host_resolver(m_io_service)
|
||||||
|
, m_next_downloading_connect_torrent(0)
|
||||||
|
, m_next_finished_connect_torrent(0)
|
||||||
, m_download_connect_attempts(0)
|
, m_download_connect_attempts(0)
|
||||||
|
, m_next_scrape_torrent(0)
|
||||||
, m_tick_residual(0)
|
, m_tick_residual(0)
|
||||||
, m_deferred_submit_disk_jobs(false)
|
, m_deferred_submit_disk_jobs(false)
|
||||||
, m_pending_auto_manage(false)
|
, m_pending_auto_manage(false)
|
||||||
|
@ -435,6 +442,8 @@ namespace aux {
|
||||||
m_ssl_udp_socket.subscribe(this);
|
m_ssl_udp_socket.subscribe(this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// TODO: 3 remove REQUESST_LOGGING build configuration. Make sure the
|
||||||
|
// same information can be logged via alerts
|
||||||
#ifdef TORRENT_REQUEST_LOGGING
|
#ifdef TORRENT_REQUEST_LOGGING
|
||||||
char log_filename[200];
|
char log_filename[200];
|
||||||
#ifdef TORRENT_WINDOWS
|
#ifdef TORRENT_WINDOWS
|
||||||
|
@ -478,10 +487,6 @@ namespace aux {
|
||||||
m_next_dht_torrent = m_torrents.begin();
|
m_next_dht_torrent = m_torrents.begin();
|
||||||
#endif
|
#endif
|
||||||
m_next_lsd_torrent = m_torrents.begin();
|
m_next_lsd_torrent = m_torrents.begin();
|
||||||
m_next_downloading_connect_torrent = 0;
|
|
||||||
m_next_finished_connect_torrent = 0;
|
|
||||||
m_next_scrape_torrent = 0;
|
|
||||||
|
|
||||||
m_tcp_mapping[0] = -1;
|
m_tcp_mapping[0] = -1;
|
||||||
m_tcp_mapping[1] = -1;
|
m_tcp_mapping[1] = -1;
|
||||||
m_udp_mapping[0] = -1;
|
m_udp_mapping[0] = -1;
|
||||||
|
|
|
@ -134,6 +134,8 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
peer_info.web_seed = true;
|
peer_info.web_seed = true;
|
||||||
restart_request.piece = -1;
|
restart_request.piece = -1;
|
||||||
|
restart_request.start = -1;
|
||||||
|
restart_request.length = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
web_seed_t::web_seed_t(std::string const& url_, web_seed_entry::type_t type_
|
web_seed_t::web_seed_t(std::string const& url_, web_seed_entry::type_t type_
|
||||||
|
@ -148,6 +150,8 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
peer_info.web_seed = true;
|
peer_info.web_seed = true;
|
||||||
restart_request.piece = -1;
|
restart_request.piece = -1;
|
||||||
|
restart_request.start = -1;
|
||||||
|
restart_request.length = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
|
@ -266,6 +270,7 @@ namespace libtorrent
|
||||||
, m_downloaded(0xffffff)
|
, m_downloaded(0xffffff)
|
||||||
, m_last_scrape((std::numeric_limits<boost::int16_t>::min)())
|
, m_last_scrape((std::numeric_limits<boost::int16_t>::min)())
|
||||||
, m_progress_ppm(0)
|
, m_progress_ppm(0)
|
||||||
|
, m_last_active_change(0)
|
||||||
, m_use_resume_save_path(p.flags & add_torrent_params::flag_use_resume_save_path)
|
, m_use_resume_save_path(p.flags & add_torrent_params::flag_use_resume_save_path)
|
||||||
{
|
{
|
||||||
if (m_pinned)
|
if (m_pinned)
|
||||||
|
|
Loading…
Reference in New Issue