diff options
author | Michael Scott <michael.scott@linaro.org> | 2016-06-05 11:20:13 -0700 |
---|---|---|
committer | Michael Scott <michael.scott@linaro.org> | 2016-06-20 15:01:02 +0000 |
commit | 3217c5c7d9612d3984af7384940ed0949b900b6a (patch) | |
tree | 34d47c33650c4e2f2432d0ca7b0f8e73ebd8786b /debuggerd/debuggerd.cpp | |
parent | 863d8e11b9b62388d9d00d7192b5e6f39fa089fa (diff) |
batterymonitor: simplify readFromFile and use std::string buffers
In readFromFile() when a newline is not found in the data, we reset
the initial character of the buffer to \0, but leave the count as is
(something >0 in this case).
Later in getBooleanField() we could erroneously treat a response as
"true" because count would be >0 and the initial value of buf would
be != '0' (set to \0 in this case).
To fixup error paths such as this, we can simplify readFromFile
by using android::base functions: ReadFromFileString() and Trim().
NOTES:
- Converted char * buffers used with readFromFile to std::string
- Removed unused variable btech from BatteryMonitor::update
Testing Done:
- Build healthd and recovery for angler device
- Confirm that known values are being read correctly from kernel
sysfs.
Change-Id: I238bbff097543767f352aa084bf0acbc1324baca
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Diffstat (limited to 'debuggerd/debuggerd.cpp')
0 files changed, 0 insertions, 0 deletions