changeset 4204:318c16cfccab

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 17 Sep 2020 16:18:01 +0200
parents 4d42408da117
children d962a2996637
files OrthancFramework/Sources/DicomNetworking/DicomFindAnswers.cpp OrthancFramework/Sources/DicomNetworking/DicomFindAnswers.h OrthancFramework/UnitTestsSources/JobsTests.cpp OrthancFramework/UnitTestsSources/LoggingTests.cpp OrthancFramework/UnitTestsSources/MemoryCacheTests.cpp OrthancFramework/UnitTestsSources/RestApiTests.cpp OrthancFramework/UnitTestsSources/StreamTests.cpp OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp OrthancServer/Plugins/Engine/OrthancPluginDatabase.h OrthancServer/Plugins/Engine/OrthancPlugins.cpp OrthancServer/Plugins/Engine/PluginsJob.h OrthancServer/Resources/RunCppCheck.sh OrthancServer/Sources/DicomInstanceOrigin.h OrthancServer/Sources/LuaScripting.cpp OrthancServer/Sources/LuaScripting.h OrthancServer/Sources/OrthancConfiguration.cpp OrthancServer/Sources/OrthancConfiguration.h OrthancServer/Sources/OrthancFindRequestHandler.cpp OrthancServer/Sources/OrthancFindRequestHandler.h OrthancServer/Sources/OrthancGetRequestHandler.cpp OrthancServer/Sources/OrthancGetRequestHandler.h OrthancServer/Sources/OrthancMoveRequestHandler.h OrthancServer/Sources/OrthancRestApi/OrthancRestApi.h OrthancServer/Sources/Search/DatabaseConstraint.h OrthancServer/Sources/Search/DicomTagConstraint.h OrthancServer/Sources/Search/HierarchicalMatcher.h OrthancServer/Sources/ServerContext.h OrthancServer/Sources/ServerJobs/CleaningInstancesJob.h OrthancServer/Sources/ServerJobs/DicomModalityStoreJob.h OrthancServer/Sources/ServerJobs/LuaJobManager.h OrthancServer/Sources/ServerJobs/ResourceModificationJob.h
diffstat 31 files changed, 152 insertions(+), 133 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomNetworking/DicomFindAnswers.cpp	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancFramework/Sources/DicomNetworking/DicomFindAnswers.cpp	Thu Sep 17 16:18:01 2020 +0200
@@ -116,7 +116,7 @@
   }
 
 
-  void DicomFindAnswers::Add(ParsedDicomFile& dicom)
+  void DicomFindAnswers::Add(const ParsedDicomFile& dicom)
   {
     AddAnswerInternal(dicom.Clone(true));
   }
--- a/OrthancFramework/Sources/DicomNetworking/DicomFindAnswers.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancFramework/Sources/DicomNetworking/DicomFindAnswers.h	Thu Sep 17 16:18:01 2020 +0200
@@ -64,7 +64,7 @@
 
     void Add(const DicomMap& map);
 
-    void Add(ParsedDicomFile& dicom);
+    void Add(const ParsedDicomFile& dicom);
 
     void Add(const void* dicom,
              size_t size);
--- a/OrthancFramework/UnitTestsSources/JobsTests.cpp	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancFramework/UnitTestsSources/JobsTests.cpp	Thu Sep 17 16:18:01 2020 +0200
@@ -168,7 +168,7 @@
     {
     }
     
-    DummyInstancesJob(const Json::Value& value) :
+    explicit DummyInstancesJob(const Json::Value& value) :
       SetOfInstancesJob(value)
     {
       if (HasTrailingStep())
@@ -831,7 +831,7 @@
 
 
 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer,
-                                         JobOperationValue& value)
+                                         const JobOperationValue& value)
 {
   Json::Value a = 42;
   value.Serialize(a);
@@ -1030,8 +1030,8 @@
 }
 
 
