From 69e8325e5d2f3f404734808fedd2dc0493f28001 Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Fri, 4 Oct 2019 12:18:24 -0700 Subject: [PATCH] strtoul result shouldn't be narrowed to uint32_t before checking for ULONG_MAX ... otherwise this is always false. Test: presubmit Bug: 72331526 Change-Id: Ie1262ebf2eff4143bbef7b9d473c8ac5b7c9ffe4 --- power/stats/1.0/default/PowerStats.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/power/stats/1.0/default/PowerStats.cpp b/power/stats/1.0/default/PowerStats.cpp index 78766f2a17..68275cef8a 100644 --- a/power/stats/1.0/default/PowerStats.cpp +++ b/power/stats/1.0/default/PowerStats.cpp @@ -87,7 +87,7 @@ size_t PowerStats::parsePowerRails() { std::string railFileName; std::string spsFileName; uint32_t index = 0; - uint32_t samplingRate; + unsigned long samplingRate; for (const auto& path : mPm.devicePaths) { railFileName = path + "/enabled_rails"; spsFileName = path + "/sampling_rate"; @@ -109,10 +109,11 @@ size_t PowerStats::parsePowerRails() { while (std::getline(railNames, line)) { std::vector words = android::base::Split(line, ":"); if (words.size() == 2) { - mPm.railsInfo.emplace(words[0], RailData{.devicePath = path, - .index = index, - .subsysName = words[1], - .samplingRate = samplingRate}); + mPm.railsInfo.emplace( + words[0], RailData{.devicePath = path, + .index = index, + .subsysName = words[1], + .samplingRate = static_cast(samplingRate)}); index++; } else { ALOGW("Unexpected format in file: %s", railFileName.c_str());