From 6e0afbaa19d646fb0b6295c88c3656793c471704 Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Fri, 7 Feb 2020 16:26:33 +0800 Subject: [PATCH] Fix build Explicitly use `std::min` 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 9a194569ae..80719d3fa6 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(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(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 b9dcb831f4..4f8844d988 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 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 5ee39015bb..df0318c99a 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; }