-static bool IsSameTagValue(ParsedDicomFile& dicom1,
-                           ParsedDicomFile& dicom2,
+static bool IsSameTagValue(const ParsedDicomFile& dicom1,
+                           const ParsedDicomFile& dicom2,
                            DicomTag tag)
 {
   std::string a, b;
@@ -1073,12 +1073,12 @@
     std::unique_ptr<ParsedDicomFile> second(source.Clone(true));
     modification.Apply(*second);
 
-    std::string s;
-    ASSERT_TRUE(second->GetTagValue(s, DICOM_TAG_STUDY_DESCRIPTION));
-    ASSERT_TRUE(s.empty());
-    ASSERT_FALSE(second->GetTagValue(s, DICOM_TAG_SERIES_DESCRIPTION));
-    ASSERT_TRUE(second->GetTagValue(s, DICOM_TAG_PATIENT_NAME));
-    ASSERT_EQ("Test 4", s);
+    std::string t;
+    ASSERT_TRUE(second->GetTagValue(t, DICOM_TAG_STUDY_DESCRIPTION));
+    ASSERT_TRUE(t.empty());
+    ASSERT_FALSE(second->GetTagValue(t, DICOM_TAG_SERIES_DESCRIPTION));
+    ASSERT_TRUE(second->GetTagValue(t, DICOM_TAG_PATIENT_NAME));
+    ASSERT_EQ("Test 4", t);
 
     ASSERT_TRUE(IsSameTagValue(source, *modified, DICOM_TAG_STUDY_INSTANCE_UID));
     ASSERT_TRUE(IsSameTagValue(source, *second, DICOM_TAG_STUDY_INSTANCE_UID));
@@ -1369,13 +1369,13 @@
   }
 
   {
-    Json::Value s;
-    s["AllowStorageCommitment"] = false;
-    s["AET"] = "AET";
-    s["Host"] = "host";
-    s["Port"] = "104";
+    Json::Value t;
+    t["AllowStorageCommitment"] = false;
+    t["AET"] = "AET";
+    t["Host"] = "host";
+    t["Port"] = "104";
     
-    RemoteModalityParameters modality(s);
+    RemoteModalityParameters modality(t);
     ASSERT_TRUE(modality.IsAdvancedFormatNeeded());
     ASSERT_EQ("AET", modality.GetApplicationEntityTitle());
     ASSERT_EQ("host", modality.GetHost());
@@ -1386,15 +1386,15 @@
   }
 
   {
-    Json::Value s;
-    s["AllowNAction"] = false;
-    s["AllowNEventReport"] = true;
-    s["AET"] = "AET";
-    s["Host"] = "host";
-    s["Port"] = "104";
-    s["AllowTranscoding"] = false;
+    Json::Value t;
+    t["AllowNAction"] = false;
+    t["AllowNEventReport"] = true;
+    t["AET"] = "AET";
+    t["Host"] = "host";
+    t["Port"] = "104";
+    t["AllowTranscoding"] = false;
     
-    RemoteModalityParameters modality(s);
+    RemoteModalityParameters modality(t);
     ASSERT_TRUE(modality.IsAdvancedFormatNeeded());
     ASSERT_EQ("AET", modality.GetApplicationEntityTitle());
     ASSERT_EQ("host", modality.GetHost());
@@ -1405,14 +1405,14 @@
   }
 
   {
-    Json::Value s;
-    s["AllowNAction"] = true;
-    s["AllowNEventReport"] = true;
-    s["AET"] = "AET";
-    s["Host"] = "host";
-    s["Port"] = "104";
+    Json::Value t;
+    t["AllowNAction"] = true;
+    t["AllowNEventReport"] = true;
+    t["AET"] = "AET";
+    t["Host"] = "host";
+    t["Port"] = "104";
     
-    RemoteModalityParameters modality(s);
+    RemoteModalityParameters modality(t);
     ASSERT_FALSE(modality.IsAdvancedFormatNeeded());
     ASSERT_EQ("AET", modality.GetApplicationEntityTitle());
     ASSERT_EQ("host", modality.GetHost());
--- a/OrthancFramework/UnitTestsSources/LoggingTests.cpp	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancFramework/UnitTestsSources/LoggingTests.cpp	Thu Sep 17 16:18:01 2020 +0200
@@ -113,7 +113,7 @@
   class FuncStreamBuf : public std::stringbuf
   {
   public:
-    FuncStreamBuf(T func) : func_(func) {}
+    explicit FuncStreamBuf(T func) : func_(func) {}
 
     virtual int sync()
     {
--- a/OrthancFramework/UnitTestsSources/MemoryCacheTests.cpp	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancFramework/UnitTestsSources/MemoryCacheTests.cpp	Thu Sep 17 16:18:01 2020 +0200
@@ -252,7 +252,7 @@
     std::string value_;
 
   public:
-    S(const std::string& value) : value_(value)
+    explicit S(const std::string& value) : value_(value)
     {
     }
 
@@ -300,7 +300,7 @@
 
   size_t count = 0;
   for (std::list<std::string>::const_iterator
-         it = i.begin(); it != i.end(); it++)
+         it = i.begin(); it != i.end(); ++it)
   {
     if (*it == first ||
         *it == second)
--- a/OrthancFramework/UnitTestsSources/RestApiTests.cpp	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancFramework/UnitTestsSources/RestApiTests.cpp	Thu Sep 17 16:18:01 2020 +0200
@@ -533,12 +533,14 @@
     ASSERT_EQ(v, v2);
 
     p.Serialize(v2, false, false /* no password */);
-    WebServiceParameters p2(v2);
     ASSERT_EQ(Json::arrayValue, v2.type());
     ASSERT_EQ(3u, v2.size());
     ASSERT_EQ("http://localhost:8042/", v2[0u].asString());
     ASSERT_EQ("user", v2[1u].asString());
     ASSERT_TRUE(v2[2u].asString().empty());
+
+    WebServiceParameters p2(v2);  // Test decoding
+    ASSERT_EQ("http://localhost:8042/", p2.GetUrl());
   }
 
   {
@@ -552,7 +554,6 @@
 
     Json::Value v2;
     p.Serialize(v2, false, true);
-    WebServiceParameters p2(v2);
 
     ASSERT_EQ(Json::objectValue, v2.type());
     ASSERT_EQ(3u, v2.size());
@@ -560,6 +561,9 @@
     ASSERT_TRUE(v2["Pkcs11"].asBool());
     ASSERT_EQ(Json::objectValue, v2["HttpHeaders"].type());
     ASSERT_EQ(0u, v2["HttpHeaders"].size());
+
+    WebServiceParameters p2(v2);  // Test decoding
+    ASSERT_EQ("http://localhost:8042/", p2.GetUrl());
   }
 
   {
@@ -573,7 +577,6 @@
 
     Json::Value v2;
     p.Serialize(v2, false, true);
-    WebServiceParameters p2(v2);
 
     ASSERT_EQ(Json::objectValue, v2.type());
     ASSERT_EQ(6u, v2.size());
@@ -584,6 +587,9 @@
     ASSERT_FALSE(v2["Pkcs11"].asBool());
     ASSERT_EQ(Json::objectValue, v2["HttpHeaders"].type());
     ASSERT_EQ(0u, v2["HttpHeaders"].size());
+
+    WebServiceParameters p2(v2);  // Test decoding
+    ASSERT_EQ("http://localhost:8042/", p2.GetUrl());
   }
 
   {
@@ -981,7 +987,7 @@
     {
     }
       
-    virtual bool ReadNextChunk(std::string& chunk)
+    virtual bool ReadNextChunk(std::string& chunk) ORTHANC_OVERRIDE
     {
       if (pos_ == size_)
       {
@@ -1018,7 +1024,7 @@
                                             const char* username,
                                             HttpMethod method,
                                             const UriComponents& uri,
-                                            const Arguments& headers)
+                                            const Arguments& headers) ORTHANC_OVERRIDE
     {
       return false;
     }
@@ -1032,7 +1038,7 @@
                         const Arguments& headers,
                         const GetArguments& getArguments,
                         const void* bodyData,
-                        size_t bodySize)
+                        size_t bodySize) ORTHANC_OVERRIDE
     {
       printf("received %d\n", static_cast<int>(bodySize));
 
--- a/OrthancFramework/UnitTestsSources/StreamTests.cpp	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancFramework/UnitTestsSources/StreamTests.cpp	Thu Sep 17 16:18:01 2020 +0200
@@ -110,7 +110,7 @@
   std::string s = Toolbox::GenerateUuid();
   s = s + s + s + s;
  
-  std::string compressed, compressed2;
+  std::string compressed;
   ZlibCompressor c;
   ASSERT_TRUE(c.HasPrefixWithUncompressedSize());
   IBufferCompressor::Compress(compressed, c, s);
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp	Thu Sep 17 16:18:01 2020 +0200
@@ -62,22 +62,22 @@
     }
 
   public:
-    Transaction(OrthancPluginDatabase& that) :
-    that_(that)
+    explicit Transaction(OrthancPluginDatabase& that) :
+      that_(that)
     {
     }
 
-    virtual void Begin()
+    virtual void Begin() ORTHANC_OVERRIDE
     {
       CheckSuccess(that_.backend_.startTransaction(that_.payload_));
     }
 
-    virtual void Rollback()
+    virtual void Rollback() ORTHANC_OVERRIDE
     {
       CheckSuccess(that_.backend_.rollbackTransaction(that_.payload_));
     }
 
-    virtual void Commit(int64_t diskSizeDelta)
+    virtual void Commit(int64_t diskSizeDelta) ORTHANC_OVERRIDE
     {
       if (that_.fastGetTotalSize_)
       {
@@ -229,7 +229,10 @@
     errorDictionary_(errorDictionary),
     backend_(backend),
     payload_(payload),
-    listener_(NULL)
+    listener_(NULL),
+    fastGetTotalSize_(false),
+    currentDiskSize_(0),
+    answerDoneIgnored_(false)
   {
     static const char* const MISSING = "  Missing extension in database index plugin: ";
     
@@ -571,11 +574,11 @@
 
   void OrthancPluginDatabase::GetLastChange(std::list<ServerIndexChange>& target /*out*/)
   {
-    bool ignored = false;
+    answerDoneIgnored_ = false;
 
     ResetAnswers();
     answerChanges_ = &target;
-    answerDone_ = &ignored;
+    answerDone_ = &answerDoneIgnored_;
 
     CheckSuccess(backend_.getLastChange(GetContext(), payload_));
   }
@@ -583,11 +586,11 @@
 
   void OrthancPluginDatabase::GetLastExportedResource(std::list<ExportedResource>& target /*out*/)
   {
-    bool ignored = false;
+    answerDoneIgnored_ = false;
 
     ResetAnswers();
     answerExportedResources_ = &target;
-    answerDone_ = &ignored;
+    answerDone_ = &answerDoneIgnored_;
 
     CheckSuccess(backend_.getLastExportedResource(GetContext(), payload_));
   }
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabase.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabase.h	Thu Sep 17 16:18:01 2020 +0200
@@ -81,6 +81,7 @@
     std::list<ServerIndexChange>*  answerChanges_;
     std::list<ExportedResource>*   answerExportedResources_;
     bool*                          answerDone_;
+    bool                           answerDoneIgnored_;
     std::list<std::string>*        answerMatchingResources_;
     std::list<std::string>*        answerMatchingInstances_;
     AnswerMetadata*                answerMetadata_;
--- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp	Thu Sep 17 16:18:01 2020 +0200
@@ -369,10 +369,11 @@
       }
       
     public:
-      DicomWebBinaryFormatter(OrthancPluginDicomWebBinaryCallback callback) :
+      explicit DicomWebBinaryFormatter(OrthancPluginDicomWebBinaryCallback callback) :
         oldCallback_(callback),
         newCallback_(NULL),
-        newPayload_(NULL)
+        newPayload_(NULL),
+        currentMode_(DicomWebJsonVisitor::BinaryMode_Ignore)
       {
       }
       
@@ -380,7 +381,8 @@
                               void* payload) :
         oldCallback_(NULL),
         newCallback_(callback),
-        newPayload_(payload)
+        newPayload_(payload),
+        currentMode_(DicomWebJsonVisitor::BinaryMode_Ignore)
       {
       }
       
@@ -388,7 +390,7 @@
                                                      const std::vector<DicomTag>& parentTags,
                                                      const std::vector<size_t>& parentIndexes,
                                                      const DicomTag& tag,
-                                                     ValueRepresentation vr)
+                                                     ValueRepresentation vr) ORTHANC_OVERRIDE
       {
         if (oldCallback_ == NULL &&
             newCallback_ == NULL)
@@ -446,7 +448,7 @@
 
       void Apply(char** target,
                  bool isJson,
-                 ParsedDicomFile& dicom)
+                 const ParsedDicomFile& dicom)
       {
         DicomWebJsonVisitor visitor;
         visitor.SetFormatter(*this);
@@ -506,9 +508,9 @@
       std::string                 multipartContentType_;
       std::string                 multipartFirstPart_;
       std::map<std::string, std::string>  multipartFirstHeaders_;
-
+      
     public:
-      PluginHttpOutput(HttpOutput& output) :
+      explicit PluginHttpOutput(HttpOutput& output) :
         output_(output),
         logDetails_(false),
         multipartState_(MultipartState_None)
@@ -728,7 +730,7 @@
       boost::regex                      regex_;
 
     public:
-      ChunkedRestCallback(_OrthancPluginChunkedRestCallback parameters) :
+      explicit ChunkedRestCallback(_OrthancPluginChunkedRestCallback parameters) :
         parameters_(parameters),
         regex_(parameters.pathRegularExpression)
       {
@@ -775,8 +777,9 @@
           handler_ = NULL;
         }
 
-        virtual StorageCommitmentFailureReason Lookup(const std::string& sopClassUid,
-                                                      const std::string& sopInstanceUid)
+        virtual StorageCommitmentFailureReason Lookup(
+          const std::string& sopClassUid,
+          const std::string& sopInstanceUid) ORTHANC_OVERRIDE
         {
           assert(handler_ != NULL);
           OrthancPluginStorageCommitmentFailureReason reason =
@@ -797,7 +800,7 @@
       _OrthancPluginRegisterStorageCommitmentScpCallback  parameters_;
 
     public:
-      StorageCommitmentScp(_OrthancPluginRegisterStorageCommitmentScpCallback parameters) :
+      explicit StorageCommitmentScp(_OrthancPluginRegisterStorageCommitmentScpCallback parameters) :
         parameters_(parameters)
       {
       }
@@ -857,7 +860,7 @@
       ServerContext* context_;
 
     public:
-      ServerContextLock(PImpl& that) : 
+      explicit ServerContextLock(PImpl& that) : 
         lock_(that.contextMutex_),
         context_(that.context_)
       {
@@ -962,7 +965,7 @@
     }
 
   public:
-    WorklistHandler(OrthancPlugins& that) : that_(that)
+    explicit WorklistHandler(OrthancPlugins& that) : that_(that)
     {
       Reset();
     }
@@ -974,9 +977,9 @@
                         const std::string& calledAet,
                         ModalityManufacturer manufacturer)
     {
-      static const char* LUA_CALLBACK = "IncomingWorklistRequestFilter";
-
-      {
+      {
+        static const char* LUA_CALLBACK = "IncomingWorklistRequestFilter";
+
         PImpl::ServerContextLock lock(*that_.pimpl_);
         LuaScripting::Lock lua(lock.GetContext().GetLuaScripting());
 
@@ -1082,7 +1085,7 @@
     }
 
   public:
-    FindHandler(OrthancPlugins& that) : that_(that)
+    explicit FindHandler(OrthancPlugins& that) : that_(that)
     {
       Reset();
     }
@@ -1264,7 +1267,7 @@
 
 
   public:
-    MoveHandler(OrthancPlugins& that)
+    explicit MoveHandler(OrthancPlugins& that)
     {
       boost::recursive_mutex::scoped_lock lock(that.pimpl_->invokeServiceMutex_);
       params_ = that.pimpl_->moveCallbacks_;
@@ -1338,7 +1341,7 @@
     {
     }
 
-    virtual bool ReadNextChunk(std::string& chunk)
+    virtual bool ReadNextChunk(std::string& chunk) ORTHANC_OVERRIDE
     {
       if (params_.requestIsDone(params_.request))
       {
@@ -1387,7 +1390,7 @@
     }
 
     virtual void AddHeader(const std::string& key,
-                           const std::string& value)
+                           const std::string& value) ORTHANC_OVERRIDE
     {
       OrthancPluginErrorCode error = params_.answerAddHeader(params_.answer, key.c_str(), value.c_str());
         
@@ -1399,7 +1402,7 @@
     }
       
     virtual void AddChunk(const void* data,
-                          size_t size)
+                          size_t size) ORTHANC_OVERRIDE
     {
       OrthancPluginErrorCode error = params_.answerAddChunk(params_.answer, data, size);
         
@@ -1533,7 +1536,7 @@
       std::vector<const char*>  cgroups_;
       
     public:
-      RestCallbackMatcher(const UriComponents& uri) :
+      explicit RestCallbackMatcher(const UriComponents& uri) :
         flatUri_(Toolbox::FlattenUri(uri))
       {
       }
@@ -1846,7 +1849,7 @@
     const DicomInstanceToStore&  instance_;
 
   public:
-    DicomInstanceFromCallback(const DicomInstanceToStore& instance) :
+    explicit DicomInstanceFromCallback(const DicomInstanceToStore& instance) :
       instance_(instance)
     {
     }
@@ -1897,7 +1900,7 @@
     DicomInstanceToStore              instance_;
 
   public:
-    DicomInstanceFromTranscoded(IDicomTranscoder::DicomImage& transcoded) :
+    explicit DicomInstanceFromTranscoded(IDicomTranscoder::DicomImage& transcoded) :
       parsed_(transcoded.ReleaseAsParsedDicomFile())
     {
       instance_.SetParsedDicomFile(*parsed_);
@@ -3327,11 +3330,11 @@
   {
     const _OrthancPluginDrawText& p = *reinterpret_cast<const _OrthancPluginDrawText*>(parameters);
 
-    ImageAccessor& target = *reinterpret_cast<ImageAccessor*>(p.image);
-
     {
       OrthancConfiguration::ReaderLock lock;
       const Font& font = lock.GetConfiguration().GetFontRegistry().GetFont(p.fontIndex);
+
+      ImageAccessor& target = *reinterpret_cast<ImageAccessor*>(p.image);
       font.Draw(target, p.utf8Text, p.x, p.y, p.r, p.g, p.b);
     }
   }
@@ -5037,7 +5040,7 @@
     }
 
     virtual void AddBodyChunk(const void* data,
-                              size_t size)
+                              size_t size) ORTHANC_OVERRIDE
     {
       if (static_cast<uint32_t>(size) != size)
       {
@@ -5047,8 +5050,8 @@
       assert(reader_ != NULL);
       parameters_.addChunk(reader_, data, size);
     }    
-
-    virtual void Execute(HttpOutput& output)
+    
+    virtual void Execute(HttpOutput& output) ORTHANC_OVERRIDE
     {
       assert(reader_ != NULL);
 
--- a/OrthancServer/Plugins/Engine/PluginsJob.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Plugins/Engine/PluginsJob.h	Thu Sep 17 16:18:01 2020 +0200
@@ -48,7 +48,7 @@
     std::string              type_;
 
   public:
-    PluginsJob(const _OrthancPluginCreateJob& parameters);
+    explicit PluginsJob(const _OrthancPluginCreateJob& parameters);
 
     virtual ~PluginsJob();
 
--- a/OrthancServer/Resources/RunCppCheck.sh	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Resources/RunCppCheck.sh	Thu Sep 17 16:18:01 2020 +0200
@@ -10,11 +10,15 @@
 
 cat <<EOF > /tmp/cppcheck-suppressions.txt
 constParameter:../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp
+knownArgument:../../OrthancFramework/UnitTestsSources/ImageTests.cpp
+knownConditionTrueFalse:../../OrthancServer/Plugins/Engine/OrthancPlugins.cpp
+nullPointer:../../OrthancFramework/UnitTestsSources/RestApiTests.cpp:309
 nullPointerRedundantCheck:../../OrthancFramework/UnitTestsSources/DicomMapTests.cpp
-stlFindInsert:../../OrthancFramework/Sources/DicomFormat/DicomMap.cpp
+stlFindInsert:../../OrthancFramework/Sources/DicomFormat/DicomMap.cpp:1070
+syntaxError:../../OrthancFramework/Sources/SQLite/FunctionContext.h:50
+syntaxError:../../OrthancFramework/UnitTestsSources/ZipTests.cpp:129
 unreadVariable:../../OrthancFramework/Sources/FileStorage/StorageAccessor.cpp
-useInitializationList:../../OrthancFramework/Sources/Images/PngReader.cpp
-syntaxError:../../OrthancFramework/Sources/SQLite/FunctionContext.h
+useInitializationList:../../OrthancFramework/Sources/Images/PngReader.cpp:89
 EOF
 
 ${CPPCHECK} --enable=all --quiet --std=c++11 \
--- a/OrthancServer/Sources/DicomInstanceOrigin.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/DicomInstanceOrigin.h	Thu Sep 17 16:18:01 2020 +0200
@@ -46,7 +46,7 @@
     std::string   dicomCalledAet_;
     std::string   httpUsername_;
 
-    DicomInstanceOrigin(RequestOrigin origin) :
+    explicit DicomInstanceOrigin(RequestOrigin origin) :
       origin_(origin)
     {
     }
@@ -57,7 +57,7 @@
     {
     }
 
-    DicomInstanceOrigin(const Json::Value& serialized);
+    explicit DicomInstanceOrigin(const Json::Value& serialized);
 
     static DicomInstanceOrigin FromDicomProtocol(const char* remoteIp,
                                                  const char* remoteAet,
--- a/OrthancServer/Sources/LuaScripting.cpp	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/LuaScripting.cpp	Thu Sep 17 16:18:01 2020 +0200
@@ -74,7 +74,7 @@
       instance.GetOrigin().Format(origin_);
     }
 
-    virtual void Apply(LuaScripting& that)
+    virtual void Apply(LuaScripting& that) ORTHANC_OVERRIDE
     {
       static const char* NAME = "OnStoredInstance";
 
@@ -103,12 +103,12 @@
     std::string    command_;
 
   public:
-    ExecuteEvent(const std::string& command) :
+    explicit ExecuteEvent(const std::string& command) :
       command_(command)
     {
     }
 
-    virtual void Apply(LuaScripting& that)
+    virtual void Apply(LuaScripting& that) ORTHANC_OVERRIDE
     {
       LuaScripting::Lock lock(that);
 
@@ -127,12 +127,12 @@
     ServerIndexChange  change_;
 
   public:
-    StableResourceEvent(const ServerIndexChange& change) :
-    change_(change)
+    explicit StableResourceEvent(const ServerIndexChange& change) :
+      change_(change)
     {
     }
 
-    virtual void Apply(LuaScripting& that)
+    virtual void Apply(LuaScripting& that) ORTHANC_OVERRIDE
     {
       const char* name;
 
@@ -223,7 +223,7 @@
     {
     }
 
-    virtual void Apply(LuaScripting& that)
+    virtual void Apply(LuaScripting& that) ORTHANC_OVERRIDE
     {
       std::string functionName;
       
@@ -273,7 +273,7 @@
     {
     }
 
-    virtual void Apply(LuaScripting& that)
+    virtual void Apply(LuaScripting& that) ORTHANC_OVERRIDE
     {
       std::string functionName;
       
@@ -327,7 +327,7 @@
     {
     }
 
-    virtual void Apply(LuaScripting& that)
+    virtual void Apply(LuaScripting& that) ORTHANC_OVERRIDE
     {
       std::string functionName;
       
--- a/OrthancServer/Sources/LuaScripting.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/LuaScripting.h	Thu Sep 17 16:18:01 2020 +0200
@@ -112,7 +112,7 @@
       }
     };
 
-    LuaScripting(ServerContext& context);
+    explicit LuaScripting(ServerContext& context);
 
     ~LuaScripting();
 
--- a/OrthancServer/Sources/OrthancConfiguration.cpp	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/OrthancConfiguration.cpp	Thu Sep 17 16:18:01 2020 +0200
@@ -917,7 +917,7 @@
 
 
   void OrthancConfiguration::DefaultExtractDicomSummary(DicomMap& target,
-                                                        ParsedDicomFile& dicom)
+                                                        const ParsedDicomFile& dicom)
   {
     std::set<DicomTag> ignoreTagLength;
     dicom.ExtractDicomSummary(target, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength);
@@ -925,7 +925,7 @@
   
     
   void OrthancConfiguration::DefaultDicomDatasetToJson(Json::Value& target,
-                                                       ParsedDicomFile& dicom)
+                                                       const ParsedDicomFile& dicom)
   {
     std::set<DicomTag> ignoreTagLength;
     DefaultDicomDatasetToJson(target, dicom, ignoreTagLength);
@@ -933,7 +933,7 @@
   
     
   void OrthancConfiguration::DefaultDicomDatasetToJson(Json::Value& target,
-                                                       ParsedDicomFile& dicom,
+                                                       const ParsedDicomFile& dicom,
                                                        const std::set<DicomTag>& ignoreTagLength)
   {
     dicom.DatasetToJson(target, DicomToJsonFormat_Full, DicomToJsonFlags_Default, 
@@ -942,9 +942,8 @@
   
 
   void OrthancConfiguration::DefaultDicomHeaderToJson(Json::Value& target,
-                                                      ParsedDicomFile& dicom)
+                                                      const ParsedDicomFile& dicom)
   {
-    std::set<DicomTag> ignoreTagLength;
     dicom.HeaderToJson(target, DicomToJsonFormat_Full);
   }
 }
--- a/OrthancServer/Sources/OrthancConfiguration.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/OrthancConfiguration.h	Thu Sep 17 16:18:01 2020 +0200
@@ -69,7 +69,8 @@
     ServerIndex*             serverIndex_;
 
     OrthancConfiguration() :
-      configurationFileArg_(NULL)
+      configurationFileArg_(NULL),
+      serverIndex_(NULL)
     {
     }
 
@@ -246,16 +247,16 @@
     }
 
     static void DefaultExtractDicomSummary(DicomMap& target,
-                                           ParsedDicomFile& dicom);
+                                           const ParsedDicomFile& dicom);
     
     static void DefaultDicomDatasetToJson(Json::Value& target,
-                                          ParsedDicomFile& dicom);
+                                          const ParsedDicomFile& dicom);
     
     static void DefaultDicomDatasetToJson(Json::Value& target,
-                                          ParsedDicomFile& dicom,
+                                          const ParsedDicomFile& dicom,
                                           const std::set<DicomTag>& ignoreTagLength);
     
     static void DefaultDicomHeaderToJson(Json::Value& target,
-                                         ParsedDicomFile& dicom);
+                                         const ParsedDicomFile& dicom);
   };
 }
--- a/OrthancServer/Sources/OrthancFindRequestHandler.cpp	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/OrthancFindRequestHandler.cpp	Thu Sep 17 16:18:01 2020 +0200
@@ -538,7 +538,7 @@
       }
     }
 
-    virtual bool IsDicomAsJsonNeeded() const
+    virtual bool IsDicomAsJsonNeeded() const ORTHANC_OVERRIDE
     {
       // Ask the "DICOM-as-JSON" attachment only if sequences are to
       // be returned OR if "query_" contains non-main DICOM tags!
@@ -564,7 +564,7 @@
               !withoutSpecialTags.HasOnlyMainDicomTags());
     }
       
-    virtual void MarkAsComplete()
+    virtual void MarkAsComplete() ORTHANC_OVERRIDE
     {
       answers_.SetComplete(true);
     }
@@ -572,7 +572,7 @@
     virtual void Visit(const std::string& publicId,
                        const std::string& instanceId,
                        const DicomMap& mainDicomTags,
-                       const Json::Value* dicomAsJson) 
+                       const Json::Value* dicomAsJson) ORTHANC_OVERRIDE
     {
       std::unique_ptr<DicomMap> counters(ComputeCounters(context_, instanceId, level_, query_));
 
--- a/OrthancServer/Sources/OrthancFindRequestHandler.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/OrthancFindRequestHandler.h	Thu Sep 17 16:18:01 2020 +0200
@@ -63,7 +63,7 @@
                         ModalityManufacturer manufacturer);
 
   public:
