Skip to content

Commit ad7c3ff

Browse files
authored
Fix implicit conversion changes signess warning in perf_counters.cc (#1765)
`read_bytes` is `ssize_t` (and we know it's non-negative), we need to explicitly cast it to `size_t`.
1 parent eaafe69 commit ad7c3ff

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/perf_counters.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ size_t PerfCounterValues::Read(const std::vector<int>& leaders) {
3939
auto read_bytes = ::read(lead, ptr, size);
4040
if (read_bytes >= ssize_t(sizeof(uint64_t))) {
4141
// Actual data bytes are all bytes minus initial padding
42-
std::size_t data_bytes = read_bytes - sizeof(uint64_t);
42+
std::size_t data_bytes =
43+
static_cast<std::size_t>(read_bytes) - sizeof(uint64_t);
4344
// This should be very cheap since it's in hot cache
4445
std::memmove(ptr, ptr + sizeof(uint64_t), data_bytes);
4546
// Increment our counters

0 commit comments

Comments
 (0)