diff --git a/src/beast/beast/Atomic.h b/src/beast/beast/Atomic.h index 97b271b8e..e64debf0b 100644 --- a/src/beast/beast/Atomic.h +++ b/src/beast/beast/Atomic.h @@ -300,8 +300,16 @@ template inline Type Atomic::operator+= (const Type amountToAdd) noexcept { #if BEAST_ATOMICS_MAC +# ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" +# pragma clang diagnostic ignored "-Wint-to-pointer-cast" +# endif return sizeof (Type) == 4 ? (Type) OSAtomicAdd32Barrier ((int32_t) castTo32Bit (amountToAdd), (BEAST_MAC_ATOMICS_VOLATILE int32_t*) &value) : (Type) OSAtomicAdd64Barrier ((int64_t) amountToAdd, (BEAST_MAC_ATOMICS_VOLATILE int64_t*) &value); +# ifdef __clang__ +# pragma clang diagnostic pop +# endif #elif BEAST_ATOMICS_WINDOWS return sizeof (Type) == 4 ? (Type) (beast_InterlockedExchangeAdd ((volatile long*) &value, (long) amountToAdd) + (long) amountToAdd) : (Type) (beast_InterlockedExchangeAdd64 ((volatile __int64*) &value, (__int64) amountToAdd) + (__int64) amountToAdd); @@ -320,8 +328,16 @@ template inline Type Atomic::operator++() noexcept { #if BEAST_ATOMICS_MAC +# ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" +# pragma clang diagnostic ignored "-Wint-to-pointer-cast" +# endif return sizeof (Type) == 4 ? (Type) OSAtomicIncrement32Barrier ((BEAST_MAC_ATOMICS_VOLATILE int32_t*) &value) : (Type) OSAtomicIncrement64Barrier ((BEAST_MAC_ATOMICS_VOLATILE int64_t*) &value); +# ifdef __clang__ +# pragma clang diagnostic pop +# endif #elif BEAST_ATOMICS_WINDOWS return sizeof (Type) == 4 ? (Type) beast_InterlockedIncrement ((volatile long*) &value) : (Type) beast_InterlockedIncrement64 ((volatile __int64*) &value); @@ -334,8 +350,16 @@ template inline Type Atomic::operator--() noexcept { #if BEAST_ATOMICS_MAC +# ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" +# pragma clang diagnostic ignored "-Wint-to-pointer-cast" +# endif return sizeof (Type) == 4 ? (Type) OSAtomicDecrement32Barrier ((BEAST_MAC_ATOMICS_VOLATILE int32_t*) &value) : (Type) OSAtomicDecrement64Barrier ((BEAST_MAC_ATOMICS_VOLATILE int64_t*) &value); +# ifdef __clang__ +# pragma clang diagnostic pop +# endif #elif BEAST_ATOMICS_WINDOWS return sizeof (Type) == 4 ? (Type) beast_InterlockedDecrement ((volatile long*) &value) : (Type) beast_InterlockedDecrement64 ((volatile __int64*) &value); diff --git a/src/beast/beast/container/detail/aged_ordered_container.h b/src/beast/beast/container/detail/aged_ordered_container.h index 2759fd5b0..7c933d60d 100644 --- a/src/beast/beast/container/detail/aged_ordered_container.h +++ b/src/beast/beast/container/detail/aged_ordered_container.h @@ -1469,7 +1469,7 @@ operator[] (Key const& key) std::piecewise_construct, std::forward_as_tuple (key), std::forward_as_tuple ())); chronological.list.push_back (*p); - auto const iter (m_cont.insert_commit (*p, d)); + m_cont.insert_commit (*p, d); return p->value.second; } return result.first->value.second; @@ -1492,7 +1492,7 @@ operator[] (Key&& key) std::forward_as_tuple (std::move (key)), std::forward_as_tuple ())); chronological.list.push_back (*p); - auto const iter (m_cont.insert_commit (*p, d)); + m_cont.insert_commit (*p, d); return p->value.second; } return result.first->value.second; diff --git a/src/beast/beast/container/detail/aged_unordered_container.h b/src/beast/beast/container/detail/aged_unordered_container.h index f5e3ec3de..23af08bba 100644 --- a/src/beast/beast/container/detail/aged_unordered_container.h +++ b/src/beast/beast/container/detail/aged_unordered_container.h @@ -2077,7 +2077,7 @@ operator[] (Key const& key) std::forward_as_tuple (key), std::forward_as_tuple ())); chronological.list.push_back (*p); - auto const iter (m_cont.insert_commit (*p, d)); + m_cont.insert_commit (*p, d); return p->value.second; } return result.first->value.second; @@ -2103,7 +2103,7 @@ operator[] (Key&& key) std::forward_as_tuple (std::move (key)), std::forward_as_tuple ())); chronological.list.push_back (*p); - auto const iter (m_cont.insert_commit (*p, d)); + m_cont.insert_commit (*p, d); return p->value.second; } return result.first->value.second; diff --git a/src/beast/beast/insight/impl/StatsDCollector.cpp b/src/beast/beast/insight/impl/StatsDCollector.cpp index 4625bc118..85271097c 100644 --- a/src/beast/beast/insight/impl/StatsDCollector.cpp +++ b/src/beast/beast/insight/impl/StatsDCollector.cpp @@ -335,7 +335,7 @@ public: void log (std::vector const& buffers) { - buffers; + (void)buffers; #if BEAST_STATSDCOLLECTOR_TRACING_ENABLED std::stringstream ss; for (auto const& buffer : buffers) diff --git a/src/beast/beast/strings/CharacterFunctions.h b/src/beast/beast/strings/CharacterFunctions.h index 4c17e4463..f36954412 100644 --- a/src/beast/beast/strings/CharacterFunctions.h +++ b/src/beast/beast/strings/CharacterFunctions.h @@ -343,9 +343,9 @@ public: const beast_wchar c = src.getAndAdvance(); const size_t bytesNeeded = DestCharPointerType::getBytesRequiredFor (c); - maxBytes -= bytesNeeded; - if (c == 0 || maxBytes < 0) + if (c == 0 || maxBytes < bytesNeeded) break; + maxBytes -= bytesNeeded; dest.write (c); } diff --git a/src/beast/beast/strings/StringFromNumber.h b/src/beast/beast/strings/StringFromNumber.h index 3534f27b0..b50a989e2 100644 --- a/src/beast/beast/strings/StringFromNumber.h +++ b/src/beast/beast/strings/StringFromNumber.h @@ -64,6 +64,9 @@ public: #pragma warning (push) #pragma warning (disable: 4127) // conditional expression is constant #pragma warning (disable: 4146) // unary minus operator applied to unsigned type, result still unsigned +#elif defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wtautological-compare" #endif // pass in a pointer to the END of a buffer.. template @@ -86,6 +89,8 @@ public: } #ifdef _MSC_VER #pragma warning (pop) +#elif defined(__clang__) +#pragma clang diagnostic pop #endif struct StackArrayStream : public std::basic_streambuf > diff --git a/src/beast/modules/beast_asio/async/ComposedAsyncOperation.h b/src/beast/modules/beast_asio/async/ComposedAsyncOperation.h index a5884ccb1..e15837124 100644 --- a/src/beast/modules/beast_asio/async/ComposedAsyncOperation.h +++ b/src/beast/modules/beast_asio/async/ComposedAsyncOperation.h @@ -33,9 +33,8 @@ protected: SharedHandler. A reference to the SharedHandler is maintained for the lifetime of the composed operation. */ - ComposedAsyncOperation (std::size_t size, SharedHandlerPtr const& ptr) - : m_size (size) - , m_ptr (ptr) + explicit ComposedAsyncOperation (SharedHandlerPtr const& ptr) + : m_ptr (ptr) { // Illegal to do anything with handler here, because // usually it hasn't been assigned by the derived class yet. @@ -93,7 +92,6 @@ protected: } private: - std::size_t const m_size; SharedHandlerPtr const m_ptr; }; diff --git a/src/beast/modules/beast_asio/protocol/HandshakeDetector.h b/src/beast/modules/beast_asio/protocol/HandshakeDetector.h index d1ec84c14..e4d734f5c 100644 --- a/src/beast/modules/beast_asio/protocol/HandshakeDetector.h +++ b/src/beast/modules/beast_asio/protocol/HandshakeDetector.h @@ -129,7 +129,7 @@ private: AsyncOp (HandshakeDetectLogicType & logic, Stream& stream, BuffersType& buffer, SharedHandlerPtr const& handler) - : ComposedAsyncOperation (sizeof (*this), handler) + : ComposedAsyncOperation (handler) , m_logic (logic) , m_stream (stream) , m_buffer (buffer) diff --git a/src/beast/modules/beast_asio/tests/TestPeerDetails.h b/src/beast/modules/beast_asio/tests/TestPeerDetails.h index 8ad8b9284..d8b69202b 100644 --- a/src/beast/modules/beast_asio/tests/TestPeerDetails.h +++ b/src/beast/modules/beast_asio/tests/TestPeerDetails.h @@ -27,7 +27,7 @@ class TestPeerDetails public: virtual ~TestPeerDetails () { } - virtual String name () = 0; + virtual String name () const = 0; virtual Socket& get_socket () = 0; diff --git a/src/beast/modules/beast_asio/tests/TestPeerDetailsTcp.h b/src/beast/modules/beast_asio/tests/TestPeerDetailsTcp.h index 8e64ca49c..11fdbde84 100644 --- a/src/beast/modules/beast_asio/tests/TestPeerDetailsTcp.h +++ b/src/beast/modules/beast_asio/tests/TestPeerDetailsTcp.h @@ -54,7 +54,7 @@ public: return ".tcp?"; } - String name () + String name () const { return getArgName (m_protocol); } diff --git a/src/ripple/peerfinder/impl/Counts.h b/src/ripple/peerfinder/impl/Counts.h index 040df3f35..9ff0ccc84 100644 --- a/src/ripple/peerfinder/impl/Counts.h +++ b/src/ripple/peerfinder/impl/Counts.h @@ -29,9 +29,8 @@ namespace PeerFinder { class Counts { public: - explicit Counts (clock_type& clock) - : m_clock (clock) - , m_attempts (0) + Counts () + : m_attempts (0) , m_active (0) , m_in_max (0) , m_in_active (0) @@ -299,8 +298,6 @@ private: } private: - clock_type& m_clock; - /** Outbound connection attempts. */ int m_attempts; diff --git a/src/ripple/peerfinder/impl/Logic.h b/src/ripple/peerfinder/impl/Logic.h index 942103b19..118041d25 100644 --- a/src/ripple/peerfinder/impl/Logic.h +++ b/src/ripple/peerfinder/impl/Logic.h @@ -65,7 +65,7 @@ public: clock_type& clock, Journal journal) : stopping (false) - , counts (clock) + , counts () , livecache (clock, Journal ( journal, Reporting::livecache)) , bootcache (*store, clock, Journal ( diff --git a/src/ripple/resource/impl/Logic.h b/src/ripple/resource/impl/Logic.h index 4a2b1e6c7..711f98998 100644 --- a/src/ripple/resource/impl/Logic.h +++ b/src/ripple/resource/impl/Logic.h @@ -201,8 +201,6 @@ public: { SharedState::Access state (m_state); - Table::iterator iter ( - state->table.find (*prior.key)); std::pair result ( state->table.emplace (key, 0)); entry = &result.first->second; diff --git a/src/ripple/resource/impl/Tests.cpp b/src/ripple/resource/impl/Tests.cpp index 845d0a0b9..7364866b2 100644 --- a/src/ripple/resource/impl/Tests.cpp +++ b/src/ripple/resource/impl/Tests.cpp @@ -87,7 +87,7 @@ public: Consumer c (logic.newInboundEndpoint (addr)); // Create load until we get a warning - for (std::size_t n (maxLoopCount); n>=0; --n) + for (std::size_t n (maxLoopCount); true; --n) { if (n == 0) { @@ -104,7 +104,7 @@ public: } // Create load until we get dropped - for (std::size_t n (maxLoopCount); n>=0; --n) + for (std::size_t n (maxLoopCount); true; --n) { if (n == 0) { @@ -127,7 +127,7 @@ public: expect (c.disconnect ()); } - for (std::size_t n (maxLoopCount); n>=0; --n) + for (std::size_t n (maxLoopCount); true; --n) { Consumer c (logic.newInboundEndpoint (addr)); if (n == 0) diff --git a/src/ripple/rocksdb/rocksdb/table/block_based_table_builder.cc b/src/ripple/rocksdb/rocksdb/table/block_based_table_builder.cc index 3131a1bc4..302da2fc1 100644 --- a/src/ripple/rocksdb/rocksdb/table/block_based_table_builder.cc +++ b/src/ripple/rocksdb/rocksdb/table/block_based_table_builder.cc @@ -296,6 +296,15 @@ Status BlockBasedTableBuilder::status() const { return rep_->status; } +// +// Warning: This function is also being used in the file +// block_based_table_reader.cc even though it is declared static, due +// to the source-file-concatenation build scheme. There is an idential +// file-local function in block_based_table_reader.cc too, but it was +// not being used. +// Do not change this function without reviewing its impact on the code +// in block_based_table_reader.cc. +// static void DeleteCachedBlock(const Slice& key, void* value) { Block* block = reinterpret_cast(value); delete block; diff --git a/src/ripple/rocksdb/rocksdb/table/block_based_table_reader.cc b/src/ripple/rocksdb/rocksdb/table/block_based_table_reader.cc index 67da647d8..3189ca729 100644 --- a/src/ripple/rocksdb/rocksdb/table/block_based_table_reader.cc +++ b/src/ripple/rocksdb/rocksdb/table/block_based_table_reader.cc @@ -166,10 +166,28 @@ void DeleteBlock(void* arg, void* ignored) { delete reinterpret_cast(arg); } -void DeleteCachedBlock(const Slice& key, void* value) { - Block* block = reinterpret_cast(value); - delete block; -} +// +// Commented out DeleteCachedBlock to silence the following warning: +// +// warning: unused function 'DeleteCachedBlock' +// +// Although it looks like this function is being used later in this file, +// it is not. Instead a file-static function of the same name is being +// used from block_based_table_builder.cc. That function is being found +// because this file and block_based_table_builder.cc are being +// concatenated in ripple_rocksdb.cpp. Fortunately the version of +// DeleteCachedBlock in block_based_table_builder.cc is identical to this +// one. So everything is working. +// +// This function has not been removed because it will need to be +// uncommented in the event we abandon the source file concatenation build +// model. In that event, failure to uncomment this function will lead to a +// compile-time error, not a run-time error (so this is safe). +// +// void DeleteCachedBlock(const Slice& key, void* value) { +// Block* block = reinterpret_cast(value); +// delete block; +// } void DeleteCachedFilter(const Slice& key, void* value) { auto filter = reinterpret_cast(value); diff --git a/src/ripple_app/contracts/Interpreter.cpp b/src/ripple_app/contracts/Interpreter.cpp index 2d979830b..26af22558 100644 --- a/src/ripple_app/contracts/Interpreter.cpp +++ b/src/ripple_app/contracts/Interpreter.cpp @@ -195,14 +195,19 @@ Data::pointer Interpreter::getUint160Data () bool Interpreter::jumpTo (int offset) { - mInstructionPointer += offset; - - if ( (mInstructionPointer < 0) || (mInstructionPointer > mCode->size ()) ) + if (offset < 0) { - mInstructionPointer -= offset; - return (false); + if (-offset > mInstructionPointer) + return false; + } + else + { + if (offset > mCode->size () || + mInstructionPointer > mCode->size () - offset) + return false; } + mInstructionPointer += offset; return (true); } diff --git a/src/ripple_app/main/Application.cpp b/src/ripple_app/main/Application.cpp index ff89603a0..915cf865d 100644 --- a/src/ripple_app/main/Application.cpp +++ b/src/ripple_app/main/Application.cpp @@ -891,7 +891,7 @@ public: // PropertyStream // - void onWrite (PropertyStream& stream) + void onWrite (PropertyStream::Map& stream) { } diff --git a/src/ripple_app/misc/SerializedTransaction.cpp b/src/ripple_app/misc/SerializedTransaction.cpp index de056793e..d94860152 100644 --- a/src/ripple_app/misc/SerializedTransaction.cpp +++ b/src/ripple_app/misc/SerializedTransaction.cpp @@ -235,6 +235,13 @@ void SerializedTransaction::setSourceAccount (const RippleAddress& naSource) setFieldAccount (sfAccount, naSource); } +Json::Value SerializedTransaction::getJson (int) const +{ + Json::Value ret = STObject::getJson (0); + ret["hash"] = getTransactionID ().GetHex (); + return ret; +} + Json::Value SerializedTransaction::getJson (int options, bool binary) const { if (binary) @@ -245,10 +252,7 @@ Json::Value SerializedTransaction::getJson (int options, bool binary) const ret["hash"] = getTransactionID ().GetHex (); return ret; } - - Json::Value ret = STObject::getJson (0); - ret["hash"] = getTransactionID ().GetHex (); - return ret; + return getJson(options); } std::string SerializedTransaction::getSQLValueHeader () diff --git a/src/ripple_app/misc/SerializedTransaction.h b/src/ripple_app/misc/SerializedTransaction.h index be5378a2d..bc1c4feb3 100644 --- a/src/ripple_app/misc/SerializedTransaction.h +++ b/src/ripple_app/misc/SerializedTransaction.h @@ -101,7 +101,8 @@ public: uint256 getTransactionID () const; - virtual Json::Value getJson (int options, bool binary = false) const; + virtual Json::Value getJson (int options) const; + virtual Json::Value getJson (int options, bool binary) const; void sign (const RippleAddress & naAccountPrivate); bool checkSign (const RippleAddress & naAccountPublic) const; diff --git a/src/ripple_app/node/SqliteFactory.cpp b/src/ripple_app/node/SqliteFactory.cpp index 5fedf2bea..23e453ebd 100644 --- a/src/ripple_app/node/SqliteFactory.cpp +++ b/src/ripple_app/node/SqliteFactory.cpp @@ -48,11 +48,9 @@ static int s_nodeStoreDBCount = NUMBER (s_nodeStoreDBInit); class SqliteBackend : public NodeStore::Backend { public: - SqliteBackend (size_t keyBytes, std::string const& path, NodeStore::Scheduler& scheduler) - : m_keyBytes (keyBytes) - , m_name (path) + explicit SqliteBackend (std::string const& path) + : m_name (path) , m_db (new DatabaseCon(path, s_nodeStoreDBInit, s_nodeStoreDBCount)) - , m_scheduler (scheduler) { String s; @@ -218,10 +216,8 @@ public: } private: - size_t const m_keyBytes; std::string const m_name; std::unique_ptr m_db; - NodeStore::Scheduler& m_scheduler; }; //------------------------------------------------------------------------------ @@ -235,11 +231,10 @@ public: } std::unique_ptr createInstance ( - size_t keyBytes, NodeStore::Parameters const& keyValues, - NodeStore::Scheduler& scheduler, Journal) + size_t, NodeStore::Parameters const& keyValues, + NodeStore::Scheduler&, Journal) { - return std::make_unique ( - keyBytes, keyValues ["path"].toStdString (), scheduler); + return std::make_unique (keyValues ["path"].toStdString ()); } }; diff --git a/src/ripple_app/peers/UniqueNodeList.cpp b/src/ripple_app/peers/UniqueNodeList.cpp index 6e188dc58..f7379f4f1 100644 --- a/src/ripple_app/peers/UniqueNodeList.cpp +++ b/src/ripple_app/peers/UniqueNodeList.cpp @@ -437,11 +437,11 @@ public: { int iDomains = 0; int iNodes = 0; - Database* db = getApp().getWalletDB ()->getDB (); #if 0 { DeprecatedScopedLock sl (getApp().getWalletDB ()->getDBLock ()); + Database* db = getApp().getWalletDB ()->getDB (); if (db->executeSQL (str (boost::format ("SELECT COUNT(*) AS Count FROM SeedDomains WHERE Source='%s' OR Source='%c';") % vsManual % vsValidator)) && db->startIterRows ()) iDomains = db->getInt ("Count"); diff --git a/src/ripple_basics/utility/UptimeTimer.h b/src/ripple_basics/utility/UptimeTimer.h index 7984b5015..3beaf7d75 100644 --- a/src/ripple_basics/utility/UptimeTimer.h +++ b/src/ripple_basics/utility/UptimeTimer.h @@ -44,9 +44,7 @@ public: private: // VFALCO DEPRECATED, Use a memory barrier instead of forcing a cache line - int m_pad1; // make sure m_elapsedTime fits in its own cache line int volatile m_elapsedTime; - int m_pad2; time_t m_startTime; diff --git a/src/ripple_core/nodestore/backend/NullFactory.cpp b/src/ripple_core/nodestore/backend/NullFactory.cpp index df194e3ed..a1107112e 100644 --- a/src/ripple_core/nodestore/backend/NullFactory.cpp +++ b/src/ripple_core/nodestore/backend/NullFactory.cpp @@ -23,8 +23,7 @@ namespace NodeStore { class NullBackend : public Backend { public: - explicit NullBackend (Scheduler& scheduler) - : m_scheduler (scheduler) + NullBackend () { } @@ -60,7 +59,6 @@ public: } private: - Scheduler& m_scheduler; }; //------------------------------------------------------------------------------ @@ -74,9 +72,9 @@ public: } std::unique_ptr createInstance ( - size_t, Parameters const&, Scheduler& scheduler, Journal journal) + size_t, Parameters const&, Scheduler&, Journal) { - return std::make_unique (scheduler); + return std::make_unique (); } }; diff --git a/src/ripple_net/basics/MultiSocket.cpp b/src/ripple_net/basics/MultiSocket.cpp index c9d8a5528..0dd299404 100644 --- a/src/ripple_net/basics/MultiSocket.cpp +++ b/src/ripple_net/basics/MultiSocket.cpp @@ -100,7 +100,7 @@ public: return holder.context->get (); } - String name () + String name () const { return getArgName (m_flags); } diff --git a/src/ripple_net/basics/impl/MultiSocketType.h b/src/ripple_net/basics/impl/MultiSocketType.h index fd46a6b88..603beb4df 100644 --- a/src/ripple_net/basics/impl/MultiSocketType.h +++ b/src/ripple_net/basics/impl/MultiSocketType.h @@ -161,7 +161,7 @@ protected: //-------------------------------------------------------------------------- // What would we return from here? - bool native_handle (char const*, void*) const + bool native_handle (char const*, void*) { pure_virtual_called (__FILE__, __LINE__); return false; @@ -832,7 +832,7 @@ protected: AsyncOp (MultiSocketType & owner, Stream& stream, handshake_type type, ConstBuffers const& buffers, SharedHandlerPtr const& handler) - : ComposedAsyncOperation (sizeof (*this), handler) + : ComposedAsyncOperation (handler) , m_handler (handler) , m_owner (owner) , m_stream (stream) diff --git a/src/ripple_overlay/impl/Peers.cpp b/src/ripple_overlay/impl/Peers.cpp index 35533990b..97a905dc6 100644 --- a/src/ripple_overlay/impl/Peers.cpp +++ b/src/ripple_overlay/impl/Peers.cpp @@ -497,7 +497,7 @@ public: // //-------------------------------------------------------------------------- - void onWrite (PropertyStream& stream) + void onWrite (PropertyStream::Map& stream) { } @@ -589,7 +589,7 @@ public: PeerByShortId::iterator const iter ( m_shortIdMap.find (id)); if (iter != m_shortIdMap.end ()) - iter->second; + return iter->second; return Peer::pointer(); } }; diff --git a/src/ripple_rpc/impl/Manager.cpp b/src/ripple_rpc/impl/Manager.cpp index 22a55dca7..5b60e4435 100644 --- a/src/ripple_rpc/impl/Manager.cpp +++ b/src/ripple_rpc/impl/Manager.cpp @@ -41,9 +41,8 @@ public: void add (std::string const& method, handler_type&& handler) { - std::pair result (m_map.emplace ( - std::piecewise_construct, std::forward_as_tuple (method), - std::forward_as_tuple (std::move (handler)))); + m_map.emplace (std::piecewise_construct, std::forward_as_tuple (method), + std::forward_as_tuple (std::move (handler))); } bool dispatch (Request& req)