HwmonTemp: fixed support for more than 10 sensors
Problem: HwmonTemp does not work when more than 10 temp sensors are
specified.
Solution: use std::to_string instead of ASCII math
Tested: on a system with a device that reports 10+ sensors, all sensors
are now reported correctly.
Signed-off-by: Jason Ling <jasonling@google.com>
Change-Id: Ied2780356b1a65f8248f5675a694dc6a03ce5ece
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index ef38bae..be7be98 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -227,7 +227,7 @@
{
++i;
auto findKey =
- baseConfigMap->find("Name" + std::string(1, '0' + i));
+ baseConfigMap->find("Name" + std::to_string(i));
if (findKey == baseConfigMap->end())
{
break;
@@ -238,7 +238,7 @@
auto& sensor = sensors[sensorName];
sensor = nullptr;
sensor = std::make_shared<HwmonTempSensor>(
- directory.string() + "/temp" + std::string(1, '1' + i) +
+ directory.string() + "/temp" + std::to_string(i + 1) +
"_input",
sensorType, objectServer, dbusConnection, io,
sensorName, std::vector<thresholds::Threshold>(),