diff options
author | Colin Cross <ccross@android.com> | 2023-03-31 17:54:40 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2023-04-10 13:19:30 -0700 |
commit | 1d1544b52c5c156b82dc31ae4be6ae62efb2d661 (patch) | |
tree | d593aa6fc0337455a95756f24fffa3fbd85618d4 | |
parent | 775f35376eb847cb4ccb12fa9880885a18ab0171 (diff) | |
download | common-1d1544b52c5c156b82dc31ae4be6ae62efb2d661.tar.gz |
Fix formatting when _FILE_OFFSET_BITS=64
_FILE_OFFSET_BITS=64 can change off_t to be larger than a long.
Cast to intmax_t and print with %jd or switch to ptrdiff_t and
print with %td.
Bug: 275601166
Test: builds
Change-Id: I011cc53f108aaa7f773b0d09511728864f602429
-rw-r--r-- | libacryl/acrylic_layer.cpp | 7 | ||||
-rw-r--r-- | libhwjpeg/libhwjpeg-exynos.cpp | 8 |
2 files changed, 8 insertions, 7 deletions
diff --git a/libacryl/acrylic_layer.cpp b/libacryl/acrylic_layer.cpp index b90d541..5c587fc 100644 --- a/libacryl/acrylic_layer.cpp +++ b/libacryl/acrylic_layer.cpp @@ -140,7 +140,8 @@ bool AcrylicCanvas::setImageBuffer(int fd[MAX_HW2D_PLANES], size_t len[MAX_HW2D_ for (int i = 0; i < num_buffers; i++) { if ((offset[i] < 0) || (static_cast<size_t>(offset[i]) >= len[i])) { - ALOGE("Too large offset %ld for length %zu of buffer[%d]", offset[i], len[i], i); + ALOGE("Too large offset %jd for length %zu of buffer[%d]", + static_cast<intmax_t>(offset[i]), len[i], i); return false; } @@ -155,8 +156,8 @@ bool AcrylicCanvas::setImageBuffer(int fd[MAX_HW2D_PLANES], size_t len[MAX_HW2D_ m.mBufferFd[i] = fd[i]; mBufferLength[i] = len[i]; mBufferOffset[i] = offset[i]; - ALOGD_TEST("Configured buffer[%d]: fd %d, len %zu, offset %u (type: %s)", - i, m.mBufferFd[i], mBufferLength[i], mBufferOffset[i], + ALOGD_TEST("Configured buffer[%d]: fd %d, len %zu, offset %jd (type: %s)", i, + m.mBufferFd[i], mBufferLength[i], static_cast<intmax_t>(mBufferOffset[i]), canvasTypeName(mCanvasType)); } diff --git a/libhwjpeg/libhwjpeg-exynos.cpp b/libhwjpeg/libhwjpeg-exynos.cpp index 7f82da9..5f6dd6e 100644 --- a/libhwjpeg/libhwjpeg-exynos.cpp +++ b/libhwjpeg/libhwjpeg-exynos.cpp @@ -49,10 +49,10 @@ private: size_t GetLength(unsigned char *addr); bool ParseFrame(unsigned char *addr); - off_t GetOffset(unsigned char *addr) { + ptrdiff_t GetOffset(unsigned char *addr) { unsigned long beg = reinterpret_cast<unsigned long>(m_pStreamBase); unsigned long cur = reinterpret_cast<unsigned long>(addr); - return static_cast<off_t>(cur - beg); + return static_cast<ptrdiff_t>(cur - beg); } public: @@ -130,7 +130,7 @@ bool CJpegStreamParser::Parse(unsigned char *streambase, size_t length) { return true; // this is the successful exit point } else if (marker == 0xD9) { // EOI // This will not meet. - ALOGE("Unexpected EOI found at %lu\n", GetOffset(addr - 2)); + ALOGE("Unexpected EOI found at %td\n", GetOffset(addr - 2)); return false; } else { if ((marker == 0xCC) || (marker == 0xDC)) { // DAC and DNL @@ -145,7 +145,7 @@ bool CJpegStreamParser::Parse(unsigned char *streambase, size_t length) { } if (filelen < 2 || GetLength(addr) == 0) { - ALOGE("Invalid length 0 is read at offset %lu", GetOffset(addr)); + ALOGE("Invalid length 0 is read at offset %td", GetOffset(addr)); return false; } |