changeset 4690:13efc0967cea

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 10 Jun 2021 11:21:22 +0200
parents ead3b81f4541
children a08ef46c95a1
files OrthancFramework/Sources/Compression/ZipWriter.cpp OrthancFramework/Sources/Compression/ZipWriter.h OrthancFramework/Sources/DicomFormat/DicomPath.cpp OrthancFramework/Sources/DicomFormat/DicomPath.h OrthancFramework/Sources/DicomParsing/DicomModification.cpp OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp OrthancServer/Resources/RunCppCheck.sh OrthancServer/Sources/OrthancRestApi/OrthancRestArchive.cpp OrthancServer/UnitTestsSources/SizeOfTests.impl.h
diffstat 9 files changed, 69 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/Compression/ZipWriter.cpp	Thu Jun 10 10:54:14 2021 +0200
+++ b/OrthancFramework/Sources/Compression/ZipWriter.cpp	Thu Jun 10 11:21:22 2021 +0200
@@ -270,7 +270,7 @@
     BufferWithSeek  buffer_;
     
   public:
-    StreamBuffer(IOutputStream& stream) :
+    explicit StreamBuffer(IOutputStream& stream) :
       stream_(stream),
       success_(true),
       startCurrentFile_(0)
--- a/OrthancFramework/Sources/Compression/ZipWriter.h	Thu Jun 10 10:54:14 2021 +0200
+++ b/OrthancFramework/Sources/Compression/ZipWriter.h	Thu Jun 10 11:21:22 2021 +0200
@@ -79,7 +79,7 @@
       uint64_t       archiveSize_;
       
     public:
-      MemoryStream(std::string& target);
+      explicit MemoryStream(std::string& target);
       
       virtual void Write(const std::string& chunk) ORTHANC_OVERRIDE;
       
--- a/OrthancFramework/Sources/DicomFormat/DicomPath.cpp	Thu Jun 10 10:54:14 2021 +0200
+++ b/OrthancFramework/Sources/DicomFormat/DicomPath.cpp	Thu Jun 10 11:21:22 2021 +0200
@@ -112,6 +112,12 @@
   }
 
 
+  DicomPath::DicomPath(const Orthanc::DicomTag& tag) :
+    finalTag_(tag)
+  {
+  }
+
+
   DicomPath::DicomPath(const Orthanc::DicomTag& sequence,
                        size_t index,
                        const Orthanc::DicomTag& tag) :
@@ -149,7 +155,7 @@
 
 
   DicomPath::DicomPath(const std::vector<Orthanc::DicomTag>& parentTags,
-                       const std::vector<size_t> parentIndexes,
+                       const std::vector<size_t>& parentIndexes,
                        const Orthanc::DicomTag& finalTag) :
     finalTag_(finalTag)
   {
@@ -182,6 +188,36 @@
   }
   
 
