diff Sources/StructureSetGeometry.cpp @ 57:ce2333b5cb00 nexus

fix warnings
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 21 May 2024 16:02:23 +0200
parents 8a1daa321afe
children
line wrap: on
line diff
--- a/Sources/StructureSetGeometry.cpp	Tue May 21 15:27:40 2024 +0200
+++ b/Sources/StructureSetGeometry.cpp	Tue May 21 16:02:23 2024 +0200
@@ -159,8 +159,8 @@
   // Find the projection along the normal with the largest support
 
   bool first = true;
-  size_t bestSupport;
-  double bestProjection;
+  size_t bestSupport = 0;       // Explicit initialization to avoid valgrind warnings on old compilers
+  double bestProjection = 0.0;  // Explicit initialization to make old compilers happy
 
   std::list<size_t> candidates;
   for (size_t i = 0; i < projections.size(); i++)
@@ -211,6 +211,12 @@
     candidates.swap(next);
   }
 
+  if (first)
+  {
+    // Should never happen
+    throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
+  }
+
 
   // Compute the range of the projections