summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2023-11-01 22:09:07 +0300
committerEd Tanous <ed@tanous.net>2023-11-06 08:48:10 +0300
commit931edc79bc0c3d6bc90019718190cc345edbd696 (patch)
tree8e5aa47184646f21f4ca408a66fe6b7e13799cde /redfish-core
parent72b90760b3c37739f407985d504d5e45e97c2e63 (diff)
downloadbmcweb-931edc79bc0c3d6bc90019718190cc345edbd696.tar.xz
Make callback a template to avoid memory leak
Tested: Gunnar built this and below for a p10bmc, webui-vue looks reasonable and the Validator had no new errors. Did a few operations: delete a log, set an ntp server, etc. Change-Id: I587ccd04515164fce1ea0bf5baf9f820347c63e6 Signed-off-by: Ed Tanous <edtanous@google.com> Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/lib/sensors.hpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 7258d1d850..530e1f1748 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -2742,9 +2742,10 @@ inline void setSensorsOverride(
* @param node Node (group) of sensors. See sensors::node for supported values
* @param mapComplete Callback to be called with retrieval result
*/
+template <typename Callback>
inline void retrieveUriToDbusMap(const std::string& chassis,
const std::string& node,
- SensorsAsyncResp::DataCompleteCb&& mapComplete)
+ Callback&& mapComplete)
{
decltype(sensors::paths)::const_iterator pathIt =
std::find_if(sensors::paths.cbegin(), sensors::paths.cend(),
@@ -2758,7 +2759,8 @@ inline void retrieveUriToDbusMap(const std::string& chassis,
}
auto asyncResp = std::make_shared<bmcweb::AsyncResp>();
- auto callback = [asyncResp, mapCompleteCb{std::move(mapComplete)}](
+ auto callback = [asyncResp,
+ mapCompleteCb{std::forward<Callback>(mapComplete)}](
const boost::beast::http::status status,
const std::map<std::string, std::string>& uriToDbus) {
mapCompleteCb(status, uriToDbus);