From 830cf5dd9ff911173327662d4e0d7390395e8bf3 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 12 Feb 2024 15:39:59 -0500 Subject: [PATCH] cpp-common/bt2: fix trivial-ish mistakes in plugin-dev.hpp MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix a few problems that were found by exercising the `plugin-dev.hpp` code a bit more. ⚾ Use public inheritance in `SinkCompClsBridge`. ⚾ Add return statement in happy path of `SinkCompClsBridge::graphIsConfigured`. ⚾ Use `DataT&` as the parameter type to `_addOutputPort` and `_addInputPort` methods, matching what `Self*Component::add*Port` expects. ⚾ Call `_outputPortConnected` instead of `outputPortConnected` in `UserSourceComponent::outputPortConnected`, which otherwise results in infinite recursion. Change-Id: Ieab12436c4b85b5a33195be0ea388b3f545f07cd Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/11789 Reviewed-by: Philippe Proulx Tested-by: jenkins --- src/cpp-common/bt2/plugin-dev.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cpp-common/bt2/plugin-dev.hpp b/src/cpp-common/bt2/plugin-dev.hpp index 33ab5b42..916ff1ae 100644 --- a/src/cpp-common/bt2/plugin-dev.hpp +++ b/src/cpp-common/bt2/plugin-dev.hpp @@ -235,8 +235,8 @@ struct SinkCompClsLibTypes final template class SinkCompClsBridge final : - CompClsBridge, - CompClsBridgeWithInputPorts, SinkCompClsLibTypes> + public CompClsBridge, + public CompClsBridgeWithInputPorts, SinkCompClsLibTypes> { private: using CompClsBridge::userCompFromLibSelfCompPtr; @@ -270,6 +270,7 @@ public: { try { userCompFromLibSelfCompPtr(libSelfCompPtr).graphIsConfigured(); + return BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK; } catch (const std::bad_alloc&) { return BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_MEMORY_ERROR; } catch (const Error&) { @@ -561,7 +562,7 @@ public: void outputPortConnected(const SelfComponentOutputPort outputPort, const ConstInputPort inputPort) { - static_cast(*this).outputPortConnected(outputPort, inputPort); + static_cast(*this)._outputPortConnected(outputPort, inputPort); } protected: @@ -585,7 +586,7 @@ protected: } template - _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT * const data) + _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT& data) { return this->_selfComp().addOutputPort(name, data); } @@ -693,7 +694,7 @@ protected: } template - _OutputPorts::Port _addInputPort(const bt2c::CStringView name, DataT * const data) + _OutputPorts::Port _addInputPort(const bt2c::CStringView name, DataT& data) { return this->_selfComp().addInputPort(name, data); } @@ -709,7 +710,7 @@ protected: } template - _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT * const data) + _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT& data) { return this->_selfComp().addOutputPort(name, data); } @@ -822,7 +823,7 @@ protected: } template - _InputPorts::Port _addInputPort(const bt2c::CStringView name, DataT * const data) + _InputPorts::Port _addInputPort(const bt2c::CStringView name, DataT& data) { return this->_selfComp().addInputPort(name, data); } -- 2.34.1