changeset 4519:a3c6678aa7b1

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 22 Feb 2021 16:51:23 +0100
parents cb8fcecf1b02
children f5cb0c0ffbed
files OrthancFramework/Sources/DicomParsing/MemoryBufferTranscoder.cpp OrthancFramework/Sources/FileStorage/FileInfo.cpp OrthancFramework/Sources/FileStorage/FileInfo.h OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp OrthancServer/Resources/RunCppCheck.sh OrthancServer/Sources/DicomInstanceToStore.cpp OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp OrthancServer/Sources/ServerContext.cpp
diffstat 8 files changed, 25 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/MemoryBufferTranscoder.cpp	Mon Feb 22 16:32:11 2021 +0100
+++ b/OrthancFramework/Sources/DicomParsing/MemoryBufferTranscoder.cpp	Mon Feb 22 16:51:23 2021 +0100
@@ -41,7 +41,6 @@
     // Debug mode
     ParsedDicomFile parsed(transcoded);
 
-    std::string s;
     DicomTransferSyntax a, b;
     if (!const_cast<const ParsedDicomFile&>(parsed).LookupTransferSyntax(b) ||
         !FromDcmtkBridge::LookupOrthancTransferSyntax(a, parsed.GetDcmtkObject()) ||
--- a/OrthancFramework/Sources/FileStorage/FileInfo.cpp	Mon Feb 22 16:32:11 2021 +0100
+++ b/OrthancFramework/Sources/FileStorage/FileInfo.cpp	Mon Feb 22 16:51:23 2021 +0100
@@ -27,6 +27,16 @@
 
 namespace Orthanc
 {
+  FileInfo::FileInfo() :
+    valid_(false),
+    contentType_(FileContentType_Unknown),
+    uncompressedSize_(0),
+    compressionType_(CompressionType_None),
+    compressedSize_(0)
+  {
+  }
+
+  
   FileInfo::FileInfo(const std::string& uuid,
                      FileContentType contentType,
                      uint64_t size,
--- a/OrthancFramework/Sources/FileStorage/FileInfo.h	Mon Feb 22 16:32:11 2021 +0100
+++ b/OrthancFramework/Sources/FileStorage/FileInfo.h	Mon Feb 22 16:51:23 2021 +0100
@@ -42,10 +42,7 @@
     std::string      compressedMD5_;
 
   public:
-    FileInfo() :
-      valid_(false)
-    {
-    }
+    FileInfo();
 
     /**
      * Constructor for an uncompressed attachment.
--- a/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp	Mon Feb 22 16:32:11 2021 +0100
+++ b/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp	Mon Feb 22 16:51:23 2021 +0100
@@ -1310,7 +1310,6 @@
   {
     DicomMap summary;
     f.ExtractDicomSummary(summary, 256);
-    std::string s;
     ASSERT_EQ("1314310016", summary.GetStringValue(DicomTag(0x0010, 0x9431), "nope", false));
   }
 
--- a/OrthancServer/Resources/RunCppCheck.sh	Mon Feb 22 16:32:11 2021 +0100
+++ b/OrthancServer/Resources/RunCppCheck.sh	Mon Feb 22 16:51:23 2021 +0100
@@ -14,17 +14,17 @@
 knownConditionTrueFalse:../../OrthancServer/Plugins/Engine/OrthancPlugins.cpp
 nullPointer:../../OrthancFramework/UnitTestsSources/RestApiTests.cpp:319
 nullPointerRedundantCheck:../../OrthancFramework/UnitTestsSources/DicomMapTests.cpp
-stlFindInsert:../../OrthancFramework/Sources/DicomFormat/DicomMap.cpp:1163
+stlFindInsert:../../OrthancFramework/Sources/DicomFormat/DicomMap.cpp:1194
 stlFindInsert:../../OrthancFramework/Sources/RestApi/RestApiCallDocumentation.cpp:164
 stlFindInsert:../../OrthancFramework/Sources/RestApi/RestApiCallDocumentation.cpp:72
 stlFindInsert:../../OrthancServer/Sources/OrthancWebDav.cpp:385
 stlFindInsert:../../OrthancServer/Sources/ServerIndex.cpp:400
 syntaxError:../../OrthancFramework/Sources/SQLite/FunctionContext.h:50
 syntaxError:../../OrthancFramework/UnitTestsSources/ZipTests.cpp:130
-syntaxError:../../OrthancServer/UnitTestsSources/UnitTestsMain.cpp:319
+syntaxError:../../OrthancServer/UnitTestsSources/UnitTestsMain.cpp:321
 uninitMemberVar:../../OrthancServer/Sources/ServerJobs/StorageCommitmentScpJob.cpp:427
 unreadVariable:../../OrthancFramework/Sources/FileStorage/StorageAccessor.cpp
-unreadVariable:../../OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp:1108
+unreadVariable:../../OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp:1121
 unusedFunction
 useInitializationList:../../OrthancFramework/Sources/Images/PngReader.cpp:89
 useInitializationList:../../OrthancServer/Sources/ServerJobs/DicomModalityStoreJob.cpp:285
--- a/OrthancServer/Sources/DicomInstanceToStore.cpp	Mon Feb 22 16:32:11 2021 +0100
+++ b/OrthancServer/Sources/DicomInstanceToStore.cpp	Mon Feb 22 16:51:23 2021 +0100
@@ -102,7 +102,7 @@
     }
 
   public:
-    FromParsedDicomFile(ParsedDicomFile& parsed) :
+    explicit FromParsedDicomFile(ParsedDicomFile& parsed) :
       parsed_(parsed)
     {
     }
@@ -151,7 +151,7 @@
     }
 
   public:
-    FromDcmDataset(DcmDataset& dataset) :
+    explicit FromDcmDataset(DcmDataset& dataset) :
       dataset_(dataset)
     {
     }
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp	Mon Feb 22 16:32:11 2021 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp	Mon Feb 22 16:51:23 2021 +0100
@@ -64,7 +64,7 @@
 
 
   static void SetupResourceAnswer(Json::Value& result,
-                                  DicomInstanceToStore& instance,
+                                  const DicomInstanceToStore& instance,
                                   StoreStatus status,
                                   const std::string& instanceId)
   {
--- a/OrthancServer/Sources/ServerContext.cpp	Mon Feb 22 16:32:11 2021 +0100
+++ b/OrthancServer/Sources/ServerContext.cpp	Mon Feb 22 16:51:23 2021 +0100
@@ -586,7 +586,7 @@
       FileInfo dicomUntilPixelData;
       if (hasPixelDataOffset &&
           (!area_.HasReadRange() ||
-           compression != CompressionType_None))
+           compressionEnabled_))
       {
         dicomUntilPixelData = accessor.Write(dicom.GetBufferData(), pixelDataOffset, 
                                              FileContentType_DicomUntilPixelData, compression, storeMD5_);
@@ -856,7 +856,7 @@
        **/
     
       bool hasPixelDataOffset;
-      uint64_t pixelDataOffset;
+      uint64_t pixelDataOffset = 0;  // dummy initialization
 
       {
         std::string s;
@@ -902,9 +902,11 @@
          * "true".
          **/
       
-        StorageAccessor accessor(area_, GetMetricsRegistry());
-        std::unique_ptr<IMemoryBuffer> dicom(
-          area_.ReadRange(attachment.GetUuid(), FileContentType_Dicom, 0, pixelDataOffset));
+        std::unique_ptr<IMemoryBuffer> dicom;
+        {
+          MetricsRegistry::Timer timer(GetMetricsRegistry(), "orthanc_storage_read_range_duration_ms");
+          dicom.reset(area_.ReadRange(attachment.GetUuid(), FileContentType_Dicom, 0, pixelDataOffset));
+        }
 
         if (dicom.get() == NULL)
         {
@@ -973,7 +975,7 @@
                                boost::lexical_cast<std::string>(pixelDataOffset));
 
             if (!area_.HasReadRange() ||
-                compressionEnabled_ != CompressionType_None)
+                compressionEnabled_)
             {
               AddAttachment(instancePublicId, FileContentType_DicomUntilPixelData,
                             dicom.empty() ? NULL: dicom.c_str(), pixelDataOffset);