From 9fc03ec85f85097f35efc41f00024dc5067f55d4 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Wed, 18 Jun 2014 21:13:20 +0200 Subject: [PATCH] cppcheck --- arangod/VocBase/voc-shaper.cpp | 9 ++++++++- arangod/Wal/Slots.cpp | 3 --- lib/Basics/StringUtils.cpp | 27 ++++++++++++++++++--------- lib/BasicsC/logging.c | 3 +-- lib/Rest/Version.cpp | 18 ------------------ lib/Rest/Version.h | 33 +++------------------------------ 6 files changed, 30 insertions(+), 63 deletions(-) diff --git a/arangod/VocBase/voc-shaper.cpp b/arangod/VocBase/voc-shaper.cpp index e1ab822ce4..7b56fd0731 100644 --- a/arangod/VocBase/voc-shaper.cpp +++ b/arangod/VocBase/voc-shaper.cpp @@ -646,15 +646,19 @@ int TRI_MoveMarkerVocShaper (TRI_shaper_t* s, if (marker->_type == TRI_DF_MARKER_SHAPE) { char* p = ((char*) marker) + sizeof(TRI_df_shape_marker_t); TRI_shape_t* l = (TRI_shape_t*) p; + void* f; MUTEX_LOCKER(shaper->_shapeLock); // remove the old marker // and re-insert the marker with the new pointer - void* f = TRI_InsertKeyAssociativeSynced(&shaper->_shapeIds, &l->_sid, l, true); + f = TRI_InsertKeyAssociativeSynced(&shaper->_shapeIds, &l->_sid, l, true); // note: this assertion is wrong if the recovery collects the shape in the WAL and it has not been transferred // into the collection datafile yet // TRI_ASSERT(f != nullptr); + if (f != nullptr) { + LOG_TRACE("shape already existed in shape ids array"); + } // same for the shape dictionary // delete and re-insert @@ -662,6 +666,9 @@ int TRI_MoveMarkerVocShaper (TRI_shaper_t* s, // note: this assertion is wrong if the recovery collects the shape in the WAL and it has not been transferred // into the collection datafile yet // TRI_ASSERT(f != nullptr); + if (f != nullptr) { + LOG_TRACE("shape already existed in shape dictionary"); + } } else if (marker->_type == TRI_DF_MARKER_ATTRIBUTE) { TRI_df_attribute_marker_t* m = (TRI_df_attribute_marker_t*) marker; diff --git a/arangod/Wal/Slots.cpp b/arangod/Wal/Slots.cpp index 4e6556d660..6972e01080 100644 --- a/arangod/Wal/Slots.cpp +++ b/arangod/Wal/Slots.cpp @@ -425,9 +425,6 @@ int Slots::closeLogfile (Slot::TickType& lastCommittedTick, return res; } - // advance to next slot - slot = &_slots[_handoutIndex]; - _logfileManager->setLogfileOpen(_logfile); worked = true; return TRI_ERROR_NO_ERROR; diff --git a/lib/Basics/StringUtils.cpp b/lib/Basics/StringUtils.cpp index cde47466ae..62956a3c34 100644 --- a/lib/Basics/StringUtils.cpp +++ b/lib/Basics/StringUtils.cpp @@ -606,6 +606,8 @@ namespace triagens { if (len >= (SIZE_MAX - 1) / 6) { THROW_OUT_OF_MEMORY_ERROR(); } + + bool corrupted = false; char * buffer = new char [6 * len + 1]; char * qtr = buffer; @@ -717,12 +719,14 @@ namespace triagens { // corrupted unicode else { *qtr = *ptr; + corrupted = true; } } // corrupted unicode else { *qtr = *ptr; + corrupted = true; } } @@ -744,21 +748,25 @@ namespace triagens { // corrupted unicode else { *qtr = *ptr; + corrupted = true; } } // corrupted unicode else { *qtr = *ptr; + corrupted = true; } } // corrupted unicode else { *qtr = *ptr; + corrupted = true; } } // corrupted unicode else { *qtr = *ptr; + corrupted = true; } } @@ -779,6 +787,10 @@ namespace triagens { delete[] buffer; + if (corrupted) { + LOG_WARNING("escaped corrupted unicode string"); + } + return result; } @@ -2984,7 +2996,6 @@ namespace triagens { string ret; int i = 0; - int j = 0; unsigned char const* bytesToEncode = reinterpret_cast(in.c_str()); size_t in_len = in.size(); @@ -3007,7 +3018,7 @@ namespace triagens { } if (i != 0) { - for(j = i; j < 3; j++) { + for(int j = i; j < 3; j++) { charArray3[j] = '\0'; } @@ -3016,7 +3027,7 @@ namespace triagens { charArray4[2] = ((charArray3[1] & 0x0f) << 2) + ((charArray3[2] & 0xc0) >> 6); charArray4[3] = charArray3[2] & 0x3f; - for (j = 0; (j < i + 1); j++) { + for (int j = 0; (j < i + 1); j++) { ret += BASE64_CHARS[charArray4[j]]; } @@ -3037,7 +3048,6 @@ namespace triagens { string ret; int i = 0; - int j = 0; int inp = 0; int in_len = (int) source.size(); @@ -3065,11 +3075,11 @@ namespace triagens { } if (i) { - for (j = i; j < 4; j++) { + for (int j = i; j < 4; j++) { charArray4[j] = 0; } - for (j = 0; j < 4; j++) { + for (int j = 0; j < 4; j++) { charArray4[j] = BASE64_REVS[charArray4[j]]; } @@ -3077,7 +3087,7 @@ namespace triagens { charArray3[1] = ((charArray4[1] & 0xf) << 4) + ((charArray4[2] & 0x3c) >> 2); charArray3[2] = ((charArray4[2] & 0x3) << 6) + charArray4[3]; - for (j = 0; j < i - 1; j++) { + for (int j = 0; j < i - 1; j++) { ret += charArray3[j]; } } @@ -3223,11 +3233,10 @@ namespace triagens { } size_t k = 0; - size_t delPos; size_t offSet = 0; while (true) { - delPos = sourceStr.find(delimiter, offSet); + size_t delPos = sourceStr.find(delimiter, offSet); if ((delPos == sourceStr.npos) || (delPos >= sourceLength) || (offSet >= sourceLength)) { return sourceStr.substr(offSet); diff --git a/lib/BasicsC/logging.c b/lib/BasicsC/logging.c index fcb9dd2a48..21a3fb63d6 100644 --- a/lib/BasicsC/logging.c +++ b/lib/BasicsC/logging.c @@ -1342,11 +1342,10 @@ TRI_vector_t* TRI_BufferLogging (TRI_log_level_e level, uint64_t start, bool use //////////////////////////////////////////////////////////////////////////////// void TRI_FreeBufferLogging (TRI_vector_t* buffer) { - TRI_log_buffer_t* buf; size_t i; for (i = 0; i < buffer->_length; ++i) { - buf = TRI_AtVector(buffer, i); + TRI_log_buffer_t* buf = TRI_AtVector(buffer, i); TRI_FreeString(TRI_UNKNOWN_MEM_ZONE, buf->_text); } diff --git a/lib/Rest/Version.cpp b/lib/Rest/Version.cpp index cbca1fcc82..d53caa2417 100644 --- a/lib/Rest/Version.cpp +++ b/lib/Rest/Version.cpp @@ -48,11 +48,6 @@ using namespace triagens::rest; // --SECTION-- public static functions // ----------------------------------------------------------------------------- -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup ArangoDB -/// @{ -//////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// /// @brief initialise //////////////////////////////////////////////////////////////////////////////// @@ -285,25 +280,12 @@ void Version::getJson (TRI_memory_zone_t* zone, TRI_json_t* dst) { } } -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - // ----------------------------------------------------------------------------- // --SECTION-- public static variables // ----------------------------------------------------------------------------- -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup ArangoDB -/// @{ -//////////////////////////////////////////////////////////////////////////////// - std::map Version::Values; -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - // Local Variables: // mode: outline-minor // outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" diff --git a/lib/Rest/Version.h b/lib/Rest/Version.h index 8f67588882..ff0edb2a16 100644 --- a/lib/Rest/Version.h +++ b/lib/Rest/Version.h @@ -51,34 +51,20 @@ namespace triagens { // --SECTION-- constructors and destructors // ----------------------------------------------------------------------------- -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup ArangoDB -/// @{ -//////////////////////////////////////////////////////////////////////////////// - private: //////////////////////////////////////////////////////////////////////////////// /// @brief create the version information //////////////////////////////////////////////////////////////////////////////// - Version (); - Version (const Version&); - Version& operator= (const Version&); - -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// + Version () = delete; + Version (Version const&) = delete; + Version& operator= (Version const&) = delete; // ----------------------------------------------------------------------------- // --SECTION-- public static functions // ----------------------------------------------------------------------------- -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup ArangoDB -/// @{ -//////////////////////////////////////////////////////////////////////////////// - public: //////////////////////////////////////////////////////////////////////////////// @@ -171,27 +157,14 @@ namespace triagens { static void getJson (struct TRI_memory_zone_s*, struct TRI_json_s*); -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - // ----------------------------------------------------------------------------- // --SECTION-- public static variables // ----------------------------------------------------------------------------- -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup ArangoDB -/// @{ -//////////////////////////////////////////////////////////////////////////////// - public: static std::map Values; -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - }; }