summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
m---------externals/catch0
m---------externals/xbyak0
-rw-r--r--src/common/common_funcs.h42
-rw-r--r--src/common/file_util.cpp2
-rw-r--r--src/common/file_util.h2
-rw-r--r--src/common/misc.cpp16
-rw-r--r--src/common/string_util.cpp12
-rw-r--r--src/common/string_util.h3
-rw-r--r--src/common/swap.h100
-rw-r--r--src/core/file_sys/content_archive.cpp5
-rw-r--r--src/core/file_sys/content_archive.h7
-rw-r--r--src/core/file_sys/partition_filesystem.cpp29
-rw-r--r--src/core/file_sys/partition_filesystem.h10
-rw-r--r--src/core/file_sys/savedata_factory.cpp2
-rw-r--r--src/core/file_sys/savedata_factory.h2
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp2
-rw-r--r--src/core/hle/service/acc/acc.h2
-rw-r--r--src/core/hle/service/am/am.h2
-rw-r--r--src/core/hle/service/am/applet_ae.cpp2
-rw-r--r--src/core/hle/service/am/applet_ae.h2
-rw-r--r--src/core/hle/service/am/applet_oe.cpp2
-rw-r--r--src/core/hle/service/am/applet_oe.h2
-rw-r--r--src/core/hle/service/apm/interface.h2
-rw-r--r--src/core/hle/service/audio/audren_u.cpp4
-rw-r--r--src/core/hle/service/bcat/module.h2
-rw-r--r--src/core/hle/service/fatal/fatal.h2
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp10
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp39
-rw-r--r--src/core/hle/service/friend/friend.h2
-rw-r--r--src/core/hle/service/nfp/nfp.h2
-rw-r--r--src/core/hle/service/nifm/nifm.h2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdisp_disp0.h2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_gpu.h2
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.h2
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp13
-rw-r--r--src/core/hle/service/pctl/module.h2
-rw-r--r--src/core/hle/service/sm/sm.h2
-rw-r--r--src/core/hle/service/spl/module.h2
-rw-r--r--src/core/hle/service/time/time.h2
-rw-r--r--src/core/hle/service/vi/vi.cpp4
-rw-r--r--src/core/hle/service/vi/vi.h4
-rw-r--r--src/core/loader/nro.cpp2
-rw-r--r--src/core/loader/nso.cpp8
44 files changed, 151 insertions, 207 deletions
diff --git a/externals/catch b/externals/catch
-Subproject cd76f5730c9a3afa19f3b9c83608d9c7ab325a1
+Subproject d2a130f2433aeaca070e3e4d6298a80049d21cf
diff --git a/externals/xbyak b/externals/xbyak
-Subproject 2794cde79eb71e86490061cac9622ad0067b8d1
+Subproject 71b75f653f3858403eb33d48f6346eef34b837f
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index 995938d0b..93f1c0044 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -4,6 +4,8 @@
#pragma once
+#include <string>
+
#if !defined(ARCHITECTURE_x86_64) && !defined(ARCHITECTURE_ARM)
#include <cstdlib> // for exit
#endif
@@ -36,40 +38,6 @@
#define Crash() exit(1)
#endif
-// GCC 4.8 defines all the rotate functions now
-// Small issue with GCC's lrotl/lrotr intrinsics is they are still 32bit while we require 64bit
-#ifdef _rotl
-#define rotl _rotl
-#else
-inline u32 rotl(u32 x, int shift) {
- shift &= 31;
- if (!shift)
- return x;
- return (x << shift) | (x >> (32 - shift));
-}
-#endif
-
-#ifdef _rotr
-#define rotr _rotr
-#else
-inline u32 rotr(u32 x, int shift) {
- shift &= 31;
- if (!shift)
- return x;
- return (x >> shift) | (x << (32 - shift));
-}
-#endif
-
-inline u64 _rotl64(u64 x, unsigned int shift) {
- unsigned int n = shift % 64;
- return (x << n) | (x >> (64 - n));
-}
-
-inline u64 _rotr64(u64 x, unsigned int shift) {
- unsigned int n = shift % 64;
- return (x >> n) | (x << (64 - n));
-}
-
#else // _MSC_VER
// Locale Cross-Compatibility
@@ -80,17 +48,13 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
}
#define Crash() DebugBreak()
-// cstdlib provides these on MSVC
-#define rotr _rotr
-#define rotl _rotl
-
#endif // _MSC_VER ndef
// Generic function to get last error message.
// Call directly after the command or use the error num.
// This function might change the error code.
// Defined in Misc.cpp.
-const char* GetLastErrorMsg();
+std::string GetLastErrorMsg();
namespace Common {
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index bf955386c..c882ab39f 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -592,7 +592,7 @@ std::string GetBundleDirectory() {
#endif
#ifdef _WIN32
-std::string& GetExeDirectory() {
+const std::string& GetExeDirectory() {
static std::string exe_path;
if (exe_path.empty()) {
wchar_t wchar_exe_path[2048];
diff --git a/src/common/file_util.h b/src/common/file_util.h
index 026c84d94..1f38b1560 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -133,7 +133,7 @@ std::string GetBundleDirectory();
#endif
#ifdef _WIN32
-std::string& GetExeDirectory();
+const std::string& GetExeDirectory();
std::string AppDataRoamingDirectory();
#endif
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index 7be2235b0..217a87098 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.cpp
@@ -4,34 +4,28 @@
#include <cstddef>
#ifdef _WIN32
-#include <windows.h>
+#include <Windows.h>
#else
#include <cerrno>
#include <cstring>
#endif
-// Neither Android nor OS X support TLS
-#if defined(__APPLE__) || (ANDROID && __clang__)
-#define __thread
-#endif
+#include "common/common_funcs.h"
// Generic function to get last error message.
// Call directly after the command or use the error num.
// This function might change the error code.
-const char* GetLastErrorMsg() {
+std::string GetLastErrorMsg() {
static const size_t buff_size = 255;
+ char err_str[buff_size];
#ifdef _WIN32
- static __declspec(thread) char err_str[buff_size] = {};
-
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), err_str, buff_size, nullptr);
#else
- static __thread char err_str[buff_size] = {};
-
// Thread safe (XSI-compliant)
strerror_r(errno, err_str, buff_size);
#endif
- return err_str;
+ return std::string(err_str, buff_size);
}
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 0027888c7..f3ad3d68a 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -34,18 +34,6 @@ std::string ToUpper(std::string str) {
return str;
}
-// faster than sscanf
-bool AsciiToHex(const char* _szValue, u32& result) {
- char* endptr = nullptr;
- const u32 value = strtoul(_szValue, &endptr, 16);
-
- if (!endptr || *endptr)
- return false;
-
- result = value;
- return true;
-}
-
// For Debugging. Read out an u8 array.
std::string ArrayToString(const u8* data, size_t size, int line_len, bool spaces) {
std::ostringstream oss;
diff --git a/src/common/string_util.h b/src/common/string_util.h
index 1f5a383cb..daa071f83 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -57,9 +57,6 @@ static bool TryParse(const std::string& str, N* const output) {
return false;
}
-// TODO: kill this
-bool AsciiToHex(const char* _szValue, u32& result);
-
std::string TabsToSpaces(int tab_size, const std::string& in);
void SplitString(const std::string& str, char delim, std::vector<std::string>& output);
diff --git a/src/common/swap.h b/src/common/swap.h
index f025f7450..fc7af4280 100644
--- a/src/common/swap.h
+++ b/src/common/swap.h
@@ -167,7 +167,7 @@ inline double swapd(double f) {
template <typename T, typename F>
struct swap_struct_t {
- typedef swap_struct_t<T, F> swapped_t;
+ using swapped_t = swap_struct_t;
protected:
T value = T();
@@ -177,7 +177,7 @@ protected:
}
public:
- T const swap() const {
+ T swap() const {
return swap(value);
}
swap_struct_t() = default;
@@ -185,39 +185,39 @@ public:
template <typename S>
swapped_t& operator=(const S& source) {
- value = swap((T)source);
+ value = swap(static_cast<T>(source));
return *this;
}
operator s8() const {
- return (s8)swap();
+ return static_cast<s8>(swap());
}
operator u8() const {
- return (u8)swap();
+ return static_cast<u8>(swap());
}
operator s16() const {
- return (s16)swap();
+ return static_cast<s16>(swap());
}
operator u16() const {
- return (u16)swap();
+ return static_cast<u16>(swap());
}
operator s32() const {
- return (s32)swap();
+ return static_cast<s32>(swap());
}
operator u32() const {
- return (u32)swap();
+ return static_cast<u32>(swap());
}
operator s64() const {
- return (s64)swap();
+ return static_cast<s64>(swap());
}
operator u64() const {
- return (u64)swap();
+ return static_cast<u64>(swap());
}
operator float() const {
- return (float)swap();
+ return static_cast<float>(swap());
}
operator double() const {
- return (double)swap();
+ return static_cast<double>(swap());
}
// +v
@@ -253,7 +253,7 @@ public:
}
template <typename S>
swapped_t operator+(const S& i) const {
- return swap() + (T)i;
+ return swap() + static_cast<T>(i);
}
// v - 5
swapped_t operator-(const swapped_t& i) const {
@@ -261,7 +261,7 @@ public:
}
template <typename S>
swapped_t operator-(const S& i) const {
- return swap() - (T)i;
+ return swap() - static_cast<T>(i);
}
// v += 5
@@ -271,7 +271,7 @@ public:
}
template <typename S>
swapped_t& operator+=(const S& i) {
- value = swap(swap() + (T)i);
+ value = swap(swap() + static_cast<T>(i));
return *this;
}
// v -= 5
@@ -281,7 +281,7 @@ public:
}
template <typename S>
swapped_t& operator-=(const S& i) {
- value = swap(swap() - (T)i);
+ value = swap(swap() - static_cast<T>(i));
return *this;
}
@@ -541,7 +541,7 @@ S operator&(const S& i, const swap_struct_t<T, F> v) {
template <typename S, typename T, typename F>
S operator&(const swap_struct_t<T, F> v, const S& i) {
- return (S)(v.swap() & i);
+ return static_cast<S>(v.swap() & i);
}
// Comparaison
@@ -606,51 +606,51 @@ struct swap_double_t {
};
#if COMMON_LITTLE_ENDIAN
-typedef u32 u32_le;
-typedef u16 u16_le;
-typedef u64 u64_le;
+using u16_le = u16;
+using u32_le = u32;
+using u64_le = u64;
-typedef s32 s32_le;
-typedef s16 s16_le;
-typedef s64 s64_le;
+using s16_le = s16;
+using s32_le = s32;
+using s64_le = s64;
-typedef float float_le;
-typedef double double_le;
+using float_le = float;
+using double_le = double;
-typedef swap_struct_t<u64, swap_64_t<u64>> u64_be;
-typedef swap_struct_t<s64, swap_64_t<s64>> s64_be;
+using u64_be = swap_struct_t<u64, swap_64_t<u64>>;
+using s64_be = swap_struct_t<s64, swap_64_t<s64>>;
-typedef swap_struct_t<u32, swap_32_t<u32>> u32_be;
-typedef swap_struct_t<s32, swap_32_t<s32>> s32_be;
+using u32_be = swap_struct_t<u32, swap_32_t<u32>>;
+using s32_be = swap_struct_t<s32, swap_32_t<s32>>;
-typedef swap_struct_t<u16, swap_16_t<u16>> u16_be;
-typedef swap_struct_t<s16, swap_16_t<s16>> s16_be;
+using u16_be = swap_struct_t<u16, swap_16_t<u16>>;
+using s16_be = swap_struct_t<s16, swap_16_t<s16>>;
-typedef swap_struct_t<float, swap_float_t<float>> float_be;
-typedef swap_struct_t<double, swap_double_t<double>> double_be;
+using float_be = swap_struct_t<float, swap_float_t<float>>;
+using double_be = swap_struct_t<double, swap_double_t<double>>;
#else
-typedef swap_struct_t<u64, swap_64_t<u64>> u64_le;
-typedef swap_struct_t<s64, swap_64_t<s64>> s64_le;
+using u64_le = swap_struct_t<u64, swap_64_t<u64>>;
+using s64_le = swap_struct_t<s64, swap_64_t<s64>>;
-typedef swap_struct_t<u32, swap_32_t<u32>> u32_le;
-typedef swap_struct_t<s32, swap_32_t<s32>> s32_le;
+using u32_le = swap_struct_t<u32, swap_32_t<u32>>;
+using s32_le = swap_struct_t<s32, swap_32_t<s32>>;
-typedef swap_struct_t<u16, swap_16_t<u16>> u16_le;
-typedef swap_struct_t<s16, swap_16_t<s16>> s16_le;
+using u16_le = swap_struct_t<u16, swap_16_t<u16>>;
+using s16_le = swap_struct_t<s16, swap_16_t<s16>>;
-typedef swap_struct_t<float, swap_float_t<float>> float_le;
-typedef swap_struct_t<double, swap_double_t<double>> double_le;
+using float_le = swap_struct_t<float, swap_float_t<float>>;
+using double_le = swap_struct_t<double, swap_double_t<double>>;
-typedef u32 u32_be;
-typedef u16 u16_be;
-typedef u64 u64_be;
+using u16_be = u16;
+using u32_be = u32;
+using u64_be = u64;
-typedef s32 s32_be;
-typedef s16 s16_be;
-typedef s64 s64_be;
+using s16_be = s16;
+using s32_be = s32;
+using s64_be = s64;
-typedef float float_be;
-typedef double double_be;
+using float_be = float;
+using double_be = double;
#endif
diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp
index 6cfef774d..d6b20c047 100644
--- a/src/core/file_sys/content_archive.cpp
+++ b/src/core/file_sys/content_archive.cpp
@@ -2,6 +2,9 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <algorithm>
+#include <utility>
+
#include "common/logging/log.h"
#include "core/file_sys/content_archive.h"
#include "core/file_sys/vfs_offset.h"
@@ -61,7 +64,7 @@ struct RomFSSuperblock {
};
static_assert(sizeof(RomFSSuperblock) == 0xE8, "RomFSSuperblock has incorrect size.");
-NCA::NCA(VirtualFile file_) : file(file_) {
+NCA::NCA(VirtualFile file_) : file(std::move(file_)) {
if (sizeof(NCAHeader) != file->ReadObject(&header))
LOG_CRITICAL(Loader, "File reader errored out during header read.");
diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h
index 129a70b97..0b8b9db61 100644
--- a/src/core/file_sys/content_archive.h
+++ b/src/core/file_sys/content_archive.h
@@ -4,6 +4,11 @@
#pragma once
+#include <array>
+#include <memory>
+#include <string>
+#include <vector>
+
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/swap.h"
@@ -48,7 +53,7 @@ struct NCAHeader {
};
static_assert(sizeof(NCAHeader) == 0x400, "NCAHeader has incorrect size.");
-inline bool IsDirectoryExeFS(std::shared_ptr<FileSys::VfsDirectory> pfs) {
+inline bool IsDirectoryExeFS(const std::shared_ptr<VfsDirectory>& pfs) {
// According to switchbrew, an exefs must only contain these two files:
return pfs->GetFile("main") != nullptr && pfs->GetFile("main.npdm") != nullptr;
}
diff --git a/src/core/file_sys/partition_filesystem.cpp b/src/core/file_sys/partition_filesystem.cpp
index 15b1fb946..d4097a510 100644
--- a/src/core/file_sys/partition_filesystem.cpp
+++ b/src/core/file_sys/partition_filesystem.cpp
@@ -11,6 +11,11 @@
namespace FileSys {
+bool PartitionFilesystem::Header::HasValidMagicValue() const {
+ return magic == Common::MakeMagic('H', 'F', 'S', '0') ||
+ magic == Common::MakeMagic('P', 'F', 'S', '0');
+}
+
PartitionFilesystem::PartitionFilesystem(std::shared_ptr<VfsFile> file) {
// At least be as large as the header
if (file->GetSize() < sizeof(Header)) {
@@ -20,19 +25,17 @@ PartitionFilesystem::PartitionFilesystem(std::shared_ptr<VfsFile> file) {
// For cartridges, HFSs can get very large, so we need to calculate the size up to
// the actual content itself instead of just blindly reading in the entire file.
- Header pfs_header;
if (sizeof(Header) != file->ReadObject(&pfs_header)) {
status = Loader::ResultStatus::Error;
return;
}
- if (pfs_header.magic != Common::MakeMagic('H', 'F', 'S', '0') &&
- pfs_header.magic != Common::MakeMagic('P', 'F', 'S', '0')) {
+ if (!pfs_header.HasValidMagicValue()) {
status = Loader::ResultStatus::ErrorInvalidFormat;
return;
}
- bool is_hfs = pfs_header.magic == Common::MakeMagic('H', 'F', 'S', '0');
+ is_hfs = pfs_header.magic == Common::MakeMagic('H', 'F', 'S', '0');
size_t entry_size = is_hfs ? sizeof(HFSEntry) : sizeof(PFSEntry);
size_t metadata_size =
@@ -40,27 +43,13 @@ PartitionFilesystem::PartitionFilesystem(std::shared_ptr<VfsFile> file) {
// Actually read in now...
std::vector<u8> file_data = file->ReadBytes(metadata_size);
+ const size_t total_size = file_data.size();
- if (file_data.size() != metadata_size) {
- status = Loader::ResultStatus::Error;
- return;
- }
-
- size_t total_size = file_data.size();
- if (total_size < sizeof(Header)) {
+ if (total_size != metadata_size) {
status = Loader::ResultStatus::Error;
return;
}
- memcpy(&pfs_header, file_data.data(), sizeof(Header));
- if (pfs_header.magic != Common::MakeMagic('H', 'F', 'S', '0') &&
- pfs_header.magic != Common::MakeMagic('P', 'F', 'S', '0')) {
- status = Loader::ResultStatus::ErrorInvalidFormat;
- return;
- }
-
- is_hfs = pfs_header.magic == Common::MakeMagic('H', 'F', 'S', '0');
-
size_t entries_offset = sizeof(Header);
size_t strtab_offset = entries_offset + (pfs_header.num_entries * entry_size);
content_offset = strtab_offset + pfs_header.strtab_size;
diff --git a/src/core/file_sys/partition_filesystem.h b/src/core/file_sys/partition_filesystem.h
index 9656b40bf..7c7a75816 100644
--- a/src/core/file_sys/partition_filesystem.h
+++ b/src/core/file_sys/partition_filesystem.h
@@ -42,6 +42,8 @@ private:
u32_le num_entries;
u32_le strtab_size;
INSERT_PADDING_BYTES(0x4);
+
+ bool HasValidMagicValue() const;
};
static_assert(sizeof(Header) == 0x10, "PFS/HFS header structure size is wrong");
@@ -73,11 +75,11 @@ private:
#pragma pack(pop)
- Loader::ResultStatus status;
+ Loader::ResultStatus status{};
- Header pfs_header;
- bool is_hfs;
- size_t content_offset;
+ Header pfs_header{};
+ bool is_hfs = false;
+ size_t content_offset = 0;
std::vector<VirtualFile> pfs_files;
std::vector<VirtualDir> pfs_dirs;
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp
index 6a53b2b10..dfdca83d6 100644
--- a/src/core/file_sys/savedata_factory.cpp
+++ b/src/core/file_sys/savedata_factory.cpp
@@ -11,7 +11,7 @@
namespace FileSys {
-std::string SaveDataDescriptor::DebugInfo() {
+std::string SaveDataDescriptor::DebugInfo() const {
return fmt::format("[type={:02X}, title_id={:016X}, user_id={:016X}{:016X}, save_id={:016X}]",
static_cast<u8>(type), title_id, user_id[1], user_id[0], save_id);
}
diff --git a/src/core/file_sys/savedata_factory.h b/src/core/file_sys/savedata_factory.h
index 53c69876f..e3a578c0f 100644
--- a/src/core/file_sys/savedata_factory.h
+++ b/src/core/file_sys/savedata_factory.h
@@ -37,7 +37,7 @@ struct SaveDataDescriptor {
u64_le zero_2;
u64_le zero_3;
- std::string DebugInfo();
+ std::string DebugInfo() const;
};
static_assert(sizeof(SaveDataDescriptor) == 0x40, "SaveDataDescriptor has incorrect size.");
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index b89c8c33d..911e6fbc1 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -302,7 +302,7 @@ size_t HLERequestContext::WriteBuffer(const void* buffer, size_t size, int buffe
}
size_t HLERequestContext::WriteBuffer(const std::vector<u8>& buffer, int buffer_index) const {
- return WriteBuffer(buffer.data(), buffer.size());
+ return WriteBuffer(buffer.data(), buffer.size(), buffer_index);
}
size_t HLERequestContext::GetReadBufferSize(int buffer_index) const {
diff --git a/src/core/hle/service/acc/acc.h b/src/core/hle/service/acc/acc.h
index 58f8d260c..0a01d954c 100644
--- a/src/core/hle/service/acc/acc.h
+++ b/src/core/hle/service/acc/acc.h
@@ -12,7 +12,7 @@ class Module final {
public:
class Interface : public ServiceFramework<Interface> {
public:
- Interface(std::shared_ptr<Module> module, const char* name);
+ explicit Interface(std::shared_ptr<Module> module, const char* name);
void GetUserExistence(Kernel::HLERequestContext& ctx);
void ListAllUsers(Kernel::HLERequestContext& ctx);
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h
index 1da79fd01..8f4f98346 100644
--- a/src/core/hle/service/am/am.h
+++ b/src/core/hle/service/am/am.h
@@ -72,7 +72,7 @@ public:
class ISelfController final : public ServiceFramework<ISelfController> {
public:
- ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger);
+ explicit ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger);
private:
void SetFocusHandlingMode(Kernel::HLERequestContext& ctx);
diff --git a/src/core/hle/service/am/applet_ae.cpp b/src/core/hle/service/am/applet_ae.cpp
index 180057ec2..7cebc918a 100644
--- a/src/core/hle/service/am/applet_ae.cpp
+++ b/src/core/hle/service/am/applet_ae.cpp
@@ -12,7 +12,7 @@ namespace Service::AM {
class ILibraryAppletProxy final : public ServiceFramework<ILibraryAppletProxy> {
public:
- ILibraryAppletProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
+ explicit ILibraryAppletProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
: ServiceFramework("ILibraryAppletProxy"), nvflinger(std::move(nvflinger)) {
static const FunctionInfo functions[] = {
{0, &ILibraryAppletProxy::GetCommonStateGetter, "GetCommonStateGetter"},
diff --git a/src/core/hle/service/am/applet_ae.h b/src/core/hle/service/am/applet_ae.h
index f3a96651e..bdc57b9bc 100644
--- a/src/core/hle/service/am/applet_ae.h
+++ b/src/core/hle/service/am/applet_ae.h
@@ -17,7 +17,7 @@ namespace AM {
class AppletAE final : public ServiceFramework<AppletAE> {
public:
- AppletAE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger);
+ explicit AppletAE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger);
~AppletAE() = default;
private:
diff --git a/src/core/hle/service/am/applet_oe.cpp b/src/core/hle/service/am/applet_oe.cpp
index 278259eda..beea7d19b 100644
--- a/src/core/hle/service/am/applet_oe.cpp
+++ b/src/core/hle/service/am/applet_oe.cpp
@@ -12,7 +12,7 @@ namespace Service::AM {
class IApplicationProxy final : public ServiceFramework<IApplicationProxy> {
public:
- IApplicationProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
+ explicit IApplicationProxy(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
: ServiceFramework("IApplicationProxy"), nvflinger(std::move(nvflinger)) {
static const FunctionInfo functions[] = {
{0, &IApplicationProxy::GetCommonStateGetter, "GetCommonStateGetter"},
diff --git a/src/core/hle/service/am/applet_oe.h b/src/core/hle/service/am/applet_oe.h
index d2ab44c67..c52e2a322 100644
--- a/src/core/hle/service/am/applet_oe.h
+++ b/src/core/hle/service/am/applet_oe.h
@@ -17,7 +17,7 @@ namespace AM {
class AppletOE final : public ServiceFramework<AppletOE> {
public:
- AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger);
+ explicit AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger);
~AppletOE() = default;
private:
diff --git a/src/core/hle/service/apm/interface.h b/src/core/hle/service/apm/interface.h
index b99dbb412..85258a666 100644
--- a/src/core/hle/service/apm/interface.h
+++ b/src/core/hle/service/apm/interface.h
@@ -10,7 +10,7 @@ namespace Service::APM {
class APM final : public ServiceFramework<APM> {
public:
- APM(std::shared_ptr<Module> apm, const char* name);
+ explicit APM(std::shared_ptr<Module> apm, const char* name);
~APM() = default;
private:
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index b7f591c6d..2a8b3e216 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -17,7 +17,7 @@ constexpr u64 audio_ticks{static_cast<u64>(CoreTiming::BASE_CLOCK_RATE / 200)};
class IAudioRenderer final : public ServiceFramework<IAudioRenderer> {
public:
- IAudioRenderer(AudioRendererParameter audren_params)
+ explicit IAudioRenderer(AudioRendererParameter audren_params)
: ServiceFramework("IAudioRenderer"), worker_params(audren_params) {
static const FunctionInfo functions[] = {
{0, nullptr, "GetAudioRendererSampleRate"},
@@ -176,7 +176,7 @@ private:
struct UpdateDataHeader {
UpdateDataHeader() {}
- UpdateDataHeader(const AudioRendererParameter& config) {
+ explicit UpdateDataHeader(const AudioRendererParameter& config) {
revision = Common::MakeMagic('R', 'E', 'V', '4'); // 5.1.0 Revision
behavior_size = 0xb0;
memory_pools_size = (config.effect_count + (config.voice_count * 4)) * 0x10;
diff --git a/src/core/hle/service/bcat/module.h b/src/core/hle/service/bcat/module.h
index 8366fb877..62f6f5f9d 100644
--- a/src/core/hle/service/bcat/module.h
+++ b/src/core/hle/service/bcat/module.h
@@ -12,7 +12,7 @@ class Module final {
public:
class Interface : public ServiceFramework<Interface> {
public:
- Interface(std::shared_ptr<Module> module, const char* name);
+ explicit Interface(std::shared_ptr<Module> module, const char* name);
void CreateBcatService(Kernel::HLERequestContext& ctx);
diff --git a/src/core/hle/service/fatal/fatal.h b/src/core/hle/service/fatal/fatal.h
index 5bd111a14..ca607e236 100644
--- a/src/core/hle/service/fatal/fatal.h
+++ b/src/core/hle/service/fatal/fatal.h
@@ -12,7 +12,7 @@ class Module final {
public:
class Interface : public ServiceFramework<Interface> {
public:
- Interface(std::shared_ptr<Module> module, const char* name);
+ explicit Interface(std::shared_ptr<Module> module, const char* name);
void ThrowFatalWithPolicy(Kernel::HLERequestContext& ctx);
void ThrowFatalWithCpuContext(Kernel::HLERequestContext& ctx);
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index ec528ef40..dffcdfbaf 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -2,7 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
-#pragma optimize("", off)
+#include <utility>
#include "common/assert.h"
#include "common/file_util.h"
@@ -25,14 +25,14 @@ constexpr u64 EMULATED_SD_REPORTED_SIZE = 32000000000;
static FileSys::VirtualDir GetDirectoryRelativeWrapped(FileSys::VirtualDir base,
const std::string& dir_name) {
- if (dir_name == "." || dir_name == "" || dir_name == "/" || dir_name == "\\")
+ if (dir_name.empty() || dir_name == "." || dir_name == "/" || dir_name == "\\")
return base;
return base->GetDirectoryRelative(dir_name);
}
VfsDirectoryServiceWrapper::VfsDirectoryServiceWrapper(FileSys::VirtualDir backing_)
- : backing(backing_) {}
+ : backing(std::move(backing_)) {}
std::string VfsDirectoryServiceWrapper::GetName() const {
return backing->GetName();
@@ -193,6 +193,10 @@ ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType(
if (dir == nullptr)
return FileSys::ERROR_PATH_NOT_FOUND;
auto filename = FileUtil::GetFilename(path);
+ // TODO(Subv): Some games use the '/' path, find out what this means.
+ if (filename.empty())
+ return MakeResult(FileSys::EntryType::Directory);
+
if (dir->GetFile(filename) != nullptr)
return MakeResult(FileSys::EntryType::File);
if (dir->GetSubdirectory(filename) != nullptr)
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index 1b003bd84..e7ffb6bd1 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -3,6 +3,14 @@
// Refer to the license.txt file included.
#include <cinttypes>
+#include <cstring>
+#include <iterator>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "common/assert.h"
+#include "common/common_types.h"
#include "common/logging/log.h"
#include "common/string_util.h"
#include "core/core.h"
@@ -26,7 +34,7 @@ enum class StorageId : u8 {
class IStorage final : public ServiceFramework<IStorage> {
public:
- IStorage(FileSys::VirtualFile backend_)
+ explicit IStorage(FileSys::VirtualFile backend_)
: ServiceFramework("IStorage"), backend(std::move(backend_)) {
static const FunctionInfo functions[] = {
{0, &IStorage::Read, "Read"}, {1, nullptr, "Write"}, {2, nullptr, "Flush"},
@@ -133,19 +141,19 @@ private:
return;
}
- std::vector<u8> data = ctx.ReadBuffer();
- std::vector<u8> actual_data(length);
+ const std::vector<u8> data = ctx.ReadBuffer();
ASSERT_MSG(
- data.size() <= length,
+ static_cast<s64>(data.size()) <= length,
"Attempting to write more data than requested (requested={:016X}, actual={:016X}).",
length, data.size());
- std::copy(data.begin(), data.end(), actual_data.begin());
// Write the data to the Storage backend
- auto written = backend->WriteBytes(data, offset);
+ const auto write_size =
+ static_cast<std::size_t>(std::distance(data.begin(), data.begin() + length));
+ const std::size_t written = backend->Write(data.data(), write_size, offset);
- ASSERT_MSG(written == length,
+ ASSERT_MSG(static_cast<s64>(written) == length,
"Could not write all bytes to file (requested={:016X}, actual={:016X}).", length,
written);
@@ -223,23 +231,20 @@ private:
LOG_DEBUG(Service_FS, "called, unk=0x{:X}", unk);
// Calculate how many entries we can fit in the output buffer
- u64 count_entries = ctx.GetWriteBufferSize() / sizeof(FileSys::Entry);
+ const u64 count_entries = ctx.GetWriteBufferSize() / sizeof(FileSys::Entry);
// Cap at total number of entries.
- u64 actual_entries = std::min(count_entries, entries.size() - next_entry_index);
+ const u64 actual_entries = std::min(count_entries, entries.size() - next_entry_index);
- // Read the data from the Directory backend
- std::vector<FileSys::Entry> entry_data(entries.begin() + next_entry_index,
- entries.begin() + next_entry_index + actual_entries);
+ // Determine data start and end
+ const auto* begin = reinterpret_cast<u8*>(entries.data() + next_entry_index);
+ const auto* end = reinterpret_cast<u8*>(entries.data() + next_entry_index + actual_entries);
+ const auto range_size = static_cast<std::size_t>(std::distance(begin, end));
next_entry_index += actual_entries;
- // Convert the data into a byte array
- std::vector<u8> output(entry_data.size() * sizeof(FileSys::Entry));
- std::memcpy(output.data(), entry_data.data(), output.size());
-
// Write the data to memory
- ctx.WriteBuffer(output);
+ ctx.WriteBuffer(begin, range_size);
IPC::ResponseBuilder rb{ctx, 4};
rb.Push(RESULT_SUCCESS);
diff --git a/src/core/hle/service/friend/friend.h b/src/core/hle/service/friend/friend.h
index 4b72115c0..c1b36518a 100644
--- a/src/core/hle/service/friend/friend.h
+++ b/src/core/hle/service/friend/friend.h
@@ -12,7 +12,7 @@ class Module final {
public:
class Interface : public ServiceFramework<Interface> {
public:
- Interface(std::shared_ptr<Module> module, const char* name);
+ explicit Interface(std::shared_ptr<Module> module, const char* name);
void CreateFriendService(Kernel::HLERequestContext& ctx);
diff --git a/src/core/hle/service/nfp/nfp.h b/src/core/hle/service/nfp/nfp.h
index 262a666cb..0cd7be3d5 100644
--- a/src/core/hle/service/nfp/nfp.h
+++ b/src/core/hle/service/nfp/nfp.h
@@ -12,7 +12,7 @@ class Module final {
public:
class Interface : public ServiceFramework<Interface> {
public:
- Interface(std::shared_ptr<Module> module, const char* name);
+ explicit Interface(std::shared_ptr<Module> module, const char* name);
void CreateUserInterface(Kernel::HLERequestContext& ctx);
diff --git a/src/core/hle/service/nifm/nifm.h b/src/core/hle/service/nifm/nifm.h
index 4ad3f3bcf..11f1b5831 100644
--- a/src/core/hle/service/nifm/nifm.h
+++ b/src/core/hle/service/nifm/nifm.h
@@ -12,7 +12,7 @@ class Module final {
public:
class Interface : public ServiceFramework<Interface> {
public:
- Interface(std::shared_ptr<Module> module, const char* name);
+ explicit Interface(std::shared_ptr<Module> module, const char* name);
void CreateGeneralServiceOld(Kernel::HLERequestContext& ctx);
void CreateGeneralService(Kernel::HLERequestContext& ctx);
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h
index d4631a32b..6f0697b58 100644
--- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h
+++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h
@@ -17,7 +17,7 @@ class nvmap;
class nvdisp_disp0 final : public nvdevice {
public:
- nvdisp_disp0(std::shared_ptr<nvmap> nvmap_dev) : nvdevice(), nvmap_dev(std::move(nvmap_dev)) {}
+ explicit nvdisp_disp0(std::shared_ptr<nvmap> nvmap_dev) : nvmap_dev(std::move(nvmap_dev)) {}
~nvdisp_disp0() = default;
u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override;
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
index d4c4b4db3..9f8999d9c 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
@@ -18,7 +18,7 @@ class nvmap;
class nvhost_as_gpu final : public nvdevice {
public:
- nvhost_as_gpu(std::shared_ptr<nvmap> nvmap_dev) : nvmap_dev(std::move(nvmap_dev)) {}
+ explicit nvhost_as_gpu(std::shared_ptr<nvmap> nvmap_dev) : nvmap_dev(std::move(nvmap_dev)) {}
~nvhost_as_gpu() override = default;
u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override;
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
index 56b5ed60d..c9f6b9b6a 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
@@ -18,7 +18,7 @@ constexpr u32 NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO(0x8);
class nvhost_gpu final : public nvdevice {
public:
- nvhost_gpu(std::shared_ptr<nvmap> nvmap_dev) : nvmap_dev(std::move(nvmap_dev)) {}
+ explicit nvhost_gpu(std::shared_ptr<nvmap> nvmap_dev) : nvmap_dev(std::move(nvmap_dev)) {}
~nvhost_gpu() override = default;
u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override;
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h
index 579940817..35b2c65fc 100644
--- a/src/core/hle/service/nvdrv/nvdrv.h
+++ b/src/core/hle/service/nvdrv/nvdrv.h
@@ -30,7 +30,7 @@ public:
/// Returns a pointer to one of the available devices, identified by its name.
template <typename T>
- std::shared_ptr<T> GetDevice(std::string name) {
+ std::shared_ptr<T> GetDevice(const std::string& name) {
auto itr = devices.find(name);
if (itr == devices.end())
return nullptr;
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index d580f779e..1fca1743d 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -23,15 +23,10 @@ constexpr u64 frame_ticks = static_cast<u64>(CoreTiming::BASE_CLOCK_RATE / SCREE
NVFlinger::NVFlinger() {
// Add the different displays to the list of displays.
- Display default_{0, "Default"};
- Display external{1, "External"};
- Display edid{2, "Edid"};
- Display internal{3, "Internal"};
-
- displays.emplace_back(default_);
- displays.emplace_back(external);
- displays.emplace_back(edid);
- displays.emplace_back(internal);
+ displays.emplace_back(0, "Default");
+ displays.emplace_back(1, "External");
+ displays.emplace_back(2, "Edid");
+ displays.emplace_back(3, "Internal");
// Schedule the screen composition events
composition_event =
diff --git a/src/core/hle/service/pctl/module.h b/src/core/hle/service/pctl/module.h
index 68da628a8..e7d492760 100644
--- a/src/core/hle/service/pctl/module.h
+++ b/src/core/hle/service/pctl/module.h
@@ -12,7 +12,7 @@ class Module final {
public:
class Interface : public ServiceFramework<Interface> {
public:
- Interface(std::shared_ptr<Module> module, const char* name);
+ explicit Interface(std::shared_ptr<Module> module, const char* name);
void CreateService(Kernel::HLERequestContext& ctx);
void CreateServiceWithoutInitialize(Kernel::HLERequestContext& ctx);
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h
index 13f5c4c28..e2a00e4f6 100644
--- a/src/core/hle/service/sm/sm.h
+++ b/src/core/hle/service/sm/sm.h
@@ -22,7 +22,7 @@ namespace Service::SM {
/// Interface to "sm:" service
class SM final : public ServiceFramework<SM> {
public:
- SM(std::shared_ptr<ServiceManager> service_manager);
+ explicit SM(std::shared_ptr<ServiceManager> service_manager);
~SM() override;
private:
diff --git a/src/core/hle/service/spl/module.h b/src/core/hle/service/spl/module.h
index 6ab91b400..f24d998e8 100644
--- a/src/core/hle/service/spl/module.h
+++ b/src/core/hle/service/spl/module.h
@@ -12,7 +12,7 @@ class Module final {
public:
class Interface : public ServiceFramework<Interface> {
public:
- Interface(std::shared_ptr<Module> module, const char* name);
+ explicit Interface(std::shared_ptr<Module> module, const char* name);
void GetRandomBytes(Kernel::HLERequestContext& ctx);
diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h
index 49af38589..8dde28a94 100644
--- a/src/core/hle/service/time/time.h
+++ b/src/core/hle/service/time/time.h
@@ -57,7 +57,7 @@ class Module final {
public:
class Interface : public ServiceFramework<Interface> {
public:
- Interface(std::shared_ptr<Module> time, const char* name);
+ explicit Interface(std::shared_ptr<Module> time, const char* name);
void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx);
void GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx);
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index eccee6e33..3a69b85f9 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -579,7 +579,7 @@ private:
class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> {
public:
- ISystemDisplayService() : ServiceFramework("ISystemDisplayService") {
+ explicit ISystemDisplayService() : ServiceFramework("ISystemDisplayService") {
static const FunctionInfo functions[] = {
{1200, nullptr, "GetZOrderCountMin"},
{1202, nullptr, "GetZOrderCountMax"},
@@ -777,7 +777,7 @@ private:
class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> {
public:
- IApplicationDisplayService(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
+ explicit IApplicationDisplayService(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
~IApplicationDisplayService() = default;
private:
diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h
index e8bda01d7..92f5b6059 100644
--- a/src/core/hle/service/vi/vi.h
+++ b/src/core/hle/service/vi/vi.h
@@ -24,8 +24,8 @@ class Module final {
public:
class Interface : public ServiceFramework<Interface> {
public:
- Interface(std::shared_ptr<Module> module, const char* name,
- std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
+ explicit Interface(std::shared_ptr<Module> module, const char* name,
+ std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);
void GetDisplayService(Kernel::HLERequestContext& ctx);
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp
index a007d3e6e..465b827bb 100644
--- a/src/core/loader/nro.cpp
+++ b/src/core/loader/nro.cpp
@@ -82,7 +82,7 @@ bool AppLoader_NRO::LoadNro(FileSys::VirtualFile file, VAddr load_base) {
if (program_image.size() != PageAlignSize(nro_header.file_size))
return {};
- for (int i = 0; i < nro_header.segments.size(); ++i) {
+ for (std::size_t i = 0; i < nro_header.segments.size(); ++i) {
codeset->segments[i].addr = nro_header.segments[i].offset;
codeset->segments[i].offset = nro_header.segments[i].offset;
codeset->segments[i].size = PageAlignSize(nro_header.segments[i].size);
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index 59049d016..c66561bf4 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -68,8 +68,7 @@ FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& file) {
static std::vector<u8> DecompressSegment(const std::vector<u8>& compressed_data,
const NsoSegmentHeader& header) {
- std::vector<u8> uncompressed_data;
- uncompressed_data.resize(header.size);
+ std::vector<u8> uncompressed_data(header.size);
const int bytes_uncompressed = LZ4_decompress_safe(
reinterpret_cast<const char*>(compressed_data.data()),
reinterpret_cast<char*>(uncompressed_data.data()), compressed_data.size(), header.size);
@@ -82,8 +81,7 @@ static std::vector<u8> DecompressSegment(const std::vector<u8>& compressed_data,
static std::vector<u8> ReadSegment(FileUtil::IOFile& file, const NsoSegmentHeader& header,
size_t compressed_size) {
- std::vector<u8> compressed_data;
- compressed_data.resize(compressed_size);
+ std::vector<u8> compressed_data(compressed_size);
file.Seek(header.offset, SEEK_SET);
if (compressed_size != file.ReadBytes(compressed_data.data(), compressed_size)) {
@@ -115,7 +113,7 @@ VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base) {
// Build program image
Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create("");
std::vector<u8> program_image;
- for (int i = 0; i < nso_header.segments.size(); ++i) {
+ for (std::size_t i = 0; i < nso_header.segments.size(); ++i) {
const std::vector<u8> compressed_data =
file->ReadBytes(nso_header.segments_compressed_size[i], nso_header.segments[i].offset);
std::vector<u8> data = DecompressSegment(compressed_data, nso_header.segments[i]);