-    OrthancFindRequestHandler(ServerContext& context);
+    explicit OrthancFindRequestHandler(ServerContext& context);
 
     virtual void Handle(DicomFindAnswers& answers,
                         const DicomMap& input,
@@ -71,7 +71,7 @@
                         const std::string& remoteIp,
                         const std::string& remoteAet,
                         const std::string& calledAet,
-                        ModalityManufacturer manufacturer);
+                        ModalityManufacturer manufacturer) ORTHANC_OVERRIDE;
 
     unsigned int GetMaxResults() const
     {
--- a/OrthancServer/Sources/OrthancGetRequestHandler.cpp	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/OrthancGetRequestHandler.cpp	Thu Sep 17 16:18:01 2020 +0200
@@ -79,7 +79,7 @@
     std::string dicom;
     context_.ReadDicom(dicom, id);
     
-    if (dicom.size() <= 0)
+    if (dicom.empty())
     {
       return Status_Failure;
     }
@@ -475,9 +475,9 @@
         }
         else
         {
-          for (size_t i = 0; i < tmp.size(); i++)
+          for (size_t j = 0; j < tmp.size(); j++)
           {
-            publicIds.push_back(tmp[i]);
+            publicIds.push_back(tmp[j]);
           }
         }
       }
@@ -488,7 +488,8 @@
 
 
     OrthancGetRequestHandler::OrthancGetRequestHandler(ServerContext& context) :
