Skip to content

Commit

Permalink
fix: avoid integer precision loss
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Oct 5, 2023
1 parent e567cfc commit b4ca82b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/glog/logging.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1741,7 +1741,7 @@ class GLOG_EXPORT Logger {
// Get the current LOG file size.
// The returned value is approximate since some
// logged data may not have been flushed to disk yet.
virtual uint32 LogSize() = 0;
virtual std::size_t LogSize() = 0;
};

// Get the logger for the specified severity level. The logger
Expand Down
4 changes: 2 additions & 2 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ class LogFileObject : public base::Logger {

// It is the actual file length for the system loggers,
// i.e., INFO, ERROR, etc.
uint32 LogSize() override {
std::size_t LogSize() override {
MutexLock l(&lock_);
return file_length_;
}
Expand All @@ -475,7 +475,7 @@ class LogFileObject : public base::Logger {
LogSeverity severity_;
uint32 bytes_since_flush_{0};
uint32 dropped_mem_length_{0};
uint32 file_length_{0};
std::size_t file_length_{0};
unsigned int rollover_attempt_;
int64 next_flush_time_{0}; // cycle count at which to flush log
WallTime start_time_;
Expand Down
4 changes: 2 additions & 2 deletions src/logging_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ struct MyLogger : public base::Logger {

void Flush() override {}

uint32 LogSize() override { return data.length(); }
std::size_t LogSize() override { return data.length(); }

private:
bool* set_on_destruction_;
Expand Down Expand Up @@ -1027,7 +1027,7 @@ struct RecordDeletionLogger : public base::Logger {
wrapped_logger_->Write(force_flush, timestamp, message, length);
}
void Flush() override { wrapped_logger_->Flush(); }
uint32 LogSize() override { return wrapped_logger_->LogSize(); }
std::size_t LogSize() override { return wrapped_logger_->LogSize(); }

private:
bool* set_on_destruction_;
Expand Down

0 comments on commit b4ca82b

Please sign in to comment.