From 47a6bf014d322fc712a82911788ed97c1a83cb82 Mon Sep 17 00:00:00 2001 From: John Stultz Date: Wed, 6 Nov 2019 00:23:34 +0000 Subject: [PATCH] healthd: Fix incorrect return check In commit 1d4368b4943b ("[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 1d4368b4943b 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 --- healthd/BatteryMonitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index 9e168e9e5..1c388f2ed 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -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; }