fix some warnings, mostly 0 -> nullptr
This commit is contained in:
parent
53ab7684fd
commit
c66f4cc62a
|
@ -81,10 +81,10 @@ extern char const* libtorrent_assert_log;
|
|||
#ifndef TORRENT_USE_SYSTEM_ASSERTS
|
||||
|
||||
#define TORRENT_ASSERT_PRECOND(x) \
|
||||
do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, TORRENT_FUNCTION, 0, 1); } TORRENT_WHILE_0
|
||||
do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, TORRENT_FUNCTION, nullptr, 1); } TORRENT_WHILE_0
|
||||
|
||||
#define TORRENT_ASSERT(x) \
|
||||
do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, TORRENT_FUNCTION, 0, 0); } TORRENT_WHILE_0
|
||||
do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, TORRENT_FUNCTION, nullptr, 0); } TORRENT_WHILE_0
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
#define TORRENT_ASSERT_VAL(x, y) \
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace libtorrent {
|
|||
TORRENT_EXTRA_EXPORT std::string base32decode(string_view s);
|
||||
|
||||
TORRENT_EXTRA_EXPORT string_view url_has_argument(
|
||||
string_view url, std::string argument, std::string::size_type* out_pos = 0);
|
||||
string_view url, std::string argument, std::string::size_type* out_pos = nullptr);
|
||||
|
||||
// replaces \ with /
|
||||
TORRENT_EXTRA_EXPORT void convert_path_to_posix(std::string& path);
|
||||
|
|
|
@ -176,7 +176,7 @@ namespace libtorrent {
|
|||
const_iterator operator--(int)
|
||||
{ const_iterator ret(*this); dec(); return ret; }
|
||||
|
||||
const_iterator(): buf(0), bit(0x80000000) {}
|
||||
const_iterator() {}
|
||||
bool operator==(const_iterator const& rhs) const
|
||||
{ return buf == rhs.buf && bit == rhs.bit; }
|
||||
|
||||
|
@ -212,8 +212,8 @@ namespace libtorrent {
|
|||
}
|
||||
const_iterator(std::uint32_t const* ptr, int offset)
|
||||
: buf(ptr), bit(0x80000000 >> offset) {}
|
||||
std::uint32_t const* buf;
|
||||
std::uint32_t bit;
|
||||
std::uint32_t const* buf = nullptr;
|
||||
std::uint32_t bit = 0x80000000;
|
||||
};
|
||||
|
||||
const_iterator begin() const { return const_iterator(m_buf ? buf() : nullptr, 0); }
|
||||
|
|
|
@ -119,15 +119,14 @@ namespace aux {
|
|||
struct cached_block_entry
|
||||
{
|
||||
cached_block_entry()
|
||||
: buf(0)
|
||||
, refcount(0)
|
||||
: refcount(0)
|
||||
, dirty(0)
|
||||
, pending(0)
|
||||
, cache_hit(0)
|
||||
{
|
||||
}
|
||||
|
||||
char* buf;
|
||||
char* buf = nullptr;
|
||||
|
||||
static constexpr int max_refcount = (1 << 29) - 1;
|
||||
|
||||
|
|
|
@ -38,15 +38,15 @@ namespace libtorrent {
|
|||
template <class T>
|
||||
struct copy_ptr
|
||||
{
|
||||
copy_ptr(): m_ptr(0) {}
|
||||
copy_ptr(): m_ptr(nullptr) {}
|
||||
explicit copy_ptr(T* t): m_ptr(t) {}
|
||||
copy_ptr(copy_ptr const& p): m_ptr(p.m_ptr ? new T(*p.m_ptr) : 0) {}
|
||||
void reset(T* t = 0) { delete m_ptr; m_ptr = t; }
|
||||
copy_ptr(copy_ptr const& p): m_ptr(p.m_ptr ? new T(*p.m_ptr) : nullptr) {}
|
||||
void reset(T* t = nullptr) { delete m_ptr; m_ptr = t; }
|
||||
copy_ptr& operator=(copy_ptr const& p)
|
||||
{
|
||||
if (m_ptr == p.m_ptr) return *this;
|
||||
delete m_ptr;
|
||||
m_ptr = p.m_ptr ? new T(*p.m_ptr) : 0;
|
||||
m_ptr = p.m_ptr ? new T(*p.m_ptr) : nullptr;
|
||||
return *this;
|
||||
}
|
||||
T* operator->() { return m_ptr; }
|
||||
|
@ -59,10 +59,10 @@ namespace libtorrent {
|
|||
m_ptr = p.m_ptr;
|
||||
p.m_ptr = tmp;
|
||||
}
|
||||
explicit operator bool() const { return m_ptr != 0; }
|
||||
explicit operator bool() const { return m_ptr != nullptr; }
|
||||
~copy_ptr() { delete m_ptr; }
|
||||
private:
|
||||
T* m_ptr;
|
||||
T* m_ptr = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace libtorrent {
|
|||
// set the holder object to hold the specified buffer
|
||||
// (or nullptr by default). If it's already holding a
|
||||
// disk buffer, it will first be freed.
|
||||
void reset(char* buf = 0);
|
||||
void reset(char* buf = nullptr);
|
||||
void reset(aux::block_cache_reference const& ref, char* buf);
|
||||
|
||||
// swap pointers of two disk buffer holders.
|
||||
|
|
|
@ -270,7 +270,7 @@ namespace libtorrent {
|
|||
// can be changed by calling ``set_name``.
|
||||
void add_file_borrow(string_view filename
|
||||
, std::string const& path, std::int64_t file_size
|
||||
, file_flags_t file_flags = {}, char const* filehash = 0
|
||||
, file_flags_t file_flags = {}, char const* filehash = nullptr
|
||||
, std::int64_t mtime = 0, string_view symlink_path = string_view());
|
||||
void add_file(std::string const& path, std::int64_t file_size
|
||||
, file_flags_t file_flags = {}
|
||||
|
@ -284,7 +284,7 @@ namespace libtorrent {
|
|||
TORRENT_DEPRECATED
|
||||
void add_file_borrow(char const* filename, int filename_len
|
||||
, std::string const& path, std::int64_t file_size
|
||||
, file_flags_t file_flags = {}, char const* filehash = 0
|
||||
, file_flags_t file_flags = {}, char const* filehash = nullptr
|
||||
, std::int64_t mtime = 0, string_view symlink_path = string_view());
|
||||
TORRENT_DEPRECATED
|
||||
void add_file(file_entry const& fe, char const* filehash = nullptr);
|
||||
|
|
|
@ -105,7 +105,7 @@ struct TORRENT_EXTRA_EXPORT http_connection
|
|||
, boost::optional<address> const& bind_addr = boost::optional<address>()
|
||||
, resolver_flags resolve_flags = resolver_flags{}, std::string const& auth_ = std::string()
|
||||
#if TORRENT_USE_I2P
|
||||
, i2p_connection* i2p_conn = 0
|
||||
, i2p_connection* i2p_conn = nullptr
|
||||
#endif
|
||||
);
|
||||
|
||||
|
@ -115,7 +115,7 @@ struct TORRENT_EXTRA_EXPORT http_connection
|
|||
, boost::optional<address> const& bind_addr = boost::optional<address>()
|
||||
, resolver_flags resolve_flags = resolver_flags{}
|
||||
#if TORRENT_USE_I2P
|
||||
, i2p_connection* i2p_conn = 0
|
||||
, i2p_connection* i2p_conn = nullptr
|
||||
#endif
|
||||
);
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace libtorrent {
|
|||
// which will be set to the byte offset into the buffer where an error occurred,
|
||||
// in case the function fails.
|
||||
TORRENT_DEPRECATED_EXPORT int lazy_bdecode(char const* start, char const* end
|
||||
, lazy_entry& ret, error_code& ec, int* error_pos = 0
|
||||
, lazy_entry& ret, error_code& ec, int* error_pos = nullptr
|
||||
, int depth_limit = 1000, int item_limit = 1000000);
|
||||
|
||||
// for backwards compatibility, does not report error code
|
||||
|
@ -142,7 +142,7 @@ namespace libtorrent {
|
|||
};
|
||||
|
||||
// internal
|
||||
lazy_entry() : m_begin(0), m_len(0), m_size(0), m_type(none_t)
|
||||
lazy_entry() : m_size(0), m_type(none_t)
|
||||
{ m_data.start = nullptr; }
|
||||
|
||||
// tells you which specific type this lazy entry has.
|
||||
|
@ -370,11 +370,11 @@ namespace libtorrent {
|
|||
|
||||
// used for dictionaries and lists to record the range
|
||||
// in the original buffer they are based on
|
||||
char const* m_begin;
|
||||
char const* m_begin = nullptr;
|
||||
|
||||
// the number of bytes this entry extends in the
|
||||
// bencoded buffer
|
||||
std::uint32_t m_len;
|
||||
std::uint32_t m_len = 0;
|
||||
|
||||
// if list or dictionary, the number of items
|
||||
std::uint32_t m_size:29;
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace libtorrent {
|
|||
, storage_mode_t storage_mode = storage_mode_sparse
|
||||
, bool paused = false
|
||||
, storage_constructor_type sc = default_storage_constructor
|
||||
, void* userdata = 0);
|
||||
, void* userdata = nullptr);
|
||||
|
||||
// deprecated in 0.16. Instead, pass in the magnet link as add_torrent_params::url
|
||||
TORRENT_DEPRECATED_EXPORT
|
||||
|
|
|
@ -654,7 +654,7 @@ namespace aux {
|
|||
#endif
|
||||
|
||||
time_t last_seen_complete() const { return m_last_seen_complete; }
|
||||
void set_last_seen_complete(int ago) { m_last_seen_complete = ::time(0) - ago; }
|
||||
void set_last_seen_complete(int ago) { m_last_seen_complete = ::time(nullptr) - ago; }
|
||||
|
||||
std::int64_t uploaded_in_last_round() const
|
||||
{ return m_statistics.total_payload_upload() - m_uploaded_at_last_round; }
|
||||
|
|
|
@ -347,7 +347,7 @@ namespace libtorrent {
|
|||
|
||||
// clears the given piece's download flag
|
||||
// this means that this piece-block can be picked again
|
||||
void abort_download(piece_block block, torrent_peer* peer = 0);
|
||||
void abort_download(piece_block block, torrent_peer* peer = nullptr);
|
||||
|
||||
// returns true if all blocks in this piece are finished
|
||||
// or if we have the piece
|
||||
|
|
|
@ -245,7 +245,7 @@ namespace libtorrent {
|
|||
, storage_mode_t storage_mode = storage_mode_sparse
|
||||
, bool paused = false
|
||||
, storage_constructor_type sc = default_storage_constructor
|
||||
, void* userdata = 0);
|
||||
, void* userdata = nullptr);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -729,7 +729,7 @@ namespace libtorrent {
|
|||
void listen_on(
|
||||
std::pair<int, int> const& port_range
|
||||
, error_code& ec
|
||||
, const char* net_interface = 0
|
||||
, const char* net_interface = nullptr
|
||||
, int flags = 0);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ namespace std
|
|||
{
|
||||
std::size_t ret;
|
||||
// this is OK because sha1_hash is already a hash
|
||||
std::memcpy(&ret, &k[0], sizeof(ret));
|
||||
std::memcpy(&ret, k.data(), sizeof(ret));
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -950,7 +950,7 @@ namespace libtorrent {
|
|||
void need_picker();
|
||||
bool has_picker() const
|
||||
{
|
||||
return m_picker.get() != 0;
|
||||
return m_picker.get() != nullptr;
|
||||
}
|
||||
|
||||
void update_max_failcount()
|
||||
|
@ -995,8 +995,8 @@ namespace libtorrent {
|
|||
|
||||
void write_resume_data(add_torrent_params& atp) const;
|
||||
|
||||
void seen_complete() { m_last_seen_complete = ::time(0); }
|
||||
int time_since_complete() const { return int(::time(0) - m_last_seen_complete); }
|
||||
void seen_complete() { m_last_seen_complete = ::time(nullptr); }
|
||||
int time_since_complete() const { return int(::time(nullptr) - m_last_seen_complete); }
|
||||
time_t last_seen_complete() const { return m_last_seen_complete; }
|
||||
|
||||
template <typename Fun, typename... Args>
|
||||
|
|
|
@ -537,7 +537,7 @@ namespace aux {
|
|||
// a torrent_plugin instance.
|
||||
void add_extension(
|
||||
std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
|
||||
, void* userdata = 0);
|
||||
, void* userdata = nullptr);
|
||||
|
||||
// ``set_metadata`` expects the *info* section of metadata. i.e. The
|
||||
// buffer passed in will be hashed and verified against the info-hash. If
|
||||
|
|
|
@ -100,9 +100,6 @@ namespace libtorrent {
|
|||
, triggered_manually(false)
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
, ssl_ctx(0)
|
||||
#endif
|
||||
#if TORRENT_USE_I2P
|
||||
, i2pconn(0)
|
||||
#endif
|
||||
{}
|
||||
|
||||
|
@ -167,7 +164,7 @@ namespace libtorrent {
|
|||
boost::asio::ssl::context* ssl_ctx;
|
||||
#endif
|
||||
#if TORRENT_USE_I2P
|
||||
i2p_connection* i2pconn;
|
||||
i2p_connection* i2pconn = nullptr;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -294,7 +294,7 @@ struct TORRENT_EXTRA_EXPORT utp_stream
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_impl == 0)
|
||||
if (m_impl == nullptr)
|
||||
{
|
||||
m_io_service.post(std::bind<void>(handler, boost::asio::error::not_connected, 0));
|
||||
return;
|
||||
|
@ -307,7 +307,7 @@ struct TORRENT_EXTRA_EXPORT utp_stream
|
|||
template <class Mutable_Buffers, class Handler>
|
||||
void async_read_some(Mutable_Buffers const& buffers, Handler const& handler)
|
||||
{
|
||||
if (m_impl == 0)
|
||||
if (m_impl == nullptr)
|
||||
{
|
||||
m_io_service.post(std::bind<void>(handler, boost::asio::error::not_connected, 0));
|
||||
return;
|
||||
|
@ -344,7 +344,7 @@ struct TORRENT_EXTRA_EXPORT utp_stream
|
|||
template <class Handler>
|
||||
void async_read_some(null_buffers const&, Handler const& handler)
|
||||
{
|
||||
if (m_impl == 0)
|
||||
if (m_impl == nullptr)
|
||||
{
|
||||
m_io_service.post(std::bind<void>(handler, boost::asio::error::not_connected, 0));
|
||||
return;
|
||||
|
@ -376,7 +376,7 @@ struct TORRENT_EXTRA_EXPORT utp_stream
|
|||
std::size_t read_some(Mutable_Buffers const& buffers, error_code& ec)
|
||||
{
|
||||
TORRENT_ASSERT(!m_read_handler);
|
||||
if (m_impl == 0)
|
||||
if (m_impl == nullptr)
|
||||
{
|
||||
ec = boost::asio::error::not_connected;
|
||||
return 0;
|
||||
|
@ -440,7 +440,7 @@ struct TORRENT_EXTRA_EXPORT utp_stream
|
|||
template <class Const_Buffers, class Handler>
|
||||
void async_write_some(Const_Buffers const& buffers, Handler const& handler)
|
||||
{
|
||||
if (m_impl == 0)
|
||||
if (m_impl == nullptr)
|
||||
{
|
||||
m_io_service.post(std::bind<void>(handler
|
||||
, boost::asio::error::not_connected, 0));
|
||||
|
|
|
@ -55,7 +55,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <functional>
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||
#include <boost/variant/get.hpp>
|
||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||
|
||||
#define DEBUG_DISK_THREAD 0
|
||||
|
||||
|
@ -1877,7 +1879,7 @@ constexpr disk_job_flags_t disk_interface::cache_hit;
|
|||
for (auto& p : pieces)
|
||||
{
|
||||
cached_piece_entry* pe = m_disk_cache.find_piece(p.first, p.second);
|
||||
if (pe == NULL) continue;
|
||||
if (pe == nullptr) continue;
|
||||
TORRENT_ASSERT(pe->outstanding_read == 1);
|
||||
pe->outstanding_read = 0;
|
||||
}
|
||||
|
|
|
@ -330,7 +330,7 @@ constexpr int CLOSE_FILE_INTERVAL = 0;
|
|||
SET(proxy_port, 0, &session_impl::update_proxy),
|
||||
SET(i2p_port, 0, &session_impl::update_i2p_bridge),
|
||||
SET(cache_size_volatile, 256, nullptr),
|
||||
SET(urlseed_max_request_bytes, 16 * 1024 * 1024, 0),
|
||||
SET(urlseed_max_request_bytes, 16 * 1024 * 1024, nullptr),
|
||||
SET(web_seed_name_lookup_retry, 1800, nullptr),
|
||||
SET(close_file_interval, CLOSE_FILE_INTERVAL, nullptr),
|
||||
SET(max_web_seed_connections, 3, nullptr),
|
||||
|
|
Loading…
Reference in New Issue