changeset 656:08eca5d86aad

fixes to cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Nov 2013 11:19:31 +0100
parents 93adc693cc60
children 5425bb6f1ea5
files Core/ChunkedBuffer.cpp Core/Compression/HierarchicalZipWriter.cpp Core/DicomFormat/DicomArray.cpp Core/DicomFormat/DicomMap.cpp Core/FileFormats/PngReader.cpp Core/FileFormats/PngWriter.cpp Core/FileStorage/FileStorage.cpp Core/HttpServer/HttpOutput.cpp Core/HttpServer/MongooseServer.cpp Core/Lua/LuaFunctionCall.cpp Core/MultiThreading/SharedMessageQueue.cpp Core/OrthancException.h Core/RestApi/RestApi.cpp Core/SQLite/Connection.cpp Core/SQLite/StatementReference.cpp Core/Uuid.cpp OrthancCppClient/Series.cpp OrthancServer/DicomProtocol/DicomServer.cpp OrthancServer/DicomProtocol/DicomUserConnection.cpp OrthancServer/FromDcmtkBridge.cpp OrthancServer/Internals/FindScp.cpp OrthancServer/Internals/MoveScp.cpp OrthancServer/OrthancFindRequestHandler.cpp OrthancServer/OrthancInitialization.cpp OrthancServer/OrthancMoveRequestHandler.cpp OrthancServer/OrthancRestApi.cpp OrthancServer/ServerContext.cpp OrthancServer/ServerEnumerations.cpp OrthancServer/ServerEnumerations.h OrthancServer/ServerIndex.cpp OrthancServer/ToDcmtkBridge.cpp Resources/Samples/OrthancClient/Basic/main.cpp Resources/Samples/OrthancClient/Vtk/main.cpp
diffstat 33 files changed, 113 insertions(+), 106 deletions(-) [+]
line wrap: on
line diff
--- a/Core/ChunkedBuffer.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/ChunkedBuffer.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -43,7 +43,7 @@
     numBytes_ = 0;
 
     for (Chunks::iterator it = chunks_.begin(); 
-         it != chunks_.end(); it++)
+         it != chunks_.end(); ++it)
     {
       delete *it;
     }
