changeset 1916:bd527bbc34df

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 20 Mar 2022 18:23:39 +0100
parents 0d1235ca4abc
children 9c52c0376ad7
files Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyViewport.cpp OrthancStone/Sources/Toolbox/BucketAccumulator2D.cpp OrthancStone/Sources/Toolbox/DicomStructureSet.cpp OrthancStone/Sources/Toolbox/Internals/BucketMapper.cpp RenderingPlugin/Sources/Plugin.cpp
diffstat 6 files changed, 22 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Sun Mar 20 18:07:11 2022 +0100
+++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Sun Mar 20 18:23:39 2022 +0100
@@ -543,7 +543,7 @@
     skipSeriesFromModalities_ = skipSeriesFromModalities;
   }
 
-  static boost::shared_ptr<ResourcesLoader> Create(OrthancStone::ILoadersContext::ILock& lock,
+  static boost::shared_ptr<ResourcesLoader> Create(const OrthancStone::ILoadersContext::ILock& lock,
                                                    const OrthancStone::DicomSource& source)
   {
     boost::shared_ptr<ResourcesLoader> loader(new ResourcesLoader(lock.GetContext(), source));
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyViewport.cpp	Sun Mar 20 18:07:11 2022 +0100
+++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyViewport.cpp	Sun Mar 20 18:23:39 2022 +0100
@@ -275,9 +275,13 @@
   void WebAssemblyViewport::Invalidate()
   {
     LOG(TRACE) << "WebAssemblyViewport::Invalidate()\n";
-    long id = emscripten_request_animation_frame(OnRequestAnimationFrame, 
-                                                 CreateObjectCookie());
-    //animationFrameCallbackIds_.push_back(id);
+
+#if 1
+    emscripten_request_animation_frame(OnRequestAnimationFrame, CreateObjectCookie());
+#else
+    animationFrameCallbackIds_.push_back(
+      emscripten_request_animation_frame(OnRequestAnimationFrame, CreateObjectCookie()));
+#endif
   }
 
   void WebAssemblyViewport::FitForPrint()
--- a/OrthancStone/Sources/Toolbox/BucketAccumulator2D.cpp	Sun Mar 20 18:07:11 2022 +0100
+++ b/OrthancStone/Sources/Toolbox/BucketAccumulator2D.cpp	Sun Mar 20 18:23:39 2022 +0100
@@ -195,7 +195,7 @@
 
       for (size_t x = 0; x < mapperX_.GetSize(); x++)
       {
-        fprintf(fp, "%7lu ", GetBucketContentSize(x, y));
+        fprintf(fp, "%7ld ", GetBucketContentSize(x, y));
       }
 
       fprintf(fp, "\n");
--- a/OrthancStone/Sources/Toolbox/DicomStructureSet.cpp	Sun Mar 20 18:07:11 2022 +0100
+++ b/OrthancStone/Sources/Toolbox/DicomStructureSet.cpp	Sun Mar 20 18:23:39 2022 +0100
@@ -917,11 +917,11 @@
           Vector normal;
           bool valid = false;
 
-          for (size_t i = 0; i + 2 < points.size(); i++)
+          for (size_t j = 0; j + 2 < points.size(); j++)
           {
-            const Vector& a = points[i];
-            const Vector& b = points[i + 1];
-            const Vector& c = points[i + 2];
+            const Vector& a = points[j];
+            const Vector& b = points[j + 1];
+            const Vector& c = points[j + 2];
             LinearAlgebra::CrossProduct(normal, b - a, c - a);  // (*)
             LinearAlgebra::NormalizeVector(normal);
 
@@ -937,9 +937,9 @@
             // Check that all the points of the polygon lie in the plane defined by the normal
             double d1 = GeometryToolbox::ProjectAlongNormal(points[0], normal);
           
-            for (size_t i = 1; i < points.size(); i++)
+            for (size_t j = 1; j < points.size(); j++)
             {
-              double d2 = GeometryToolbox::ProjectAlongNormal(points[i], normal);
+              double d2 = GeometryToolbox::ProjectAlongNormal(points[j], normal);
             
               if (!LinearAlgebra::IsNear(d1, d2))
               {
--- a/OrthancStone/Sources/Toolbox/Internals/BucketMapper.cpp	Sun Mar 20 18:07:11 2022 +0100
+++ b/OrthancStone/Sources/Toolbox/Internals/BucketMapper.cpp	Sun Mar 20 18:23:39 2022 +0100
@@ -41,7 +41,7 @@
       bucketsCount_(bucketsCount)
     {
       if (minValue >= maxValue ||
-          bucketsCount <= 0)
+          bucketsCount == 0)
       {
         throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
       }
--- a/RenderingPlugin/Sources/Plugin.cpp	Sun Mar 20 18:07:11 2022 +0100
+++ b/RenderingPlugin/Sources/Plugin.cpp	Sun Mar 20 18:23:39 2022 +0100
@@ -40,6 +40,12 @@
 #include <boost/math/constants/constants.hpp>
 
 
+static const char* const INSTANCES = "Instances";  
+static const char* const RT_STRUCT_IOD = "1.2.840.10008.5.1.4.1.1.481.3";
+static const char* const SOP_CLASS_UID = "0008,0016";
+static const char* const STRUCTURES = "Structures";
+
+
 class DicomStructureCache : public boost::noncopyable
 {
 private:
@@ -528,9 +534,6 @@
 
 static bool IsRtStruct(const std::string& instanceId)
 {
-  static const char* SOP_CLASS_UID = "0008,0016";
-  static const char* RT_STRUCT_IOD = "1.2.840.10008.5.1.4.1.1.481.3";
-      
   std::string s;
   if (OrthancPlugins::RestApiGetString(s, "/instances/" + instanceId + "/content/" + SOP_CLASS_UID, false) &&
       !s.empty())
@@ -556,8 +559,6 @@
   // This is a quick version of "/tools/find" on "SOPClassUID" (the
   // latter would load all the DICOM files from disk)
 
-  static const char* INSTANCES = "Instances";
-  
   Json::Value series;
   OrthancPlugins::RestApiGet(series, "/series?expand", false);
 
@@ -606,9 +607,6 @@
                         const char* url,
                         const OrthancPluginHttpRequest* request)
 {
-  static const char* STRUCTURES = "Structures";
-  static const char* INSTANCES = "Instances";
-  
   DicomStructureCache::Accessor accessor(DicomStructureCache::GetSingleton(), request->groups[0]);
 
   if (!accessor.IsValid())