rtu: getConfig shall return unique_ptr
Update the getConfig in PortFactory and related classes to return a
unique_ptr instead of a variable on stack to preserve polymorphic
behavior of the return port config. Without this change the values from
USBPort are dropped when casting from USBPort to PortFactoryConfig.
Change-Id: Ia250771a7fd7aedb133598446aab1e120aaf36b5
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/rtu/port/usb_port.hpp b/rtu/port/usb_port.hpp
index 5f9cff5..b2bc070 100644
--- a/rtu/port/usb_port.hpp
+++ b/rtu/port/usb_port.hpp
@@ -18,11 +18,11 @@
{
public:
explicit USBPort(sdbusplus::async::context& ctx,
- config::PortFactoryConfig& config);
+ const config::PortFactoryConfig& config);
static auto getConfig(sdbusplus::async::context& ctx,
const sdbusplus::message::object_path& objectPath)
- -> sdbusplus::async::task<std::optional<config::PortFactoryConfig>>;
+ -> sdbusplus::async::task<std::unique_ptr<config::PortFactoryConfig>>;
};
} // namespace phosphor::modbus::rtu::port