From 6462a3a6db8452523b8c07d8394fbc5dc86f7295 Mon Sep 17 00:00:00 2001 From: redfish Date: Wed, 18 May 2016 00:52:01 -0400 Subject: [PATCH 1/7] crypto: fix compile error: use named type in sizeof Btw, the warning 4200 remains disabled, but it did not get triggered (GCC 6.1.1, ARM). But, perhaps a better way than disabling the warning would be to do what is suggested here: http://stackoverflow.com/questions/3350852/how-to-correctly-fix-zero-sized-array-in-struct-union-warning-c4200-without%3E --- src/crypto/crypto.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/crypto/crypto.cpp b/src/crypto/crypto.cpp index e251d0ec..f5e65527 100644 --- a/src/crypto/crypto.cpp +++ b/src/crypto/crypto.cpp @@ -263,16 +263,17 @@ namespace crypto { PUSH_WARNINGS DISABLE_VS_WARNINGS(4200) + struct ec_point_pair { + ec_point a, b; + }; struct rs_comm { hash h; - struct { - ec_point a, b; - } ab[]; + struct ec_point_pair ab[]; }; POP_WARNINGS static inline size_t rs_comm_size(size_t pubs_count) { - return sizeof(rs_comm) + pubs_count * sizeof(rs_comm().ab[0]); + return sizeof(rs_comm) + pubs_count * sizeof(ec_point_pair); } void crypto_ops::generate_ring_signature(const hash &prefix_hash, const key_image &image, From 1a7772fbae04fbc5ca6592c079f8ddf146e8cd22 Mon Sep 17 00:00:00 2001 From: redfish Date: Wed, 18 May 2016 00:54:33 -0400 Subject: [PATCH 2/7] crypto: oaes_lib: remove unused _NR array --- src/crypto/oaes_lib.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/crypto/oaes_lib.c b/src/crypto/oaes_lib.c index 7fbe96e4..4c144689 100644 --- a/src/crypto/oaes_lib.c +++ b/src/crypto/oaes_lib.c @@ -27,10 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. * --------------------------------------------------------------------------- */ -static const char _NR[] = { - 0x4e,0x61,0x62,0x69,0x6c,0x20,0x53,0x2e,0x20, - 0x41,0x6c,0x20,0x52,0x61,0x6d,0x6c,0x69,0x00 }; - #include #include #include From 70f363401b436cb975b002627e0fd13b59e34d17 Mon Sep 17 00:00:00 2001 From: redfish Date: Wed, 18 May 2016 00:54:55 -0400 Subject: [PATCH 3/7] crypto: slow-hash: remove unused hash list for ARM This list is already defined within the function. The removed definition was shadowed. --- src/crypto/slow-hash.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c index 4efa8af6..8002b276 100644 --- a/src/crypto/slow-hash.c +++ b/src/crypto/slow-hash.c @@ -658,10 +658,6 @@ void slow_hash_free_state(void) return; } -static void (*const extra_hashes[4])(const void *, size_t, char *) = { - hash_extra_blake, hash_extra_groestl, hash_extra_jh, hash_extra_skein -}; - #define MEMORY (1 << 21) /* 2 MiB */ #define ITER (1 << 20) #define AES_BLOCK_SIZE 16 From 21dbc95b479ee935908fdcc0be5fe377c9fa003d Mon Sep 17 00:00:00 2001 From: redfish Date: Wed, 18 May 2016 00:56:25 -0400 Subject: [PATCH 4/7] crypto: slow-hash: fix misleading indent GCC warned about this one. --- src/crypto/slow-hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c index 8002b276..ee7e0ebe 100644 --- a/src/crypto/slow-hash.c +++ b/src/crypto/slow-hash.c @@ -820,7 +820,7 @@ void cn_slow_hash(const void *data, size_t length, char *hash) { for(j = 0; j < INIT_SIZE_BLK; j++) aesb_pseudo_round(&text[AES_BLOCK_SIZE * j], &text[AES_BLOCK_SIZE * j], expandedKey); - memcpy(&long_state[i * INIT_SIZE_BYTE], text, INIT_SIZE_BYTE); + memcpy(&long_state[i * INIT_SIZE_BYTE], text, INIT_SIZE_BYTE); } U64(a)[0] = U64(&state.k[0])[0] ^ U64(&state.k[32])[0]; From 68987416adb755337714964b38db3ada08ec2203 Mon Sep 17 00:00:00 2001 From: redfish Date: Wed, 18 May 2016 00:57:17 -0400 Subject: [PATCH 5/7] src: p2p: add exception spec to throwing destructors The destructors get a noexcept(true) spec by default, but these destructors in fact throw exceptions. An alternative fix might be to not throw (most if not all of these throws are non-essential error-reporting/logging). --- src/p2p/connection_basic.cpp | 2 +- src/p2p/connection_basic.hpp | 2 +- src/p2p/data_logger.cpp | 2 +- src/p2p/data_logger.hpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p2p/connection_basic.cpp b/src/p2p/connection_basic.cpp index c0b73bc3..22c5ef77 100644 --- a/src/p2p/connection_basic.cpp +++ b/src/p2p/connection_basic.cpp @@ -167,7 +167,7 @@ connection_basic::connection_basic(boost::asio::io_service& io_service, std::ato //boost::filesystem::create_directories("log/dr-monero/net/"); } -connection_basic::~connection_basic() { +connection_basic::~connection_basic() noexcept(false) { string remote_addr_str = "?"; m_ref_sock_count--; try { remote_addr_str = socket_.remote_endpoint().address().to_string(); } catch(...){} ; diff --git a/src/p2p/connection_basic.hpp b/src/p2p/connection_basic.hpp index 8be79873..5452fa6f 100644 --- a/src/p2p/connection_basic.hpp +++ b/src/p2p/connection_basic.hpp @@ -103,7 +103,7 @@ class connection_basic { // not-templated base class for rapid developmet of som // first counter is the ++/-- count of current sockets, the other socket_number is only-increasing ++ number generator connection_basic(boost::asio::io_service& io_service, std::atomic &ref_sock_count, std::atomic &sock_number); - virtual ~connection_basic(); + virtual ~connection_basic() noexcept(false); // various handlers to be called from connection class: void do_send_handler_write(const void * ptr , size_t cb); diff --git a/src/p2p/data_logger.cpp b/src/p2p/data_logger.cpp index ca0726c5..fe54aef6 100644 --- a/src/p2p/data_logger.cpp +++ b/src/p2p/data_logger.cpp @@ -103,7 +103,7 @@ namespace net_utils _info_c("dbg/data","Data logger constructed"); } - data_logger::~data_logger() { + data_logger::~data_logger() noexcept(false) { _note_c("dbg/data","Destructor of the data logger"); { boost::lock_guard lock(mMutex); diff --git a/src/p2p/data_logger.hpp b/src/p2p/data_logger.hpp index 148afc0a..278d08bf 100644 --- a/src/p2p/data_logger.hpp +++ b/src/p2p/data_logger.hpp @@ -55,7 +55,7 @@ enum class data_logger_state { state_before_init, state_during_init, state_ready public: static data_logger &get_instance(); ///< singleton static void kill_instance(); ///< call this before ending main to allow more gracefull shutdown of the main singleton and it's background thread - ~data_logger(); ///< destr, will be called when singleton is killed when global m_obj dies. will kill theads etc + ~data_logger() noexcept(false); ///< destr, will be called when singleton is killed when global m_obj dies. will kill theads etc private: data_logger(); ///< constructor is private, use only via singleton get_instance From c2d7300d2ebea0c5567268f320fe3427f4399667 Mon Sep 17 00:00:00 2001 From: redfish Date: Wed, 18 May 2016 00:59:07 -0400 Subject: [PATCH 6/7] contrib: epee: add exception spec to throwing destructors The destructors get a noexcept(true) spec by default, but these destructors in fact throw exceptions. An alternative fix might be to not throw (most if not all of these throws are non-essential error-reporting/logging). --- contrib/epee/include/net/abstract_tcp_server2.inl | 2 +- contrib/epee/include/net/net_utils_base.h | 2 +- contrib/epee/include/storages/portable_storage_from_bin.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl index ca9429c9..94dbe745 100644 --- a/contrib/epee/include/net/abstract_tcp_server2.inl +++ b/contrib/epee/include/net/abstract_tcp_server2.inl @@ -88,7 +88,7 @@ PRAGMA_WARNING_DISABLE_VS(4355) PRAGMA_WARNING_DISABLE_VS(4355) //--------------------------------------------------------------------------------- template - connection::~connection() + connection::~connection() noexcept(false) { if(!m_was_shutdown) { diff --git a/contrib/epee/include/net/net_utils_base.h b/contrib/epee/include/net/net_utils_base.h index f963e774..78e555fa 100644 --- a/contrib/epee/include/net/net_utils_base.h +++ b/contrib/epee/include/net/net_utils_base.h @@ -119,7 +119,7 @@ namespace net_utils virtual bool add_ref()=0; virtual bool release()=0; protected: - virtual ~i_service_endpoint(){} + virtual ~i_service_endpoint() noexcept(false) {} }; diff --git a/contrib/epee/include/storages/portable_storage_from_bin.h b/contrib/epee/include/storages/portable_storage_from_bin.h index bc2fb146..44a80cb2 100644 --- a/contrib/epee/include/storages/portable_storage_from_bin.h +++ b/contrib/epee/include/storages/portable_storage_from_bin.h @@ -68,7 +68,7 @@ namespace epee ++m_counter_ref; CHECK_AND_ASSERT_THROW_MES(m_counter_ref < EPEE_PORTABLE_STORAGE_RECURSION_LIMIT_INTERNAL, "Wrong blob data in portable storage: recursion limitation (" << EPEE_PORTABLE_STORAGE_RECURSION_LIMIT_INTERNAL << ") exceeded"); } - ~recursuion_limitation_guard() + ~recursuion_limitation_guard() noexcept(false) { CHECK_AND_ASSERT_THROW_MES(m_counter_ref != 0, "Internal error: m_counter_ref == 0 while ~recursuion_limitation_guard()"); --m_counter_ref; From de030d99a504838c87f84fabe15f173477d3b17d Mon Sep 17 00:00:00 2001 From: moneroexample Date: Wed, 18 May 2016 12:51:28 +0800 Subject: [PATCH 7/7] fix: error: -Werror=misleading-indentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compilation of bitmonero on Arch with gcc 6.1 results in the following error: /home/mwo/bitmonero/tests/unit_tests/hardfork.cpp: In member function ‘virtual void TestDB::set_hard_fork_version(uint64_t, uint8_t)’: /home/mwo/bitmonero/tests/unit_tests/hardfork.cpp:132:5: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation] if (versions.size() <= height) versions.resize(height+1); versions[height] = version; This can be fixed by simply unfolding this line into three lines. --- tests/unit_tests/hardfork.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp index 6d4a100d..1d1f8594 100644 --- a/tests/unit_tests/hardfork.cpp +++ b/tests/unit_tests/hardfork.cpp @@ -129,7 +129,9 @@ public: return starting_height[version]; } virtual void set_hard_fork_version(uint64_t height, uint8_t version) { - if (versions.size() <= height) versions.resize(height+1); versions[height] = version; + if (versions.size() <= height) + versions.resize(height+1); + versions[height] = version; } virtual uint8_t get_hard_fork_version(uint64_t height) const { return versions[height];