From 6e0afbaa19d646fb0b6295c88c3656793c471704 Mon Sep 17 00:00:00 2001 From: zhupengfei <zhupf321@gmail.com> Date: Fri, 7 Feb 2020 16:26:33 +0800 Subject: [PATCH] Fix build Explicitly use `std::min<std::size_t>` Added virtual destructor --- src/core/file_sys/layered_fs.cpp | 9 +++++---- src/core/file_sys/layered_fs.h | 2 +- src/core/file_sys/romfs_reader.h | 4 ++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/core/file_sys/layered_fs.cpp b/src/core/file_sys/layered_fs.cpp index 9a194569a..80719d3fa 100644 --- a/src/core/file_sys/layered_fs.cpp +++ b/src/core/file_sys/layered_fs.cpp @@ -515,12 +515,13 @@ std::size_t LayeredFS::ReadFile(std::size_t offset, std::size_t length, u8* buff const auto relative_offset = offset - current->first; std::size_t to_read{}; if (current->second->relocation.size > relative_offset) { - to_read = - std::min(current->second->relocation.size - relative_offset, length - read_size); + to_read = std::min<std::size_t>(current->second->relocation.size - relative_offset, + length - read_size); } const auto alignment = - std::min(Common::AlignUp(current->second->relocation.size, 16) - relative_offset, - length - read_size) - + std::min<std::size_t>(Common::AlignUp(current->second->relocation.size, 16) - + relative_offset, + length - read_size) - to_read; // Read the file in different ways depending on relocation type diff --git a/src/core/file_sys/layered_fs.h b/src/core/file_sys/layered_fs.h index b9dcb831f..4f8844d98 100644 --- a/src/core/file_sys/layered_fs.h +++ b/src/core/file_sys/layered_fs.h @@ -42,7 +42,7 @@ class LayeredFS : public RomFSReader { public: explicit LayeredFS(std::shared_ptr<RomFSReader> romfs, std::string patch_path, std::string patch_ext_path); - ~LayeredFS(); + ~LayeredFS() override; std::size_t GetSize() const override; std::size_t ReadFile(std::size_t offset, std::size_t length, u8* buffer) override; diff --git a/src/core/file_sys/romfs_reader.h b/src/core/file_sys/romfs_reader.h index 5ee39015b..df0318c99 100644 --- a/src/core/file_sys/romfs_reader.h +++ b/src/core/file_sys/romfs_reader.h @@ -11,6 +11,8 @@ namespace FileSys { */ class RomFSReader { public: + virtual ~RomFSReader() = default; + virtual std::size_t GetSize() const = 0; virtual std::size_t ReadFile(std::size_t offset, std::size_t length, u8* buffer) = 0; }; @@ -30,6 +32,8 @@ public: : is_encrypted(true), file(std::move(file)), key(key), ctr(ctr), file_offset(file_offset), crypto_offset(crypto_offset), data_size(data_size) {} + ~DirectRomFSReader() override = default; + std::size_t GetSize() const override { return data_size; }