changeset 318:49d897b15ac7

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Apr 2026 19:15:34 +0200
parents a713408177ec
children 2e57aac1dd8a 0535d9f8fe3c
files Plugin/AssociativeArray.cpp Plugin/AuthorizationWebService.cpp Plugin/BaseAuthorizationService.h Plugin/MemoryCache.cpp Plugin/MemoryCache.h Plugin/OrthancResource.h Plugin/Plugin.cpp
diffstat 7 files changed, 23 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/Plugin/AssociativeArray.cpp	Tue Apr 07 18:02:05 2026 +0200
+++ b/Plugin/AssociativeArray.cpp	Tue Apr 07 19:15:34 2026 +0200
@@ -39,7 +39,7 @@
         Orthanc::Toolbox::ToLowerCase(key, headersKeys[i]);
       }
         
-      map_[headersKeys[i]] = headersValues[i];
+      map_[key] = headersValues[i];
     }
   }
 
--- a/Plugin/AuthorizationWebService.cpp	Tue Apr 07 18:02:05 2026 +0200
+++ b/Plugin/AuthorizationWebService.cpp	Tue Apr 07 19:15:34 2026 +0200
@@ -252,7 +252,7 @@
 
       return true;
     }
-    catch (Orthanc::OrthancException& ex)
+    catch (const Orthanc::OrthancException& ex)
     {
       return false;
     }
@@ -341,7 +341,7 @@
 
       return true;
     }
-    catch (Orthanc::OrthancException& ex)
+    catch (const Orthanc::OrthancException& ex)
     {
       return false;
     }
@@ -451,7 +451,7 @@
 
       return true;
     }
-    catch (Orthanc::OrthancException& ex)
+    catch (const Orthanc::OrthancException& ex)
     {
       return false;
     }
@@ -519,7 +519,7 @@
 
       return true;
     }
-    catch (Orthanc::OrthancException& ex)
+    catch (const Orthanc::OrthancException& ex)
     {
       return false;
     }
@@ -565,7 +565,7 @@
 
       return true;
     }
-    catch (Orthanc::OrthancException& ex)
+    catch (const Orthanc::OrthancException& ex)
     {
       return false;
     }
@@ -604,7 +604,7 @@
 
       return true;
     }
-    catch (Orthanc::OrthancException& ex)
+    catch (const Orthanc::OrthancException& ex)
     {
       return false;
     }
--- a/Plugin/BaseAuthorizationService.h	Tue Apr 07 18:02:05 2026 +0200
+++ b/Plugin/BaseAuthorizationService.h	Tue Apr 07 19:15:34 2026 +0200
@@ -48,10 +48,6 @@
                                            const UserProfile& profile) = 0;
 
   public:
-    virtual ~BaseAuthorizationService()
-    {
-    }
-    
     virtual bool IsGranted(unsigned int& validity,
                            OrthancPluginHttpMethod method,
                            const AccessedResource& access,
--- a/Plugin/MemoryCache.cpp	Tue Apr 07 18:02:05 2026 +0200
+++ b/Plugin/MemoryCache.cpp	Tue Apr 07 19:15:34 2026 +0200
@@ -101,9 +101,16 @@
     
   MemoryCache::~MemoryCache()
   {
-    while (!index_.IsEmpty())
+    try
     {
-      RemoveOldest();
+      while (!index_.IsEmpty())
+      {
+        RemoveOldest();
+      }
+    }
+    catch (Orthanc::OrthancException&)
+    {
+      // Destructors cannot throw exceptions
     }
   }
     
--- a/Plugin/MemoryCache.h	Tue Apr 07 18:02:05 2026 +0200
+++ b/Plugin/MemoryCache.h	Tue Apr 07 19:15:34 2026 +0200
@@ -64,7 +64,7 @@
   public:
     explicit MemoryCache(unsigned int maxSize);
     
-    ~MemoryCache();
+    ~MemoryCache() ORTHANC_OVERRIDE;
 
     virtual void Invalidate(const std::string& key) ORTHANC_OVERRIDE;
 
--- a/Plugin/OrthancResource.h	Tue Apr 07 18:02:05 2026 +0200
+++ b/Plugin/OrthancResource.h	Tue Apr 07 19:15:34 2026 +0200
@@ -41,7 +41,8 @@
 
   public:
     OrthancResource() :
-      isValid_(false)
+      isValid_(false),
+      level_(Orthanc::ResourceType_Instance) // dummy initialization
     {
     }
     
--- a/Plugin/Plugin.cpp	Tue Apr 07 18:02:05 2026 +0200
+++ b/Plugin/Plugin.cpp	Tue Apr 07 19:15:34 2026 +0200
@@ -527,7 +527,6 @@
     // Based on the tokens, check if the user has access based on its permissions and the mapping between urls and permissions
     ////////////////////////////////////////////////////////////////
     bool hasUserRequiredPermissions = false;
-    std::string userId;
 
     if (permissionParser_.get() != NULL &&
       authorizationService_.get() != NULL) 
@@ -536,6 +535,8 @@
       std::string matchedPattern;
       if (permissionParser_->Parse(requiredPermissions, matchedPattern, method, uri))
       {
+        std::string userId;
+
         if (authTokens.empty())
         {
           std::string msg = std::string("Testing whether anonymous user has any of the required permissions '") + JoinStrings(requiredPermissions) + "' required to match '" + matchedPattern + "'";
@@ -1124,8 +1125,6 @@
         }
         else if (queryLevel == Orthanc::ResourceType_Series || queryLevel == Orthanc::ResourceType_Instance)
         {
-          std::string studyInstanceUID;
-
           if (!HasAccessToAllLabels(profile)) // no need to adjust anything if the user has access to all labels
           {
             bool granted = false;
@@ -1141,6 +1140,7 @@
             }
             else
             { // try to get the StudyInstanceUID from the Query
+              std::string studyInstanceUID;
 
               if (!GetStudyInstanceUIDFromQuery(studyInstanceUID, query))
               {
@@ -2315,7 +2315,7 @@
         std::string dicomWebRoot = "/dicom-web/";
         std::string oe2Root = "/ui/";
 
-        bool hasBasicAuthEnabled = orthancFullConfiguration.GetBooleanValue("AuthenticationEnabled", "true");
+        bool hasBasicAuthEnabled = orthancFullConfiguration.GetBooleanValue("AuthenticationEnabled", true);
 
         if (orthancFullConfiguration.IsSection("DicomWeb"))
         {