# HG changeset patch # User Alain Mazy # Date 1778516164 -7200 # Node ID 1e3cecbb1310bc5725e1b18ec00929504a571d41 # Parent 8eea67b02a17ea995a0b3310156581d67284ab70 clang-tidy (cont) diff -r 8eea67b02a17 -r 1e3cecbb1310 OrthancFramework/Sources/MetricsRegistry.cpp --- a/OrthancFramework/Sources/MetricsRegistry.cpp Mon May 11 17:54:44 2026 +0200 +++ b/OrthancFramework/Sources/MetricsRegistry.cpp Mon May 11 18:16:04 2026 +0200 @@ -323,7 +323,7 @@ virtual void SetInitialValue(int64_t value) ORTHANC_OVERRIDE { - value_.Update(value, MetricsUpdatePolicy_Directly); + value_.Update(static_cast(value), MetricsUpdatePolicy_Directly); } }; diff -r 8eea67b02a17 -r 1e3cecbb1310 OrthancFramework/Sources/SQLite/Statement.cpp --- a/OrthancFramework/Sources/SQLite/Statement.cpp Mon May 11 17:54:44 2026 +0200 +++ b/OrthancFramework/Sources/SQLite/Statement.cpp Mon May 11 18:16:04 2026 +0200 @@ -63,8 +63,8 @@ #else // Trace logging is enabled in debug builds # include "../Logging.h" -# define LOG_CREATE(message) CLOG(TRACE, SQLITE) << "SQLite::Statement create: " << message; -# define LOG_APPLY(message); // CLOG(TRACE, SQLITE) << "SQLite::Statement apply: " << message; +# define LOG_CREATE(message) CLOG(TRACE, SQLITE) << "SQLite::Statement create: " << (message); +# define LOG_APPLY(message); // CLOG(TRACE, SQLITE) << "SQLite::Statement apply: " << (message); #endif #include diff -r 8eea67b02a17 -r 1e3cecbb1310 OrthancFramework/UnitTestsSources/DicomMapTests.cpp --- a/OrthancFramework/UnitTestsSources/DicomMapTests.cpp Mon May 11 17:54:44 2026 +0200 +++ b/OrthancFramework/UnitTestsSources/DicomMapTests.cpp Mon May 11 18:16:04 2026 +0200 @@ -157,9 +157,9 @@ ASSERT_NE(defaultSeriesSignature, defaultStudySignature); ASSERT_NE(defaultSeriesSignature, defaultPatientSignature); - std::string patientSignature = DicomMap::GetMainDicomTagsSignature(ResourceType_Patient); - std::string studySignature = DicomMap::GetMainDicomTagsSignature(ResourceType_Study); - std::string seriesSignature = DicomMap::GetMainDicomTagsSignature(ResourceType_Series); + // std::string patientSignature = DicomMap::GetMainDicomTagsSignature(ResourceType_Patient); + // std::string studySignature = DicomMap::GetMainDicomTagsSignature(ResourceType_Study); + // std::string seriesSignature = DicomMap::GetMainDicomTagsSignature(ResourceType_Series); std::string instanceSignature = DicomMap::GetMainDicomTagsSignature(ResourceType_Instance); // // at start, default and current signature should be equal !! This is not true anymore since we have added new MainDicomTags in 1.12.5 @@ -473,7 +473,7 @@ // "800\0" in US COLMUNS tag - m.SetValue(DICOM_TAG_COLUMNS, "800\0", false); + m.SetValue(DICOM_TAG_COLUMNS, "800\\0", false); ASSERT_TRUE(m.GetValue(DICOM_TAG_COLUMNS).ParseFirstUnsignedInteger(ui)); ASSERT_EQ(800u, ui); m.SetValue(DICOM_TAG_COLUMNS, "800", false); @@ -1505,7 +1505,7 @@ } } } - catch (boost::filesystem::filesystem_error&) + catch (boost::filesystem::filesystem_error&) // NOLINT(bugprone-empty-catch) { } } diff -r 8eea67b02a17 -r 1e3cecbb1310 OrthancFramework/UnitTestsSources/RestApiTests.cpp --- a/OrthancFramework/UnitTestsSources/RestApiTests.cpp Mon May 11 17:54:44 2026 +0200 +++ b/OrthancFramework/UnitTestsSources/RestApiTests.cpp Mon May 11 18:16:04 2026 +0200 @@ -318,7 +318,7 @@ const HttpToolbox::Arguments& components, const UriComponents& trailing) ORTHANC_OVERRIDE { - return resource.Handle(*(RestApiGetCall*) NULL); + return resource.Handle(*(RestApiGetCall*) NULL); // NOLINT(clang-analyzer-core.NonNullParamChecker) } }; } @@ -1208,7 +1208,7 @@ chunk.resize(chunkSize); for (size_t i = 0; i < chunkSize; i++) { - chunk[i] = '0' + (pos % 10); + chunk[i] = static_cast('0' + (pos % 10)); pos++; } @@ -1266,7 +1266,7 @@ while (pos_ < size_ && i < chunk.size()) { - chunk[i] = '0' + (pos_ % 7); + chunk[i] = static_cast('0' + (pos_ % 7)); pos_++; i++; } diff -r 8eea67b02a17 -r 1e3cecbb1310 OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp --- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp Mon May 11 17:54:44 2026 +0200 +++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp Mon May 11 18:16:04 2026 +0200 @@ -148,7 +148,7 @@ target.set_is_case_sensitive(source.IsCaseSensitive()); target.set_is_mandatory(source.IsMandatory()); - target.mutable_values()->Reserve(source.GetValuesCount()); + target.mutable_values()->Reserve(static_cast(source.GetValuesCount())); for (size_t j = 0; j < source.GetValuesCount(); j++) { target.add_values(source.GetValue(j)); @@ -189,7 +189,7 @@ target.set_is_case_sensitive(source.IsCaseSensitive()); target.set_is_mandatory(source.IsMandatory()); - target.mutable_values()->Reserve(source.GetValuesCount()); + target.mutable_values()->Reserve(static_cast(source.GetValuesCount())); for (size_t j = 0; j < source.GetValuesCount(); j++) { target.add_values(source.GetValue(j)); @@ -383,7 +383,12 @@ requestSerialized.empty() ? NULL : requestSerialized.c_str(), requestSerialized.size())); - bool success = response.ParseFromArray(responseSerialized.data, responseSerialized.size); + if (responseSerialized.size > static_cast(std::numeric_limits::max())) + { + throw OrthancException(ErrorCode_DatabasePlugin, "Cannot unserialize protobuf originating from the database plugin, response size too large"); + } + + bool success = response.ParseFromArray(responseSerialized.data, static_cast(responseSerialized.size)); if (responseSerialized.size > 0) { @@ -1307,7 +1312,7 @@ request.mutable_lookup_resources()->set_limit(limit); request.mutable_lookup_resources()->set_retrieve_instances_ids(instancesId != NULL); - request.mutable_lookup_resources()->mutable_lookup()->Reserve(lookup.GetSize()); + request.mutable_lookup_resources()->mutable_lookup()->Reserve(static_cast(lookup.GetSize())); for (size_t i = 0; i < lookup.GetSize(); i++) { @@ -1387,7 +1392,7 @@ { DatabasePluginMessages::TransactionRequest request; - request.mutable_set_resources_content()->mutable_tags()->Reserve(content.GetListTags().size()); + request.mutable_set_resources_content()->mutable_tags()->Reserve(static_cast(content.GetListTags().size())); for (ResourcesContent::ListTags::const_iterator it = content.GetListTags().begin(); it != content.GetListTags().end(); ++it) { DatabasePluginMessages::SetResourcesContent_Request_Tag* tag = request.mutable_set_resources_content()->add_tags(); @@ -1398,7 +1403,7 @@ tag->set_value(it->GetValue()); } - request.mutable_set_resources_content()->mutable_metadata()->Reserve(content.GetListMetadata().size()); + request.mutable_set_resources_content()->mutable_metadata()->Reserve(static_cast(content.GetListMetadata().size())); for (ResourcesContent::ListMetadata::const_iterator it = content.GetListMetadata().begin(); it != content.GetListMetadata().end(); ++it) { DatabasePluginMessages::SetResourcesContent_Request_Metadata* metadata = request.mutable_set_resources_content()->add_metadata(); diff -r 8eea67b02a17 -r 1e3cecbb1310 OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Mon May 11 17:54:44 2026 +0200 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Mon May 11 18:16:04 2026 +0200 @@ -2349,7 +2349,7 @@ } const DicomValue* value; - if ((value = summary_.TestAndGetValue(DICOM_TAG_SOP_CLASS_UID)) != NULL && + if ((value = summary_.TestAndGetValue(DICOM_TAG_SOP_CLASS_UID)) != NULL && // NOLINT(bugprone-assignment-in-if-condition) !value->IsNull() && !value->IsBinary()) { @@ -2574,10 +2574,10 @@ const DicomValue* value; const DicomValue* value2; - if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGES_IN_ACQUISITION)) != NULL && + if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGES_IN_ACQUISITION)) != NULL && // NOLINT(bugprone-assignment-in-if-condition) !value->IsNull() && !value->IsBinary() && - (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS)) != NULL && + (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS)) != NULL && // NOLINT(bugprone-assignment-in-if-condition) !value2->IsNull() && !value2->IsBinary()) { @@ -2588,10 +2588,10 @@ return (target > 0); } - else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_SLICES)) != NULL && + else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_SLICES)) != NULL && // NOLINT(bugprone-assignment-in-if-condition) !value->IsNull() && !value->IsBinary() && - (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TIME_SLICES)) != NULL && + (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TIME_SLICES)) != NULL && // NOLINT(bugprone-assignment-in-if-condition) !value2->IsBinary() && !value2->IsNull()) { @@ -2602,7 +2602,7 @@ return (target > 0); } - else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES)) != NULL && + else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES)) != NULL && // NOLINT(bugprone-assignment-in-if-condition) !value->IsNull() && !value->IsBinary()) { @@ -2610,10 +2610,10 @@ return (target > 0); } } - catch (OrthancException&) + catch (OrthancException&) // NOLINT(bugprone-empty-catch) { } - catch (boost::bad_lexical_cast&) + catch (boost::bad_lexical_cast&) // NOLINT(bugprone-empty-catch) { } @@ -2928,7 +2928,7 @@ } const DicomValue* value; - if ((value = dicomSummary_.TestAndGetValue(DICOM_TAG_SOP_CLASS_UID)) != NULL && + if ((value = dicomSummary_.TestAndGetValue(DICOM_TAG_SOP_CLASS_UID)) != NULL && // NOLINT(bugprone-assignment-in-if-condition) !value->IsNull() && !value->IsBinary()) { @@ -2937,8 +2937,8 @@ } - if ((value = dicomSummary_.TestAndGetValue(DICOM_TAG_INSTANCE_NUMBER)) != NULL || - (value = dicomSummary_.TestAndGetValue(DICOM_TAG_IMAGE_INDEX)) != NULL) + if ((value = dicomSummary_.TestAndGetValue(DICOM_TAG_INSTANCE_NUMBER)) != NULL || // NOLINT(bugprone-assignment-in-if-condition) + (value = dicomSummary_.TestAndGetValue(DICOM_TAG_IMAGE_INDEX)) != NULL) // NOLINT(bugprone-assignment-in-if-condition) { if (!value->IsNull() && !value->IsBinary())