Mercurial > hg > orthanc-webviewer
changeset 197:0ef2d8b970ab
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 23 Apr 2018 11:42:31 +0200 |
parents | b83fe581f6ae |
children | f30ce523a629 93e650b7f986 |
files | Plugin/Cache/CacheIndex.h Plugin/Cache/CacheManager.cpp Plugin/Cache/CacheScheduler.cpp Plugin/DecodedImageAdapter.h Plugin/Plugin.cpp Plugin/ViewerPrefetchPolicy.h UnitTestsSources/UnitTestsMain.cpp |
diffstat | 7 files changed, 29 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugin/Cache/CacheIndex.h Fri Apr 20 14:23:34 2018 +0200 +++ b/Plugin/Cache/CacheIndex.h Mon Apr 23 11:42:31 2018 +0200 @@ -35,8 +35,8 @@ public: CacheIndex(const CacheIndex& other) : - bundle_(other.bundle_), - item_(other.item_) + bundle_(other.bundle_), + item_(other.item_) { }
--- a/Plugin/Cache/CacheManager.cpp Fri Apr 20 14:23:34 2018 +0200 +++ b/Plugin/Cache/CacheManager.cpp Mon Apr 23 11:42:31 2018 +0200 @@ -228,7 +228,7 @@ transaction->Commit(); for (std::list<std::string>::const_iterator - it = toRemove.begin(); it != toRemove.end(); it++) + it = toRemove.begin(); it != toRemove.end(); ++it) { pimpl_->storage_.Remove(*it, Orthanc::FileContentType_Unknown); } @@ -357,8 +357,6 @@ std::string uuid = Toolbox::GenerateUuid(); pimpl_->storage_.Create(uuid, data, content.size(), Orthanc::FileContentType_Unknown); - bool ok = true; - // Remove the previous cached value. This might happen if the same // item is accessed very quickly twice: Another factory could have // been cached a value before the check for existence in Access(). @@ -377,7 +375,6 @@ } } - if (ok) { SQLite::Statement s(pimpl_->db_, SQLITE_FROM_HERE, "INSERT INTO Cache VALUES(NULL, ?, ?, ?, ?)"); s.BindInt(0, bundleIndex); @@ -387,25 +384,20 @@ if (!s.Run()) { - ok = false; + // Error: Remove the stored file + pimpl_->storage_.Remove(uuid, Orthanc::FileContentType_Unknown); } - } + else + { + transaction->Commit(); - if (!ok) - { - // Error: Remove the stored file - pimpl_->storage_.Remove(uuid, Orthanc::FileContentType_Unknown); - } - else - { - transaction->Commit(); - - pimpl_->bundles_[bundleIndex] = bundle; + pimpl_->bundles_[bundleIndex] = bundle; - for (std::list<std::string>::const_iterator - it = toRemove.begin(); it != toRemove.end(); it++) - { - pimpl_->storage_.Remove(*it, Orthanc::FileContentType_Unknown); + for (std::list<std::string>::const_iterator + it = toRemove.begin(); it != toRemove.end(); ++it) + { + pimpl_->storage_.Remove(*it, Orthanc::FileContentType_Unknown); + } } }
--- a/Plugin/Cache/CacheScheduler.cpp Fri Apr 20 14:23:34 2018 +0200 +++ b/Plugin/Cache/CacheScheduler.cpp Mon Apr 23 11:42:31 2018 +0200 @@ -34,7 +34,7 @@ std::string value_; public: - DynamicString(const std::string& value) : value_(value) + explicit DynamicString(const std::string& value) : value_(value) { } @@ -53,7 +53,7 @@ std::set<std::string> content_; public: - PrefetchQueue(size_t maxSize) : queue_(maxSize) + explicit PrefetchQueue(size_t maxSize) : queue_(maxSize) { queue_.SetLifoPolicy(); } @@ -305,7 +305,7 @@ CacheScheduler::~CacheScheduler() { for (BundleSchedulers::iterator it = bundles_.begin(); - it != bundles_.end(); it++) + it != bundles_.end(); ++it) { delete it->second; }
--- a/Plugin/DecodedImageAdapter.h Fri Apr 20 14:23:34 2018 +0200 +++ b/Plugin/DecodedImageAdapter.h Mon Apr 23 11:42:31 2018 +0200 @@ -61,7 +61,8 @@ OrthancPluginContext* context_; public: - DecodedImageAdapter(OrthancPluginContext* context) : context_(context) + explicit DecodedImageAdapter(OrthancPluginContext* context) : + context_(context) { }
--- a/Plugin/Plugin.cpp Fri Apr 20 14:23:34 2018 +0200 +++ b/Plugin/Plugin.cpp Mon Apr 23 11:42:31 2018 +0200 @@ -50,7 +50,7 @@ std::string value_; public: - DynamicString(const char* value) : value_(value) + explicit DynamicString(const char* value) : value_(value) { } @@ -94,7 +94,7 @@ public: - CacheContext(const std::string& path) : storage_(path), stop_(false) + explicit CacheContext(const std::string& path) : storage_(path), stop_(false) { boost::filesystem::path p(path); db_.Open((p / "cache.db").string()); @@ -494,9 +494,10 @@ } } - static const char* CONFIG_RESTRICT_TRANSFER_SYNTAXES = "RestrictTransferSyntaxes"; if (enableGdcm) { + static const char* CONFIG_RESTRICT_TRANSFER_SYNTAXES = "RestrictTransferSyntaxes"; + if (configuration[CONFIG_WEB_VIEWER].isMember(CONFIG_RESTRICT_TRANSFER_SYNTAXES)) { const Json::Value& config = configuration[CONFIG_WEB_VIEWER][CONFIG_RESTRICT_TRANSFER_SYNTAXES]; @@ -579,11 +580,11 @@ /* By default, use GDCM */ bool enableGdcm = true; - /* By default, a cache of 100 MB is used */ - int cacheSize = 100; - try { + /* By default, a cache of 100 MB is used */ + int cacheSize = 100; + boost::filesystem::path cachePath; ParseConfiguration(enableGdcm, decodingThreads, cachePath, cacheSize);
--- a/Plugin/ViewerPrefetchPolicy.h Fri Apr 20 14:23:34 2018 +0200 +++ b/Plugin/ViewerPrefetchPolicy.h Mon Apr 23 11:42:31 2018 +0200 @@ -42,7 +42,8 @@ const std::string& path); public: - ViewerPrefetchPolicy(OrthancPluginContext* context) : context_(context) + explicit ViewerPrefetchPolicy(OrthancPluginContext* context) : + context_(context) { }