changeset 231:a08fcc590d61

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Apr 2026 19:32:16 +0200
parents 9544238ce850
children d0d686f3a643
files Aws/AwsS3StoragePlugin.cpp Common/EncryptionHelpers.cpp Common/EncryptionHelpers.h Common/FileSystemStorage.h Common/StoragePlugin.cpp
diffstat 5 files changed, 19 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/Aws/AwsS3StoragePlugin.cpp	Wed Jan 28 08:22:01 2026 +0100
+++ b/Aws/AwsS3StoragePlugin.cpp	Tue Apr 07 19:32:16 2026 +0200
@@ -77,7 +77,7 @@
                      Aws::S3::Model::StorageClass storageClass,
                      const std::map<std::string, std::string>& tags);
 
-  virtual ~AwsS3StoragePlugin();
+  virtual ~AwsS3StoragePlugin() ORTHANC_OVERRIDE;
 
   virtual IWriter* GetWriterForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled) ORTHANC_OVERRIDE;
   virtual IReader* GetReaderForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled) ORTHANC_OVERRIDE;
@@ -136,10 +136,6 @@
   {
   }
 
-  virtual ~DirectWriter()
-  {
-  }
-
   virtual void Write(const char* data, size_t size) ORTHANC_OVERRIDE
   {
     Aws::S3::Model::PutObjectRequest putObjectRequest;
@@ -190,16 +186,11 @@
   {
   }
 
-  virtual ~DirectReader()
-  {
-
-  }
-
   virtual size_t GetSize() ORTHANC_OVERRIDE
   {
     std::string firstExceptionMessage;
 
-    for (auto& path: paths_)
+    for (const std::string& path: paths_)
     {
       try
       {
@@ -263,7 +254,7 @@
   {
     std::string firstExceptionMessage;
 
-    for (auto& path: paths_)
+    for (const std::string& path: paths_)
     {
       try
       {
@@ -341,10 +332,6 @@
   {
   }
 
-  virtual ~TransferWriter()
-  {
-  }
-
   virtual void Write(const char* data, size_t size) ORTHANC_OVERRIDE
   {
     boost::interprocess::bufferstream buffer(const_cast<char*>(static_cast<const char*>(data)), static_cast<size_t>(size));
@@ -374,11 +361,6 @@
   {
   }
 
-  virtual ~TransferReader()
-  {
-
-  }
-
   virtual void ReadWhole(char* data, size_t size) ORTHANC_OVERRIDE
   {
     std::string firstExceptionMessage;
@@ -454,8 +436,6 @@
 class AwsOrthancLogger : public Aws::Utils::Logging::LogSystemInterface
 {
 public:
-    virtual ~AwsOrthancLogger() {}
-
     /**
      * Gets the currently configured log level for this logger.
      */
@@ -794,7 +774,7 @@
   }
 
   // DeleteObject succeeds even if the file does not exist -> we need to try to delete every path
-  for (auto& path: paths)
+  for (const std::string& path: paths)
   {
     Aws::S3::Model::DeleteObjectRequest deleteObjectRequest;
     deleteObjectRequest.SetBucket(bucketName_.c_str());
--- a/Common/EncryptionHelpers.cpp	Wed Jan 28 08:22:01 2026 +0100
+++ b/Common/EncryptionHelpers.cpp	Tue Apr 07 19:32:16 2026 +0200
@@ -251,7 +251,7 @@
         ) // StreamTransformationFilter
     ); // StringSource
 
-    output.Assign((const byte*)outputString.data(), outputString.size());
+    output.Assign(reinterpret_cast<const byte*>(outputString.data()), outputString.size());
   }
   catch (CryptoPP::Exception& e)
   {
@@ -303,13 +303,13 @@
     //  defines two channels: "" (empty) and "AAD"
     //   channel "" is encrypted and authenticated
     //   channel "AAD" is authenticated
-    ef.ChannelPut("AAD", (const byte*)prefix.data(), prefix.size());
+    ef.ChannelPut("AAD", reinterpret_cast<const byte*>(prefix.data()), prefix.size());
     ef.ChannelMessageEnd("AAD");
 
     // Authenticated data *must* be pushed before
     //  Confidential/Authenticated data. Otherwise
     //  we must catch the BadState exception
-    ef.ChannelPut("", (const byte*)data, size);
+    ef.ChannelPut("", reinterpret_cast<const byte*>(data), size);
     ef.ChannelMessageEnd("");
   }
   catch(CryptoPP::Exception& e)
@@ -354,9 +354,9 @@
                                       AuthenticatedDecryptionFilter::THROW_EXCEPTION, INTEGRITY_CHECK_TAG_SIZE);
 
     // The order of the following calls are important
-    df.ChannelPut("", (const byte*)mac.data(), mac.size());
-    df.ChannelPut("AAD", (const byte*)prefix.data(), prefix.size());
-    df.ChannelPut("", (const byte*)(data) + prefixSize, size - INTEGRITY_CHECK_TAG_SIZE - prefixSize);
+    df.ChannelPut("", reinterpret_cast<const byte*>(mac.data()), mac.size());
+    df.ChannelPut("AAD", reinterpret_cast<const byte*>(prefix.data()), prefix.size());
+    df.ChannelPut("", reinterpret_cast<const byte*>(data) + prefixSize, size - INTEGRITY_CHECK_TAG_SIZE - prefixSize);
 
     // If the object throws, it will most likely occur
     //  during ChannelMessageEnd()
@@ -381,7 +381,7 @@
     {
       assert(n == size - OVERHEAD_SIZE);
 
-      df.Get((byte*)output, n);
+      df.Get(reinterpret_cast<byte*>(output), n);
     }
   }
   catch (CryptoPP::Exception& ex)
--- a/Common/EncryptionHelpers.h	Wed Jan 28 08:22:01 2026 +0100
+++ b/Common/EncryptionHelpers.h	Tue Apr 07 19:32:16 2026 +0200
@@ -66,7 +66,7 @@
   // since the memory used during encryption/decryption can grow up to a bit more than 2 times the input,
   // we want to limit the number of threads doing concurrent processing according to the available memory
   // instead of the number of concurrent threads
-  EncryptionHelpers(size_t maxConcurrentInputSize = 1024*1024*1024);
+  explicit EncryptionHelpers(size_t maxConcurrentInputSize = 1024*1024*1024);
 
   void SetCurrentMasterKey(uint32_t id, const std::string& path);
 
@@ -92,11 +92,11 @@
 
   void EncryptInternal(std::string& output, const char* data, size_t size, const CryptoPP::SecByteBlock& masterKey);
 
-  void DecryptInternal(char* output, const char* data, size_t size, const CryptoPP::SecByteBlock& masterKey);
+  static void DecryptInternal(char* output, const char* data, size_t size, const CryptoPP::SecByteBlock& masterKey);
 
-  void EncryptPrefixSecBlock(std::string& output, const CryptoPP::SecByteBlock& input, const CryptoPP::SecByteBlock& masterKey);
+  static void EncryptPrefixSecBlock(std::string& output, const CryptoPP::SecByteBlock& input, const CryptoPP::SecByteBlock& masterKey);
 
-  void DecryptPrefixSecBlock(CryptoPP::SecByteBlock& output, const std::string& input, const CryptoPP::SecByteBlock& masterKey);
+  static void DecryptPrefixSecBlock(CryptoPP::SecByteBlock& output, const std::string& input, const CryptoPP::SecByteBlock& masterKey);
 
   std::string GetMasterKeyIdentifier(const CryptoPP::SecByteBlock& masterKey);
 
--- a/Common/FileSystemStorage.h	Wed Jan 28 08:22:01 2026 +0100
+++ b/Common/FileSystemStorage.h	Tue Apr 07 19:32:16 2026 +0200
@@ -40,7 +40,6 @@
       fsync_(fsync)
     {}
 
-    virtual ~FileSystemWriter() {}
     virtual void Write(const char* data, size_t size) ORTHANC_OVERRIDE;
   };
 
@@ -52,7 +51,6 @@
     : path_(path)
     {}
 
-    virtual ~FileSystemReader() {}
     virtual size_t GetSize() ORTHANC_OVERRIDE;
     virtual void ReadWhole(char* data, size_t size) ORTHANC_OVERRIDE;
     virtual void ReadRange(char* data, size_t size, size_t fromOffset) ORTHANC_OVERRIDE;
--- a/Common/StoragePlugin.cpp	Wed Jan 28 08:22:01 2026 +0100
+++ b/Common/StoragePlugin.cpp	Tue Apr 07 19:32:16 2026 +0200
@@ -40,9 +40,9 @@
 #include <boost/filesystem.hpp>
 #include <boost/filesystem/fstream.hpp>
 
-#include "../Common/EncryptionHelpers.h"
-#include "../Common/EncryptionConfigurator.h"
-#include "../Common/FileSystemStorage.h"
+#include "EncryptionHelpers.h"
+#include "EncryptionConfigurator.h"
+#include "FileSystemStorage.h"
 
 #include <Logging.h>
 #include <SystemToolbox.h>
@@ -117,7 +117,7 @@
 
       try
       {
-        crypto->Encrypt(encryptedFile, (const char*)content, size);
+        crypto->Encrypt(encryptedFile, reinterpret_cast<const char*>(content), size);
       }
       catch (EncryptionException& ex)
       {