replace pointer parameters with references
The methods declared in sensorhandler.hpp are all defined with
pointer parameters. Since these parameters should always be valid and
not null, using raw pointers is unnecessary and can be misleading, so
passing them as references makes the API safer and more idiomatic in
modern C++.
Change-Id: Iaec6caeb1e04fcc38cc244dd66634724c62dd0c1
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index c6a167f..97ab5e5 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -1905,8 +1905,8 @@
// populate sensor name from path
auto name = sensor::parseSdrIdFromPath(path);
- get_sdr::body::set_id_strlen(name.size(), &record.body);
- get_sdr::body::set_id_type(3, &record.body); // "8-bit ASCII + Latin 1"
+ get_sdr::body::set_id_strlen(name.size(), record.body);
+ get_sdr::body::set_id_type(3, record.body); // "8-bit ASCII + Latin 1"
std::memcpy(record.body.id_string, name.c_str(),
std::min(name.length() + 1, sizeof(record.body.id_string)));
@@ -1921,7 +1921,7 @@
sensorSettable =
mappedVariant<bool>(mutability->second, "Mutable", false);
}
- get_sdr::body::init_settable_state(sensorSettable, &record.body);
+ get_sdr::body::init_settable_state(sensorSettable, record.body);
// Grant write permission to sensors deemed externally settable
details::sdrWriteTable.setWritePermission(sensorNum, sensorSettable);
@@ -2008,7 +2008,7 @@
if (ipmi::sensor::Mutability::Write ==
(sensor->second.mutability & ipmi::sensor::Mutability::Write))
{
- get_sdr::body::init_settable_state(true, &(record.body));
+ get_sdr::body::init_settable_state(true, record.body);
}
auto id_string = sensor->second.sensorName;
@@ -2021,15 +2021,15 @@
if (id_string.length() > FULL_RECORD_ID_STR_MAX_LENGTH)
{
get_sdr::body::set_id_strlen(FULL_RECORD_ID_STR_MAX_LENGTH,
- &(record.body));
+ record.body);
}
else
{
- get_sdr::body::set_id_strlen(id_string.length(), &(record.body));
+ get_sdr::body::set_id_strlen(id_string.length(), record.body);
}
get_sdr::body::set_id_type(3, &record.body); // "8-bit ASCII + Latin 1"
std::strncpy(record.body.id_string, id_string.c_str(),
- get_sdr::body::get_id_strlen(&(record.body)));
+ get_sdr::body::get_id_strlen(record.body));
}
#endif
@@ -2090,8 +2090,8 @@
// populate sensor name from path
auto name = sensor::parseSdrIdFromPath(path);
int nameSize = std::min(name.size(), sizeof(record.body.id_string));
- get_sdr::body::set_id_strlen(nameSize, &record.body);
- get_sdr::body::set_id_type(3, &record.body); // "8-bit ASCII + Latin 1"
+ get_sdr::body::set_id_strlen(nameSize, record.body);
+ get_sdr::body::set_id_type(3, record.body); // "8-bit ASCII + Latin 1"
std::memset(record.body.id_string, 0x00, sizeof(record.body.id_string));
std::memcpy(record.body.id_string, name.c_str(), nameSize);