changeset 4206:171af1567473

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 17 Sep 2020 20:49:15 +0200
parents d962a2996637
children 116bd42caf49 f659f79eb12a
files OrthancServer/Resources/RunCppCheck.sh OrthancServer/Sources/ServerJobs/DicomMoveScuJob.cpp OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp OrthancServer/Sources/ServerJobs/StorageCommitmentScpJob.cpp
diffstat 4 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Resources/RunCppCheck.sh	Thu Sep 17 17:58:19 2020 +0200
+++ b/OrthancServer/Resources/RunCppCheck.sh	Thu Sep 17 20:49:15 2020 +0200
@@ -15,9 +15,11 @@
 nullPointer:../../OrthancFramework/UnitTestsSources/RestApiTests.cpp:309
 nullPointerRedundantCheck:../../OrthancFramework/UnitTestsSources/DicomMapTests.cpp
 stlFindInsert:../../OrthancFramework/Sources/DicomFormat/DicomMap.cpp:1070
-stlFindInsert:../../OrthancServer/Sources/ServerIndex.cpp:398
+stlFindInsert:../../OrthancServer/Sources/ServerIndex.cpp:400
 syntaxError:../../OrthancFramework/Sources/SQLite/FunctionContext.h:50
 syntaxError:../../OrthancFramework/UnitTestsSources/ZipTests.cpp:129
+syntaxError:../../OrthancServer/UnitTestsSources/UnitTestsMain.cpp:314
+uninitMemberVar:../../OrthancServer/Sources/ServerJobs/StorageCommitmentScpJob.cpp:427
 unreadVariable:../../OrthancFramework/Sources/FileStorage/StorageAccessor.cpp
 unreadVariable:../../OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp:714
 useInitializationList:../../OrthancFramework/Sources/Images/PngReader.cpp:89
--- a/OrthancServer/Sources/ServerJobs/DicomMoveScuJob.cpp	Thu Sep 17 17:58:19 2020 +0200
+++ b/OrthancServer/Sources/ServerJobs/DicomMoveScuJob.cpp	Thu Sep 17 20:49:15 2020 +0200
@@ -217,11 +217,10 @@
                                    const Json::Value& serialized) :
     SetOfCommandsJob(new Unserializer(*this), serialized),
     context_(context),
+    parameters_(DicomAssociationParameters::UnserializeJob(serialized)),
+    targetAet_(SerializationToolbox::ReadString(serialized, TARGET_AET)),
     query_(Json::arrayValue)
   {
-    parameters_ = DicomAssociationParameters::UnserializeJob(serialized);
-    targetAet_ = SerializationToolbox::ReadString(serialized, TARGET_AET);
-
     if (serialized.isMember(QUERY) &&
         serialized[QUERY].type() == Json::arrayValue)
     {
--- a/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp	Thu Sep 17 17:58:19 2020 +0200
+++ b/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp	Thu Sep 17 20:49:15 2020 +0200
@@ -274,7 +274,8 @@
     CleaningInstancesJob(context, true /* by default, keep source */),
     modification_(new DicomModification),
     isAnonymization_(false),
-    transcode_(false)
+    transcode_(false),
+    transferSyntax_(DicomTransferSyntax_LittleEndianExplicit)  // dummy initialization
   {
   }
 
--- a/OrthancServer/Sources/ServerJobs/StorageCommitmentScpJob.cpp	Thu Sep 17 17:58:19 2020 +0200
+++ b/OrthancServer/Sources/ServerJobs/StorageCommitmentScpJob.cpp	Thu Sep 17 20:49:15 2020 +0200
@@ -107,7 +107,8 @@
                   size_t index) :
       that_(that),
       index_(index),
-      hasFailureReason_(false)
+      hasFailureReason_(false),
+      failureReason_(StorageCommitmentFailureReason_Success)
     {
     }
 
@@ -426,11 +427,18 @@
   StorageCommitmentScpJob::StorageCommitmentScpJob(ServerContext& context,
                                                    const Json::Value& serialized) :
     SetOfCommandsJob(new Unserializer(*this), serialized),
-    context_(context)
+    context_(context),
+    transactionUid_(SerializationToolbox::ReadString(serialized, TRANSACTION_UID)),
+    calledAet_(SerializationToolbox::ReadString(serialized, CALLED_AET))
+    // "ready_" is initialized by the unserializer
   {
-    transactionUid_ = SerializationToolbox::ReadString(serialized, TRANSACTION_UID);
+    if (serialized.type() != Json::objectValue ||
+        !serialized.isMember(REMOTE_MODALITY))
+    {
+      throw OrthancException(ErrorCode_BadFileFormat);
+    }
+    
     remoteModality_ = RemoteModalityParameters(serialized[REMOTE_MODALITY]);
-    calledAet_ = SerializationToolbox::ReadString(serialized, CALLED_AET);
     SerializationToolbox::ReadArrayOfStrings(sopClassUids_, serialized, SOP_CLASS_UIDS);
     SerializationToolbox::ReadArrayOfStrings(sopInstanceUids_, serialized, SOP_INSTANCE_UIDS);
   }