changeset 6387:32c736c4beb7

cppcheck: knownConditionTrueFalse
author Alain Mazy <am@orthanc.team>
date Wed, 12 Nov 2025 10:26:18 +0100
parents 0b94f843be89
children cb0aeb02f56b
files OrthancFramework/Sources/Images/ImageProcessing.cpp OrthancFramework/Sources/Images/PngReader.cpp OrthancFramework/Sources/Toolbox.cpp OrthancServer/Resources/RunCppCheck.sh OrthancServer/Sources/Database/Compatibility/GenericFind.cpp OrthancServer/Sources/ServerJobs/ArchiveJob.cpp OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp
diffstat 7 files changed, 13 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/Images/ImageProcessing.cpp	Mon Nov 10 18:44:19 2025 +0100
+++ b/OrthancFramework/Sources/Images/ImageProcessing.cpp	Wed Nov 12 10:26:18 2025 +0100
@@ -2161,7 +2161,7 @@
           PolygonEdge edge(v1, v2, GetPolygonNextY(points, i));
           globalEdgeTable[v1.GetY()].push_back(edge);
         }
-        else if (v1.GetY() > v2.GetY())
+        else
         {
           // Down-going edge
           PolygonEdge edge(v2, v1, yPrev);
--- a/OrthancFramework/Sources/Images/PngReader.cpp	Mon Nov 10 18:44:19 2025 +0100
+++ b/OrthancFramework/Sources/Images/PngReader.cpp	Wed Nov 12 10:26:18 2025 +0100
@@ -102,9 +102,9 @@
       }
 
       endInfo_ = png_create_info_struct(png_);
-      if (!info_)
+      if (!endInfo_)
       {
-        png_destroy_read_struct(&png_, &info_, NULL);
+        png_destroy_read_struct(&png_, &endInfo_, NULL);
         throw OrthancException(ErrorCode_NotEnoughMemory);
       }
     }
--- a/OrthancFramework/Sources/Toolbox.cpp	Mon Nov 10 18:44:19 2025 +0100
+++ b/OrthancFramework/Sources/Toolbox.cpp	Wed Nov 12 10:26:18 2025 +0100
@@ -2935,17 +2935,10 @@
     else if (ORTHANC_SCANF(version, "%4d", &a) == 1 &&
              a >= 0)
     {
-      if (a >= 0)
-      {
-        major = static_cast<unsigned int>(a);
-        minor = 0;
-        revision = 0;
-        return true;
-      }
-      else
-      {
-        return false;
-      }
+      major = static_cast<unsigned int>(a);
+      minor = 0;
+      revision = 0;
+      return true;
     }
     else
     {
--- a/OrthancServer/Resources/RunCppCheck.sh	Mon Nov 10 18:44:19 2025 +0100
+++ b/OrthancServer/Resources/RunCppCheck.sh	Wed Nov 12 10:26:18 2025 +0100
@@ -51,6 +51,10 @@
 constParameterPointer:../../OrthancFramework/Sources/Logging.cpp:447
 constParameterPointer:../../OrthancFramework/Sources/Logging.cpp:451
 constParameterPointer:../../OrthancFramework/Sources/Toolbox.cpp:3053
+knownConditionTrueFalse:../../OrthancFramework/Sources/DicomNetworking/Internals/CommandDispatcher.cpp:114
+knownConditionTrueFalse:../../OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.cpp:425
+knownConditionTrueFalse:../../OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.cpp:345
+
 EOF
 
 # TODO: re-enable nullPointerOutOfMemory
--- a/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp	Mon Nov 10 18:44:19 2025 +0100
+++ b/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp	Wed Nov 12 10:26:18 2025 +0100
@@ -187,7 +187,6 @@
                                request.GetOrthancIdentifiers(), ResourceType_Series, request.GetLevel());
       }
       else if (request.GetMetadataConstraintsCount() == 0 &&
-               request.GetOrdering().empty() &&
                !request.GetOrthancIdentifiers().HasPatientId() &&
                !request.GetOrthancIdentifiers().HasStudyId() &&
                !request.GetOrthancIdentifiers().HasSeriesId() &&
--- a/OrthancServer/Sources/ServerJobs/ArchiveJob.cpp	Mon Nov 10 18:44:19 2025 +0100
+++ b/OrthancServer/Sources/ServerJobs/ArchiveJob.cpp	Wed Nov 12 10:26:18 2025 +0100
@@ -813,16 +813,11 @@
 
             writer.OpenFile(filename_.c_str());
 
-            std::unique_ptr<ParsedDicomFile> parsed;
-            
             writer.Write(content);
 
             if (dicomDir != NULL)
             {
-              if (parsed.get() == NULL)
-              {
-                parsed.reset(new ParsedDicomFile(content));
-              }
+              std::unique_ptr<ParsedDicomFile> parsed(new ParsedDicomFile(content));
 
               dicomDir->Add(dicomDirFolder, filename_, *parsed);
             }
--- a/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp	Mon Nov 10 18:44:19 2025 +0100
+++ b/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp	Wed Nov 12 10:26:18 2025 +0100
@@ -719,7 +719,7 @@
       }
 
       // and we must make sure that we overwite them with the modified resources
-      if (IsKeepSource() && !GetContext().IsOverwriteInstances())
+      if (!GetContext().IsOverwriteInstances())
       {
         throw OrthancException(ErrorCode_BadRequest,
                               "When keeping StudyInstanceUID, SeriesInstanceUID and SOPInstanceUID tag, you must have the 'OverwriteInstances' Orthanc configuration set to true in order to replace the modified resources");