changeset 2250:66e2e0a35283

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 02 Dec 2025 14:30:15 +0100
parents f1db8845b45c
children dee4cce1857a
files OrthancStone/Sources/Loaders/BasicFetchingStrategy.cpp OrthancStone/Sources/Loaders/BasicFetchingStrategy.h OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp OrthancStone/Sources/Oracle/GenericOracleRunner.h OrthancStone/Sources/Platforms/Sdl/SdlOpenGLContext.cpp OrthancStone/Sources/Platforms/Sdl/SdlViewport.cpp OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.cpp OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyViewport.cpp
diffstat 8 files changed, 19 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancStone/Sources/Loaders/BasicFetchingStrategy.cpp	Tue Dec 02 13:40:47 2025 +0100
+++ b/OrthancStone/Sources/Loaders/BasicFetchingStrategy.cpp	Tue Dec 02 14:30:15 2025 +0100
@@ -32,7 +32,7 @@
   void BasicFetchingStrategy::Schedule(unsigned int item,
                                        unsigned int quality)
   {
-    assert(item < GetItemsCount() &&
+    assert(item < sorter_->GetItemsCount() &&
            quality <= maxQuality_);
       
     if (nextQuality_[item] <= quality)
@@ -57,7 +57,7 @@
 
     nextQuality_.resize(sorter_->GetItemsCount(), 0);   // Does not change along calls to "SetCurrent()"
       
-    SetCurrent(initialItem);
+    SetCurrentInternal(initialItem);
   }
 
 
@@ -93,7 +93,7 @@
   }
 
   
-  void BasicFetchingStrategy::SetCurrent(unsigned int item)
+  void BasicFetchingStrategy::SetCurrentInternal(unsigned int item)
   {
     // TODO - This function is O(N) complexity where "N" is the
     // number of items times the max quality. Could use a LRU index.
@@ -103,7 +103,7 @@
     std::vector<unsigned int> v;
     sorter_->Sort(v, item);
 
-    assert(v.size() == GetItemsCount());
+    assert(v.size() == sorter_->GetItemsCount());
 
     if (v.size() == 0)
     {
--- a/OrthancStone/Sources/Loaders/BasicFetchingStrategy.h	Tue Dec 02 13:40:47 2025 +0100
+++ b/OrthancStone/Sources/Loaders/BasicFetchingStrategy.h	Tue Dec 02 14:30:15 2025 +0100
@@ -69,7 +69,9 @@
 
     void Schedule(unsigned int item,
                   unsigned int quality);
-    
+
+    void SetCurrentInternal(unsigned int item);
+
   public:
     BasicFetchingStrategy(IFetchingItemsSorter* sorter,   // Takes ownership
                           unsigned int maxQuality,
@@ -92,7 +94,10 @@
     virtual bool GetNext(unsigned int& item,
                          unsigned int& quality) ORTHANC_OVERRIDE;
     
-    virtual void SetCurrent(unsigned int item) ORTHANC_OVERRIDE;
+    virtual void SetCurrent(unsigned int item) ORTHANC_OVERRIDE
+    {
+      SetCurrentInternal(item);
+    }
 
     virtual void RecycleFurthest(unsigned int& item) ORTHANC_OVERRIDE;
   };
--- a/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp	Tue Dec 02 13:40:47 2025 +0100
+++ b/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp	Tue Dec 02 14:30:15 2025 +0100
@@ -399,7 +399,7 @@
     }
     else
     {
-      ImageBuffer3D& target = volume_->GetPixelData();
+      const ImageBuffer3D& target = volume_->GetPixelData();
 
       const uint64_t width = target.GetWidth();
       const uint64_t height = target.GetHeight();
--- a/OrthancStone/Sources/Oracle/GenericOracleRunner.h	Tue Dec 02 13:40:47 2025 +0100
+++ b/OrthancStone/Sources/Oracle/GenericOracleRunner.h	Tue Dec 02 14:30:15 2025 +0100
@@ -72,7 +72,7 @@
       rootDirectory_ = rootDirectory;
     }
 
-    const std::string GetRootDirectory() const
+    const std::string& GetRootDirectory() const
     {
       return rootDirectory_;
     }
--- a/OrthancStone/Sources/Platforms/Sdl/SdlOpenGLContext.cpp	Tue Dec 02 13:40:47 2025 +0100
+++ b/OrthancStone/Sources/Platforms/Sdl/SdlOpenGLContext.cpp	Tue Dec 02 14:30:15 2025 +0100
@@ -97,7 +97,7 @@
       std::stringstream ss;
       ss << "Cannot set current OpenGL context. SDL error text: " << errText;
       std::string errStr = ss.str();
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, errStr.c_str());
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, errStr);
     }
 
     // This makes our buffer swap synchronized with the monitor's vertical refresh
--- a/OrthancStone/Sources/Platforms/Sdl/SdlViewport.cpp	Tue Dec 02 13:40:47 2025 +0100
+++ b/OrthancStone/Sources/Platforms/Sdl/SdlViewport.cpp	Tue Dec 02 14:30:15 2025 +0100
@@ -241,7 +241,7 @@
       }
     }
 
-    sdlSurface_ = SDL_CreateRGBSurfaceFrom((void*)(compositor.GetCanvas().GetBuffer()), width, height, 32,
+    sdlSurface_ = SDL_CreateRGBSurfaceFrom(const_cast<void*>(compositor.GetCanvas().GetBuffer()), width, height, 32,
                                            compositor.GetCanvas().GetPitch(), rmask, gmask, bmask, 0);
     if (!sdlSurface_)
     {
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.cpp	Tue Dec 02 13:40:47 2025 +0100
+++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.cpp	Tue Dec 02 14:30:15 2025 +0100
@@ -56,7 +56,7 @@
   public:
     TimeoutContext(WebAssemblyOracle& oracle,
                    boost::weak_ptr<IObserver> receiver,
-                   IOracleCommand* command) :
+                   SleepOracleCommand* command) :
       oracle_(oracle),
       receiver_(receiver)
     {
@@ -66,7 +66,7 @@
       }
       else
       {
-        command_.reset(dynamic_cast<SleepOracleCommand*>(command));
+        command_.reset(command);
       }
     }
 
@@ -770,7 +770,7 @@
       {
         unsigned int timeoutMS = dynamic_cast<SleepOracleCommand*>(command)->GetDelay();
         emscripten_set_timeout(TimeoutContext::Callback, timeoutMS,
-                               new TimeoutContext(*this, receiver, protection.release()));
+                               new TimeoutContext(*this, receiver, dynamic_cast<SleepOracleCommand*>(protection.release())));
         break;
       }
             
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyViewport.cpp	Tue Dec 02 13:40:47 2025 +0100
+++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyViewport.cpp	Tue Dec 02 14:30:15 2025 +0100
@@ -83,7 +83,7 @@
     WebAssemblyViewport& that_;
 
   public:
-    WasmLock(WebAssemblyViewport& that) :
+    explicit WasmLock(WebAssemblyViewport& that) :
       that_(that)
     {
     }