@@ -70,7 +70,7 @@
 
     size_t pos = 0;
     for (Chunks::iterator it = chunks_.begin(); 
-         it != chunks_.end(); it++)
+         it != chunks_.end(); ++it)
     {
       assert(*it != NULL);
 
--- a/Core/Compression/HierarchicalZipWriter.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/Compression/HierarchicalZipWriter.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -81,12 +81,12 @@
     std::string result;
 
     Stack::const_iterator it = stack_.begin();
-    it++;  // Skip the root node (to avoid absolute paths)
+    ++it;  // Skip the root node (to avoid absolute paths)
 
     while (it != stack_.end())
     {
       result += (*it)->name_ + "/";
-      it++;
+      ++it;
     }
 
     return result;
@@ -118,7 +118,7 @@
 
   HierarchicalZipWriter::Index::~Index()
   {
-    for (Stack::iterator it = stack_.begin(); it != stack_.end(); it++)
+    for (Stack::iterator it = stack_.begin(); it != stack_.end(); ++it)
     {
       delete *it;
     }
--- a/Core/DicomFormat/DicomArray.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/DicomFormat/DicomArray.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -41,7 +41,7 @@
     elements_.reserve(map.map_.size());
     
     for (DicomMap::Map::const_iterator it = 
-           map.map_.begin(); it != map.map_.end(); it++)
+           map.map_.begin(); it != map.map_.end(); ++it)
     {
       elements_.push_back(new DicomElement(it->first, *it->second));
     }
--- a/Core/DicomFormat/DicomMap.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/DicomFormat/DicomMap.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -128,7 +128,7 @@
 
   void DicomMap::Clear()
   {
-    for (Map::iterator it = map_.begin(); it != map_.end(); it++)
+    for (Map::iterator it = map_.begin(); it != map_.end(); ++it)
     {
       delete it->second;
     }
@@ -180,7 +180,7 @@
   {
     std::auto_ptr<DicomMap> result(new DicomMap);
 
-    for (Map::const_iterator it = map_.begin(); it != map_.end(); it++)
+    for (Map::const_iterator it = map_.begin(); it != map_.end(); ++it)
     {
       result->map_.insert(std::make_pair(it->first, it->second->Clone()));
     }
--- a/Core/FileFormats/PngReader.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/FileFormats/PngReader.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -242,7 +242,7 @@
                                           png_bytep outBytes, 
                                           png_size_t byteCountToRead)
   {
-    MemoryBuffer* from = (MemoryBuffer*) png_get_io_ptr(png_ptr);
+    MemoryBuffer* from = reinterpret_cast<MemoryBuffer*>(png_get_io_ptr(png_ptr));
 
     if (!from->ok_)
     {
--- a/Core/FileFormats/PngWriter.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/FileFormats/PngWriter.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -231,7 +231,7 @@
                              png_bytep data, 
                              png_size_t size)
   {
-    ChunkedBuffer* buffer = (ChunkedBuffer*) png_get_io_ptr(png_ptr);
+    ChunkedBuffer* buffer = reinterpret_cast<ChunkedBuffer*>(png_get_io_ptr(png_ptr));
     buffer->AddChunk(reinterpret_cast<const char*>(data), size);
   }
 
--- a/Core/FileStorage/FileStorage.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/FileStorage/FileStorage.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -267,7 +267,7 @@
     List result;
     ListAllFiles(result);
 
-    for (List::const_iterator it = result.begin(); it != result.end(); it++)
+    for (List::const_iterator it = result.begin(); it != result.end(); ++it)
     {
       Remove(*it);
     }
--- a/Core/HttpServer/HttpOutput.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/HttpServer/HttpOutput.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -89,7 +89,7 @@
     std::string s = "HTTP/1.1 200 OK\r\n";
 
     for (Header::const_iterator 
-           it = header.begin(); it != header.end(); it++)
+           it = header.begin(); it != header.end(); ++it)
     {
       s += it->first + ": " + it->second + "\r\n";
     }
@@ -144,7 +144,7 @@
                                   const HttpHandler::Arguments& cookies)
   {
     for (HttpHandler::Arguments::const_iterator it = cookies.begin();
-         it != cookies.end(); it++)
+         it != cookies.end(); ++it)
     {
       header.push_back(std::make_pair("Set-Cookie", it->first + "=" + it->second));
     }
--- a/Core/HttpServer/MongooseServer.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/HttpServer/MongooseServer.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -129,7 +129,7 @@
     void Clear()
     {
       for (Content::iterator it = content_.begin();
-           it != content_.end(); it++)
+           it != content_.end(); ++it)
       {
         delete *it;
       }
@@ -138,7 +138,7 @@
     Content::iterator Find(const std::string& filename)
     {
       for (Content::iterator it = content_.begin();
-           it != content_.end(); it++)
+           it != content_.end(); ++it)
       {
         if ((*it)->GetFilename() == filename)
         {
@@ -254,7 +254,7 @@
   HttpHandler* MongooseServer::FindHandler(const UriComponents& forUri) const
   {
     for (Handlers::const_iterator it = 
-           handlers_.begin(); it != handlers_.end(); it++) 
+           handlers_.begin(); it != handlers_.end(); ++it) 
     {
       if ((*it)->IsServedUri(forUri))
       {
@@ -570,7 +570,7 @@
   {
     if (event == MG_NEW_REQUEST) 
     {
-      MongooseServer* that = (MongooseServer*) (request->user_data);
+      MongooseServer* that = reinterpret_cast<MongooseServer*>(request->user_data);
       MongooseOutput output(connection);
 
       // Check remote calls
@@ -816,7 +816,7 @@
     Stop();
 
     for (Handlers::iterator it = 
-           handlers_.begin(); it != handlers_.end(); it++)
+           handlers_.begin(); it != handlers_.end(); ++it)
     {
       delete *it;
     }
--- a/Core/Lua/LuaFunctionCall.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/Lua/LuaFunctionCall.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -130,7 +130,7 @@
       Json::Value::Members members = value.getMemberNames();
 
       for (Json::Value::Members::const_iterator 
-             it = members.begin(); it != members.end(); it++)
+             it = members.begin(); it != members.end(); ++it)
       {
         // Push the index of the cell
         lua_pushstring(context_.lua_, it->c_str());
--- a/Core/MultiThreading/SharedMessageQueue.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/MultiThreading/SharedMessageQueue.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -42,7 +42,7 @@
 
   SharedMessageQueue::~SharedMessageQueue()
   {
-    for (Queue::iterator it = queue_.begin(); it != queue_.end(); it++)
+    for (Queue::iterator it = queue_.begin(); it != queue_.end(); ++it)
     {
       delete *it;
     }
--- a/Core/OrthancException.h	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/OrthancException.h	Mon Nov 04 11:19:31 2013 +0100
@@ -46,21 +46,20 @@
   public:
     static const char* GetDescription(ErrorCode error);
 
-    OrthancException(const char* custom)
+    OrthancException(const char* custom) : 
+      error_(ErrorCode_Custom),
+      custom_(custom)
     {
-      error_ = ErrorCode_Custom;
-      custom_ = custom;
     }
 
-    OrthancException(const std::string& custom)
+    OrthancException(const std::string& custom) : 
+      error_(ErrorCode_Custom),
+      custom_(custom)
     {
-      error_ = ErrorCode_Custom;
-      custom_ = custom;
     }
 
-    OrthancException(ErrorCode error)
+    OrthancException(ErrorCode error) : error_(error)
     {
-      error_ = error;
     }
 
     ErrorCode GetErrorCode() const
--- a/Core/RestApi/RestApi.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/RestApi/RestApi.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -51,7 +51,7 @@
     result.clear();
 
     for (HttpHandler::Arguments::const_iterator 
-           it = getArguments_->begin(); it != getArguments_->end(); it++)
+           it = getArguments_->begin(); it != getArguments_->end(); ++it)
     {
       result[it->first] = it->second;
     }
@@ -63,7 +63,7 @@
   bool RestApi::IsGetAccepted(const UriComponents& uri)
   {
     for (GetHandlers::const_iterator it = getHandlers_.begin();
-         it != getHandlers_.end(); it++)
+         it != getHandlers_.end(); ++it)
     {
       if (it->first->Match(uri))
       {
@@ -77,7 +77,7 @@
   bool RestApi::IsPutAccepted(const UriComponents& uri)
   {
     for (PutHandlers::const_iterator it = putHandlers_.begin();
-         it != putHandlers_.end(); it++)
+         it != putHandlers_.end(); ++it)
     {
       if (it->first->Match(uri))
       {
@@ -91,7 +91,7 @@
   bool RestApi::IsPostAccepted(const UriComponents& uri)
   {
     for (PostHandlers::const_iterator it = postHandlers_.begin();
-         it != postHandlers_.end(); it++)
+         it != postHandlers_.end(); ++it)
     {
       if (it->first->Match(uri))
       {
@@ -105,7 +105,7 @@
   bool RestApi::IsDeleteAccepted(const UriComponents& uri)
   {
     for (DeleteHandlers::const_iterator it = deleteHandlers_.begin();
-         it != deleteHandlers_.end(); it++)
+         it != deleteHandlers_.end(); ++it)
     {
       if (it->first->Match(uri))
       {
@@ -147,25 +147,25 @@
   RestApi::~RestApi()
   {
     for (GetHandlers::iterator it = getHandlers_.begin(); 
-         it != getHandlers_.end(); it++)
+         it != getHandlers_.end(); ++it)
     {
       delete it->first;
     } 
 
     for (PutHandlers::iterator it = putHandlers_.begin(); 
-         it != putHandlers_.end(); it++)
+         it != putHandlers_.end(); ++it)
     {
       delete it->first;
     } 
 
     for (PostHandlers::iterator it = postHandlers_.begin(); 
-         it != postHandlers_.end(); it++)
+         it != postHandlers_.end(); ++it)
     {
       delete it->first;
     } 
 
     for (DeleteHandlers::iterator it = deleteHandlers_.begin(); 
-         it != deleteHandlers_.end(); it++)
+         it != deleteHandlers_.end(); ++it)
     {
       delete it->first;
     } 
@@ -194,7 +194,7 @@
     if (method == HttpMethod_Get)
     {
       for (GetHandlers::const_iterator it = getHandlers_.begin();
-           it != getHandlers_.end(); it++)
+           it != getHandlers_.end(); ++it)
       {
         if (it->first->Match(components, trailing, uri))
         {
@@ -216,7 +216,7 @@
     else if (method == HttpMethod_Put)
     {
       for (PutHandlers::const_iterator it = putHandlers_.begin();
-           it != putHandlers_.end(); it++)
+           it != putHandlers_.end(); ++it)
       {
         if (it->first->Match(components, trailing, uri))
         {
@@ -238,7 +238,7 @@
     else if (method == HttpMethod_Post)
     {
       for (PostHandlers::const_iterator it = postHandlers_.begin();
-           it != postHandlers_.end(); it++)
+           it != postHandlers_.end(); ++it)
       {
         if (it->first->Match(components, trailing, uri))
         {
@@ -260,7 +260,7 @@
     else if (method == HttpMethod_Delete)
     {
       for (DeleteHandlers::const_iterator it = deleteHandlers_.begin();
-           it != deleteHandlers_.end(); it++)
+           it != deleteHandlers_.end(); ++it)
       {
         if (it->first->Match(components, trailing, uri))
         {
--- a/Core/SQLite/Connection.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/SQLite/Connection.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -111,7 +111,7 @@
     {
       for (CachedStatements::iterator 
              it = cachedStatements_.begin(); 
-           it != cachedStatements_.end(); it++)
+           it != cachedStatements_.end(); ++it)
       {
         delete it->second;
       }
@@ -331,7 +331,7 @@
       void* payload = sqlite3_user_data(rawContext);
       assert(payload != NULL);
 
-      IScalarFunction& func = *(IScalarFunction*) payload;
+      IScalarFunction& func = *reinterpret_cast<IScalarFunction*>(payload);
       func.Compute(context);
     }
 
@@ -339,7 +339,7 @@
     static void ScalarFunctionDestroyer(void* payload)
     {
       assert(payload != NULL);
-      delete (IScalarFunction*) payload;
+      delete reinterpret_cast<IScalarFunction*>(payload);
     }
 
 
--- a/Core/SQLite/StatementReference.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/SQLite/StatementReference.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -39,6 +39,7 @@
 #include "../OrthancException.h"
 
 #include <cassert>
+#include <glog/logging.h>
 #include "sqlite3.h"
 
 namespace Orthanc
@@ -103,8 +104,11 @@
       {
         if (refCount_ != 0)
         {
-          // There remain references to this object
-          throw OrthancException(ErrorCode_InternalError);
+          // There remain references to this object. We cannot throw
+          // an exception because:
+          // http://www.parashift.com/c++-faq/dtors-shouldnt-throw.html
+
+          LOG(ERROR) << "Bad value of the reference counter";
         }
         else if (statement_ != NULL)
         {
--- a/Core/Uuid.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Core/Uuid.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -141,15 +141,15 @@
     }
 
 
-    TemporaryFile::TemporaryFile()
+    TemporaryFile::TemporaryFile() : 
+      path_(CreateTemporaryPath(NULL))
     {
-      path_ = CreateTemporaryPath(NULL);
     }
 
 
-    TemporaryFile::TemporaryFile(const char* extension)
+    TemporaryFile::TemporaryFile(const char* extension) :
+      path_(CreateTemporaryPath(extension))
     {
-      path_ = CreateTemporaryPath(extension);
     }
 
 
--- a/OrthancCppClient/Series.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancCppClient/Series.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -273,7 +273,11 @@
     ReadSeries();
     status_ = Status3DImage_NotTested;
     url_ = std::string(connection_.GetOrthancUrl()) + "/series/" + id_;
+
     isVoxelSizeRead_ = false;
+    voxelSizeX_ = 0;
+    voxelSizeY_ = 0;
+    voxelSizeZ_ = 0;
 
     instances_.SetThreadCount(connection.GetThreadCount());
   }
@@ -465,7 +469,7 @@
     }
 
     uint8_t* stackTarget = reinterpret_cast<uint8_t*>(target);
-    for (Instances::iterator it = instances.begin(); it != instances.end(); it++)
+    for (Instances::iterator it = instances.begin(); it != instances.end(); ++it)
     {
       processor.Post(new ImageDownloadCommand(*it->second, format, mode, stackTarget, lineStride));
       stackTarget += stackStride;
--- a/OrthancServer/DicomProtocol/DicomServer.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/DicomProtocol/DicomServer.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -192,9 +192,10 @@
   }                           
 
 
-  DicomServer::DicomServer() : pimpl_(new PImpl)
+  DicomServer::DicomServer() : 
+    pimpl_(new PImpl),
+    aet_("ANY-SCP")
   {
-    aet_ = "ANY-SCP";
     port_ = 104;
     findRequestHandlerFactory_ = NULL;
     moveRequestHandlerFactory_ = NULL;
@@ -203,6 +204,8 @@
     checkCalledAet_ = true;
     clientTimeout_ = 30;
     isThreaded_ = true;
+    continue_ = false;
+    started_ = false;
   }
 
   DicomServer::~DicomServer()
--- a/OrthancServer/DicomProtocol/DicomUserConnection.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/DicomProtocol/DicomUserConnection.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -151,7 +151,7 @@
     const char* asFallback[2];
     std::set<std::string>::const_iterator it = abstractSyntaxes.begin();
     asFallback[0] = it->c_str();
-    it++;
+    ++it;
     asFallback[1] = it->c_str();
 
     unsigned int presentationContextId = 1;
@@ -460,12 +460,13 @@
   }
 
 
-  DicomUserConnection::DicomUserConnection() : pimpl_(new PImpl)
+  DicomUserConnection::DicomUserConnection() : 
+    pimpl_(new PImpl),
+    localAet_("STORESCU"),
+    distantAet_("ANY-SCP"),
+    distantHost_("127.0.0.1")
   {
-    localAet_ = "STORESCU";
-    distantAet_ = "ANY-SCP";
     distantPort_ = 104;
-    distantHost_ = "127.0.0.1";
     manufacturer_ = ModalityManufacturer_Generic;
 
     pimpl_->net_ = NULL;
--- a/OrthancServer/FromDcmtkBridge.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/FromDcmtkBridge.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -623,7 +623,7 @@
     }
 
     for (Tags::iterator it = privateTags.begin(); 
-         it != privateTags.end(); it++)
+         it != privateTags.end(); ++it)
     {
       DcmElement* tmp = dataset.remove(*it);
       if (tmp != NULL)
@@ -1493,7 +1493,7 @@
   void FromDcmtkBridge::Print(FILE* fp, const DicomMap& m)
   {
     for (DicomMap::Map::const_iterator 
-           it = m.map_.begin(); it != m.map_.end(); it++)
+           it = m.map_.begin(); it != m.map_.end(); ++it)
     {
       DicomTag t = it->first;
       std::string s = it->second->AsString();
@@ -1513,7 +1513,7 @@
     result.clear();
 
     for (DicomMap::Map::const_iterator 
-           it = values.map_.begin(); it != values.map_.end(); it++)
+           it = values.map_.begin(); it != values.map_.end(); ++it)
     {
       result[GetName(it->first)] = it->second->AsString();
     }
--- a/OrthancServer/Internals/FindScp.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/Internals/FindScp.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -67,7 +67,7 @@
       bzero(response, sizeof(T_DIMSE_C_FindRSP));
       *statusDetail = NULL;
 
-      FindScpData& data = *(FindScpData*) callbackData;
+      FindScpData& data = *reinterpret_cast<FindScpData*>(callbackData);
       if (data.lastRequest_ == NULL)
       {
         FromDcmtkBridge::Convert(data.input_, *requestIdentifiers);
--- a/OrthancServer/Internals/MoveScp.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/Internals/MoveScp.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -74,7 +74,7 @@
       *statusDetail = NULL;
       *responseIdentifiers = NULL;   
 
-      MoveScpData& data = *(MoveScpData*) callbackData;
+      MoveScpData& data = *reinterpret_cast<MoveScpData*>(callbackData);
       if (data.lastRequest_ == NULL)
       {
         FromDcmtkBridge::Convert(data.input_, *requestIdentifiers);
--- a/OrthancServer/OrthancFindRequestHandler.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/OrthancFindRequestHandler.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -151,7 +151,7 @@
       std::list<std::string> children;
       index.GetChildInstances(children, id);
 
-      if (children.size() == 0)
+      if (children.empty())
       {
         return false;
       }
@@ -243,7 +243,7 @@
 
     // Loop over the studies
     for (std::list<std::string>::const_iterator 
-           it = studies.begin(); it != studies.end(); it++)
+           it = studies.begin(); it != studies.end(); ++it)
     {
       try
       {
@@ -415,7 +415,7 @@
 
     DicomArray query(input);
     for (std::list<std::string>::const_iterator 
-           resource = resources.begin(); resource != resources.end(); resource++)
+           resource = resources.begin(); resource != resources.end(); ++resource)
     {
       try
       {
--- a/OrthancServer/OrthancInitialization.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/OrthancInitialization.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -144,7 +144,7 @@
         {
           RegisterUserMetadata(metadata, members[i]);
         }
-        catch (OrthancException e)
+        catch (OrthancException& e)
         {
           LOG(ERROR) << "Cannot register this user-defined metadata: " << info;
           throw e;
@@ -495,7 +495,7 @@
     GetListOfDicomModalities(modalities);
 
     for (std::set<std::string>::const_iterator 
-           it = modalities.begin(); it != modalities.end(); it++)
+           it = modalities.begin(); it != modalities.end(); ++it)
     {
       try
       {
--- a/OrthancServer/OrthancMoveRequestHandler.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/OrthancMoveRequestHandler.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -63,7 +63,7 @@
         context_.GetIndex().GetChildInstances(tmp, publicId);
 
         instances_.reserve(tmp.size());
-        for (std::list<std::string>::iterator it = tmp.begin(); it != tmp.end(); it++)
+        for (std::list<std::string>::iterator it = tmp.begin(); it != tmp.end(); ++it)
         {
           instances_.push_back(*it);
         }
--- a/OrthancServer/OrthancRestApi.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/OrthancRestApi.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -316,7 +316,7 @@
         std::list<std::string> tmp;
         context.GetIndex().GetChildInstances(tmp, stripped);
         instances.merge(tmp);
-        assert(tmp.size() == 0);
+        assert(tmp.empty());
       }
     }
     else
@@ -345,7 +345,7 @@
     ConnectToModalityUsingSymbolicName(connection, remote);
 
     for (std::list<std::string>::const_iterator 
-           it = instances.begin(); it != instances.end(); it++)
+           it = instances.begin(); it != instances.end(); ++it)
     {
       LOG(INFO) << "Sending resource " << *it << " to modality \"" << remote << "\"";
 
@@ -987,7 +987,7 @@
 
     Json::Value result = Json::arrayValue;
     for (OrthancRestApi::SetOfStrings::const_iterator 
-           it = modalities.begin(); it != modalities.end(); it++)
+           it = modalities.begin(); it != modalities.end(); ++it)
     {
       result.append(*it);
     }
@@ -1051,13 +1051,13 @@
     }
 
     for (Removals::const_iterator it = removals.begin(); 
-         it != removals.end(); it++)
+         it != removals.end(); ++it)
     {
       toModify.Remove(*it);
     }
 
     for (Replacements::const_iterator it = replacements.begin(); 
-         it != replacements.end(); it++)
+         it != replacements.end(); ++it)
     {
       toModify.Replace(it->first, it->second, mode);
     }
@@ -1270,7 +1270,7 @@
 
       SetupAnonymization(removals, replacements);
 
-      for (Removals::iterator it = toKeep.begin(); it != toKeep.end(); it++)
+      for (Removals::iterator it = toKeep.begin(); it != toKeep.end(); ++it)
       {
         if (*it == DICOM_TAG_PATIENT_ID)
         {
@@ -1284,7 +1284,7 @@
       ParseRemovals(additionalRemovals, removalsPart);
 
       for (Removals::iterator it = additionalRemovals.begin(); 
-           it != additionalRemovals.end(); it++)
+           it != additionalRemovals.end(); ++it)
       {
         removals.insert(*it);
       }     
@@ -1397,19 +1397,18 @@
     std::string id = call.GetUriComponent("id", "");
     context.GetIndex().GetChildInstances(instances, id);
 
-    if (instances.size() == 0)
+    if (instances.empty())
     {
       return;
     }
 
-
     /**
      * Loop over all the instances of the resource.
      **/
 
     UidMap uidMap;
     for (Instances::const_iterator it = instances.begin(); 
-         it != instances.end(); it++)
+         it != instances.end(); ++it)
     {
       LOG(INFO) << "Modifying instance " << *it;
       ParsedDicomFile& original = context.GetDicomFile(*it);
@@ -1662,7 +1661,7 @@
       Json::Value result = Json::arrayValue;
 
       for (std::list<MetadataType>::const_iterator 
-             it = metadata.begin(); it != metadata.end(); it++)
+             it = metadata.begin(); it != metadata.end(); ++it)
       {
         result.append(EnumerationToString(*it));
       }
@@ -1750,7 +1749,7 @@
 
     Json::Value result = Json::arrayValue;
     for (OrthancRestApi::SetOfStrings::const_iterator 
-           it = peers.begin(); it != peers.end(); it++)
+           it = peers.begin(); it != peers.end(); ++it)
     {
       result.append(*it);
     }
@@ -1798,7 +1797,7 @@
 
     // Loop over the instances that are to be sent
     for (std::list<std::string>::const_iterator 
-           it = instances.begin(); it != instances.end(); it++)
+           it = instances.begin(); it != instances.end(); ++it)
     {
       LOG(INFO) << "Sending resource " << *it << " to peer \"" << remote << "\"";
 
--- a/OrthancServer/ServerContext.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/ServerContext.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -61,6 +61,7 @@
     storage_(storagePath.string()),
     index_(*this, indexPath.string()),
     accessor_(storage_),
+    compressionEnabled_(false),
     provider_(*this),
     dicomCache_(provider_, DICOM_CACHE_SIZE)
   {
--- a/OrthancServer/ServerEnumerations.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/ServerEnumerations.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -56,7 +56,7 @@
   }
 
   void RegisterUserMetadata(int metadata,
-                            const std::string name)
+                            const std::string& name)
   {
     boost::mutex::scoped_lock lock(enumerationsMutex_);
 
--- a/OrthancServer/ServerEnumerations.h	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/ServerEnumerations.h	Mon Nov 04 11:19:31 2013 +0100
@@ -118,7 +118,7 @@
   void InitializeServerEnumerations();
 
   void RegisterUserMetadata(int metadata,
-                            const std::string name);
+                            const std::string& name);
 
   std::string GetBasePath(ResourceType type,
                           const std::string& publicId);
--- a/OrthancServer/ServerIndex.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/ServerIndex.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -91,7 +91,7 @@
       {
         for (std::list<std::string>::iterator 
                it = pendingFilesToRemove_.begin();
-             it != pendingFilesToRemove_.end(); it++)
+             it != pendingFilesToRemove_.end(); ++it)
         {
           context_.RemoveFile(*it);
         }
@@ -290,11 +290,11 @@
                                                int64_t series,
                                                const DicomMap& dicomSummary)
   {
-    const DicomValue* value;
-    const DicomValue* value2;
-          
     try
     {
+      const DicomValue* value;
+      const DicomValue* value2;
+          
       if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGES_IN_ACQUISITION)) != NULL &&
           (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS)) != NULL)
       {
@@ -407,7 +407,7 @@
       // Ensure there is enough room in the storage for the new instance
       uint64_t instanceSize = 0;
       for (Attachments::const_iterator it = attachments.begin();
-           it != attachments.end(); it++)
+           it != attachments.end(); ++it)
       {
         instanceSize += it->GetCompressedSize();
       }
@@ -512,7 +512,7 @@
 
       // Attach the files to the newly created instance
       for (Attachments::const_iterator it = attachments.begin();
-           it != attachments.end(); it++)
+           it != attachments.end(); ++it)
       {
         db_->AddAttachment(instance, *it);
       }
@@ -593,10 +593,6 @@
     try
     {
       expected = boost::lexical_cast<size_t>(s);
-      if (expected < 0)
-      {
-        return SeriesStatus_Unknown;
-      }
     }
     catch (boost::bad_lexical_cast&)
     {
@@ -609,7 +605,7 @@
 
     std::set<size_t> instances;
     for (std::list<int64_t>::const_iterator 
-           it = children.begin(); it != children.end(); it++)
+           it = children.begin(); it != children.end(); ++it)
     {
       // Get the index of this instance in the series
       s = db_->GetMetadata(*it, MetadataType_Instance_IndexInSeries);
@@ -623,7 +619,7 @@
         return SeriesStatus_Unknown;
       }
 
-      if (index <= 0 || index > expected)
+      if (!(index > 0 && index <= expected))
       {
         // Out-of-range instance index
         return SeriesStatus_Inconsistent;
@@ -715,7 +711,7 @@
       Json::Value c = Json::arrayValue;
 
       for (std::list<std::string>::const_iterator
-             it = children.begin(); it != children.end(); it++)
+             it = children.begin(); it != children.end(); ++it)
       {
         c.append(*it);
       }
@@ -1153,7 +1149,7 @@
         // Tag all the children of this resource as to be explored
         db_->GetChildrenInternalId(tmp, resource);
         for (std::list<int64_t>::const_iterator 
-               it = tmp.begin(); it != tmp.end(); it++)
+               it = tmp.begin(); it != tmp.end(); ++it)
         {
           toExplore.push(*it);
         }
@@ -1332,7 +1328,7 @@
         db_->ListAvailableAttachments(f, resource);
 
         for (std::list<FileContentType>::const_iterator
-               it = f.begin(); it != f.end(); it++)
+               it = f.begin(); it != f.end(); ++it)
         {
           FileInfo attachment;
           if (db_->LookupAttachment(attachment, resource, *it))
@@ -1364,7 +1360,7 @@
         std::list<int64_t> tmp;
         db_->GetChildrenInternalId(tmp, resource);
         for (std::list<int64_t>::const_iterator 
-               it = tmp.begin(); it != tmp.end(); it++)
+               it = tmp.begin(); it != tmp.end(); ++it)
         {
           toExplore.push(*it);
         }
@@ -1534,7 +1530,7 @@
     db_->LookupTagValue(id, tag, value);
 
     for (std::list<int64_t>::const_iterator 
-           it = id.begin(); it != id.end(); it++)
+           it = id.begin(); it != id.end(); ++it)
     {
       if (db_->GetResourceType(*it) == type)
       {
@@ -1556,7 +1552,7 @@
     db_->LookupTagValue(id, tag, value);
 
     for (std::list<int64_t>::const_iterator 
-           it = id.begin(); it != id.end(); it++)
+           it = id.begin(); it != id.end(); ++it)
     {
       result.push_back(db_->GetPublicId(*it));
     }
@@ -1574,7 +1570,7 @@
     db_->LookupTagValue(id, value);
 
     for (std::list<int64_t>::const_iterator 
-           it = id.begin(); it != id.end(); it++)
+           it = id.begin(); it != id.end(); ++it)
     {
       result.push_back(db_->GetPublicId(*it));
     }
--- a/OrthancServer/ToDcmtkBridge.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/OrthancServer/ToDcmtkBridge.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -49,7 +49,7 @@
     std::auto_ptr<DcmDataset> result(new DcmDataset);
 
     for (DicomMap::Map::const_iterator 
-           it = map.map_.begin(); it != map.map_.end(); it++)
+           it = map.map_.begin(); it != map.map_.end(); ++it)
     {
       std::string s = it->second->AsString();
       DU_putStringDOElement(result.get(), Convert(it->first), s.c_str());
--- a/Resources/Samples/OrthancClient/Basic/main.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Resources/Samples/OrthancClient/Basic/main.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -66,7 +66,7 @@
 
     return 0;
   }
-  catch (OrthancClient::OrthancClientException e)
+  catch (OrthancClient::OrthancClientException& e)
   {
     std::cerr << "EXCEPTION: [" << e.What() << "]" << std::endl;
     return -1;
--- a/Resources/Samples/OrthancClient/Vtk/main.cpp	Wed Oct 30 11:56:28 2013 +0100
+++ b/Resources/Samples/OrthancClient/Vtk/main.cpp	Mon Nov 04 11:19:31 2013 +0100
@@ -173,7 +173,7 @@
 
     return 0;
   }
-  catch (OrthancClient::OrthancClientException e)
+  catch (OrthancClient::OrthancClientException& e)
   {
     std::cerr << "EXCEPTION: [" << e.What() << "]" << std::endl;
     return -1;