-      context_(context)
+      context_(context),
+      getCancelled_(false)
     {
       position_ = 0;
       nRemaining_ = 0;
--- a/OrthancServer/Sources/OrthancGetRequestHandler.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/OrthancGetRequestHandler.h	Thu Sep 17 16:18:01 2020 +0200
@@ -80,7 +80,7 @@
     void AddFailedUIDInstance(const std::string& sopInstance);
 
   public:
-    OrthancGetRequestHandler(ServerContext& context);
+    explicit OrthancGetRequestHandler(ServerContext& context);
     
     virtual bool Handle(const DicomMap& input,
                         const std::string& originatorIp,
--- a/OrthancServer/Sources/OrthancMoveRequestHandler.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/OrthancMoveRequestHandler.h	Thu Sep 17 16:18:01 2020 +0200
@@ -32,6 +32,7 @@
 
 #pragma once
 
+#include "../../OrthancFramework/Sources/Compatibility.h"  // For ORTHANC_OVERRIDE
 #include "../../OrthancFramework/Sources/DicomNetworking/IMoveRequestHandler.h"
 
 namespace Orthanc
@@ -48,8 +49,8 @@
                            const DicomMap& input);
 
   public:
-    OrthancMoveRequestHandler(ServerContext& context) :
-    context_(context)
+    explicit OrthancMoveRequestHandler(ServerContext& context) :
+      context_(context)
     {
     }
 
@@ -58,6 +59,6 @@
                                          const std::string& originatorIp,
                                          const std::string& originatorAet,
                                          const std::string& calledAet,
-                                         uint16_t originatorId);
+                                         uint16_t originatorId) ORTHANC_OVERRIDE;
   };
 }
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.h	Thu Sep 17 16:18:01 2020 +0200
@@ -75,7 +75,7 @@
     static void ShutdownOrthanc(RestApiPostCall& call);
 
   public:
