diff options
author | Laszlo Boszormenyi (GCS) <gcs@debian.org> | 2025-02-16 09:07:36 +0100 |
---|---|---|
committer | Bernd Schubert <bernd@bsbernd.com> | 2025-02-17 19:06:31 +0100 |
commit | 5889ae6733298ab2f79c25b03b53f7a49255156e (patch) | |
tree | 1bc081fcf1306f17ae5106b1a78dc361b247cc2e | |
parent | 374892840a5767309905dcce1fcde5f80173eedf (diff) | |
download | libfuse-5889ae6733298ab2f79c25b03b53f7a49255156e.tar.gz |
Fix build of example/memfs_ll.cc on 32 bit architectures
The code uses std::min() which expects its arguments to be size_t. Two
times it uses an offset declared as off_t. While both size_t and off_t
are 32-bit integers, the latter is signed. On 64 bit architectures
the conversation of off_t -> size_t performed automatically. On 32 bit
architectures it needs a type cast.
Signed-off-by: Laszlo Boszormenyi (GCS) <gcs@debian.org>
-rw-r--r-- | example/memfs_ll.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/example/memfs_ll.cc b/example/memfs_ll.cc index c7b9663..9898f25 100644 --- a/example/memfs_ll.cc +++ b/example/memfs_ll.cc @@ -150,7 +150,7 @@ class Inode { void read_content(char *buf, size_t size, off_t offset) const { - size_t bytes_to_read = std::min(size, content.size() - offset); + size_t bytes_to_read = std::min(size, content.size() - (size_t)offset); std::copy(content.begin() + offset, content.begin() + offset + bytes_to_read, buf); } @@ -613,7 +613,7 @@ static void memfs_read(fuse_req_t req, fuse_ino_t ino, size_t size, } std::vector<char> content( - std::min(size, inode->content_size() - offset)); + std::min(size, inode->content_size() - (size_t)offset)); inode->read_content(content.data(), content.size(), offset); inode->unlock(); |