+  size_t DicomPath::GetPrefixLength() const
+  {
+    return prefix_.size();
+  }
+  
+
+  const Orthanc::DicomTag& DicomPath::GetFinalTag() const
+  {
+    return finalTag_;
+  }
+
+  
+  const Orthanc::DicomTag& DicomPath::GetPrefixTag(size_t level) const
+  {
+    return GetLevel(level).GetTag();
+  }
+
+  
+  bool DicomPath::IsPrefixUniversal(size_t level) const
+  {
+    return GetLevel(level).IsUniversal();
+  }
+  
+
+  size_t DicomPath::GetPrefixIndex(size_t level) const
+  {
+    return GetLevel(level).GetIndex();
+  }
+
+
   bool DicomPath::HasUniversal() const
   {
     for (size_t i = 0; i < prefix_.size(); i++)
@@ -273,17 +309,17 @@
 
           try
           {
-            std::string s = Toolbox::StripSpaces(right.substr(0, right.size() - 1));
-            if (s == "*")
+            std::string t = Toolbox::StripSpaces(right.substr(0, right.size() - 1));
+            if (t == "*")
             {
               path.AddUniversalTagToPrefix(tag);
             }
             else
             {
-              int index = boost::lexical_cast<int>(s);
+              int index = boost::lexical_cast<int>(t);
               if (index < 0)
               {
-                throw OrthancException(ErrorCode_ParameterOutOfRange, "Negative index in parent path: " + s);
+                throw OrthancException(ErrorCode_ParameterOutOfRange, "Negative index in parent path: " + t);
               }
               else
               {
--- a/OrthancFramework/Sources/DicomFormat/DicomPath.h	Thu Jun 10 10:54:14 2021 +0200
+++ b/OrthancFramework/Sources/DicomFormat/DicomPath.h	Thu Jun 10 11:21:22 2021 +0200
@@ -78,10 +78,7 @@
     const PrefixItem& GetLevel(size_t i) const;
     
   public:
-    explicit DicomPath(const Orthanc::DicomTag& tag) :
-      finalTag_(tag)
-    {
-    }
+    explicit DicomPath(const Orthanc::DicomTag& tag);
 
     DicomPath(const Orthanc::DicomTag& sequence,
               size_t index,
@@ -102,7 +99,7 @@
               const Orthanc::DicomTag& tag);
 
     DicomPath(const std::vector<Orthanc::DicomTag>& parentTags,
-              const std::vector<size_t> parentIndexes,
+              const std::vector<size_t>& parentIndexes,
               const Orthanc::DicomTag& finalTag);
 
     void AddIndexedTagToPrefix(const Orthanc::DicomTag& tag,
@@ -110,30 +107,15 @@
 
     void AddUniversalTagToPrefix(const Orthanc::DicomTag& tag);
 
-    size_t GetPrefixLength() const
-    {
-      return prefix_.size();
-    }
+    size_t GetPrefixLength() const;
 
-    const Orthanc::DicomTag& GetFinalTag() const
-    {
-      return finalTag_;
-    }
+    const Orthanc::DicomTag& GetFinalTag() const;
 
-    const Orthanc::DicomTag& GetPrefixTag(size_t level) const
-    {
-      return GetLevel(level).GetTag();
-    }
+    const Orthanc::DicomTag& GetPrefixTag(size_t level) const;
 
-    bool IsPrefixUniversal(size_t level) const
-    {
-      return GetLevel(level).IsUniversal();
-    }
+    bool IsPrefixUniversal(size_t level) const;
 
-    size_t GetPrefixIndex(size_t level) const
-    {
-      return GetLevel(level).GetIndex();
-    }
+    size_t GetPrefixIndex(size_t level) const;
 
     bool HasUniversal() const;
 
--- a/OrthancFramework/Sources/DicomParsing/DicomModification.cpp	Thu Jun 10 10:54:14 2021 +0200
+++ b/OrthancFramework/Sources/DicomParsing/DicomModification.cpp	Thu Jun 10 11:21:22 2021 +0200
@@ -498,7 +498,7 @@
     else
     {
       for (RemovedRanges::const_iterator it = removedRanges_.begin();
-           it != removedRanges_.end(); it++)
+           it != removedRanges_.end(); ++it)
       {
         if (it->Contains(tag))
         {
@@ -1389,7 +1389,6 @@
     Json::Value lst = Json::arrayValue;
     for (ListOfPaths::const_iterator it = keepSequences_.begin(); it != keepSequences_.end(); ++it)
     {
-      assert(it->GetPrefixLength() > 0);
       lst.append(it->Format());
     }
 
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Thu Jun 10 10:54:14 2021 +0200
+++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Thu Jun 10 11:21:22 2021 +0200
@@ -2876,7 +2876,7 @@
       bool  onlyIfExists_;
       
     public:
-      Visitor(bool onlyIfExists) :
+      explicit Visitor(bool onlyIfExists) :
         onlyIfExists_(onlyIfExists)
       {
       }
--- a/OrthancServer/Resources/RunCppCheck.sh	Thu Jun 10 10:54:14 2021 +0200
+++ b/OrthancServer/Resources/RunCppCheck.sh	Thu Jun 10 11:21:22 2021 +0200
@@ -20,7 +20,7 @@
 stlFindInsert:../../OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp:384
 stlFindInsert:../../OrthancServer/Sources/OrthancWebDav.cpp:386
 syntaxError:../../OrthancFramework/Sources/SQLite/FunctionContext.h:50
-syntaxError:../../OrthancFramework/UnitTestsSources/ZipTests.cpp:130
+syntaxError:../../OrthancFramework/UnitTestsSources/ZipTests.cpp:131
 syntaxError:../../OrthancServer/UnitTestsSources/UnitTestsMain.cpp:321
 uninitMemberVar:../../OrthancServer/Sources/ServerJobs/StorageCommitmentScpJob.cpp:427
 unreadVariable:../../OrthancFramework/Sources/FileStorage/StorageAccessor.cpp
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestArchive.cpp	Thu Jun 10 10:54:14 2021 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestArchive.cpp	Thu Jun 10 11:21:22 2021 +0200
@@ -162,18 +162,20 @@
       std::string  chunk_;
       bool         done_;
 
+      explicit SynchronousZipChunk(bool done) :
+        done_(done)
+      {
+      }
+
     public:
       static SynchronousZipChunk* CreateDone()
       {
-        std::unique_ptr<SynchronousZipChunk> item(new SynchronousZipChunk);
-        item->done_ = true;
-        return item.release();
+        return new SynchronousZipChunk(true);
       }
 
       static SynchronousZipChunk* CreateChunk(const std::string& chunk)
       {
-        std::unique_ptr<SynchronousZipChunk> item(new SynchronousZipChunk);
-        item->done_ = false;
+        std::unique_ptr<SynchronousZipChunk> item(new SynchronousZipChunk(false));
         item->chunk_ = chunk;
         return item.release();
       }
@@ -204,13 +206,13 @@
       uint64_t                               archiveSize_;
 
     public:
-      SynchronousZipStream(const boost::shared_ptr<SharedMessageQueue>& queue) :
+      explicit SynchronousZipStream(const boost::shared_ptr<SharedMessageQueue>& queue) :
         queue_(queue),
         archiveSize_(0)
       {
       }
 
-      uint64_t GetArchiveSize() const
+      virtual uint64_t GetArchiveSize() const ORTHANC_OVERRIDE
       {
         return archiveSize_;
       }
@@ -294,9 +296,9 @@
             // that more data might still be returned
             JobState state;
             if (context_.GetJobsEngine().GetRegistry().GetState(state, jobId_) &&
-                (state != JobState_Pending ||
-                 state != JobState_Running ||
-                 state != JobState_Success))
+                (state == JobState_Pending ||
+                 state == JobState_Running ||
+                 state == JobState_Success))
             {
               continue;
             }
@@ -357,7 +359,7 @@
       uint64_t                          archiveSize_;
 
     public:
-      SynchronousTemporaryStream(const boost::shared_ptr<TemporaryFile>& temp) :
+      explicit SynchronousTemporaryStream(const boost::shared_ptr<TemporaryFile>& temp) :
         temp_(temp),
         archiveSize_(0)
       {
@@ -368,7 +370,7 @@
         }
       }
       
-      uint64_t GetArchiveSize() const
+      virtual uint64_t GetArchiveSize() const ORTHANC_OVERRIDE
       {
         return archiveSize_;
       }
--- a/OrthancServer/UnitTestsSources/SizeOfTests.impl.h	Thu Jun 10 10:54:14 2021 +0200
+++ b/OrthancServer/UnitTestsSources/SizeOfTests.impl.h	Thu Jun 10 11:21:22 2021 +0200
@@ -13,6 +13,7 @@
   printf("sizeof(::Orthanc::DicomInstanceHasher) == %d\n", static_cast<int>(sizeof(::Orthanc::DicomInstanceHasher)));
   printf("sizeof(::Orthanc::DicomMap) == %d\n", static_cast<int>(sizeof(::Orthanc::DicomMap)));
   printf("sizeof(::Orthanc::DicomModification) == %d\n", static_cast<int>(sizeof(::Orthanc::DicomModification)));
+  printf("sizeof(::Orthanc::DicomPath) == %d\n", static_cast<int>(sizeof(::Orthanc::DicomPath)));
   printf("sizeof(::Orthanc::DicomStoreUserConnection) == %d\n", static_cast<int>(sizeof(::Orthanc::DicomStoreUserConnection)));
   printf("sizeof(::Orthanc::DicomStreamReader) == %d\n", static_cast<int>(sizeof(::Orthanc::DicomStreamReader)));
   printf("sizeof(::Orthanc::DicomTag) == %d\n", static_cast<int>(sizeof(::Orthanc::DicomTag)));
@@ -25,6 +26,7 @@
   printf("sizeof(::Orthanc::Font) == %d\n", static_cast<int>(sizeof(::Orthanc::Font)));
   printf("sizeof(::Orthanc::FontRegistry) == %d\n", static_cast<int>(sizeof(::Orthanc::FontRegistry)));
   printf("sizeof(::Orthanc::FromDcmtkBridge) == %d\n", static_cast<int>(sizeof(::Orthanc::FromDcmtkBridge)));
+  printf("sizeof(::Orthanc::FromDcmtkBridge::IDicomPathVisitor) == %d\n", static_cast<int>(sizeof(::Orthanc::FromDcmtkBridge::IDicomPathVisitor)));
   printf("sizeof(::Orthanc::GenericJobUnserializer) == %d\n", static_cast<int>(sizeof(::Orthanc::GenericJobUnserializer)));
   printf("sizeof(::Orthanc::GzipCompressor) == %d\n", static_cast<int>(sizeof(::Orthanc::GzipCompressor)));
   printf("sizeof(::Orthanc::HierarchicalZipWriter) == %d\n", static_cast<int>(sizeof(::Orthanc::HierarchicalZipWriter)));