healthd: Fix incorrect return check

In commit 1d4368b494 ("[REFACTOR] healthd: BatteryMonitor
use health 2.1 types"), the mapSysfsString() function was
changed to return NULL instead of -1 on error.

Everywher else that function is used commit 1d4368b494
tweaked the return value check from (ret < 0) to (!ret),
but one spot was missed.

This patch corrects the one missed check so that we compare
against null rather then negative value, since the return
value can no longer be negative.

This issue was found by inspection, and I've not seen an actual
problem with it, but thought it should be corrected.

Change-Id: I0a6564274d01276352a5dc0660b8ffbe748b5fde
Signed-off-by: John Stultz <john.stultz@linaro.org>
This commit is contained in:
John Stultz 2019-11-06 00:23:34 +00:00 committed by Yifan Hong
parent 2aabeed1fd
commit 47a6bf014d
1 changed files with 1 additions and 1 deletions

View File

@ -168,7 +168,7 @@ BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String
return ANDROID_POWER_SUPPLY_TYPE_UNKNOWN;
auto ret = mapSysfsString(buf.c_str(), supplyTypeMap);
if (ret < 0) {
if (!ret) {
KLOG_WARNING(LOG_TAG, "Unknown power supply type '%s'\n", buf.c_str());
*ret = ANDROID_POWER_SUPPLY_TYPE_UNKNOWN;
}