-    OrthancRestApi(ServerContext& context);
+    explicit OrthancRestApi(ServerContext& context);
 
     virtual bool Handle(HttpOutput& output,
                         RequestOrigin origin,
--- a/OrthancServer/Sources/Search/DatabaseConstraint.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/Search/DatabaseConstraint.h	Thu Sep 17 16:18:01 2020 +0200
@@ -109,7 +109,7 @@
                        bool mandatory);
 
 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
-    DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint);
+    explicit DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint);
 #endif
     
     ResourceType GetLevel() const
--- a/OrthancServer/Sources/Search/DicomTagConstraint.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/Search/DicomTagConstraint.h	Thu Sep 17 16:18:01 2020 +0200
@@ -70,9 +70,9 @@
                        bool caseSensitive,
                        bool mandatory);
 
-    DicomTagConstraint(const DicomTagConstraint& other);
+    explicit DicomTagConstraint(const DicomTagConstraint& other);
     
-    DicomTagConstraint(const DatabaseConstraint& constraint);
+    explicit DicomTagConstraint(const DatabaseConstraint& constraint);
 
     const DicomTag& GetTag() const
     {
--- a/OrthancServer/Sources/Search/HierarchicalMatcher.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/Search/HierarchicalMatcher.h	Thu Sep 17 16:18:01 2020 +0200
@@ -71,7 +71,7 @@
                                 bool hasCodeExtensions) const;
 
   public:
