diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-03-02 19:49:18 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-03-02 19:49:18 +0000 |
commit | 3dad67af05205f2c2bebe79d54906f2fe4c377ff (patch) | |
tree | a72e65ce5617784ddf2f4b6f752b83976892be76 | |
parent | fd42c098130890b86ba4bf7d717a0c16b3874bb4 (diff) | |
parent | 808e57e3f3af403f45d44c93da2e275d427f30cf (diff) | |
download | core-3dad67af05205f2c2bebe79d54906f2fe4c377ff.tar.gz |
Merge "healthd: Fix negativity check after cast to unsigned enum"
-rw-r--r-- | healthd/BatteryMonitor.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index 08b8b269d..fa79d0bb2 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -143,7 +143,7 @@ int BatteryMonitor::readFromFile(const String8& path, std::string* buf) { BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String8& path) { std::string buf; - BatteryMonitor::PowerSupplyType ret; + int ret; struct sysfsStringEnumMap supplyTypeMap[] = { { "Unknown", ANDROID_POWER_SUPPLY_TYPE_UNKNOWN }, { "Battery", ANDROID_POWER_SUPPLY_TYPE_BATTERY }, @@ -164,13 +164,13 @@ BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String if (readFromFile(path, &buf) <= 0) return ANDROID_POWER_SUPPLY_TYPE_UNKNOWN; - ret = (BatteryMonitor::PowerSupplyType)mapSysfsString(buf.c_str(), supplyTypeMap); + ret = mapSysfsString(buf.c_str(), supplyTypeMap); if (ret < 0) { KLOG_WARNING(LOG_TAG, "Unknown power supply type '%s'\n", buf.c_str()); ret = ANDROID_POWER_SUPPLY_TYPE_UNKNOWN; } - return ret; + return static_cast<BatteryMonitor::PowerSupplyType>(ret); } bool BatteryMonitor::getBooleanField(const String8& path) { |