Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a7e5083 authored by Bart Van Assche's avatar Bart Van Assche
Browse files

healthd: Fix readFromFile()



Not all readFromFile() callers pass an empty string. Make sure that
readFromFile() returns 0 (failure) if the *buf argument is not empty and
if reading fails.

Fixes: 3217c5c7 ("batterymonitor: simplify readFromFile and use std::string buffers")
Test: Compile-tested only.
Change-Id: I6f329491f8aa4a6d378eb7c3cbc17038eb6aa64d
Signed-off-by: default avatarBart Van Assche <bvanassche@google.com>
parent 024e18f0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -228,6 +228,7 @@ BatteryHealth getBatteryHealth(const char* status) {
}

int BatteryMonitor::readFromFile(const String8& path, std::string* buf) {
    buf->clear();
    if (android::base::ReadFileToString(path.c_str(), buf)) {
        *buf = android::base::Trim(*buf);
    }