diff --git a/src/file.cpp b/src/file.cpp index 6c796c531..f332b40ad 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -315,11 +315,23 @@ namespace { } } // namespace # else + +# ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wreserved-id-macro" +# pragma clang diagnostic ignored "-Wunused-macros" +# endif + # undef _BSD_SOURCE # define _BSD_SOURCE // deprecated since glibc 2.20 # undef _DEFAULT_SOURCE # define _DEFAULT_SOURCE # include + +# ifdef __clang__ +# pragma clang diagnostic pop +# endif + # endif #endif diff --git a/src/path.cpp b/src/path.cpp index 44cda7dce..fd9d9d6b0 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -140,10 +140,16 @@ namespace libtorrent { std::string convert_from_native_path(char const* s) { return convert_from_native(s); } #endif - template - std::unique_ptr make_free_holder(T* ptr) +namespace { + struct free_function { - return std::unique_ptr(ptr, &std::free); + void operator()(void* ptr) const noexcept { std::free(ptr); } + }; + + template + std::unique_ptr make_free_holder(T* ptr) + { + return std::unique_ptr(ptr, free_function{}); } #ifdef TORRENT_WINDOWS @@ -158,6 +164,7 @@ namespace libtorrent { return time_t(ft / 10000000 - posix_time_offset); } #endif +} // anonymous namespace native_path_string convert_to_native_path_string(std::string const& path) { diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 1c9590d6f..0a9fa0f0f 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -115,9 +115,11 @@ POSSIBILITY OF SUCH DAMAGE. #ifdef TORRENT_USE_LIBGCRYPT +#if GCRYPT_VERSION_NUMBER < 0x010600 extern "C" { GCRY_THREAD_OPTION_PTHREAD_IMPL; } +#endif namespace { @@ -126,11 +128,13 @@ namespace { { gcrypt_setup() { - gcry_check_version(0); + gcry_check_version(nullptr); +#if GCRYPT_VERSION_NUMBER < 0x010600 gcry_error_t e = gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); if (e != 0) std::fprintf(stderr, "libcrypt ERROR: %s\n", gcry_strerror(e)); e = gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); if (e != 0) std::fprintf(stderr, "initialization finished error: %s\n", gcry_strerror(e)); +#endif } } gcrypt_global_constructor; } @@ -475,8 +479,8 @@ namespace aux { session_log("start session"); #endif - error_code ec; #ifdef TORRENT_USE_OPENSSL + error_code ec; m_ssl_ctx.set_verify_mode(boost::asio::ssl::context::verify_none, ec); #if OPENSSL_VERSION_NUMBER >= 0x90812f aux::openssl_set_tlsext_servername_callback(m_ssl_ctx.native_handle() diff --git a/src/upnp.cpp b/src/upnp.cpp index 392bc5298..b7c234ccc 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -887,7 +887,6 @@ void upnp::delete_port_mapping(rootdevice& d, port_mapping_t const i) char const* soap_action = "DeletePortMapping"; char soap[2048]; - error_code ec; std::snprintf(soap, sizeof(soap), "\n" "" diff --git a/test/bittorrent_peer.cpp b/test/bittorrent_peer.cpp index cd44df386..695738581 100644 --- a/test/bittorrent_peer.cpp +++ b/test/bittorrent_peer.cpp @@ -141,7 +141,6 @@ void peer_conn::write_have_all() // unchoke write_uint32(1, ptr); write_uint8(1, ptr); - error_code ec; boost::asio::async_write(s, boost::asio::buffer(write_buf_proto.data() , static_cast(ptr - write_buf_proto.data())) , std::bind(&peer_conn::on_have_all_sent, this, _1, _2)); @@ -158,7 +157,6 @@ void peer_conn::write_have_all() // unchoke write_uint32(1, ptr); write_uint8(1, ptr); - error_code ec; boost::asio::async_write(s, boost::asio::buffer(buffer.data() , static_cast(len + 10)) , std::bind(&peer_conn::on_have_all_sent, this, _1, _2)); @@ -224,7 +222,6 @@ bool peer_conn::write_request() write_uint32(current_piece, ptr); write_uint32(block * 16 * 1024, ptr); write_uint32(16 * 1024, ptr); - error_code ec; boost::asio::async_write(s, boost::asio::buffer(m, sizeof(msg) - 1) , std::bind(&peer_conn::on_req_sent, this, m, _1, _2)); diff --git a/test/test_ip_filter.cpp b/test/test_ip_filter.cpp index 6801a9bd9..a143cb115 100644 --- a/test/test_ip_filter.cpp +++ b/test/test_ip_filter.cpp @@ -96,7 +96,6 @@ TORRENT_TEST(session_get_ip_filter) TORRENT_TEST(ip_filter) { std::vector> range; - error_code ec; // **** test joining of ranges at the end **** ip_range expected1[] = diff --git a/test/test_remap_files.cpp b/test/test_remap_files.cpp index f44c1ba2f..8dbfb55cb 100644 --- a/test/test_remap_files.cpp +++ b/test/test_remap_files.cpp @@ -59,9 +59,6 @@ void test_remap_files(storage_mode_t storage_mode = storage_mode_sparse) { using namespace lt; - // in case the previous run was terminated - error_code ec; - // create a torrent with 2 files, remap them into 3 files and make sure // the file priorities don't break things static std::array const file_sizes{{100000, 100000}}; diff --git a/test/test_storage.cpp b/test/test_storage.cpp index 8c4e9e743..431de576e 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -982,7 +982,7 @@ void alloc_iov(iovec_t* iov, int num_bufs) { for (int i = 0; i < num_bufs; ++i) { - iov[i] = { new char[num_bufs * (i + 1)] + iov[i] = { new char[static_cast(num_bufs * (i + 1))] , static_cast(num_bufs * (i + 1)) }; } } diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 809588085..c239122d1 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -636,7 +636,6 @@ TORRENT_TEST(test_have_piece_no_metadata) TORRENT_TEST(test_have_piece_out_of_range) { lt::session ses(settings()); - error_code ec; add_torrent_params p; static std::array const file_sizes{{100000, 100000}}; @@ -672,7 +671,6 @@ TORRENT_TEST(test_read_piece_no_metadata) TORRENT_TEST(test_read_piece_out_of_range) { lt::session ses(settings()); - error_code ec; add_torrent_params p; static std::array const file_sizes{{100000, 100000}};