Mercurial > hg > orthanc
changeset 6789:261a3e91c870
cppcheck
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Sun, 17 May 2026 17:34:18 +0200 |
| parents | 91ed79f64b74 |
| children | f45d29cd02df |
| files | OrthancFramework/Sources/Cache/SharedObjectCache.h OrthancFramework/Sources/DataSource/DataSourceAnswer.h OrthancFramework/Sources/DataSource/DataSourceMemoryBudget.h OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp OrthancFramework/Sources/DataSource/StorageAreaDataSource.h OrthancFramework/Sources/MultiThreading/CallableGroup.h OrthancFramework/Sources/MultiThreading/ThreadPool.cpp OrthancFramework/Sources/MultiThreading/ThreadPool.h OrthancFramework/UnitTestsSources/JobsTests.cpp OrthancServer/Resources/RunCppCheck-2.20.0.sh |
| diffstat | 10 files changed, 41 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/Cache/SharedObjectCache.h Thu May 14 10:34:27 2026 +0200 +++ b/OrthancFramework/Sources/Cache/SharedObjectCache.h Sun May 17 17:34:18 2026 +0200 @@ -49,7 +49,7 @@ void MakeRoom(size_t newObjectSize); public: - SharedObjectCache(size_t capacity); + explicit SharedObjectCache(size_t capacity); ~SharedObjectCache();
--- a/OrthancFramework/Sources/DataSource/DataSourceAnswer.h Thu May 14 10:34:27 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/DataSourceAnswer.h Sun May 17 17:34:18 2026 +0200 @@ -85,7 +85,7 @@ void EnqueueInternal(Item* item); public: - DataSourceAnswer(unsigned int finalSize); + explicit DataSourceAnswer(unsigned int finalSize); ~DataSourceAnswer();
--- a/OrthancFramework/Sources/DataSource/DataSourceMemoryBudget.h Thu May 14 10:34:27 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/DataSourceMemoryBudget.h Sun May 17 17:34:18 2026 +0200 @@ -46,7 +46,7 @@ uint64_t currentMemory_; public: - DataSourceMemoryBudget(uint64_t maximumMemory); + explicit DataSourceMemoryBudget(uint64_t maximumMemory); void Acquire(size_t memory) ORTHANC_NOEXCEPT;
--- a/OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp Thu May 14 10:34:27 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp Sun May 17 17:34:18 2026 +0200 @@ -46,7 +46,7 @@ std::unique_ptr<IMemoryBuffer> buffer_; public: - Value(IMemoryBuffer* buffer) : + explicit Value(IMemoryBuffer* buffer) : buffer_(buffer) { if (buffer == NULL)
--- a/OrthancFramework/Sources/DataSource/StorageAreaDataSource.h Thu May 14 10:34:27 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/StorageAreaDataSource.h Sun May 17 17:34:18 2026 +0200 @@ -50,7 +50,7 @@ std::unique_ptr<IPluginStorageArea> area_; public: - StorageAreaDataSource(IPluginStorageArea* area); + explicit StorageAreaDataSource(IPluginStorageArea* area); IPluginStorageArea& GetArea() const; @@ -66,7 +66,7 @@ const Value& GetValue() const; public: - Range(const boost::shared_ptr<IDynamicObject>& value); + explicit Range(const boost::shared_ptr<IDynamicObject>& value); const void* GetData() const;
--- a/OrthancFramework/Sources/MultiThreading/CallableGroup.h Thu May 14 10:34:27 2026 +0200 +++ b/OrthancFramework/Sources/MultiThreading/CallableGroup.h Sun May 17 17:34:18 2026 +0200 @@ -58,7 +58,7 @@ CallableGroup& that_; public: - Iterator(CallableGroup& that); + explicit Iterator(CallableGroup& that); bool HasNext() const;
--- a/OrthancFramework/Sources/MultiThreading/ThreadPool.cpp Thu May 14 10:34:27 2026 +0200 +++ b/OrthancFramework/Sources/MultiThreading/ThreadPool.cpp Sun May 17 17:34:18 2026 +0200 @@ -66,7 +66,7 @@ assert(callable != NULL); } - void Execute() + void Execute() ORTHANC_OVERRIDE { boost::shared_ptr<Internals::FutureState> locked = state_.lock(); @@ -91,7 +91,7 @@ } } - void Cancel() + void Cancel() ORTHANC_OVERRIDE { boost::shared_ptr<Internals::FutureState> locked = state_.lock(); @@ -113,24 +113,25 @@ std::unique_ptr<IRunnable> runnable_; public: - RunnableTask(IRunnable* runnable) : + explicit RunnableTask(IRunnable* runnable) : runnable_(runnable) { assert(runnable != NULL); } - void Execute() + void Execute() ORTHANC_OVERRIDE { runnable_->Run(); } - void Cancel() + void Cancel() ORTHANC_OVERRIDE { } }; - void ThreadPool::StopInternal(bool throws) + template <bool throws> + void ThreadPool::StopInternal() { { boost::mutex::scoped_lock lock(mutex_); @@ -206,7 +207,7 @@ } - void ThreadPool::WorkerLoop(std::string threadName) + void ThreadPool::WorkerLoop(const std::string& threadName) { Logging::SetCurrentThreadName(threadName); @@ -247,6 +248,12 @@ } + ThreadPool::~ThreadPool() + { + StopInternal<false>(); // don't throw in destructor + } + + void ThreadPool::SetLoggingThreadName(const std::string& name) { boost::mutex::scoped_lock lock(mutex_); @@ -392,4 +399,10 @@ queue_.Enqueue(new RunnableTask(protection.release())); } + + + void ThreadPool::Stop() + { + StopInternal<true>(); + } }
--- a/OrthancFramework/Sources/MultiThreading/ThreadPool.h Thu May 14 10:34:27 2026 +0200 +++ b/OrthancFramework/Sources/MultiThreading/ThreadPool.h Sun May 17 17:34:18 2026 +0200 @@ -54,17 +54,15 @@ State state_; unsigned int dequeueTimeoutMilliseconds_; - void StopInternal(bool throws); + template <bool throws> + void StopInternal(); - void WorkerLoop(std::string threadName); + void WorkerLoop(const std::string& threadName); public: ThreadPool(); - ~ThreadPool() - { - StopInternal(false /* don't throw in destructor */); - } + virtual ~ThreadPool() ORTHANC_OVERRIDE; void SetLoggingThreadName(const std::string& name); @@ -82,9 +80,6 @@ virtual void Submit(IRunnable* runnable /* takes ownership */) ORTHANC_OVERRIDE; - virtual void Stop() ORTHANC_OVERRIDE - { - StopInternal(true); - } + virtual void Stop() ORTHANC_OVERRIDE; }; }
--- a/OrthancFramework/UnitTestsSources/JobsTests.cpp Thu May 14 10:34:27 2026 +0200 +++ b/OrthancFramework/UnitTestsSources/JobsTests.cpp Sun May 17 17:34:18 2026 +0200 @@ -1927,7 +1927,7 @@ FileInfo attachment_; public: - Identifier(const FileInfo& attachment) : + explicit Identifier(const FileInfo& attachment) : attachment_(attachment) { } @@ -1937,7 +1937,7 @@ return attachment_; } - virtual bool GetCacheKey(std::string& key) const + virtual bool GetCacheKey(std::string& key) const ORTHANC_OVERRIDE { // TODO - Support "read until pixel data" key = (attachment_.GetUuid() + "|" + @@ -1976,7 +1976,7 @@ }; public: - DicomDataSource(const boost::shared_ptr<DataSourceReader>& storageAreaReader) : + explicit DicomDataSource(const boost::shared_ptr<DataSourceReader>& storageAreaReader) : storageAreaReader_(storageAreaReader), checkMD5_(false) { @@ -2015,7 +2015,7 @@ boost::shared_ptr<IDynamicObject> value_; public: - Dicom(const boost::shared_ptr<IDynamicObject>& value) : + explicit Dicom(const boost::shared_ptr<IDynamicObject>& value) : value_(value) { if (value.get() == NULL)
--- a/OrthancServer/Resources/RunCppCheck-2.20.0.sh Thu May 14 10:34:27 2026 +0200 +++ b/OrthancServer/Resources/RunCppCheck-2.20.0.sh Sun May 17 17:34:18 2026 +0200 @@ -10,12 +10,13 @@ fi cat <<EOF > /tmp/cppcheck-suppressions.txt +assertWithSideEffect:../../OrthancFramework/Sources/DataSource/DataSourceReader.cpp:208 assertWithSideEffect:../../OrthancServer/Sources/Database/Compatibility/DatabaseLookup.cpp:292 assertWithSideEffect:../../OrthancServer/Sources/Database/Compatibility/DatabaseLookup.cpp:391 assertWithSideEffect:../../OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp:287 -constParameterPointer:../../OrthancFramework/Sources/Logging.cpp:448 -constParameterPointer:../../OrthancFramework/Sources/Logging.cpp:452 -constParameterPointer:../../OrthancFramework/Sources/Toolbox.cpp:3343 +constParameterPointer:../../OrthancFramework/Sources/Logging.cpp:450 +constParameterPointer:../../OrthancFramework/Sources/Logging.cpp:454 +constParameterPointer:../../OrthancFramework/Sources/Toolbox.cpp:3351 missingInclude:../../OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp:41 nullPointer:../../OrthancFramework/UnitTestsSources/RestApiTests.cpp:321 stlFindInsert:../../OrthancFramework/Sources/RestApi/RestApiCallDocumentation.cpp:166 @@ -24,7 +25,7 @@ syntaxError:../../OrthancFramework/Sources/SQLite/FunctionContext.h syntaxError:../../OrthancFramework/UnitTestsSources/DicomMapTests.cpp:74 syntaxError:../../OrthancServer/UnitTestsSources/UnitTestsMain.cpp:325 -useInitializationList:../../OrthancFramework/Sources/Images/PngReader.cpp:97 +useInitializationList:../../OrthancFramework/Sources/Images/PngReader.cpp:99 useInitializationList:../../OrthancFramework/Sources/Images/PngWriter.cpp:99 useInitializationList:../../OrthancServer/Sources/ServerJobs/DicomModalityStoreJob.cpp:280 variableScope:../../OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp:230
