changeset 4858:8b51d65584f0

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 24 Dec 2021 15:32:08 +0100
parents 275bc6769d60
children 6f780611fc03
files OrthancServer/Resources/RunCppCheck.sh OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp OrthancServer/Sources/ServerContext.cpp
diffstat 3 files changed, 24 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Resources/RunCppCheck.sh	Mon Dec 20 11:24:47 2021 +0100
+++ b/OrthancServer/Resources/RunCppCheck.sh	Fri Dec 24 15:32:08 2021 +0100
@@ -12,25 +12,25 @@
 constParameter:../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp
 knownArgument:../../OrthancFramework/UnitTestsSources/ImageTests.cpp
 knownConditionTrueFalse:../../OrthancServer/Plugins/Engine/OrthancPlugins.cpp
-nullPointer:../../OrthancFramework/UnitTestsSources/RestApiTests.cpp:320
+nullPointer:../../OrthancFramework/UnitTestsSources/RestApiTests.cpp:321
 nullPointerRedundantCheck:../../OrthancFramework/UnitTestsSources/DicomMapTests.cpp
-stlFindInsert:../../OrthancFramework/Sources/DicomFormat/DicomMap.cpp:1194
-stlFindInsert:../../OrthancFramework/Sources/RestApi/RestApiCallDocumentation.cpp:164
-stlFindInsert:../../OrthancFramework/Sources/RestApi/RestApiCallDocumentation.cpp:72
-stlFindInsert:../../OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp:384
-stlFindInsert:../../OrthancServer/Sources/OrthancWebDav.cpp:386
-stlFindInsert:../../OrthancServer/Sources/ServerJobs/MergeStudyJob.cpp:51
-stlFindInsert:../../OrthancServer/Sources/ServerJobs/SplitStudyJob.cpp:201
-syntaxError:../../OrthancFramework/Sources/SQLite/FunctionContext.h:50
-syntaxError:../../OrthancFramework/UnitTestsSources/ZipTests.cpp:131
-syntaxError:../../OrthancServer/UnitTestsSources/UnitTestsMain.cpp:321
-uninitMemberVar:../../OrthancServer/Sources/ServerJobs/StorageCommitmentScpJob.cpp:427
+stlFindInsert:../../OrthancFramework/Sources/DicomFormat/DicomMap.cpp:1195
+stlFindInsert:../../OrthancFramework/Sources/RestApi/RestApiCallDocumentation.cpp:165
+stlFindInsert:../../OrthancFramework/Sources/RestApi/RestApiCallDocumentation.cpp:73
+stlFindInsert:../../OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp:385
+stlFindInsert:../../OrthancServer/Sources/OrthancWebDav.cpp:387
+stlFindInsert:../../OrthancServer/Sources/ServerJobs/MergeStudyJob.cpp:52
+stlFindInsert:../../OrthancServer/Sources/ServerJobs/SplitStudyJob.cpp:202
+syntaxError:../../OrthancFramework/Sources/SQLite/FunctionContext.h:52
+syntaxError:../../OrthancFramework/UnitTestsSources/ZipTests.cpp:132
+syntaxError:../../OrthancServer/UnitTestsSources/UnitTestsMain.cpp:322
+uninitMemberVar:../../OrthancServer/Sources/ServerJobs/StorageCommitmentScpJob.cpp:428
 unreadVariable:../../OrthancFramework/Sources/FileStorage/StorageAccessor.cpp
-unreadVariable:../../OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp:1124
+unreadVariable:../../OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp:1125
 unusedFunction
-useInitializationList:../../OrthancFramework/Sources/Images/PngReader.cpp:89
-useInitializationList:../../OrthancFramework/Sources/Images/PngWriter.cpp:97
-useInitializationList:../../OrthancServer/Sources/ServerJobs/DicomModalityStoreJob.cpp:285
+useInitializationList:../../OrthancFramework/Sources/Images/PngReader.cpp:90
+useInitializationList:../../OrthancFramework/Sources/Images/PngWriter.cpp:98
+useInitializationList:../../OrthancServer/Sources/ServerJobs/DicomModalityStoreJob.cpp:286
 EOF
 
 ${CPPCHECK} --enable=all --quiet --std=c++11 \
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Mon Dec 20 11:24:47 2021 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Fri Dec 24 15:32:08 2021 +0100
@@ -1162,8 +1162,8 @@
       bool           rescale_;
       unsigned int   depth_;
       unsigned int   currentDepth_;
+      unsigned int   width_;
       unsigned int   height_;
-      unsigned int   width_;
       PixelFormat    format_;
       ChunkedBuffer  buffer_;
 
@@ -1172,11 +1172,14 @@
                    bool rescale) :
         rescale_(rescale),
         depth_(depth),
-        currentDepth_(0)
+        currentDepth_(0),
+        width_(0),  // dummy initialization
+        height_(0),  // dummy initialization
+        format_(PixelFormat_Grayscale8)  // dummy initialization
       {
       }
 
-      void WriteFrame(ParsedDicomFile& dicom,
+      void WriteFrame(const ParsedDicomFile& dicom,
                       unsigned int frame)
       {
         std::unique_ptr<ImageAccessor> decoded(dicom.DecodeFrame(frame));
--- a/OrthancServer/Sources/ServerContext.cpp	Mon Dec 20 11:24:47 2021 +0100
+++ b/OrthancServer/Sources/ServerContext.cpp	Fri Dec 24 15:32:08 2021 +0100
@@ -701,14 +701,13 @@
     DicomInstanceToStore* dicom = &receivedDicom;
     std::unique_ptr<DicomInstanceToStore> modifiedDicom;
 
-    void* modifiedDicomBuffer = NULL;
-    size_t modifiedDicomBufferSize = 0;
-
     std::unique_ptr<MallocMemoryBuffer> raii(new MallocMemoryBuffer);
 
 #if ORTHANC_ENABLE_PLUGINS == 1
     if (HasPlugins())
     {
+      void* modifiedDicomBuffer = NULL;
+      size_t modifiedDicomBufferSize = 0;
 
       bool store = GetPlugins().ApplyReceivedInstanceCallbacks(receivedDicom.GetBufferData(), 
                                                                receivedDicom.GetBufferSize(),