Skip to content

Commit

Permalink
Fix warnings on Linux
Browse files Browse the repository at this point in the history
- Missing imports that weren't necessary on Mac OS X.
- Signed comparision issues.
- Content-length was wrong type -- should really be off_t.
  • Loading branch information
bbockelm committed Nov 25, 2024
1 parent 73a8c0d commit b4fd3c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/S3File.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<off_t>(cache_size);
if (cache_end > req_off) {
auto cache_buf_off = static_cast<size_t>(req_off - cache_off);
auto cache_copy_bytes =
Expand Down Expand Up @@ -426,19 +426,20 @@ 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<off_t>(S3File::m_cache_entry_size));
}

bool S3File::S3Cache::CouldUse(off_t req_off, size_t req_size,
off_t cache_off) {
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<off_t>(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<off_t>(req_size) > cache_off;
}
}

Expand Down Expand Up @@ -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<off_t>(m_cache_entry_size) *
static_cast<off_t>(m_cache_entry_size);
if (needed_off > m_a.m_off) {
m_b.m_off = needed_off;
download_b = true;
Expand Down
3 changes: 2 additions & 1 deletion src/S3File.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <XrdSec/XrdSecEntityAttr.hh>
#include <XrdVersion.hh>

#include <atomic>
#include <condition_variable>
#include <memory>
#include <mutex>
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit b4fd3c6

Please sign in to comment.