From 019bc9f6b2a7de85a0684c6f9efd37d1ea3282e4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 28 May 2021 01:46:26 -0400 Subject: common/fs/file: Default initialize IOFile members Prevents a potential uninitialized read vector in the move constructor. --- src/common/fs/file.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/common/fs/file.h b/src/common/fs/file.h index 209f9664b..daea935a2 100644 --- a/src/common/fs/file.h +++ b/src/common/fs/file.h @@ -441,8 +441,8 @@ public: private: std::filesystem::path file_path; - FileAccessMode file_access_mode; - FileType file_type; + FileAccessMode file_access_mode{}; + FileType file_type{}; std::FILE* file = nullptr; }; -- cgit v1.2.3 From 6806a893bd148bc376e415643205ee29dedeaed5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 28 May 2021 01:47:50 -0400 Subject: common/fs/file: Devirtualize destructor IOFile is a final class, so there's no need for a virtual destructor. --- src/common/fs/file.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/fs/file.h b/src/common/fs/file.h index daea935a2..33a8b9d2f 100644 --- a/src/common/fs/file.h +++ b/src/common/fs/file.h @@ -142,7 +142,7 @@ public: FileType type = FileType::BinaryFile, FileShareFlag flag = FileShareFlag::ShareReadOnly); - virtual ~IOFile(); + ~IOFile(); IOFile(IOFile&& other) noexcept; IOFile& operator=(IOFile&& other) noexcept; -- cgit v1.2.3 From 210c2c9a560565d644384ddb99098822600ceb7a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 28 May 2021 01:49:38 -0400 Subject: common/fs/file: Explicitly delete copy constructors Relocates them to the same place the move equivalents are at for consistent viewing. --- src/common/fs/file.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/fs/file.h b/src/common/fs/file.h index 33a8b9d2f..50e270c5b 100644 --- a/src/common/fs/file.h +++ b/src/common/fs/file.h @@ -117,7 +117,7 @@ template } #endif -class IOFile final : NonCopyable { +class IOFile final { public: IOFile(); @@ -144,6 +144,9 @@ public: ~IOFile(); + IOFile(const IOFile&) = delete; + IOFile& operator=(const IOFile&) = delete; + IOFile(IOFile&& other) noexcept; IOFile& operator=(IOFile&& other) noexcept; -- cgit v1.2.3