From 0d97553a5e1d91edfc325f1d9f5cf8c8bdd6a496 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 16 Aug 2025 16:29:06 +0100 Subject: Fix-up all the clang-tidy warnings --- src/blob.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/blob.cpp') diff --git a/src/blob.cpp b/src/blob.cpp index 2211736..285cd0b 100644 --- a/src/blob.cpp +++ b/src/blob.cpp @@ -2,17 +2,16 @@ #include "repo.h" #include #include -#include #include #include #include -#include +#include #include #include -GitFS::Blob::Blob(const Repo * const r, std::string && path) : - repo(r), entry(Git::TreeEntryByPath(repo->tree, path)), blob(getBlob()), blobSize(git_blob_rawsize(blob.get())), - blobContent(static_cast(git_blob_rawcontent(blob.get()))) +GitFS::Blob::Blob(const Repo * const repo, const std::string & path) : + repo(repo), entry(Git::treeEntryByPath(repo->tree, path)), blob(getBlob()), + blobContent(static_cast(git_blob_rawcontent(blob.get())), git_blob_rawsize(blob.get())) { } @@ -28,35 +27,36 @@ GitFS::Blob::getBlob() const throw NetFS::SystemError(ELOOP); } - return Git::BlobLookup(repo->repo, *git_tree_entry_id(entry.get())); + return Git::blobLookup(repo->repo, *git_tree_entry_id(entry.get())); } void -GitFS::Blob::close(const ::Ice::Current & current) +GitFS::Blob::close(const ::Ice::Current & ice) { - current.adapter->remove(current.id); + ice.adapter->remove(ice.id); } NetFS::Attr GitFS::Blob::fgetattr(const ::Ice::Current &) { - NetFS::Attr a; - a << *blob << *entry << *repo->commit; - a.gid = repo->gid; - a.uid = repo->uid; - return a; + NetFS::Attr attr; + attr << *blob << *entry << *repo->commit; + attr.gid = repo->gid; + attr.uid = repo->uid; + return attr; } NetFS::Buffer -GitFS::Blob::read(long long int o, long long int s, const ::Ice::Current &) +GitFS::Blob::read(long long int offsetSized, long long int sizeLong, const ::Ice::Current &) { - const auto offset {static_cast(o)}; - const auto size {static_cast(s)}; - if (offset > blobSize) { + const size_t offset = safe {offsetSized}; + if (offset > blobContent.size()) { return {}; } - auto len = std::min(blobSize - offset, size); - return {blobContent + offset, blobContent + offset + len}; + const size_t size = safe {sizeLong}; + const auto len = std::min(blobContent.size() - offset, size); + const auto range = blobContent.subspan(offset, len); + return {range.begin(), range.end()}; } void -- cgit v1.2.3