summaryrefslogtreecommitdiff
path: root/thermal
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-10-25 02:33:25 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-10-25 02:33:25 +0000
commita3f2100b5d40e9eda9ecf5cb722b2752e5a2622f (patch)
treeb1061b9b2ee8d6d7e7924d6b80484fa631fd2b73 /thermal
parentb5e74cab05120da6b6910b9ee6333044838237e5 (diff)
parentebba951a6bd465b97555a667870e39e409bacd0e (diff)
downloadbonito-a3f2100b5d40e9eda9ecf5cb722b2752e5a2622f.tar.gz
Merge "thermal: utils: device_file_watcher: Use readFileFromString instead of infile.read" into pi-dev
Diffstat (limited to 'thermal')
-rw-r--r--thermal/utils/device_file_watcher.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/thermal/utils/device_file_watcher.cpp b/thermal/utils/device_file_watcher.cpp
index 1720cd3e..49a64516 100644
--- a/thermal/utils/device_file_watcher.cpp
+++ b/thermal/utils/device_file_watcher.cpp
@@ -20,6 +20,7 @@
#include <sys/resource.h>
#include <sys/types.h>
+#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/strings.h>
@@ -110,12 +111,8 @@ void DeviceFileWatcher::watchFilesForModificationsAndCallback() {
std::lock_guard<std::mutex> _lock(watcher_mutex_);
std::string path = watch_to_file_path_map_.at(event->wd);
- // Bound the read to 2 characters because we should only be reading
- // integer CPU throttling values.
- char file_contents[2];
- std::ifstream infile(path, std::ifstream::in);
- infile.read(file_contents, 2);
- std::string data(file_contents);
+ std::string data;
+ android::base::ReadFileToString(path, &data);
data = android::base::Trim(data);
if (!data.empty()) {