From 87c46a144d37f50450edabc5a9c35888951ae028 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 22 Apr 2015 04:24:45 +0000 Subject: [PATCH] fix more warnings and some build issues --- ed25519/src/add_scalar.cpp | 3 ++ ed25519/src/fe.cpp | 3 ++ ed25519/src/ge.cpp | 3 ++ ed25519/src/key_exchange.cpp | 3 ++ ed25519/src/keypair.cpp | 3 ++ ed25519/src/sc.cpp | 3 ++ ed25519/src/seed.cpp | 3 ++ ed25519/src/sha512.cpp | 3 ++ ed25519/src/sign.cpp | 3 ++ ed25519/src/verify.cpp | 3 ++ include/libtorrent/assert.hpp | 6 ++- .../libtorrent/aux_/disable_warnings_push.hpp | 1 + include/libtorrent/block_cache.hpp | 4 +- include/libtorrent/invariant_check.hpp | 6 +++ src/ConvertUTF.cpp | 2 + src/assert.cpp | 6 +++ src/block_cache.cpp | 50 +++++++++---------- src/disk_buffer_pool.cpp | 7 +++ src/kademlia/routing_table.cpp | 4 ++ src/part_file.cpp | 8 ++- 20 files changed, 95 insertions(+), 29 deletions(-) diff --git a/ed25519/src/add_scalar.cpp b/ed25519/src/add_scalar.cpp index 72cc852b9..c0e191a98 100644 --- a/ed25519/src/add_scalar.cpp +++ b/ed25519/src/add_scalar.cpp @@ -1,3 +1,6 @@ +// ignore warnings in this file +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include "libtorrent/ed25519.hpp" #include "ge.h" #include "sc.h" diff --git a/ed25519/src/fe.cpp b/ed25519/src/fe.cpp index e2e79ffbb..809f0c335 100644 --- a/ed25519/src/fe.cpp +++ b/ed25519/src/fe.cpp @@ -1,3 +1,6 @@ +// ignore warnings in this file +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include "fixedint.h" #include "fe.h" diff --git a/ed25519/src/ge.cpp b/ed25519/src/ge.cpp index 107039e3b..c6fc00472 100644 --- a/ed25519/src/ge.cpp +++ b/ed25519/src/ge.cpp @@ -1,3 +1,6 @@ +// ignore warnings in this file +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include "ge.h" #include "precomp_data.h" diff --git a/ed25519/src/key_exchange.cpp b/ed25519/src/key_exchange.cpp index b0b090758..1d728ed5a 100644 --- a/ed25519/src/key_exchange.cpp +++ b/ed25519/src/key_exchange.cpp @@ -1,3 +1,6 @@ +// ignore warnings in this file +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include "libtorrent/ed25519.hpp" #include "fe.h" diff --git a/ed25519/src/keypair.cpp b/ed25519/src/keypair.cpp index 7d2d14338..90d8dbc3b 100644 --- a/ed25519/src/keypair.cpp +++ b/ed25519/src/keypair.cpp @@ -1,3 +1,6 @@ +// ignore warnings in this file +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include "libtorrent/ed25519.hpp" #include "sha512.h" #include "ge.h" diff --git a/ed25519/src/sc.cpp b/ed25519/src/sc.cpp index 2c4ae8738..a6656c4d5 100644 --- a/ed25519/src/sc.cpp +++ b/ed25519/src/sc.cpp @@ -1,3 +1,6 @@ +// ignore warnings in this file +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include "fixedint.h" #include "sc.h" diff --git a/ed25519/src/seed.cpp b/ed25519/src/seed.cpp index 7619c66bc..d595cdc11 100644 --- a/ed25519/src/seed.cpp +++ b/ed25519/src/seed.cpp @@ -1,3 +1,6 @@ +// ignore warnings in this file +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include "libtorrent/ed25519.hpp" #ifndef ED25519_NO_SEED diff --git a/ed25519/src/sha512.cpp b/ed25519/src/sha512.cpp index add156243..1b4c23f9e 100644 --- a/ed25519/src/sha512.cpp +++ b/ed25519/src/sha512.cpp @@ -1,3 +1,6 @@ +// ignore warnings in this file +#include "libtorrent/aux_/disable_warnings_push.hpp" + /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic diff --git a/ed25519/src/sign.cpp b/ed25519/src/sign.cpp index 6badd2c03..cf4b20d2a 100644 --- a/ed25519/src/sign.cpp +++ b/ed25519/src/sign.cpp @@ -1,3 +1,6 @@ +// ignore warnings in this file +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include "libtorrent/ed25519.hpp" #include "sha512.h" #include "ge.h" diff --git a/ed25519/src/verify.cpp b/ed25519/src/verify.cpp index 37b4ed573..b5d81b8e5 100644 --- a/ed25519/src/verify.cpp +++ b/ed25519/src/verify.cpp @@ -1,3 +1,6 @@ +// ignore warnings in this file +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include "libtorrent/ed25519.hpp" #include "sha512.h" #include "ge.h" diff --git a/include/libtorrent/assert.hpp b/include/libtorrent/assert.hpp index b9c2acce8..1bd449764 100644 --- a/include/libtorrent/assert.hpp +++ b/include/libtorrent/assert.hpp @@ -57,7 +57,11 @@ extern char const* libtorrent_assert_log; #include #endif -TORRENT_EXPORT void assert_print(char const* fmt, ...); +TORRENT_EXPORT void assert_print(char const* fmt, ...) +#if defined __GNUC__ || defined __clang__ + __attribute__((format(printf, 1, 2))) +#endif + ; #if TORRENT_USE_ASSERTS || defined TORRENT_ASIO_DEBUGGING TORRENT_NO_RETURN diff --git a/include/libtorrent/aux_/disable_warnings_push.hpp b/include/libtorrent/aux_/disable_warnings_push.hpp index f559e158c..f4ce52808 100644 --- a/include/libtorrent/aux_/disable_warnings_push.hpp +++ b/include/libtorrent/aux_/disable_warnings_push.hpp @@ -60,6 +60,7 @@ POSSIBILITY OF SUCH DAMAGE. #pragma clang diagnostic ignored "-Wweak-vtable" #pragma clang diagnostic ignored "-Wundef" #pragma clang diagnostic ignored "-Wshadow" +#pragma clang diagnostic ignored "-Wimplicit-fallthrough" #endif #ifdef _MSC_VER diff --git a/include/libtorrent/block_cache.hpp b/include/libtorrent/block_cache.hpp index f26b56382..801842dc4 100644 --- a/include/libtorrent/block_cache.hpp +++ b/include/libtorrent/block_cache.hpp @@ -94,7 +94,7 @@ namespace libtorrent last_job }; - static char const* job_names[7]; + static char const* const job_names[7]; }; char const* job_name(int j); @@ -104,7 +104,7 @@ namespace libtorrent #endif - extern const char* job_action_name[]; + extern const char* const job_action_name[]; struct TORRENT_EXTRA_EXPORT partial_hash { diff --git a/include/libtorrent/invariant_check.hpp b/include/libtorrent/invariant_check.hpp index 388552954..8e9e7c0ef 100644 --- a/include/libtorrent/invariant_check.hpp +++ b/include/libtorrent/invariant_check.hpp @@ -48,6 +48,9 @@ namespace libtorrent } } + invariant_checker_impl(invariant_checker_impl const& rhs) + : self(rhs.self) {} + ~invariant_checker_impl() { TORRENT_TRY @@ -61,6 +64,9 @@ namespace libtorrent } T const& self; + + private: + invariant_checker_impl& operator=(invariant_checker_impl const&); }; template diff --git a/src/ConvertUTF.cpp b/src/ConvertUTF.cpp index f93a1d56f..c661118ea 100644 --- a/src/ConvertUTF.cpp +++ b/src/ConvertUTF.cpp @@ -38,6 +38,8 @@ ------------------------------------------------------------------------ */ +// ignore warnings in this file +#include "libtorrent/aux_/disable_warnings_push.hpp" #include "libtorrent/ConvertUTF.h" #ifdef CVTUTF_DEBUG diff --git a/src/assert.cpp b/src/assert.cpp index 649e1b798..a4fe0d43a 100644 --- a/src/assert.cpp +++ b/src/assert.cpp @@ -221,6 +221,9 @@ char const* libtorrent_assert_log = "asserts.log"; boost::atomic assert_counter(0); #endif +#if defined __GNUC__ || defined __clang__ +__attribute__((format(printf, 1, 2))) +#endif TORRENT_EXPORT void assert_print(char const* fmt, ...) { #ifdef TORRENT_PRODUCTION_ASSERTS @@ -296,6 +299,9 @@ TORRENT_NO_RETURN TORRENT_EXPORT void assert_fail(char const* expr, int line #else +#if defined __GNUC__ || defined __clang__ +__attribute__((format(printf, 1, 2))) +#endif TORRENT_EXPORT void assert_print(char const*, ...) {} TORRENT_EXPORT void assert_fail(char const*, int, char const* , char const*, char const*, int) {} diff --git a/src/block_cache.cpp b/src/block_cache.cpp index cbdfda08d..1d22cfa64 100644 --- a/src/block_cache.cpp +++ b/src/block_cache.cpp @@ -180,33 +180,33 @@ void log_refcounts(cached_piece_entry const* pe) } #endif +const char* const job_action_name[] = +{ + "read", + "write", + "hash", + "move_storage", + "release_files", + "delete_files", + "check_fastresume", + "save_resume_data", + "rename_file", + "stop_torrent", + "cache_piece", + "finalize_file", + "flush_piece", + "flush_hashed", + "flush_storage", + "trim_cache", + "set_file_priority", + "load_torrent", + "clear_piece", + "tick_storage", +}; + #if TORRENT_USE_ASSERTS - const char* job_action_name[] = - { - "read", - "write", - "hash", - "move_storage", - "release_files", - "delete_files", - "check_fastresume", - "save_resume_data", - "rename_file", - "stop_torrent", - "cache_piece", - "finalize_file", - "flush_piece", - "flush_hashed", - "flush_storage", - "trim_cache", - "set_file_priority", - "load_torrent", - "clear_piece", - "tick_storage", - }; - - char const* piece_log_t::job_names[7] = + char const* const piece_log_t::job_names[7] = { "flushing", "flush_expired", diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index cebde4fb7..e6ce6a004 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -162,6 +162,7 @@ namespace libtorrent // more buffers to received data into void disk_buffer_pool::check_buffer_level(mutex::scoped_lock& l) { + TORRENT_ASSERT(l.locked()); if (!m_exceeded_max_size || m_in_use > m_low_watermark) return; m_exceeded_max_size = false; @@ -214,6 +215,8 @@ namespace libtorrent , mutex::scoped_lock& l) const { TORRENT_ASSERT(m_magic == 0x1337); + TORRENT_ASSERT(l.locked()); + TORRENT_UNUSED(l); #if TORRENT_HAVE_MMAP if (m_cache_pool) @@ -325,6 +328,8 @@ namespace libtorrent { TORRENT_ASSERT(m_settings_set); TORRENT_ASSERT(m_magic == 0x1337); + TORRENT_ASSERT(l.locked()); + TORRENT_UNUSED(l); char* ret; #if TORRENT_HAVE_MMAP @@ -601,6 +606,8 @@ namespace libtorrent TORRENT_ASSERT(m_magic == 0x1337); TORRENT_ASSERT(m_settings_set); TORRENT_ASSERT(is_disk_buffer(buf, l)); + TORRENT_ASSERT(l.locked()); + TORRENT_UNUSED(l); #if TORRENT_USE_MLOCK if (m_lock_disk_cache) diff --git a/src/kademlia/routing_table.cpp b/src/kademlia/routing_table.cpp index 2cee5faf9..bccf132c5 100644 --- a/src/kademlia/routing_table.cpp +++ b/src/kademlia/routing_table.cpp @@ -401,6 +401,8 @@ routing_table::table_t::iterator routing_table::find_bucket(node_id const& id) return i; } +namespace { + bool compare_ip_cidr(node_entry const& lhs, node_entry const& rhs) { TORRENT_ASSERT(lhs.addr().is_v4() == rhs.addr().is_v4()); @@ -413,6 +415,8 @@ bool compare_ip_cidr(node_entry const& lhs, node_entry const& rhs) return dist <= cutoff; } +} // anonymous namespace + node_entry* routing_table::find_node(udp::endpoint const& ep , routing_table::table_t::iterator* bucket) { diff --git a/src/part_file.cpp b/src/part_file.cpp index e2baba1f3..ad7abef9c 100644 --- a/src/part_file.cpp +++ b/src/part_file.cpp @@ -287,8 +287,14 @@ namespace libtorrent m_path = path; } - void part_file::import_file(file& f, boost::int64_t offset, boost::int64_t size, error_code& ec) + void part_file::import_file(file& f, boost::int64_t offset + , boost::int64_t size, error_code& ec) { + TORRENT_UNUSED(f); + TORRENT_UNUSED(offset); + TORRENT_UNUSED(size); + TORRENT_UNUSED(ec); + // not implemented assert(false); }