Mercurial > hg > orthanc
changeset 4199:fbc49a65340a
cppcheck
line wrap: on
line diff
--- a/OrthancFramework/Sources/Cache/LeastRecentlyUsedIndex.h Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/Cache/LeastRecentlyUsedIndex.h Wed Sep 16 20:28:20 2020 +0200 @@ -146,12 +146,11 @@ { keys.clear(); keys.reserve(GetSize()); - for (typename Index::const_iterator it = index_.begin(); it != index_.end(); it++) + for (typename Index::const_iterator it = index_.begin(); it != index_.end(); ++it) { keys.push_back(it->first); } } - }; @@ -168,7 +167,7 @@ assert(index_.size() == queue_.size()); for (typename Index::const_iterator - it = index_.begin(); it != index_.end(); it++) + it = index_.begin(); it != index_.end(); ++it) { assert(it->second != queue_.end()); assert(it->second->first == it->first);
--- a/OrthancFramework/Sources/Cache/MemoryStringCache.cpp Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/Cache/MemoryStringCache.cpp Wed Sep 16 20:28:20 2020 +0200 @@ -31,7 +31,7 @@ std::string content_; public: - StringValue(const std::string& content) : + explicit StringValue(const std::string& content) : content_(content) { }
--- a/OrthancFramework/Sources/Cache/SharedArchive.h Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/Cache/SharedArchive.h Wed Sep 16 20:28:20 2020 +0200 @@ -70,7 +70,7 @@ }; - SharedArchive(size_t maxSize); + explicit SharedArchive(size_t maxSize); ~SharedArchive();
--- a/OrthancFramework/Sources/Compression/GzipCompressor.h Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/Compression/GzipCompressor.h Wed Sep 16 20:28:20 2020 +0200 @@ -23,6 +23,7 @@ #pragma once #include "DeflateBaseCompressor.h" +#include "../Enumerations.h" // For ORTHANC_OVERRIDE namespace Orthanc { @@ -40,10 +41,10 @@ virtual void Compress(std::string& compressed, const void* uncompressed, - size_t uncompressedSize); + size_t uncompressedSize) ORTHANC_OVERRIDE; virtual void Uncompress(std::string& uncompressed, const void* compressed, - size_t compressedSize); + size_t compressedSize) ORTHANC_OVERRIDE; }; }
--- a/OrthancFramework/Sources/Compression/HierarchicalZipWriter.h Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/Compression/HierarchicalZipWriter.h Wed Sep 16 20:28:20 2020 +0200 @@ -84,7 +84,7 @@ ZipWriter writer_; public: - HierarchicalZipWriter(const char* path); + explicit HierarchicalZipWriter(const char* path); ~HierarchicalZipWriter();
--- a/OrthancFramework/Sources/Compression/ZlibCompressor.h Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/Compression/ZlibCompressor.h Wed Sep 16 20:28:20 2020 +0200 @@ -23,6 +23,7 @@ #pragma once #include "DeflateBaseCompressor.h" +#include "../Enumerations.h" // For ORTHANC_OVERRIDE namespace Orthanc { @@ -36,10 +37,10 @@ virtual void Compress(std::string& compressed, const void* uncompressed, - size_t uncompressedSize); + size_t uncompressedSize) ORTHANC_OVERRIDE; virtual void Uncompress(std::string& uncompressed, const void* compressed, - size_t compressedSize); + size_t compressedSize) ORTHANC_OVERRIDE; }; }
--- a/OrthancFramework/Sources/DicomFormat/DicomInstanceHasher.h Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/DicomFormat/DicomInstanceHasher.h Wed Sep 16 20:28:20 2020 +0200 @@ -55,7 +55,7 @@ const std::string& instanceUid); public: - DicomInstanceHasher(const DicomMap& instance); + explicit DicomInstanceHasher(const DicomMap& instance); DicomInstanceHasher(const std::string& patientId, const std::string& studyUid,
--- a/OrthancFramework/Sources/DicomFormat/DicomMap.cpp Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/DicomFormat/DicomMap.cpp Wed Sep 16 20:28:20 2020 +0200 @@ -190,7 +190,7 @@ { } - DicomTag2(const DicomTag& tag) : + explicit DicomTag2(const DicomTag& tag) : DicomTag(tag) { } @@ -212,7 +212,7 @@ { assert(target.find(tags[i].name_) == target.end()); - target[tags[i].name_] = tags[i].tag_; + target[tags[i].name_] = DicomTag2(tags[i].tag_); } } @@ -1230,43 +1230,43 @@ bool supported = true; std::string s; - for (Json::Value::ArrayIndex i = 0; i < value.size() && supported; i++) + for (Json::Value::ArrayIndex j = 0; j < value.size() && supported; j++) { if (!s.empty()) { s += '\\'; } - switch (value[i].type()) + switch (value[j].type()) { case Json::objectValue: if (vr == ValueRepresentation_PersonName && - value[i].type() == Json::objectValue) + value[j].type() == Json::objectValue) { - if (value[i].isMember(ALPHABETIC) && - value[i][ALPHABETIC].type() == Json::stringValue) + if (value[j].isMember(ALPHABETIC) && + value[j][ALPHABETIC].type() == Json::stringValue) { - s += value[i][ALPHABETIC].asString(); + s += value[j][ALPHABETIC].asString(); } bool hasIdeographic = false; - if (value[i].isMember(IDEOGRAPHIC) && - value[i][IDEOGRAPHIC].type() == Json::stringValue) + if (value[j].isMember(IDEOGRAPHIC) && + value[j][IDEOGRAPHIC].type() == Json::stringValue) { - s += '=' + value[i][IDEOGRAPHIC].asString(); + s += '=' + value[j][IDEOGRAPHIC].asString(); hasIdeographic = true; } - if (value[i].isMember(PHONETIC) && - value[i][PHONETIC].type() == Json::stringValue) + if (value[j].isMember(PHONETIC) && + value[j][PHONETIC].type() == Json::stringValue) { if (!hasIdeographic) { s += '='; } - s += '=' + value[i][PHONETIC].asString(); + s += '=' + value[j][PHONETIC].asString(); } } else @@ -1278,19 +1278,19 @@ break; case Json::stringValue: - s += value[i].asString(); + s += value[j].asString(); break; case Json::intValue: - s += boost::lexical_cast<std::string>(value[i].asInt()); + s += boost::lexical_cast<std::string>(value[j].asInt()); break; case Json::uintValue: - s += boost::lexical_cast<std::string>(value[i].asUInt()); + s += boost::lexical_cast<std::string>(value[j].asUInt()); break; case Json::realValue: - s += boost::lexical_cast<std::string>(value[i].asDouble()); + s += boost::lexical_cast<std::string>(value[j].asDouble()); break; default:
--- a/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp Wed Sep 16 20:28:20 2020 +0200 @@ -70,10 +70,10 @@ DcmDataset *responseIdentifiers /* pending response identifiers */ ) { - FindPayload& payload = *reinterpret_cast<FindPayload*>(callbackData); - if (responseIdentifiers != NULL) { + FindPayload& payload = *reinterpret_cast<FindPayload*>(callbackData); + if (payload.isWorklist) { ParsedDicomFile answer(*responseIdentifiers); @@ -654,7 +654,7 @@ void DicomControlUserConnection::FindWorklist(DicomFindAnswers& result, - ParsedDicomFile& query) + const ParsedDicomFile& query) { DcmDataset* dataset = query.GetDcmtkObject().getDataset(); const char* sopClass = UID_FINDModalityWorklistInformationModel;
--- a/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.h Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.h Wed Sep 16 20:28:20 2020 +0200 @@ -54,7 +54,7 @@ const DicomMap& fields); public: - DicomControlUserConnection(const DicomAssociationParameters& params); + explicit DicomControlUserConnection(const DicomAssociationParameters& params); const DicomAssociationParameters& GetParameters() const { @@ -93,6 +93,6 @@ const std::string& instanceUid); void FindWorklist(DicomFindAnswers& result, - ParsedDicomFile& query); + const ParsedDicomFile& query); }; }
--- a/OrthancFramework/Sources/DicomNetworking/DicomFindAnswers.h Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/DicomNetworking/DicomFindAnswers.h Wed Sep 16 20:28:20 2020 +0200 @@ -37,7 +37,7 @@ void AddAnswerInternal(ParsedDicomFile* answer); public: - DicomFindAnswers(bool isWorklist); + explicit DicomFindAnswers(bool isWorklist); ~DicomFindAnswers() {
--- a/OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.h Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.h Wed Sep 16 20:28:20 2020 +0200 @@ -96,7 +96,7 @@ DicomTransferSyntax sourceSyntax); public: - DicomStoreUserConnection(const DicomAssociationParameters& params); + explicit DicomStoreUserConnection(const DicomAssociationParameters& params); const DicomAssociationParameters& GetParameters() const {
--- a/OrthancFramework/Sources/DicomNetworking/Internals/CommandDispatcher.cpp Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/DicomNetworking/Internals/CommandDispatcher.cpp Wed Sep 16 20:28:20 2020 +0200 @@ -137,20 +137,17 @@ const char* transferSyntax, T_ASC_SC_ROLE acceptedRole) { - OFCondition cond = EC_Normal; int n, i, k; DUL_PRESENTATIONCONTEXT *dpc; T_ASC_PresentationContext pc; - OFBool accepted = OFFalse; - OFBool abstractOK = OFFalse; n = ASC_countPresentationContexts(params); for (i = 0; i < n; i++) { - cond = ASC_getPresentationContext(params, i, &pc); + OFCondition cond = ASC_getPresentationContext(params, i, &pc); if (cond.bad()) return cond; - abstractOK = OFFalse; - accepted = OFFalse; + OFBool abstractOK = OFFalse; + OFBool accepted = OFFalse; if (dcmFindNameOfUID(pc.abstractSyntax) == NULL) { @@ -178,7 +175,7 @@ /* do not refuse if already accepted */ dpc = findPresentationContextID(params->DULparams.acceptedPresentationContext, pc.presentationContextID); - if ((dpc == NULL) || ((dpc != NULL) && (dpc->result != ASC_P_ACCEPTANCE))) + if (dpc == NULL || dpc->result != ASC_P_ACCEPTANCE) { if (abstractOK) {
--- a/OrthancFramework/Sources/DicomNetworking/RemoteModalityParameters.h Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/DicomNetworking/RemoteModalityParameters.h Wed Sep 16 20:28:20 2020 +0200 @@ -58,7 +58,7 @@ Clear(); } - RemoteModalityParameters(const Json::Value& serialized) + explicit RemoteModalityParameters(const Json::Value& serialized) { Unserialize(serialized); }
--- a/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h Wed Sep 16 20:28:20 2020 +0200 @@ -98,12 +98,11 @@ ParsedDicomFile(DcmFileFormat* dicom); // This takes ownership (no clone) public: - ParsedDicomFile(bool createIdentifiers); // Create a minimal DICOM instance + explicit ParsedDicomFile(bool createIdentifiers); // Create a minimal DICOM instance ParsedDicomFile(const DicomMap& map, Encoding defaultEncoding, - bool permissive - ); + bool permissive); ParsedDicomFile(const DicomMap& map, Encoding defaultEncoding, @@ -114,11 +113,11 @@ ParsedDicomFile(const void* content, size_t size); - ParsedDicomFile(const std::string& content); + explicit ParsedDicomFile(const std::string& content); - ParsedDicomFile(DcmDataset& dicom); // This clones the DCMTK object + explicit ParsedDicomFile(DcmDataset& dicom); // This clones the DCMTK object - ParsedDicomFile(DcmFileFormat& dicom); // This clones the DCMTK object + explicit ParsedDicomFile(DcmFileFormat& dicom); // This clones the DCMTK object static ParsedDicomFile* AcquireDcmtkObject(DcmFileFormat* dicom) // No clone here {
--- a/OrthancFramework/Sources/HttpServer/HttpFileSender.h Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/HttpServer/HttpFileSender.h Wed Sep 16 20:28:20 2020 +0200 @@ -61,13 +61,13 @@ **/ virtual HttpCompression SetupHttpCompression(bool /*gzipAllowed*/, - bool /*deflateAllowed*/) + bool /*deflateAllowed*/) ORTHANC_OVERRIDE { return HttpCompression_None; } - virtual bool HasContentFilename(std::string& filename); + virtual bool HasContentFilename(std::string& filename) ORTHANC_OVERRIDE; - virtual std::string GetContentType(); + virtual std::string GetContentType() ORTHANC_OVERRIDE; }; }
--- a/OrthancFramework/Sources/Toolbox.h Wed Sep 16 18:13:13 2020 +0200 +++ b/OrthancFramework/Sources/Toolbox.h Wed Sep 16 20:28:20 2020 +0200 @@ -88,7 +88,7 @@ void FindEndOfLine(); public: - LinesIterator(const std::string& content); + explicit LinesIterator(const std::string& content); bool GetLine(std::string& target) const;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancServer/Resources/RunCppCheck.sh Wed Sep 16 20:28:20 2020 +0200 @@ -0,0 +1,61 @@ +#!/bin/bash + +set -ex + +CPPCHECK=cppcheck + +if [ $# -ge 1 ]; then + CPPCHECK=$1 +fi + +${CPPCHECK} --enable=all --quiet --std=c++11 \ + -DBOOST_HAS_DATE_TIME=1 \ + -DBOOST_HAS_FILESYSTEM_V3=1 \ + -DBOOST_HAS_REGEX=1 \ + -DCIVETWEB_HAS_DISABLE_KEEP_ALIVE=1 \ + -DDCMTK_VERSION_NUMBER=365 \ + -DMONGOOSE_USE_CALLBACKS=1 \ + -DORTHANC_BUILDING_FRAMEWORK_LIBRARY=0 \ + -DORTHANC_BUILDING_SERVER_LIBRARY=1 \ + -DORTHANC_BUILD_UNIT_TESTS=1 \ + -DORTHANC_ENABLE_BASE64=1 \ + -DORTHANC_ENABLE_CIVETWEB=1 \ + -DORTHANC_ENABLE_CURL=1 \ + -DORTHANC_ENABLE_DCMTK=1 \ + -DORTHANC_ENABLE_DCMTK_JPEG=1 \ + -DORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS=1 \ + -DORTHANC_ENABLE_DCMTK_NETWORKING=1 \ + -DORTHANC_ENABLE_DCMTK_TRANSCODING=1 \ + -DORTHANC_ENABLE_JPEG=1 \ + -DORTHANC_ENABLE_LOCALE=1 \ + -DORTHANC_ENABLE_LOGGING=1 \ + -DORTHANC_ENABLE_LOGGING_STDIO=1 \ + -DORTHANC_ENABLE_LUA=1 \ + -DORTHANC_ENABLE_MD5=1 \ + -DORTHANC_ENABLE_MONGOOSE=0 \ + -DORTHANC_ENABLE_PKCS11=1 \ + -DORTHANC_ENABLE_PLUGINS=1 \ + -DORTHANC_ENABLE_PNG=1 \ + -DORTHANC_ENABLE_PUGIXML=1 \ + -DORTHANC_ENABLE_SQLITE=1 \ + -DORTHANC_ENABLE_SSL=1 \ + -DORTHANC_ENABLE_ZLIB=1 \ + -DORTHANC_SANDBOXED=0 \ + -DORTHANC_SQLITE_VERSION=3027001 \ + -DORTHANC_UNIT_TESTS_LINK_FRAMEWORK=1 \ + -DPUGIXML_VERSION=150 \ + -DUNIT_TESTS_WITH_HTTP_CONNEXIONS=1 \ + -D__BYTE_ORDER=__LITTLE_ENDIAN \ + -D__GNUC__ \ + -D__cplusplus=201103 \ + -D__linux__ \ + -UNDEBUG \ + \ + ../../OrthancFramework/Sources \ + ../../OrthancFramework/UnitTestsSources \ + ../../OrthancServer/Plugins/Engine \ + ../../OrthancServer/Plugins/Include \ + ../../OrthancServer/Sources \ + ../../OrthancServer/UnitTestsSources \ + \ + 2>&1 | grep -vE '\[unusedFunction\]$|^\^$|^$|function .* is never used'