summaryrefslogtreecommitdiffstats
path: root/pixelstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@google.com>2020-03-20 09:47:01 -0700
committerJaegeuk Kim <jaegeuk@google.com>2020-03-20 09:53:30 -0700
commitf4c1d872051ceb95e930d5f156a8317f1cb04ac6 (patch)
tree63f48100917456dcd31cdeed323460df4afd91a7 /pixelstats
parentb77ba38eaf7c2525eb7f0a6bfc3811e494dee175 (diff)
downloadplatform_hardware_google_pixel-f4c1d872051ceb95e930d5f156a8317f1cb04ac6.tar.gz
platform_hardware_google_pixel-f4c1d872051ceb95e930d5f156a8317f1cb04ac6.tar.bz2
platform_hardware_google_pixel-f4c1d872051ceb95e930d5f156a8317f1cb04ac6.zip
pixelstats: avoid nullptr when device has no f2fs definition
This fixes the case where device has no f2fs definition Bug: 146053177 Signed-off-by: Jaegeuk Kim <jaegeuk@google.com> Change-Id: I07f331187728a06ca2bfa326ec366bce1103cd0a
Diffstat (limited to 'pixelstats')
-rw-r--r--pixelstats/SysfsCollector.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/pixelstats/SysfsCollector.cpp b/pixelstats/SysfsCollector.cpp
index f9ae928..faccc60 100644
--- a/pixelstats/SysfsCollector.cpp
+++ b/pixelstats/SysfsCollector.cpp
@@ -358,7 +358,6 @@ static std::string getUserDataBlock() {
}
void SysfsCollector::logF2fsStats() {
- std::string userdataBlock;
int dirty, free, cp_calls_fg, gc_calls_fg, moved_block_fg, vblocks;
int cp_calls_bg, gc_calls_bg, moved_block_bg;
@@ -367,7 +366,7 @@ void SysfsCollector::logF2fsStats() {
return;
}
- userdataBlock = getUserDataBlock();
+ std::string userdataBlock = getUserDataBlock();
if (!ReadFileToInt(kF2fsStatsPath + (userdataBlock + "/dirty_segments"), &dirty)) {
ALOGV("Unable to read dirty segments");
@@ -535,8 +534,15 @@ void SysfsCollector::logZramStats() {
}
void SysfsCollector::logBootStats() {
- std::string userdataBlock = getUserDataBlock();
int mounted_time_sec = 0;
+
+ if (kF2fsStatsPath == nullptr) {
+ ALOGE("F2fs stats path not specified");
+ return;
+ }
+
+ std::string userdataBlock = getUserDataBlock();
+
if (!ReadFileToInt(kF2fsStatsPath + (userdataBlock + "/mounted_time_sec"), &mounted_time_sec)) {
ALOGV("Unable to read mounted_time_sec");
return;