From 32b79573db66702200ce371b1f56f6f9c79fd2d2 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Mon, 3 Aug 2026 13:55:24 -0500 Subject: [PATCH] Fix straggling errors --- form/root_storage/root_tbranch_read_container.cpp | 6 ++++-- form/root_storage/root_tbranch_write_container.cpp | 5 ++--- form/root_storage/root_ttree_write_container.cpp | 8 +++++--- form/root_storage/root_ttree_write_container.hpp | 1 + form/storage/storage_reader.cpp | 1 - phlex/core/framework_graph.hpp | 3 ++- test/core_misc_test.cpp | 4 ++-- test/fold_duplicate_layer_name_test.cpp | 2 +- test/unfold.cpp | 5 +---- 9 files changed, 18 insertions(+), 17 deletions(-) diff --git a/form/root_storage/root_tbranch_read_container.cpp b/form/root_storage/root_tbranch_read_container.cpp index b37c3d6fc..ba11df128 100644 --- a/form/root_storage/root_tbranch_read_container.cpp +++ b/form/root_storage/root_tbranch_read_container.cpp @@ -31,7 +31,7 @@ ROOT_TBranch_Read_ContainerImp::ROOT_TBranch_Read_ContainerImp(std::string const void ROOT_TBranch_Read_ContainerImp::setFile(std::shared_ptr file) { - ROOT_TFileImp* root_tfile_imp = dynamic_cast(file.get()); + auto* root_tfile_imp = dynamic_cast(file.get()); if (root_tfile_imp == nullptr) { throw std::runtime_error( "ROOT_TBranch_Read_ContainerImp::setFile can't attach to non-ROOT file"); @@ -166,7 +166,9 @@ bool ROOT_TBranch_Read_ContainerImp::read(int id, void const** data, std::type_i " (col_name='" + col_name() + "', type='" + DemangleName(type) + "')"); } - branchBuffer = klass->New(); + // ROOT returns ownership of dynamically created branch payload objects here. + // NOLINTNEXTLINE(readability-redundant-casting) + branchBuffer = gsl::owner{klass->New()}; branchStatus = m_tree->SetBranchAddress( col_name().c_str(), reinterpret_cast(&branchBuffer), klass, EDataType::kOther_t, true); } diff --git a/form/root_storage/root_tbranch_write_container.cpp b/form/root_storage/root_tbranch_write_container.cpp index 70d311bbc..c786d00fd 100644 --- a/form/root_storage/root_tbranch_write_container.cpp +++ b/form/root_storage/root_tbranch_write_container.cpp @@ -32,7 +32,7 @@ void ROOT_TBranch_Write_ContainerImp::setAttribute(std::string const& key, std:: void ROOT_TBranch_Write_ContainerImp::setFile(std::shared_ptr file) { this->Storage_Associative_Write_Container::setFile(file); - ROOT_TFileImp* root_tfile_imp = dynamic_cast(file.get()); + auto* root_tfile_imp = dynamic_cast(file.get()); if (root_tfile_imp == nullptr) { throw std::runtime_error( "ROOT_TBranch_Write_ContainerImp::setFile can't attach to non-ROOT file"); @@ -43,8 +43,7 @@ void ROOT_TBranch_Write_ContainerImp::setFile(std::shared_ptr fil void ROOT_TBranch_Write_ContainerImp::setParent(std::shared_ptr parent) { this->Storage_Associative_Write_Container::setParent(parent); - ROOT_TTree_Write_ContainerImp* root_ttree_imp = - dynamic_cast(parent.get()); + auto* root_ttree_imp = dynamic_cast(parent.get()); if (root_ttree_imp == nullptr) { throw std::runtime_error("ROOT_TBranch_Write_ContainerImp::setParent"); } diff --git a/form/root_storage/root_ttree_write_container.cpp b/form/root_storage/root_ttree_write_container.cpp index 803eedbc0..1a769d100 100644 --- a/form/root_storage/root_ttree_write_container.cpp +++ b/form/root_storage/root_ttree_write_container.cpp @@ -18,12 +18,12 @@ ROOT_TTree_Write_ContainerImp::ROOT_TTree_Write_ContainerImp(std::string const& void ROOT_TTree_Write_ContainerImp::setFile(std::shared_ptr file) { this->Storage_Write_Association::setFile(file); - ROOT_TFileImp* root_tfile_imp = dynamic_cast(file.get()); + auto* root_tfile_imp = dynamic_cast(file.get()); if (root_tfile_imp == nullptr) { throw std::runtime_error( "ROOT_TTree_Write_ContainerImp::setFile can't attach to non-ROOT file"); } - m_tfile = dynamic_cast(file.get())->getTFile(); + m_tfile = root_tfile_imp->getTFile(); } void ROOT_TTree_Write_ContainerImp::setupWrite(std::type_info const& /* type*/) @@ -35,7 +35,9 @@ void ROOT_TTree_Write_ContainerImp::setupWrite(std::type_info const& /* type*/) m_tree.reset(m_tfile->Get(name().c_str())); } if (m_tree == nullptr) { - m_tree.reset(new TTree(name().c_str(), name().c_str())); + // Mark the raw allocation as an owning pointer before transferring it. + // NOLINTNEXTLINE(readability-redundant-casting) + m_tree.reset(gsl::owner{new TTree(name().c_str(), name().c_str())}); m_tree->SetDirectory(m_tfile.get()); } if (m_tree == nullptr) { diff --git a/form/root_storage/root_ttree_write_container.hpp b/form/root_storage/root_ttree_write_container.hpp index 4e20f1a7e..6a5c90a2a 100644 --- a/form/root_storage/root_ttree_write_container.hpp +++ b/form/root_storage/root_ttree_write_container.hpp @@ -16,6 +16,7 @@ namespace form::detail::experimental { class ROOT_TTree_Write_ContainerImp : public Storage_Write_Association { public: explicit ROOT_TTree_Write_ContainerImp(std::string const& name); + ~ROOT_TTree_Write_ContainerImp() override = default; ROOT_TTree_Write_ContainerImp(ROOT_TTree_Write_ContainerImp const&) = delete; ROOT_TTree_Write_ContainerImp& operator=(ROOT_TTree_Write_ContainerImp const&) = delete; diff --git a/form/storage/storage_reader.cpp b/form/storage/storage_reader.cpp index 6f9f11b07..fce56d309 100644 --- a/form/storage/storage_reader.cpp +++ b/form/storage/storage_reader.cpp @@ -389,5 +389,4 @@ void StorageReader::readContainer(Token const& token, } } cont->second->read(token.id(), data, type); - return; } diff --git a/phlex/core/framework_graph.hpp b/phlex/core/framework_graph.hpp index 67369b54c..ed6551fb1 100644 --- a/phlex/core/framework_graph.hpp +++ b/phlex/core/framework_graph.hpp @@ -23,6 +23,7 @@ #include "oneapi/tbb/info.h" #include +#include #include #include #include @@ -187,7 +188,7 @@ namespace phlex::detail { void finalize_router(index_router::provider_input_ports_t provider_input_ports, std::map multilayer_join_index_ports); - enum class driver_mode { default_driver, deferred_driver }; + enum class driver_mode : std::uint8_t { default_driver, deferred_driver }; explicit framework_graph(driver_mode mode, int max_parallelism); resource_usage graph_resource_usage_; diff --git a/test/core_misc_test.cpp b/test/core_misc_test.cpp index 0a8b175dd..6252288ac 100644 --- a/test/core_misc_test.cpp +++ b/test/core_misc_test.cpp @@ -91,7 +91,7 @@ TEST_CASE("verify_name tests", "[core]") FAIL("Should have thrown"); } catch (std::runtime_error const& e) { std::string msg = e.what(); - CHECK(msg.find("my_module") != std::string::npos); + CHECK(msg.contains("my_module")); } } } @@ -104,5 +104,5 @@ TEST_CASE("add_to_error_messages tests", "[core]") add_to_error_messages(errors, "Node", "duplicate_node"); REQUIRE(errors.size() == 1); - CHECK(errors[0].find("duplicate_node") != std::string::npos); + CHECK(errors[0].contains("duplicate_node")); } diff --git a/test/fold_duplicate_layer_name_test.cpp b/test/fold_duplicate_layer_name_test.cpp index 666a66e7c..6b1685a76 100644 --- a/test/fold_duplicate_layer_name_test.cpp +++ b/test/fold_duplicate_layer_name_test.cpp @@ -87,7 +87,7 @@ TEST_CASE("Fold different layer paths with same trailing name", "[graph]") g.execute(); CHECK(g.execution_count("run_add") == std::size_t{index_limit} * number_limit); - CHECK(g.execution_count("job_add") == index_limit * number_limit + top_level_event_limit); + CHECK(g.execution_count("job_add") == (index_limit * number_limit) + top_level_event_limit); CHECK(g.execution_count("verify_run_sum") == index_limit); CHECK(g.execution_count("verify_job_sum") == 1); } diff --git a/test/unfold.cpp b/test/unfold.cpp index f89138db6..2e29dfa94 100644 --- a/test/unfold.cpp +++ b/test/unfold.cpp @@ -81,10 +81,7 @@ namespace { // Provider algorithms unsigned int provide_max_number(data_cell_index const& id) { return 10u * (id.number() + 1); } - numbers_t provide_ten_numbers(data_cell_index const& id) - { - return numbers_t(10, id.number() + 1); - } + auto provide_ten_numbers(data_cell_index const& id) { return numbers_t(10, id.number() + 1); } } TEST_CASE("Splitting the processing", "[graph]")