From ffdfb59564b703a7f03995b2b4318e7b814db16c Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 24 Jun 2013 18:26:24 -0700 Subject: [PATCH] Fix some warnings --- .../functional/ripple_LoadMonitor.cpp | 12 +++++++---- .../functional/ripple_LoadMonitor.h | 2 +- .../protocol/ripple_SerializedObject.cpp | 8 -------- .../protocol/ripple_SerializedObject.h | 20 +++++++++++++++++++ modules/ripple_sqlite/ripple_sqlite.c | 2 +- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/modules/ripple_core/functional/ripple_LoadMonitor.cpp b/modules/ripple_core/functional/ripple_LoadMonitor.cpp index 0544a8d662..061e7119ee 100644 --- a/modules/ripple_core/functional/ripple_LoadMonitor.cpp +++ b/modules/ripple_core/functional/ripple_LoadMonitor.cpp @@ -32,6 +32,7 @@ void LoadMonitor::update () if (now == mLastUpdate) // current return; + // VFALCO TODO Why 8? if ((now < mLastUpdate) || (now > (mLastUpdate + 8))) { // way out of date @@ -45,6 +46,13 @@ void LoadMonitor::update () } // do exponential decay + /* + David: + + "Imagine if you add 10 to something every second. And you + also reduce it by 1/4 every second. It will "idle" at 40, + correponding to 10 counts per second." + */ do { ++mLastUpdate; @@ -79,8 +87,6 @@ void LoadMonitor::addLatency (int latency) mLatencyMSPeak += latency; // VFALCO NOTE Why are we multiplying by 4? - // VFALCO NOTE conversion from 64 to 32 bit int loses data -#pragma message(BEAST_FILEANDLINE_ "Possible 32-bit overflow for long-running server instances.") int const latencyPeak = mLatencyEvents * latency * 4; if (mLatencyMSPeak < latencyPeak) @@ -108,8 +114,6 @@ void LoadMonitor::addCountAndLatency (const std::string& name, int latency) mLatencyMSPeak += latency; // VFALCO NOTE Why are we multiplying by 4? - // VFALCO NOTE conversion from 64 to 32 bit int loses data -#pragma message(BEAST_FILEANDLINE_ "Possible 32-bit overflow for long-running server instances.") int const latencyPeak = mLatencyEvents * latency * 4; if (mLatencyMSPeak < latencyPeak) diff --git a/modules/ripple_core/functional/ripple_LoadMonitor.h b/modules/ripple_core/functional/ripple_LoadMonitor.h index b8ac139f15..f66da5a6e5 100644 --- a/modules/ripple_core/functional/ripple_LoadMonitor.h +++ b/modules/ripple_core/functional/ripple_LoadMonitor.h @@ -36,7 +36,7 @@ private: boost::mutex mLock; uint64 mCounts; - uint64 mLatencyEvents; + int mLatencyEvents; uint64 mLatencyMSAvg; uint64 mLatencyMSPeak; uint64 mTargetLatencyAvg; diff --git a/modules/ripple_data/protocol/ripple_SerializedObject.cpp b/modules/ripple_data/protocol/ripple_SerializedObject.cpp index 2ab64c0232..82ce1284a0 100644 --- a/modules/ripple_data/protocol/ripple_SerializedObject.cpp +++ b/modules/ripple_data/protocol/ripple_SerializedObject.cpp @@ -1313,14 +1313,6 @@ UPTR_T STObject::parseJson (const Json::Value& object, SField::ref inN } else if (value.isInt ()) { - // VFALCO NOTE value.asInt() returns an int, which can never be greater than 7fffffff, but we - // are checking to make sure it is not greater than ffffffff, which can never be - // less than any 32 bit value (signed or unsigned). - // - // It seems this line only cares that value.asInt () is not negative, can someone - // confirm this? - // -#pragma message(BEAST_FILEANDLINE_ "Invalid signed/unsigned comparison") data.push_back (new STUInt32 (field, range_check_cast (value.asInt (), 0u, 4294967295u))); } else if (value.isUInt ()) diff --git a/modules/ripple_data/protocol/ripple_SerializedObject.h b/modules/ripple_data/protocol/ripple_SerializedObject.h index 9cfa818f96..bcc4fd426a 100644 --- a/modules/ripple_data/protocol/ripple_SerializedObject.h +++ b/modules/ripple_data/protocol/ripple_SerializedObject.h @@ -260,6 +260,26 @@ public: } private: + /** Returns a value or throws if out of range. + + This will throw if the source value cannot be represented + within the destination type. + */ + // VFALCO NOTE This won't work right + /* + template + static T getWithRangeCheck (U v) + { + if (v < std::numeric_limits ::min ()) || + v > std::numeric_limits ::max ()) + { + throw std::runtime_error ("Value out of range"); + } + + return static_cast (v); + } + */ + // VFALCO TODO these parameters should not be const references. template static T range_check_cast (const U& value, const T& minimum, const T& maximum) diff --git a/modules/ripple_sqlite/ripple_sqlite.c b/modules/ripple_sqlite/ripple_sqlite.c index d04723a607..6da2c4012c 100644 --- a/modules/ripple_sqlite/ripple_sqlite.c +++ b/modules/ripple_sqlite/ripple_sqlite.c @@ -50,7 +50,7 @@ // VFALCO TODO We should try running with SQLITE_THREADSAFE==2 and see what happens. #if SQLITE_THREADSAFE != 2 -#pragma message(BEAST_FILEANDLINE_ "Possible performance issue, SQLITE_THREADSAFE != 2") +//#pragma message(BEAST_FILEANDLINE_ "Possible performance issue, SQLITE_THREADSAFE != 2") #endif #include "sqlite/sqlite3.c"