diff options
author | Benjamin Barenblat <bbaren@google.com> | 2022-07-18 12:23:48 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-07-18 12:24:41 -0700 |
commit | 65ac1e611c45843482ae74e7291c578aa7881f5b (patch) | |
tree | a48b47fa6ffbffb3a16e49c536c9d7cda03c6e12 /absl/debugging | |
parent | 6162604bee9e1018ff807c6f655cb1ee81b92a04 (diff) |
Avoid signedness change when casting off_t
Some ABSL_RAW_LOG statements print off_t values by casting them to
uintmax_t. However, POSIX says off_t is signed [1], so intmax_t is more
appropriate. Replace casts and format specifiers as needed.
[1] https://pubs.opengroup.org/onlinepubs/009696899/basedefs/sys/types.h.html#:~:text=off_t%20shall,%20types%2e
PiperOrigin-RevId: 461684406
Change-Id: I09ec1a3ba49cd688670618797943a84bc48dba3e
Diffstat (limited to 'absl/debugging')
-rw-r--r-- | absl/debugging/symbolize_elf.inc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/absl/debugging/symbolize_elf.inc b/absl/debugging/symbolize_elf.inc index 9bfdd915..5d6c8df3 100644 --- a/absl/debugging/symbolize_elf.inc +++ b/absl/debugging/symbolize_elf.inc @@ -442,8 +442,8 @@ static ssize_t ReadFromOffset(const int fd, void *buf, const size_t count, const off_t offset) { off_t off = lseek(fd, offset, SEEK_SET); if (off == (off_t)-1) { - ABSL_RAW_LOG(WARNING, "lseek(%d, %ju, SEEK_SET) failed: errno=%d", fd, - static_cast<uintmax_t>(offset), errno); + ABSL_RAW_LOG(WARNING, "lseek(%d, %jd, SEEK_SET) failed: errno=%d", fd, + static_cast<intmax_t>(offset), errno); return -1; } return ReadPersistent(fd, buf, count); @@ -492,9 +492,9 @@ static ABSL_ATTRIBUTE_NOINLINE bool GetSectionHeaderByType( if (len % sizeof(buf[0]) != 0) { ABSL_RAW_LOG( WARNING, - "Reading %zd bytes from offset %ju returned %zd which is not a " + "Reading %zd bytes from offset %jd returned %zd which is not a " "multiple of %zu.", - num_bytes_to_read, static_cast<uintmax_t>(offset), len, + num_bytes_to_read, static_cast<intmax_t>(offset), len, sizeof(buf[0])); return false; } |