intrusionsensor: Use const reference for std::shared_ptr
The code was passing non-const reference std::shared_ptr, which was not
a good usage because it is to express that a function might reseat the
shared pointer.
Change the functions to pass const reference so that it expresses the
correct information.
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I30d6fae90d7d79f8c170529da5dfa8c65b63f9df
diff --git a/src/IntrusionSensorMain.cpp b/src/IntrusionSensorMain.cpp
index 9ec3f5d..154b2b2 100644
--- a/src/IntrusionSensorMain.cpp
+++ b/src/IntrusionSensorMain.cpp
@@ -53,7 +53,7 @@
namespace fs = std::filesystem;
static bool getIntrusionSensorConfig(
- std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
+ const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
IntrusionSensorType* pType, int* pBusId, int* pSlaveAddr,
bool* pGpioInverted)
{
@@ -179,8 +179,8 @@
boost::container::flat_map<int, std::string> lanInfoMap;
boost::container::flat_map<std::string, int> pathSuffixMap;
-static void
- getNicNameInfo(std::shared_ptr<sdbusplus::asio::connection>& dbusConnection)
+static void getNicNameInfo(
+ const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection)
{
auto getter = std::make_shared<GetSensorConfiguration>(
dbusConnection,
@@ -329,8 +329,8 @@
*
* @return true on success and false on failure
*/
-static bool
- initializeLanStatus(std::shared_ptr<sdbusplus::asio::connection>& conn)
+static bool initializeLanStatus(
+ const std::shared_ptr<sdbusplus::asio::connection>& conn)
{
// init lan port name from configuration
getNicNameInfo(conn);