Mercurial > hg > orthanc-dicomweb
changeset 753:e4ef25e1fcba
cppcheck
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Tue, 14 Apr 2026 15:42:56 +0200 |
| parents | d0bdedd75ff7 |
| children | d7c34b3f0b51 |
| files | Plugin/Configuration.cpp Plugin/DicomWebClient.cpp Plugin/Plugin.cpp Plugin/QidoRs.cpp Plugin/WadoRs.cpp Plugin/WadoRsRetrieveFrames.cpp Plugin/WeightedAverageMetrics.h |
| diffstat | 7 files changed, 50 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugin/Configuration.cpp Tue Apr 14 14:31:12 2026 +0200 +++ b/Plugin/Configuration.cpp Tue Apr 14 15:42:56 2026 +0200 @@ -447,9 +447,10 @@ } // Remove the trailing slash, if any - if (root[root.length() - 1] == '/') + if (!root.empty() && + root[root.length() - 1] == '/') { - root = root.substr(0, root.length() - 1); + root.resize(root.length() - 1); } return root;
--- a/Plugin/DicomWebClient.cpp Tue Apr 14 14:31:12 2026 +0200 +++ b/Plugin/DicomWebClient.cpp Tue Apr 14 15:42:56 2026 +0200 @@ -229,7 +229,7 @@ { } - virtual ~SingleFunctionJob() + virtual ~SingleFunctionJob() ORTHANC_OVERRIDE { if (worker_.get() != NULL) { @@ -694,7 +694,7 @@ { } - virtual void Execute(JobContext& context) + virtual void Execute(JobContext& context) ORTHANC_OVERRIDE { std::string serverName; size_t startPosition; @@ -718,7 +718,6 @@ client->AddHeaders(that_.headers_); } - OrthancPlugins::HttpHeaders answerHeaders; Json::Value answerBody; assert(client.get() != NULL); @@ -726,6 +725,7 @@ try { + OrthancPlugins::HttpHeaders answerHeaders; client->Execute(answerHeaders, answerBody); } catch (Orthanc::OrthancException&) @@ -1040,7 +1040,7 @@ size_t pos = contentType.find(';'); if (pos != std::string::npos) { - contentType = contentType.substr(0, pos); + contentType.resize(pos); } contentType = Orthanc::Toolbox::StripSpaces(contentType); @@ -1081,7 +1081,7 @@ { } - virtual ~WadoRetrieveAnswer() + virtual ~WadoRetrieveAnswer() ORTHANC_OVERRIDE { } @@ -1245,7 +1245,7 @@ { } - virtual void Execute(JobContext& context) + virtual void Execute(JobContext& context) ORTHANC_OVERRIDE { for (;;) { @@ -1428,7 +1428,7 @@ SetFactory(*this); } - virtual ~WadoRetrieveJob() + virtual ~WadoRetrieveJob() ORTHANC_OVERRIDE { SingleFunctionJob::Finalize();
--- a/Plugin/Plugin.cpp Tue Apr 14 14:31:12 2026 +0200 +++ b/Plugin/Plugin.cpp Tue Apr 14 15:42:56 2026 +0200 @@ -747,8 +747,7 @@ } - std::string uri = root + "app/client/index.html"; - OrthancPlugins::SetRootUri(ORTHANC_DICOM_WEB_NAME, uri.c_str()); + OrthancPlugins::SetRootUri(ORTHANC_DICOM_WEB_NAME, root + "app/client/index.html"); std::string publicUrlRoot = OrthancPlugins::Configuration::GetPublicRoot(); LOG(WARNING) << "DICOMweb public root: " << publicUrlRoot;
--- a/Plugin/QidoRs.cpp Tue Apr 14 14:31:12 2026 +0200 +++ b/Plugin/QidoRs.cpp Tue Apr 14 15:42:56 2026 +0200 @@ -244,7 +244,7 @@ } } - void Print(std::ostream& out) const + void Print() const { for (Filters::const_iterator it = filters_.begin(); it != filters_.end(); ++it)
--- a/Plugin/WadoRs.cpp Tue Apr 14 14:31:12 2026 +0200 +++ b/Plugin/WadoRs.cpp Tue Apr 14 15:42:56 2026 +0200 @@ -493,7 +493,7 @@ } } - virtual ~ThreadedInstanceLoader() + virtual ~ThreadedInstanceLoader() ORTHANC_OVERRIDE { Clear(); } @@ -596,7 +596,7 @@ { } - virtual ~SynchronousInstanceLoader() + virtual ~SynchronousInstanceLoader() ORTHANC_OVERRIDE { Clear(); } @@ -1205,7 +1205,7 @@ { instance.reset(OrthancPlugins::DicomInstance::Load(orthancId, OrthancPluginLoadDicomInstanceMode_EmptyPixelData)); } - catch (Orthanc::OrthancException& e) + catch (const Orthanc::OrthancException& e) { } @@ -1771,7 +1771,7 @@ { instance.reset(OrthancPlugins::DicomInstance::Load(instanceToLoad->GetOrthancId(), OrthancPluginLoadDicomInstanceMode_EmptyPixelData)); } - catch (Orthanc::OrthancException& e) + catch (const Orthanc::OrthancException& e) { } @@ -1889,7 +1889,6 @@ const std::string& seriesOrthancId) { Orthanc::GzipCompressor compressor; - std::string compressedSeriesMetadata; std::set<std::string> instancesIds; // compute the series metadata with a placeholder WADO base url because, the base url might change (e.g if there are 2 Orthanc connected to the same DB) @@ -1899,6 +1898,7 @@ if (!IsSystemReadOnly()) { // save in attachments for future use + std::string compressedSeriesMetadata; Orthanc::IBufferCompressor::Compress(compressedSeriesMetadata, compressor, serializedSeriesMetadata); std::string instancesMd5; Orthanc::Toolbox::ComputeMD5(instancesMd5, instancesIds); @@ -1940,15 +1940,14 @@ LOG(INFO) << "DicomWEB: pre-computing the WADO-RS series metadata for series " << seriesOrthancId; - std::string studyInstanceUid, seriesInstanceUid; - Json::Value result; if (OrthancPlugins::RestApiGet(result, "/series/" + seriesOrthancId, false)) { - seriesInstanceUid = result[MAIN_DICOM_TAGS]["SeriesInstanceUID"].asString(); + const std::string seriesInstanceUid = result[MAIN_DICOM_TAGS]["SeriesInstanceUID"].asString(); + if (OrthancPlugins::RestApiGet(result, "/studies/" + result["ParentStudy"].asString(), false)) { - studyInstanceUid = result[MAIN_DICOM_TAGS]["StudyInstanceUID"].asString(); + const std::string studyInstanceUid = result[MAIN_DICOM_TAGS]["StudyInstanceUID"].asString(); MainDicomTagsCache cache; OrthancPlugins::DicomWebFormatter::HttpWriter writer(NULL /* output */, false /* isXml */); // we cache only the JSON format -> no need for an HttpOutput
--- a/Plugin/WadoRsRetrieveFrames.cpp Tue Apr 14 14:31:12 2026 +0200 +++ b/Plugin/WadoRsRetrieveFrames.cpp Tue Apr 14 15:42:56 2026 +0200 @@ -62,7 +62,7 @@ -static bool ParseTransferSyntax(Orthanc::DicomTransferSyntax& syntax, +static void ParseTransferSyntax(Orthanc::DicomTransferSyntax& syntax, const OrthancPluginHttpRequest* request) { for (uint32_t i = 0; i < request->headersCount; i++) @@ -79,7 +79,7 @@ tokens[0] == "*/*") { syntax = Orthanc::DicomTransferSyntax_LittleEndianExplicit; - return true; + return; } if (tokens[0] != "multipart/related") @@ -118,12 +118,12 @@ if (transferSyntax.empty()) { syntax = Orthanc::DicomTransferSyntax_LittleEndianExplicit; - return true; + return; } else if (transferSyntax == "*") { // don't change transferSyntax, it must have been set to the 'current' value before calling this method - return true; + return; } else { @@ -132,7 +132,7 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented, "Unknown transfer syntax in 'Accept' header: " + transferSyntax); } - return true; + return; } } else @@ -145,22 +145,22 @@ transferSyntax == "1.2.840.10008.1.2.4.70")) { syntax = Orthanc::DicomTransferSyntax_JPEGProcess14SV1; - return true; + return; } else if (type == "image/jpeg" && transferSyntax == "1.2.840.10008.1.2.4.50") { syntax = Orthanc::DicomTransferSyntax_JPEGProcess1; - return true; + return; } else if (type == "image/jpeg" && transferSyntax == "1.2.840.10008.1.2.4.51") { syntax = Orthanc::DicomTransferSyntax_JPEGProcess2_4; - return true; + return; } else if (type == "image/jpeg" && transferSyntax == "1.2.840.10008.1.2.4.57") { syntax = Orthanc::DicomTransferSyntax_JPEGProcess14; - return true; + return; } else if ((type == "image/x-dicom-rle" || // Table 6.1.1.8-3b of DICOM 2017c (backward compatibility) type == "image/dicom-rle") && // Table 8.7.3-5 of DICOM 2021a @@ -168,7 +168,7 @@ transferSyntax == "1.2.840.10008.1.2.5")) { syntax = Orthanc::DicomTransferSyntax_RLELossless; - return true; + return; } else if ((type == "image/x-jls" || // Table 6.1.1.8-3b of DICOM 2017c (backward compatibility) type == "image/jls") && // Table 8.7.3-5 of DICOM 2021a @@ -176,36 +176,36 @@ transferSyntax == "1.2.840.10008.1.2.4.80")) { syntax = Orthanc::DicomTransferSyntax_JPEGLSLossless; - return true; + return; } else if ((type == "image/x-jls" || // Table 6.1.1.8-3b of DICOM 2017c (backward compatibility) type == "image/jls") && // Table 8.7.3-5 of DICOM 2021a transferSyntax == "1.2.840.10008.1.2.4.81") { syntax = Orthanc::DicomTransferSyntax_JPEGLSLossy; - return true; + return; } else if (type == "image/jp2" && (transferSyntax.empty() || // Default transferSyntax == "1.2.840.10008.1.2.4.90")) { syntax = Orthanc::DicomTransferSyntax_JPEG2000LosslessOnly; - return true; + return; } else if (type == "image/jp2" && transferSyntax == "1.2.840.10008.1.2.4.91") { syntax = Orthanc::DicomTransferSyntax_JPEG2000; - return true; + return; } else if (type == "image/jpx" && (transferSyntax.empty() || // Default transferSyntax == "1.2.840.10008.1.2.4.92")) { syntax = Orthanc::DicomTransferSyntax_JPEG2000MulticomponentLosslessOnly; - return true; + return; } else if (type == "image/jpx" && transferSyntax == "1.2.840.10008.1.2.4.93") { syntax = Orthanc::DicomTransferSyntax_JPEG2000Multicomponent; - return true; + return; } @@ -216,62 +216,62 @@ if (type == "image/dicom+jpeg" && transferSyntax == "1.2.840.10008.1.2.4.50") { syntax = Orthanc::DicomTransferSyntax_JPEGProcess1; - return true; + return; } else if (type == "image/dicom+jpeg" && transferSyntax == "1.2.840.10008.1.2.4.51") { syntax = Orthanc::DicomTransferSyntax_JPEGProcess2_4; - return true; + return; } else if (type == "image/dicom+jpeg" && transferSyntax == "1.2.840.10008.1.2.4.57") { syntax = Orthanc::DicomTransferSyntax_JPEGProcess14; - return true; + return; } else if (type == "image/dicom+jpeg" && (transferSyntax.empty() || transferSyntax == "1.2.840.10008.1.2.4.70")) { syntax = Orthanc::DicomTransferSyntax_JPEGProcess14SV1; - return true; + return; } else if (type == "image/dicom+rle" && (transferSyntax.empty() || transferSyntax == "1.2.840.10008.1.2.5")) { syntax = Orthanc::DicomTransferSyntax_RLELossless; - return true; + return; } else if (type == "image/dicom+jpeg-ls" && (transferSyntax.empty() || transferSyntax == "1.2.840.10008.1.2.4.80")) { syntax = Orthanc::DicomTransferSyntax_JPEGLSLossless; - return true; + return; } else if (type == "image/dicom+jpeg-ls" && transferSyntax == "1.2.840.10008.1.2.4.81") { syntax = Orthanc::DicomTransferSyntax_JPEGLSLossy; - return true; + return; } else if (type == "image/dicom+jp2" && (transferSyntax.empty() || transferSyntax == "1.2.840.10008.1.2.4.90")) { syntax = Orthanc::DicomTransferSyntax_JPEG2000LosslessOnly; - return true; + return; } else if (type == "image/dicom+jp2" && transferSyntax == "1.2.840.10008.1.2.4.91") { syntax = Orthanc::DicomTransferSyntax_JPEG2000; - return true; + return; } else if (type == "image/dicom+jpx" && (transferSyntax.empty() || transferSyntax == "1.2.840.10008.1.2.4.92")) { syntax = Orthanc::DicomTransferSyntax_JPEG2000MulticomponentLosslessOnly; - return true; + return; } else if (type == "image/dicom+jpx" && transferSyntax == "1.2.840.10008.1.2.4.93") { syntax = Orthanc::DicomTransferSyntax_JPEG2000Multicomponent; - return true; + return; } throw Orthanc::OrthancException( @@ -284,7 +284,6 @@ // By default, DICOMweb expects Little Endian uncompressed pixel data syntax = Orthanc::DicomTransferSyntax_LittleEndianExplicit; - return true; } @@ -518,12 +517,9 @@ targetSyntax = Orthanc::DicomTransferSyntax_LittleEndianExplicit; } - bool transcodeThisInstance = false; - if (ParseTransferSyntax(targetSyntax, request)) - { - transcodeThisInstance = targetSyntax != currentSyntax; - } + ParseTransferSyntax(targetSyntax, request); + const bool transcodeThisInstance = (targetSyntax != currentSyntax); // maximize the use the Orthanc storage cache. Since 1.12.2, transcoded file may be stored in the storage cache if (pluginCanDownloadTranscodedFile && transcodeThisInstance)
--- a/Plugin/WeightedAverageMetrics.h Tue Apr 14 14:31:12 2026 +0200 +++ b/Plugin/WeightedAverageMetrics.h Tue Apr 14 15:42:56 2026 +0200 @@ -75,7 +75,7 @@ } public: - WeightedAverageMetrics(int64_t duration) : + explicit WeightedAverageMetrics(int64_t duration) : totalWeightedValue_(0), totalWeight_(0), duration_(duration)
