From b4fd3c639cc11cb84326e6bfbb09886dc4bf9e37 Mon Sep 17 00:00:00 2001 From: Brian Bockelman Date: Sun, 24 Nov 2024 19:06:42 -0600 Subject: [PATCH] Fix warnings on Linux - Missing imports that weren't necessary on Mac OS X. - Signed comparision issues. - Content-length was wrong type -- should really be off_t. --- src/S3File.cc | 14 ++++++++------ src/S3File.hh | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/S3File.cc b/src/S3File.cc index 1c863d0..215f9c1 100644 --- a/src/S3File.cc +++ b/src/S3File.cc @@ -363,7 +363,7 @@ OverlapCopy(off_t req_off, size_t req_size, char *req_buf, off_t cache_off, } if (cache_off <= req_off) { - auto cache_end = cache_off + cache_size; + auto cache_end = cache_off + static_cast(cache_size); if (cache_end > req_off) { auto cache_buf_off = static_cast(req_off - cache_off); auto cache_copy_bytes = @@ -426,7 +426,8 @@ bool S3File::S3Cache::CouldUseAligned(off_t req, off_t cache) { if (req < 0 || cache < 0) { return false; } - return (req >= cache) && (req < cache + S3File::m_cache_entry_size); + return (req >= cache) && + (req < cache + static_cast(S3File::m_cache_entry_size)); } bool S3File::S3Cache::CouldUse(off_t req_off, size_t req_size, @@ -434,11 +435,11 @@ bool S3File::S3Cache::CouldUse(off_t req_off, size_t req_size, if (req_off < 0 || cache_off < 0) { return false; } - auto cache_end = cache_off + m_cache_entry_size; + auto cache_end = cache_off + static_cast(m_cache_entry_size); if (req_off >= cache_off) { return req_off < cache_end; } else { - return req_off + req_size > cache_off; + return req_off + static_cast(req_size) > cache_off; } } @@ -790,8 +791,9 @@ ssize_t S3File::S3Cache::Read(S3File &file, char *buffer, off_t offset, } } else { // Select one cache entry to fetch data. - auto needed_off = - req1_off / m_cache_entry_size * m_cache_entry_size; + auto needed_off = req1_off / + static_cast(m_cache_entry_size) * + static_cast(m_cache_entry_size); if (needed_off > m_a.m_off) { m_b.m_off = needed_off; download_b = true; diff --git a/src/S3File.hh b/src/S3File.hh index 0fc0327..fec1fdc 100644 --- a/src/S3File.hh +++ b/src/S3File.hh @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -120,7 +121,7 @@ class S3File : public XrdOssDF { std::string m_object; S3AccessInfo m_ai; - size_t content_length; + off_t content_length; time_t last_modified; static const size_t m_s3_part_size =