# HG changeset patch # User Alain Mazy # Date 1762792432 -3600 # Node ID 60e32e4422183d1846a438982b0e81cec208d416 # Parent 3167e80eae75018dbec968ee59781702cc71bb11 cppcheck: variableScope diff -r 3167e80eae75 -r 60e32e442218 OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp --- a/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Fri Nov 07 18:51:42 2025 +0100 +++ b/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Mon Nov 10 17:33:52 2025 +0100 @@ -3630,9 +3630,9 @@ std::string source; Orthanc::SystemToolbox::ReadFile(source, SystemToolbox::PathFromUtf8(path)); - std::string c, k; try { + std::string c, k; scu.Transcode(c, k, transcoder, source.c_str(), source.size(), DicomTransferSyntax_LittleEndianExplicit, false, "", 0); } @@ -3678,8 +3678,6 @@ std::set s; s.insert(a); - std::string t; - IDicomTranscoder::DicomImage source, target; source.AcquireParsed(dynamic_cast(toto->clone())); @@ -3698,7 +3696,6 @@ a == DicomTransferSyntax_JPEGProcess2_4 || a == DicomTransferSyntax_JPEGLSLossy); - printf("SIZE: %d\n", static_cast(t.size())); if (sourceUid == IDicomTranscoder::GetSopInstanceUid(target.GetParsed())) { ASSERT_FALSE(lossy); diff -r 3167e80eae75 -r 60e32e442218 OrthancFramework/UnitTestsSources/JobsTests.cpp --- a/OrthancFramework/UnitTestsSources/JobsTests.cpp Fri Nov 07 18:51:42 2025 +0100 +++ b/OrthancFramework/UnitTestsSources/JobsTests.cpp Mon Nov 10 17:33:52 2025 +0100 @@ -282,10 +282,10 @@ TEST(MultiThreading, SharedMessageQueueClean) { - std::set s; - try { + std::set s; + SharedMessageQueue q; q.Enqueue(new DynamicInteger(10, s)); q.Enqueue(new DynamicInteger(20, s)); @@ -740,10 +740,10 @@ engine.SetWorkersCount(3); engine.Start(); - std::string id; SequenceOfOperationsJob* job = NULL; { + std::string id; std::unique_ptr a(new SequenceOfOperationsJob); job = a.get(); engine.GetRegistry().Submit(id, a.release(), 0); @@ -1137,9 +1137,9 @@ TEST(JobsSerialization, Registry) { Json::Value s; - std::string i1, i2; { + std::string i1, i2; JobsRegistry registry(10); registry.Submit(i1, new DummyJob(), 10); registry.Submit(i2, new SequenceOfOperationsJob(), 30); diff -r 3167e80eae75 -r 60e32e442218 OrthancServer/Plugins/Samples/Housekeeper/Plugin.cpp --- a/OrthancServer/Plugins/Samples/Housekeeper/Plugin.cpp Fri Nov 07 18:51:42 2025 +0100 +++ b/OrthancServer/Plugins/Samples/Housekeeper/Plugin.cpp Mon Nov 10 17:33:52 2025 +0100 @@ -107,7 +107,7 @@ bool isInPeriod() const { time_t now = time(NULL); - tm* nowLocalTime = localtime(&now); + const tm* nowLocalTime = localtime(&now); if (nowLocalTime->tm_wday != weekday_) { diff -r 3167e80eae75 -r 60e32e442218 OrthancServer/Resources/RunCppCheck.sh --- a/OrthancServer/Resources/RunCppCheck.sh Fri Nov 07 18:51:42 2025 +0100 +++ b/OrthancServer/Resources/RunCppCheck.sh Mon Nov 10 17:33:52 2025 +0100 @@ -39,9 +39,18 @@ assertWithSideEffect:../../OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp:3066 assertWithSideEffect:../../OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp:286 assertWithSideEffect:../../OrthancFramework/Sources/DicomNetworking/Internals/CommandDispatcher.cpp:454 +variableScope:../../OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp:228 +variableScope:../../OrthancServer/Sources/ServerJobs/OrthancPeerStoreJob.cpp:94 EOF -${CPPCHECK} --enable=all --quiet --std=c++11 \ +# TODO: re-enable nullPointerOutOfMemory + +${CPPCHECK} -j 8 --enable=all --quiet --std=c++11 \ + --suppress=missingIncludeSystem \ + --suppress=missingInclude \ + --suppress=useStlAlgorithm \ + --suppress:nullPointerOutOfMemory \ + --check-level=exhaustive \ --suppressions-list=/tmp/cppcheck-suppressions.txt \ -DBOOST_HAS_DATE_TIME=1 \ -DBOOST_HAS_FILESYSTEM_V3=1 \ diff -r 3167e80eae75 -r 60e32e442218 OrthancServer/Sources/OrthancGetRequestHandler.cpp --- a/OrthancServer/Sources/OrthancGetRequestHandler.cpp Fri Nov 07 18:51:42 2025 +0100 +++ b/OrthancServer/Sources/OrthancGetRequestHandler.cpp Mon Nov 10 17:33:52 2025 +0100 @@ -137,9 +137,10 @@ LST_Position(l, (LST_NODE*)pc); while (pc) { - DicomTransferSyntax transferSyntax; if (pc->result == ASC_P_ACCEPTANCE) { + DicomTransferSyntax transferSyntax; + if (LookupTransferSyntax(transferSyntax, pc->acceptedTransferSyntax)) { /*CLOG(TRACE, DICOM) << "C-GET SCP accepted: SOP class " << pc->abstractSyntax diff -r 3167e80eae75 -r 60e32e442218 OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp Fri Nov 07 18:51:42 2025 +0100 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp Mon Nov 10 17:33:52 2025 +0100 @@ -186,10 +186,10 @@ std::unique_ptr toStore(DicomInstanceToStore::CreateFromBuffer(content)); toStore->SetOrigin(DicomInstanceOrigin::FromRest(call)); - std::string publicId; - try { + std::string publicId; + ServerContext::StoreResult result = context.Store(publicId, *toStore, StoreInstanceMode_Default); Json::Value info; diff -r 3167e80eae75 -r 60e32e442218 OrthancServer/Sources/OrthancWebDav.cpp --- a/OrthancServer/Sources/OrthancWebDav.cpp Fri Nov 07 18:51:42 2025 +0100 +++ b/OrthancServer/Sources/OrthancWebDav.cpp Mon Nov 10 17:33:52 2025 +0100 @@ -1221,10 +1221,10 @@ std::unique_ptr instance(DicomInstanceToStore::CreateFromBuffer(uncompressedFile)); instance->SetOrigin(DicomInstanceOrigin::FromWebDav()); - std::string publicId; - try { + std::string publicId; + context_.Store(publicId, *instance, StoreInstanceMode_Default); } catch (OrthancException& e) diff -r 3167e80eae75 -r 60e32e442218 OrthancServer/Sources/ServerJobs/DicomGetScuJob.cpp --- a/OrthancServer/Sources/ServerJobs/DicomGetScuJob.cpp Fri Nov 07 18:51:42 2025 +0100 +++ b/OrthancServer/Sources/ServerJobs/DicomGetScuJob.cpp Mon Nov 10 17:33:52 2025 +0100 @@ -75,11 +75,12 @@ if (connection_.get() == NULL) { std::set sopClassesToPropose; - std::set acceptedSopClasses; std::list proposedTransferSyntaxes; if (sopClassesFromResourcesToRetrieve_.size() > 0) { + std::set acceptedSopClasses; + context_.GetAcceptedSopClasses(acceptedSopClasses, 0); // keep the sop classes from the resources to retrieve only if they are accepted by Orthanc diff -r 3167e80eae75 -r 60e32e442218 OrthancServer/Sources/SimpleInstanceOrdering.cpp --- a/OrthancServer/Sources/SimpleInstanceOrdering.cpp Fri Nov 07 18:51:42 2025 +0100 +++ b/OrthancServer/Sources/SimpleInstanceOrdering.cpp Mon Nov 10 17:33:52 2025 +0100 @@ -96,7 +96,6 @@ for (size_t i = 0; i < response.GetSize(); ++i) { const FindResponse::Resource& resource = response.GetResourceByIndex(i); - std::string instanceId = resource.GetIdentifier(); std::string strIndexInSeries; uint32_t indexInSeries = 0; @@ -110,6 +109,8 @@ if (resource.LookupAttachment(fileInfo, revisionNotUsed, FileContentType_Dicom)) { + std::string instanceId = resource.GetIdentifier(); + allIndexInSeries.insert(indexInSeries); instances_.push_back(new SimpleInstanceOrdering::Instance(instanceId, indexInSeries, fileInfo)); } diff -r 3167e80eae75 -r 60e32e442218 OrthancServer/Sources/SliceOrdering.cpp --- a/OrthancServer/Sources/SliceOrdering.cpp Fri Nov 07 18:51:42 2025 +0100 +++ b/OrthancServer/Sources/SliceOrdering.cpp Mon Nov 10 17:33:52 2025 +0100 @@ -192,12 +192,12 @@ } hasNormal_ = ComputeNormal(normal_, instance); - - std::string s; hasIndexInSeries_ = false; try { + std::string s; + if (index.LookupMetadata(s, instanceId, ResourceType_Instance, MetadataType_Instance_IndexInSeries)) { indexInSeries_ = boost::lexical_cast(Toolbox::StripSpaces(s));