PwmSensor: Fix function getValue returns wrong data type
Function "getValue" is defined as uint32_t but returns -1 in some cases.
Follow the function comment to change the return value from -1 to 0.
Change-Id: Ifd228c94e4ebe14d9bdea953506d17371f9e5f79
Signed-off-by: Yang Chen <yang.chen@quantatw.com>
diff --git a/src/PwmSensor.cpp b/src/PwmSensor.cpp
index a06d7c4..bffead9 100644
--- a/src/PwmSensor.cpp
+++ b/src/PwmSensor.cpp
@@ -212,12 +212,14 @@
std::ifstream ref(sysPath);
if (!ref.good())
{
- return -1;
+ std::cerr << "Error opening " << sysPath << "\n";
+ return 0;
}
std::string line;
if (!std::getline(ref, line))
{
- return -1;
+ std::cerr << "Error reading pwm at " << sysPath << "\n";
+ return 0;
}
try
{
@@ -226,7 +228,7 @@
}
catch (const std::invalid_argument&)
{
- std::cerr << "Error reading pwm at " << sysPath << "\n";
+ std::cerr << "Error converting pwm\n";
// throw if not initial read to be caught by dbus bindings
if (errThrow)
{