-    HierarchicalMatcher(ParsedDicomFile& query);
+    explicit HierarchicalMatcher(ParsedDicomFile& query);
 
     ~HierarchicalMatcher();
 
--- a/OrthancServer/Sources/ServerContext.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/ServerContext.h	Thu Sep 17 16:18:01 2020 +0200
@@ -96,7 +96,7 @@
       ServerContext& context_;
 
     public:
-      LuaServerListener(ServerContext& context) :
+      explicit LuaServerListener(ServerContext& context) :
         context_(context)
       {
       }
@@ -126,11 +126,11 @@
       ServerContext& context_;
 
     public:
-      DicomCacheProvider(ServerContext& context) : context_(context)
+      explicit DicomCacheProvider(ServerContext& context) : context_(context)
       {
       }
       
-      virtual IDynamicObject* Provide(const std::string& id);
+      virtual IDynamicObject* Provide(const std::string& id) ORTHANC_OVERRIDE;
     };
 
     class ServerListener
--- a/OrthancServer/Sources/ServerJobs/CleaningInstancesJob.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/ServerJobs/CleaningInstancesJob.h	Thu Sep 17 16:18:01 2020 +0200
@@ -46,7 +46,7 @@
     bool            keepSource_;
     
   protected:
-    virtual bool HandleTrailingStep();
+    virtual bool HandleTrailingStep() ORTHANC_OVERRIDE;
     
   public:
     CleaningInstancesJob(ServerContext& context,
--- a/OrthancServer/Sources/ServerJobs/DicomModalityStoreJob.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/ServerJobs/DicomModalityStoreJob.h	Thu Sep 17 16:18:01 2020 +0200
@@ -68,7 +68,7 @@
     virtual bool HandleTrailingStep() ORTHANC_OVERRIDE;
 
   public:
-    DicomModalityStoreJob(ServerContext& context);
+    explicit DicomModalityStoreJob(ServerContext& context);
 
     DicomModalityStoreJob(ServerContext& context,
                           const Json::Value& serialized);
--- a/OrthancServer/Sources/ServerJobs/LuaJobManager.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/ServerJobs/LuaJobManager.h	Thu Sep 17 16:18:01 2020 +0200
@@ -54,7 +54,7 @@
     unsigned int              trailingTimeout_;
     TimeoutDicomConnectionManager  connectionManager_;
 
-    virtual void SignalDone(const SequenceOfOperationsJob& job);
+    virtual void SignalDone(const SequenceOfOperationsJob& job) ORTHANC_OVERRIDE;
 
   public:
     LuaJobManager();
--- a/OrthancServer/Sources/ServerJobs/ResourceModificationJob.h	Thu Sep 17 15:01:31 2020 +0200
+++ b/OrthancServer/Sources/ServerJobs/ResourceModificationJob.h	Thu Sep 17 16:18:01 2020 +0200
@@ -57,7 +57,7 @@
     virtual bool HandleInstance(const std::string& instance);
     
   public:
-    ResourceModificationJob(ServerContext& context);
+    explicit ResourceModificationJob(ServerContext& context);
 
     ResourceModificationJob(ServerContext& context,
                             const Json::Value& serialized);