Skip to content

Commit

Permalink
vold: fix write kbytes handling
Browse files Browse the repository at this point in the history
Since Android platform codespace doesn't support exception handling, we
use strtoll() instead of stoll for direct error handling.

Bug: 274369737
Test: check smart idle maintenace service log
Change-Id: I57c709b1e329228790e0a883edb64dc023135a24
  • Loading branch information
Daeho Jeong committed Mar 28, 2023
1 parent c1572fe commit dd08c52
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion IdleMaint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,12 @@ static int32_t getLifeTimeWrite() {
return -1;
}

long long writeBytes = std::stoll(writeKbytesStr);
unsigned long long writeBytes = std::strtoull(writeKbytesStr.c_str(), NULL, 0);
/* Careful: values > LLONG_MAX can appear in the file due to a kernel bug. */
if (writeBytes / KBYTES_IN_SEGMENT > INT32_MAX) {
LOG(WARNING) << "Bad lifetime_write_kbytes: " << writeKbytesStr;
return -1;
}
return writeBytes / KBYTES_IN_SEGMENT;
}

Expand Down

0 comments on commit dd08c52

Please sign in to comment.