Fix some google-runtime-int warnings.
Bug: 28220065
Change-Id: Ic6b24216d216bbb165a1420b52b11c7703b810a0
diff --git a/simpleperf/dso.cpp b/simpleperf/dso.cpp
index 9c33667..e34d6bc 100644
--- a/simpleperf/dso.cpp
+++ b/simpleperf/dso.cpp
@@ -334,6 +334,6 @@
prev_symbol = &symbol;
}
if (prev_symbol != nullptr && prev_symbol->len == 0) {
- prev_symbol->len = std::numeric_limits<unsigned long long>::max() - prev_symbol->addr;
+ prev_symbol->len = std::numeric_limits<uint64_t>::max() - prev_symbol->addr;
}
}
diff --git a/simpleperf/environment.cpp b/simpleperf/environment.cpp
index 996a5e4..19b1fb1 100644
--- a/simpleperf/environment.cpp
+++ b/simpleperf/environment.cpp
@@ -84,9 +84,9 @@
const char* p = s.c_str();
char* endp;
int last_cpu;
- long cpu;
+ int cpu;
// Parse line like: 0,1-3, 5, 7-8
- while ((cpu = strtol(p, &endp, 10)) != 0 || endp != p) {
+ while ((cpu = static_cast<int>(strtol(p, &endp, 10))) != 0 || endp != p) {
if (have_dash && !cpu_set.empty()) {
for (int t = last_cpu + 1; t < cpu; ++t) {
cpu_set.insert(t);
@@ -222,7 +222,7 @@
}
if (module_mmaps->size() == 0) {
- kernel_mmap->len = std::numeric_limits<unsigned long long>::max() - kernel_mmap->start_addr;
+ kernel_mmap->len = std::numeric_limits<uint64_t>::max() - kernel_mmap->start_addr;
} else {
std::sort(
module_mmaps->begin(), module_mmaps->end(),
@@ -242,7 +242,7 @@
}
}
module_mmaps->back().len =
- std::numeric_limits<unsigned long long>::max() - module_mmaps->back().start_addr;
+ std::numeric_limits<uint64_t>::max() - module_mmaps->back().start_addr;
}
}
diff --git a/simpleperf/event_fd.cpp b/simpleperf/event_fd.cpp
index 83c5e26..5b47a99 100644
--- a/simpleperf/event_fd.cpp
+++ b/simpleperf/event_fd.cpp
@@ -38,7 +38,7 @@
std::vector<char> EventFd::data_process_buffer_;
static int perf_event_open(perf_event_attr* attr, pid_t pid, int cpu, int group_fd,
- unsigned long flags) {
+ unsigned long flags) { // NOLINT
return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);
}
diff --git a/simpleperf/record_file_writer.cpp b/simpleperf/record_file_writer.cpp
index dddd0b0..26fde59 100644
--- a/simpleperf/record_file_writer.cpp
+++ b/simpleperf/record_file_writer.cpp
@@ -77,7 +77,7 @@
}
// Write id section.
- long id_section_offset = ftell(record_fp_);
+ off_t id_section_offset = ftello(record_fp_);
if (id_section_offset == -1) {
return false;
}
@@ -88,7 +88,7 @@
}
// Write attr section.
- long attr_section_offset = ftell(record_fp_);
+ off_t attr_section_offset = ftello(record_fp_);
if (attr_section_offset == -1) {
return false;
}
@@ -103,7 +103,7 @@
}
}
- long data_section_offset = ftell(record_fp_);
+ off_t data_section_offset = ftello(record_fp_);
if (data_section_offset == -1) {
return false;
}
@@ -138,9 +138,9 @@
PLOG(ERROR) << "fseek() failed";
return false;
}
- long offset = ftell(record_fp_);
+ off_t offset = ftello(record_fp_);
if (offset == -1) {
- PLOG(ERROR) << "ftell() failed";
+ PLOG(ERROR) << "ftello() failed";
return false;
}
*file_end = static_cast<uint64_t>(offset);
diff --git a/simpleperf/runtest/comm_change.cpp b/simpleperf/runtest/comm_change.cpp
index f8b2ae6..12d64fa 100644
--- a/simpleperf/runtest/comm_change.cpp
+++ b/simpleperf/runtest/comm_change.cpp
@@ -8,9 +8,9 @@
}
int main() {
- prctl(PR_SET_NAME, reinterpret_cast<unsigned long>("RUN_COMM1"), 0, 0, 0);
+ prctl(PR_SET_NAME, reinterpret_cast<unsigned long>("RUN_COMM1"), 0, 0, 0); // NOLINT
Function1();
- prctl(PR_SET_NAME, reinterpret_cast<unsigned long>("RUN_COMM2"), 0, 0, 0);
+ prctl(PR_SET_NAME, reinterpret_cast<unsigned long>("RUN_COMM2"), 0, 0, 0); // NOLINT
Function1();
return 0;
}