From c8c2beaeffabd167a1b83a511d8e2fb0e3d3c907 Mon Sep 17 00:00:00 2001 From: Vitor K Date: Sun, 7 Jan 2024 17:37:42 -0300 Subject: [PATCH] misc: fix issues pointed out by msvc (#7316) * do not move constant variables * applet_manager: avoid possible use after move * use constant references where pointed out by msvc * extra_hid: initialize response * ValidateSaveState: passing slot separately is not necessary * common: mark HashCombine as nodiscard * cityhash: remove use of using namespace std * Prefix all size_t with std:: done automatically by executing regex replace `([^:0-9a-zA-Z_])size_t([^0-9a-zA-Z_])` -> `$1std::size_t$2` based on 7d8f115 * shared_memory.cpp: fix log error format * fix compiling with pch off --- src/android/app/src/main/jni/game_info.cpp | 8 +++--- src/android/app/src/main/jni/native.cpp | 4 +-- src/audio_core/openal_sink.cpp | 2 +- src/audio_core/sdl2_sink.cpp | 2 +- src/citra/config.cpp | 2 +- src/citra_qt/qt_image_interface.cpp | 2 +- src/common/aarch64/cpu_detect.cpp | 2 +- src/common/aarch64/oaknut_abi.h | 28 +++++++++---------- src/common/bounded_threadsafe_queue.h | 16 +++++------ src/common/cityhash.cpp | 22 +++++++-------- .../dynamic_library/dynamic_library.cpp | 2 +- src/common/file_util.cpp | 2 +- src/common/hash.h | 2 +- src/common/polyfill_thread.h | 2 +- src/common/slot_vector.h | 20 ++++++------- src/common/static_lru_cache.h | 14 +++++----- src/common/string_literal.h | 2 +- src/common/thread.cpp | 2 +- src/common/thread_worker.h | 19 +++++++------ src/core/arm/dynarmic/arm_tick_counts.cpp | 4 +-- src/core/dumping/ffmpeg_backend.cpp | 2 +- src/core/file_sys/ncch_container.cpp | 6 ++-- src/core/file_sys/patch.cpp | 4 +-- src/core/file_sys/plugin_3gx.cpp | 2 +- src/core/file_sys/plugin_3gx.h | 2 +- src/core/file_sys/romfs_reader.cpp | 14 +++++----- src/core/file_sys/romfs_reader.h | 4 +-- src/core/hle/kernel/resource_limit.cpp | 10 +++---- src/core/hle/kernel/resource_limit.h | 2 +- src/core/hle/kernel/shared_memory.cpp | 2 +- src/core/hle/kernel/svc.cpp | 4 +-- src/core/hle/kernel/thread.cpp | 2 +- src/core/hle/service/apt/applet_manager.cpp | 2 ++ src/core/hle/service/boss/online_service.cpp | 4 +-- src/core/hle/service/boss/online_service.h | 14 +++++----- src/core/hle/service/cecd/cecd.cpp | 2 +- src/core/hle/service/cfg/cfg.cpp | 2 +- src/core/hle/service/fs/file.cpp | 2 +- src/core/hle/service/http/http_c.cpp | 12 ++++---- src/core/hle/service/http/http_c.h | 2 +- src/core/hle/service/ir/extra_hid.cpp | 2 +- src/core/hle/service/soc/soc_u.cpp | 4 +-- src/core/loader/3dsx.h | 2 +- src/core/savestate.cpp | 9 +++--- .../custom_textures/custom_tex_manager.cpp | 4 +-- src/video_core/gpu_debugger.h | 1 + src/video_core/pica/output_vertex.h | 1 + src/video_core/pica/pica_core.cpp | 2 +- src/video_core/pica/pica_core.h | 2 +- src/video_core/pica/regs_external.h | 5 ++++ src/video_core/pica/regs_rasterizer.h | 1 + src/video_core/pica/shader_setup.cpp | 2 ++ src/video_core/pica/shader_setup.h | 6 ++-- src/video_core/pica/shader_unit.cpp | 1 + src/video_core/pica/shader_unit.h | 6 ++-- src/video_core/rasterizer_accelerated.cpp | 2 +- .../rasterizer_cache/rasterizer_cache.h | 2 +- .../rasterizer_cache/rasterizer_cache_base.h | 4 +-- .../rasterizer_cache/surface_base.h | 2 +- .../renderer_opengl/renderer_opengl.cpp | 2 +- .../renderer_software/sw_blitter.cpp | 6 ++-- .../renderer_software/sw_rasterizer.h | 2 +- .../renderer_vulkan/vk_instance.cpp | 2 +- .../renderer_vulkan/vk_pipeline_cache.cpp | 2 +- .../renderer_vulkan/vk_pipeline_cache.h | 2 +- .../renderer_vulkan/vk_platform.cpp | 2 +- .../renderer_vulkan/vk_rasterizer.cpp | 2 +- .../renderer_vulkan/vk_renderpass_cache.h | 4 +-- .../renderer_vulkan/vk_resource_pool.cpp | 6 ++-- .../renderer_vulkan/vk_texture_runtime.cpp | 4 +-- .../shader/generator/glsl_fs_shader_gen.cpp | 2 +- src/video_core/shader/shader.h | 1 + .../shader/shader_jit_a64_compiler.cpp | 2 +- 73 files changed, 181 insertions(+), 167 deletions(-) diff --git a/src/android/app/src/main/jni/game_info.cpp b/src/android/app/src/main/jni/game_info.cpp index b80d0dc7a..d9b7c8f12 100644 --- a/src/android/app/src/main/jni/game_info.cpp +++ b/src/android/app/src/main/jni/game_info.cpp @@ -81,8 +81,8 @@ jstring Java_org_citra_citra_1emu_model_GameInfo_getTitle(JNIEnv* env, jobject o Loader::SMDH::TitleLanguage language = Loader::SMDH::TitleLanguage::English; // Get the title from SMDH in UTF-16 format - std::u16string title{ - reinterpret_cast(smdh->titles[static_cast(language)].long_title.data())}; + std::u16string title{reinterpret_cast( + smdh->titles[static_cast(language)].long_title.data())}; return ToJString(env, Common::UTF16ToUTF8(title).data()); } @@ -93,8 +93,8 @@ jstring Java_org_citra_citra_1emu_model_GameInfo_getCompany(JNIEnv* env, jobject // Get the Publisher's name from SMDH in UTF-16 format char16_t* publisher; - publisher = - reinterpret_cast(smdh->titles[static_cast(language)].publisher.data()); + publisher = reinterpret_cast( + smdh->titles[static_cast(language)].publisher.data()); return ToJString(env, Common::UTF16ToUTF8(publisher).data()); } diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 84fcf6337..1b07847b9 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -661,8 +661,8 @@ void Java_org_citra_citra_1emu_NativeLibrary_removeAmiibo([[maybe_unused]] JNIEn JNIEXPORT jobject JNICALL Java_org_citra_citra_1emu_utils_CiaInstallWorker_installCIA( JNIEnv* env, jobject jobj, jstring jpath) { std::string path = GetJString(env, jpath); - Service::AM::InstallStatus res = - Service::AM::InstallCIA(path, [env, jobj](size_t total_bytes_read, size_t file_size) { + Service::AM::InstallStatus res = Service::AM::InstallCIA( + path, [env, jobj](std::size_t total_bytes_read, std::size_t file_size) { env->CallVoidMethod(jobj, IDCache::GetCiaInstallHelperSetProgress(), static_cast(file_size), static_cast(total_bytes_read)); }); diff --git a/src/audio_core/openal_sink.cpp b/src/audio_core/openal_sink.cpp index 23ad17a79..3129910fd 100644 --- a/src/audio_core/openal_sink.cpp +++ b/src/audio_core/openal_sink.cpp @@ -148,7 +148,7 @@ ALsizei OpenALSink::Impl::Callback(void* impl_, void* buffer, ALsizei buffer_siz return 0; } - const size_t num_frames = buffer_size_in_bytes / (2 * sizeof(s16)); + const std::size_t num_frames = buffer_size_in_bytes / (2 * sizeof(s16)); impl->cb(reinterpret_cast(buffer), num_frames); return buffer_size_in_bytes; diff --git a/src/audio_core/sdl2_sink.cpp b/src/audio_core/sdl2_sink.cpp index 10d3a3181..2aa90c48a 100644 --- a/src/audio_core/sdl2_sink.cpp +++ b/src/audio_core/sdl2_sink.cpp @@ -83,7 +83,7 @@ void SDL2Sink::Impl::Callback(void* impl_, u8* buffer, int buffer_size_in_bytes) if (!impl || !impl->cb) return; - const size_t num_frames = buffer_size_in_bytes / (2 * sizeof(s16)); + const std::size_t num_frames = buffer_size_in_bytes / (2 * sizeof(s16)); impl->cb(reinterpret_cast(buffer), num_frames); } diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 5c0ffcbdf..b6cfa2724 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -236,7 +236,7 @@ void Config::ReadValues() { std::string offset_string = sdl2_config->GetString("System", "init_time_offset", default_init_time_offset); - size_t sep_index = offset_string.find(' '); + std::size_t sep_index = offset_string.find(' '); if (sep_index == std::string::npos) { LOG_ERROR(Config, "Failed to parse init_time_offset. Using 0 00:00:00"); diff --git a/src/citra_qt/qt_image_interface.cpp b/src/citra_qt/qt_image_interface.cpp index b099ba395..7124f023f 100644 --- a/src/citra_qt/qt_image_interface.cpp +++ b/src/citra_qt/qt_image_interface.cpp @@ -25,7 +25,7 @@ bool QtImageInterface::DecodePNG(std::vector& dst, u32& width, u32& height, image = image.convertToFormat(QImage::Format_RGBA8888); // Write RGBA8 to vector - const size_t image_size = width * height * 4; + const std::size_t image_size = width * height * 4; dst.resize(image_size); std::memcpy(dst.data(), image.constBits(), image_size); diff --git a/src/common/aarch64/cpu_detect.cpp b/src/common/aarch64/cpu_detect.cpp index 52373bdef..e98fc3261 100644 --- a/src/common/aarch64/cpu_detect.cpp +++ b/src/common/aarch64/cpu_detect.cpp @@ -30,7 +30,7 @@ namespace Common { #ifdef __APPLE__ static std::string GetCPUString() { char buf[128]; - size_t buf_len = sizeof(buf); + std::size_t buf_len = sizeof(buf); if (sysctlbyname("machdep.cpu.brand_string", &buf, &buf_len, NULL, 0) == -1) { return "Unknown"; } diff --git a/src/common/aarch64/oaknut_abi.h b/src/common/aarch64/oaknut_abi.h index 025998bb5..56bb8b5f3 100644 --- a/src/common/aarch64/oaknut_abi.h +++ b/src/common/aarch64/oaknut_abi.h @@ -63,15 +63,15 @@ struct ABIFrameInfo { }; inline ABIFrameInfo ABI_CalculateFrameSize(std::bitset<64> regs, std::size_t frame_size) { - const size_t gprs_count = (regs & ABI_ALL_GPRS).count(); - const size_t fprs_count = (regs & ABI_ALL_FPRS).count(); + const std::size_t gprs_count = (regs & ABI_ALL_GPRS).count(); + const std::size_t fprs_count = (regs & ABI_ALL_FPRS).count(); - const size_t gprs_size = (gprs_count + 1) / 2 * 16; - const size_t fprs_size = fprs_count * 16; + const std::size_t gprs_size = (gprs_count + 1) / 2 * 16; + const std::size_t fprs_size = fprs_count * 16; - size_t total_size = 0; + std::size_t total_size = 0; total_size += gprs_size; - const size_t fprs_base_subtraction = total_size; + const std::size_t fprs_base_subtraction = total_size; total_size += fprs_size; total_size += frame_size; @@ -100,11 +100,11 @@ inline void ABI_PushRegisters(oaknut::CodeGenerator& code, std::bitset<64> regs, } if (!gprs.empty()) { - for (size_t i = 0; i < gprs.size() - 1; i += 2) { + for (std::size_t i = 0; i < gprs.size() - 1; i += 2) { code.STP(gprs[i], gprs[i + 1], SP, i * sizeof(u64)); } if (gprs.size() % 2 == 1) { - const size_t i = gprs.size() - 1; + const std::size_t i = gprs.size() - 1; code.STR(gprs[i], SP, i * sizeof(u64)); } } @@ -121,11 +121,11 @@ inline void ABI_PushRegisters(oaknut::CodeGenerator& code, std::bitset<64> regs, } if (!fprs.empty()) { - for (size_t i = 0; i < fprs.size() - 1; i += 2) { + for (std::size_t i = 0; i < fprs.size() - 1; i += 2) { code.STP(fprs[i], fprs[i + 1], SP, frame_info.fprs_offset + i * (sizeof(u64) * 2)); } if (fprs.size() % 2 == 1) { - const size_t i = fprs.size() - 1; + const std::size_t i = fprs.size() - 1; code.STR(fprs[i], SP, frame_info.fprs_offset + i * (sizeof(u64) * 2)); } } @@ -159,11 +159,11 @@ inline void ABI_PopRegisters(oaknut::CodeGenerator& code, std::bitset<64> regs, } if (!gprs.empty()) { - for (size_t i = 0; i < gprs.size() - 1; i += 2) { + for (std::size_t i = 0; i < gprs.size() - 1; i += 2) { code.LDP(gprs[i], gprs[i + 1], SP, i * sizeof(u64)); } if (gprs.size() % 2 == 1) { - const size_t i = gprs.size() - 1; + const std::size_t i = gprs.size() - 1; code.LDR(gprs[i], SP, i * sizeof(u64)); } } @@ -180,11 +180,11 @@ inline void ABI_PopRegisters(oaknut::CodeGenerator& code, std::bitset<64> regs, } if (!fprs.empty()) { - for (size_t i = 0; i < fprs.size() - 1; i += 2) { + for (std::size_t i = 0; i < fprs.size() - 1; i += 2) { code.LDP(fprs[i], fprs[i + 1], SP, frame_info.fprs_offset + i * (sizeof(u64) * 2)); } if (fprs.size() % 2 == 1) { - const size_t i = fprs.size() - 1; + const std::size_t i = fprs.size() - 1; code.LDR(fprs[i], SP, frame_info.fprs_offset + i * (sizeof(u64) * 2)); } } diff --git a/src/common/bounded_threadsafe_queue.h b/src/common/bounded_threadsafe_queue.h index 15c9c1db0..2b67e41a6 100644 --- a/src/common/bounded_threadsafe_queue.h +++ b/src/common/bounded_threadsafe_queue.h @@ -16,10 +16,10 @@ namespace Common { namespace detail { -constexpr size_t DefaultCapacity = 0x1000; +constexpr std::size_t DefaultCapacity = 0x1000; } // namespace detail -template +template class SPSCQueue { static_assert((Capacity & (Capacity - 1)) == 0, "Capacity must be a power of two."); @@ -74,7 +74,7 @@ private: template bool Emplace(Args&&... args) { - const size_t write_index = m_write_index.load(std::memory_order::relaxed); + const std::size_t write_index = m_write_index.load(std::memory_order::relaxed); if constexpr (Mode == PushMode::Try) { // Check if we have free slots to write to. @@ -92,7 +92,7 @@ private: } // Determine the position to write to. - const size_t pos = write_index % Capacity; + const std::size_t pos = write_index % Capacity; // Emplace into the queue. new (std::addressof(m_data[pos])) T(std::forward(args)...); @@ -109,7 +109,7 @@ private: template bool Pop(T& t, [[maybe_unused]] std::stop_token stop_token = {}) { - const size_t read_index = m_read_index.load(std::memory_order::relaxed); + const std::size_t read_index = m_read_index.load(std::memory_order::relaxed); if constexpr (Mode == PopMode::Try) { // Check if the queue is empty. @@ -136,7 +136,7 @@ private: } // Determine the position to read from. - const size_t pos = read_index % Capacity; + const std::size_t pos = read_index % Capacity; // Pop the data off the queue, moving it. t = std::move(m_data[pos]); @@ -162,7 +162,7 @@ private: std::mutex consumer_cv_mutex; }; -template +template class MPSCQueue { public: template @@ -202,7 +202,7 @@ private: std::mutex write_mutex; }; -template +template class MPMCQueue { public: template diff --git a/src/common/cityhash.cpp b/src/common/cityhash.cpp index 4e1d874b5..8a75c11c4 100644 --- a/src/common/cityhash.cpp +++ b/src/common/cityhash.cpp @@ -40,11 +40,9 @@ #define WORDS_BIGENDIAN 1 #endif -using namespace std; - -typedef uint8_t uint8; -typedef uint32_t uint32; -typedef uint64_t uint64; +typedef std::uint8_t uint8; +typedef std::uint32_t uint32; +typedef std::uint64_t uint64; namespace Common { @@ -152,19 +150,19 @@ static uint64 HashLen17to32(const char* s, std::size_t len) { // Return a 16-byte hash for 48 bytes. Quick and dirty. // Callers do best to use "random-looking" values for a and b. -static pair WeakHashLen32WithSeeds(uint64 w, uint64 x, uint64 y, uint64 z, uint64 a, - uint64 b) { +static std::pair WeakHashLen32WithSeeds(uint64 w, uint64 x, uint64 y, uint64 z, + uint64 a, uint64 b) { a += w; b = Rotate(b + a + z, 21); uint64 c = a; a += x; a += y; b += Rotate(a, 44); - return make_pair(a + z, b + c); + return std::make_pair(a + z, b + c); } // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. -static pair WeakHashLen32WithSeeds(const char* s, uint64 a, uint64 b) { +static std::pair WeakHashLen32WithSeeds(const char* s, uint64 a, uint64 b) { return WeakHashLen32WithSeeds(Fetch64(s), Fetch64(s + 8), Fetch64(s + 16), Fetch64(s + 24), a, b); } @@ -207,8 +205,8 @@ uint64 CityHash64(const char* s, std::size_t len) { uint64 x = Fetch64(s + len - 40); uint64 y = Fetch64(s + len - 16) + Fetch64(s + len - 56); uint64 z = HashLen16(Fetch64(s + len - 48) + len, Fetch64(s + len - 24)); - pair v = WeakHashLen32WithSeeds(s + len - 64, len, z); - pair w = WeakHashLen32WithSeeds(s + len - 32, y + k1, x); + std::pair v = WeakHashLen32WithSeeds(s + len - 64, len, z); + std::pair w = WeakHashLen32WithSeeds(s + len - 32, y + k1, x); x = x * k1 + Fetch64(s); // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. @@ -276,7 +274,7 @@ uint128 CityHash128WithSeed(const char* s, std::size_t len, uint128 seed) { // We expect len >= 128 to be the common case. Keep 56 bytes of state: // v, w, x, y, and z. - pair v, w; + std::pair v, w; uint64 x = Uint128Low64(seed); uint64 y = Uint128High64(seed); uint64 z = len * k1; diff --git a/src/common/dynamic_library/dynamic_library.cpp b/src/common/dynamic_library/dynamic_library.cpp index 016e27f4c..ba9d327a6 100644 --- a/src/common/dynamic_library/dynamic_library.cpp +++ b/src/common/dynamic_library/dynamic_library.cpp @@ -38,7 +38,7 @@ bool DynamicLibrary::Load(std::string_view filename) { if (!handle) { DWORD error_message_id = GetLastError(); LPSTR message_buffer = nullptr; - size_t size = + std::size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, error_message_id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 5b0ba817a..1acbb2724 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -1159,7 +1159,7 @@ std::size_t IOFile::ReadImpl(void* data, std::size_t length, std::size_t data_si } #ifdef _WIN32 -static std::size_t pread(int fd, void* buf, size_t count, uint64_t offset) { +static std::size_t pread(int fd, void* buf, std::size_t count, uint64_t offset) { long unsigned int read_bytes = 0; OVERLAPPED overlapped = {0}; HANDLE file = reinterpret_cast(_get_osfhandle(fd)); diff --git a/src/common/hash.h b/src/common/hash.h index 7b7a598ce..1a222b22e 100644 --- a/src/common/hash.h +++ b/src/common/hash.h @@ -37,7 +37,7 @@ static inline u64 ComputeStructHash64(const T& data) noexcept { * Combines the seed parameter with the provided hash, producing a new unique hash * Implementation from: http://boost.sourceforge.net/doc/html/boost/hash_combine.html */ -inline u64 HashCombine(const u64 seed, const u64 hash) { +[[nodiscard]] inline u64 HashCombine(const u64 seed, const u64 hash) { return seed ^ (hash + 0x9e3779b9 + (seed << 6) + (seed >> 2)); } diff --git a/src/common/polyfill_thread.h b/src/common/polyfill_thread.h index 60e600e28..3146075f3 100644 --- a/src/common/polyfill_thread.h +++ b/src/common/polyfill_thread.h @@ -39,7 +39,7 @@ void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred&& pred) { namespace std { namespace polyfill { -using stop_state_callback = size_t; +using stop_state_callback = std::size_t; class stop_state { public: diff --git a/src/common/slot_vector.h b/src/common/slot_vector.h index 1969afe64..204630acd 100644 --- a/src/common/slot_vector.h +++ b/src/common/slot_vector.h @@ -31,9 +31,9 @@ template class SlotVector { public: ~SlotVector() noexcept { - size_t index = 0; + std::size_t index = 0; for (u64 bits : stored_bitset) { - for (size_t bit = 0; bits; ++bit, bits >>= 1) { + for (std::size_t bit = 0; bits; ++bit, bits >>= 1) { if ((bits & 1) != 0) { values[index + bit].object.~T(); } @@ -81,7 +81,7 @@ public: ResetStorageBit(id.index); } - size_t size() const noexcept { + std::size_t size() const noexcept { return values_capacity - free_list.size(); } @@ -126,12 +126,12 @@ private: return free_index; } - void Reserve(size_t new_capacity) noexcept { + void Reserve(std::size_t new_capacity) noexcept { Entry* const new_values = new Entry[new_capacity]; - size_t index = 0; + std::size_t index = 0; for (u64 bits : stored_bitset) { - for (size_t bit = 0; bits; ++bit, bits >>= 1) { - const size_t i = index + bit; + for (std::size_t bit = 0; bits; ++bit, bits >>= 1) { + const std::size_t i = index + bit; if ((bits & 1) == 0) { continue; } @@ -144,7 +144,7 @@ private: stored_bitset.resize((new_capacity + 63) / 64); - const size_t old_free_size = free_list.size(); + const std::size_t old_free_size = free_list.size(); free_list.resize(old_free_size + (new_capacity - values_capacity)); std::iota(free_list.begin() + old_free_size, free_list.end(), static_cast(values_capacity)); @@ -155,7 +155,7 @@ private: } Entry* values = nullptr; - size_t values_capacity = 0; + std::size_t values_capacity = 0; std::vector stored_bitset; std::vector free_list; @@ -165,7 +165,7 @@ private: template <> struct std::hash { - size_t operator()(const Common::SlotId& id) const noexcept { + std::size_t operator()(const Common::SlotId& id) const noexcept { return std::hash{}(id.index); } }; diff --git a/src/common/static_lru_cache.h b/src/common/static_lru_cache.h index 0294f6120..b91f046a0 100644 --- a/src/common/static_lru_cache.h +++ b/src/common/static_lru_cache.h @@ -23,23 +23,23 @@ namespace Common { // a cache which evicts the least recently used item when it is full // the cache elements are statically allocated. -template +template class StaticLRUCache { public: using key_type = Key; using value_type = Value; - using list_type = std::list>; + using list_type = std::list>; using array_type = std::array; StaticLRUCache() = default; ~StaticLRUCache() = default; - size_t size() const { + std::size_t size() const { return m_list.size(); } - constexpr size_t capacity() const { + constexpr std::size_t capacity() const { return m_array.size(); } @@ -59,7 +59,7 @@ public: // lookup value in the cache auto i = find(key); if (i == m_list.cend()) { - size_t next_index = size(); + std::size_t next_index = size(); // insert item into the cache, but first check if it is full if (next_index >= capacity()) { // cache is full, evict the least recently used item @@ -97,10 +97,10 @@ private: [&key](const auto& el) { return el.first == key; }); } - size_t evict() { + std::size_t evict() { // evict item from the end of most recently used list typename list_type::iterator i = --m_list.end(); - size_t evicted_index = i->second; + std::size_t evicted_index = i->second; m_list.erase(i); return evicted_index; } diff --git a/src/common/string_literal.h b/src/common/string_literal.h index cc148edda..fadc9f475 100644 --- a/src/common/string_literal.h +++ b/src/common/string_literal.h @@ -9,7 +9,7 @@ namespace Common { -template +template struct StringLiteral { constexpr StringLiteral(const char (&str)[N]) { std::copy_n(str, N, value); diff --git a/src/common/thread.cpp b/src/common/thread.cpp index 73cc4948b..68004a614 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp @@ -101,7 +101,7 @@ void SetCurrentThreadName(const char* name) { #elif defined(__linux__) // Linux limits thread names to 15 characters and will outright reject any // attempt to set a longer name with ERANGE. - std::string truncated(name, std::min(strlen(name), static_cast(15))); + std::string truncated(name, std::min(strlen(name), static_cast(15))); if (int e = pthread_setname_np(pthread_self(), truncated.c_str())) { errno = e; LOG_ERROR(Common, "Failed to set thread name to '{}': {}", truncated, GetLastErrorMsg()); diff --git a/src/common/thread_worker.h b/src/common/thread_worker.h index 02a9a893d..5ef3cd5bc 100644 --- a/src/common/thread_worker.h +++ b/src/common/thread_worker.h @@ -25,7 +25,7 @@ class StatefulThreadWorker { static constexpr bool with_state = !std::is_same_v; struct DummyCallable { - int operator()(size_t) const noexcept { + int operator()(std::size_t) const noexcept { return 0; } }; @@ -33,12 +33,13 @@ class StatefulThreadWorker { using Task = std::conditional_t, UniqueFunction>; using StateMaker = - std::conditional_t, DummyCallable>; + std::conditional_t, DummyCallable>; public: - explicit StatefulThreadWorker(size_t num_workers, std::string_view name, StateMaker func = {}) + explicit StatefulThreadWorker(std::size_t num_workers, std::string_view name, + StateMaker func = {}) : workers_queued{num_workers}, thread_name{name} { - const auto lambda = [this, func](std::stop_token stop_token, size_t index) { + const auto lambda = [this, func](std::stop_token stop_token, std::size_t index) { Common::SetCurrentThreadName(thread_name.data()); { [[maybe_unused]] std::conditional_t state{func(index)}; @@ -69,7 +70,7 @@ public: wait_condition.notify_all(); }; threads.reserve(num_workers); - for (size_t i = 0; i < num_workers; ++i) { + for (std::size_t i = 0; i < num_workers; ++i) { threads.emplace_back(lambda, i); } } @@ -110,10 +111,10 @@ private: std::mutex queue_mutex; std::condition_variable_any condition; std::condition_variable wait_condition; - std::atomic work_scheduled{}; - std::atomic work_done{}; - std::atomic workers_stopped{}; - std::atomic workers_queued{}; + std::atomic work_scheduled{}; + std::atomic work_done{}; + std::atomic workers_stopped{}; + std::atomic workers_queued{}; std::string_view thread_name; std::vector threads; }; diff --git a/src/core/arm/dynarmic/arm_tick_counts.cpp b/src/core/arm/dynarmic/arm_tick_counts.cpp index f36b906f9..87f3ede25 100644 --- a/src/core/arm/dynarmic/arm_tick_counts.cpp +++ b/src/core/arm/dynarmic/arm_tick_counts.cpp @@ -13,8 +13,8 @@ namespace { template constexpr u32 GetMatchingBitsFromStringLiteral() { u32 result = 0; - for (size_t i = 0; i < haystack.strlen; i++) { - for (size_t a = 0; a < needle.strlen; a++) { + for (std::size_t i = 0; i < haystack.strlen; i++) { + for (std::size_t a = 0; a < needle.strlen; a++) { if (haystack.value[i] == needle.value[a]) { result |= 1 << (haystack.strlen - 1 - i); } diff --git a/src/core/dumping/ffmpeg_backend.cpp b/src/core/dumping/ffmpeg_backend.cpp index 1fa1be39c..b38116ed3 100644 --- a/src/core/dumping/ffmpeg_backend.cpp +++ b/src/core/dumping/ffmpeg_backend.cpp @@ -1073,7 +1073,7 @@ std::vector ListFormats() { continue; } - out.push_back({current->name, ToStdString(current->long_name), std::move(extensions), + out.push_back({current->name, ToStdString(current->long_name), extensions, std::move(supported_video_codecs), std::move(supported_audio_codecs), GetOptionList(current->priv_class, true)}); } diff --git a/src/core/file_sys/ncch_container.cpp b/src/core/file_sys/ncch_container.cpp index df9859b79..ad8b32629 100644 --- a/src/core/file_sys/ncch_container.cpp +++ b/src/core/file_sys/ncch_container.cpp @@ -57,9 +57,9 @@ static bool LZSS_Decompress(std::span compressed, std::span decomp u32 buffer_top_and_bottom; std::memcpy(&buffer_top_and_bottom, footer, sizeof(u32)); - size_t out = decompressed.size(); - size_t index = compressed.size() - ((buffer_top_and_bottom >> 24) & 0xFF); - size_t stop_index = compressed.size() - (buffer_top_and_bottom & 0xFFFFFF); + std::size_t out = decompressed.size(); + std::size_t index = compressed.size() - ((buffer_top_and_bottom >> 24) & 0xFF); + std::size_t stop_index = compressed.size() - (buffer_top_and_bottom & 0xFFFFFF); std::memset(decompressed.data(), 0, decompressed.size()); std::memcpy(decompressed.data(), compressed.data(), compressed.size()); diff --git a/src/core/file_sys/patch.cpp b/src/core/file_sys/patch.cpp index 07edb9272..fecc7fe05 100644 --- a/src/core/file_sys/patch.cpp +++ b/src/core/file_sys/patch.cpp @@ -131,7 +131,7 @@ public: return m_offset; } - bool Seek(size_t offset) { + bool Seek(std::size_t offset) { if (offset > m_size) return false; m_offset = offset; @@ -242,7 +242,7 @@ private: if (m_target_relative_offset + length > m_target.size()) return false; // Byte by byte copy. - for (size_t i = 0; i < length; ++i) + for (std::size_t i = 0; i < length; ++i) m_target.data()[m_target.Tell() + i] = m_target.data()[m_target_relative_offset++]; m_target.Seek(m_target.Tell() + length); return true; diff --git a/src/core/file_sys/plugin_3gx.cpp b/src/core/file_sys/plugin_3gx.cpp index 89d29aa9b..e325d7fca 100644 --- a/src/core/file_sys/plugin_3gx.cpp +++ b/src/core/file_sys/plugin_3gx.cpp @@ -357,7 +357,7 @@ void FileSys::Plugin3GXLoader::MapBootloader(Kernel::Process& process, Kernel::K // Write bootloader kernel.memory.WriteBlock( process, _3GX_exe_load_addr - bootloader_memory_size, bootloader.data(), - std::min(bootloader.size() * sizeof(u32), bootloader_memory_size)); + std::min(bootloader.size() * sizeof(u32), bootloader_memory_size)); game_instructions[0] = 0xE51FF004; // ldr pc, [pc, #-4] game_instructions[1] = _3GX_exe_load_addr - bootloader_memory_size; diff --git a/src/core/file_sys/plugin_3gx.h b/src/core/file_sys/plugin_3gx.h index f718841fc..742db7bf9 100644 --- a/src/core/file_sys/plugin_3gx.h +++ b/src/core/file_sys/plugin_3gx.h @@ -72,7 +72,7 @@ private: Kernel::Process& process, Kernel::KernelSystem& kernel, Service::PLGLDR::PLG_LDR& plg_ldr); - static constexpr size_t bootloader_memory_size = 0x1000; + static constexpr std::size_t bootloader_memory_size = 0x1000; static void MapBootloader(Kernel::Process& process, Kernel::KernelSystem& kernel, u32 memory_offset, std::span exe_load_func, const u32_le* exe_load_args, u32 checksum_size, u32 exe_checksum, diff --git a/src/core/file_sys/romfs_reader.cpp b/src/core/file_sys/romfs_reader.cpp index bc9bec906..40823d833 100644 --- a/src/core/file_sys/romfs_reader.cpp +++ b/src/core/file_sys/romfs_reader.cpp @@ -16,7 +16,7 @@ std::size_t DirectRomFSReader::ReadFile(std::size_t offset, std::size_t length, return 0; // Crypto++ does not like zero size buffer const auto segments = BreakupRead(offset, length); - size_t read_progress = 0; + std::size_t read_progress = 0; // Skip cache if the read is too big if (segments.size() == 1 && segments[0].second > cache_line_size) { @@ -33,8 +33,8 @@ std::size_t DirectRomFSReader::ReadFile(std::size_t offset, std::size_t length, // TODO(PabloMK7): Make cache thread safe, read the comment in CacheReady function. // std::unique_lock read_guard(cache_mutex); for (const auto& seg : segments) { - size_t read_size = cache_line_size; - size_t page = OffsetToPage(seg.first); + std::size_t read_size = cache_line_size; + std::size_t page = OffsetToPage(seg.first); // Check if segment is in cache auto cache_entry = cache.request(page); if (!cache_entry.first) { @@ -51,7 +51,7 @@ std::size_t DirectRomFSReader::ReadFile(std::size_t offset, std::size_t length, LOG_TRACE(Service_FS, "RomFS Cache HIT: page={}, length={}, into={}", page, seg.second, (seg.first - page)); } - size_t copy_amount = + std::size_t copy_amount = (read_size > (seg.first - page)) ? std::min((seg.first - page) + seg.second, read_size) - (seg.first - page) : 0; @@ -98,10 +98,10 @@ std::vector> DirectRomFSReader::BreakupRead( return ret; } - size_t curr_offset = offset; + std::size_t curr_offset = offset; while (length) { - size_t next_page = OffsetToPage(curr_offset + cache_line_size); - size_t curr_page_len = std::min(length, next_page - curr_offset); + std::size_t next_page = OffsetToPage(curr_offset + cache_line_size); + std::size_t curr_page_len = std::min(length, next_page - curr_offset); ret.push_back(std::make_pair(curr_offset, curr_page_len)); curr_offset = next_page; length -= curr_page_len; diff --git a/src/core/file_sys/romfs_reader.h b/src/core/file_sys/romfs_reader.h index 28583b413..128d10dbd 100644 --- a/src/core/file_sys/romfs_reader.h +++ b/src/core/file_sys/romfs_reader.h @@ -67,8 +67,8 @@ private: u64 data_size; // Total cache size: 128KB - static constexpr size_t cache_line_size = (1 << 13); // About 8KB - static constexpr size_t cache_line_count = 16; + static constexpr std::size_t cache_line_size = (1 << 13); // About 8KB + static constexpr std::size_t cache_line_count = 16; Common::StaticLRUCache, cache_line_count> cache; // TODO(PabloMK7): Make cache thread safe, read the comment in CacheReady function. diff --git a/src/core/hle/kernel/resource_limit.cpp b/src/core/hle/kernel/resource_limit.cpp index 8b57f22c4..b298c6879 100644 --- a/src/core/hle/kernel/resource_limit.cpp +++ b/src/core/hle/kernel/resource_limit.cpp @@ -22,22 +22,22 @@ std::shared_ptr ResourceLimit::Create(KernelSystem& kernel, std:: } s32 ResourceLimit::GetCurrentValue(ResourceLimitType type) const { - const auto index = static_cast(type); + const auto index = static_cast(type); return m_current_values[index]; } s32 ResourceLimit::GetLimitValue(ResourceLimitType type) const { - const auto index = static_cast(type); + const auto index = static_cast(type); return m_limit_values[index]; } void ResourceLimit::SetLimitValue(ResourceLimitType type, s32 value) { - const auto index = static_cast(type); + const auto index = static_cast(type); m_limit_values[index] = value; } bool ResourceLimit::Reserve(ResourceLimitType type, s32 amount) { - const auto index = static_cast(type); + const auto index = static_cast(type); const s32 limit = m_limit_values[index]; const s32 new_value = m_current_values[index] + amount; if (new_value > limit) { @@ -50,7 +50,7 @@ bool ResourceLimit::Reserve(ResourceLimitType type, s32 amount) { } bool ResourceLimit::Release(ResourceLimitType type, s32 amount) { - const auto index = static_cast(type); + const auto index = static_cast(type); const s32 value = m_current_values[index]; if (amount > value) { LOG_ERROR(Kernel, "Amount {} exceeds current value {} for resource type {}", amount, value, diff --git a/src/core/hle/kernel/resource_limit.h b/src/core/hle/kernel/resource_limit.h index cfc9dae0a..069175daa 100644 --- a/src/core/hle/kernel/resource_limit.h +++ b/src/core/hle/kernel/resource_limit.h @@ -68,7 +68,7 @@ public: bool Release(ResourceLimitType type, s32 amount); private: - using ResourceArray = std::array(ResourceLimitType::Max)>; + using ResourceArray = std::array(ResourceLimitType::Max)>; ResourceArray m_limit_values{}; ResourceArray m_current_values{}; std::string m_name; diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index 642009d2b..c68e4a297 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp @@ -127,7 +127,7 @@ Result SharedMemory::Map(Process& target_process, VAddr address, MemoryPermissio // Heap-backed memory blocks can not be mapped with other_permissions = DontCare if (base_address != 0 && other_permissions == MemoryPermission::DontCare) { - LOG_ERROR(Kernel, "cannot map id={}, address=0x{08X} name={}, permissions don't match", + LOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, permissions don't match", GetObjectId(), address, name); return ResultInvalidCombination; } diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 78fe5f143..4cc2c0ad0 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -1686,8 +1686,8 @@ Result SVC::AcceptSession(Handle* out_server_session, Handle server_port_handle) return current_process->handle_table.Create(out_server_session, std::move(session)); } -static void CopyStringPart(char* out, const char* in, size_t offset, size_t max_length) { - size_t str_size = strlen(in); +static void CopyStringPart(char* out, const char* in, std::size_t offset, std::size_t max_length) { + std::size_t str_size = strlen(in); if (offset < str_size) { strncpy(out, in + offset, max_length - 1); out[max_length - 1] = '\0'; diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 7f6046a8f..83a2ba8f7 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -244,7 +244,7 @@ void Thread::WakeAfterDelay(s64 nanoseconds, bool thread_safe_mode) { // Don't schedule a wakeup if the thread wants to wait forever if (nanoseconds == -1) return; - size_t core = thread_safe_mode ? core_id : std::numeric_limits::max(); + std::size_t core = thread_safe_mode ? core_id : std::numeric_limits::max(); thread_manager.kernel.timing.ScheduleEvent(nsToCycles(nanoseconds), thread_manager.ThreadWakeupEventType, thread_id, diff --git a/src/core/hle/service/apt/applet_manager.cpp b/src/core/hle/service/apt/applet_manager.cpp index 89c6a4a87..7e976a50e 100644 --- a/src/core/hle/service/apt/applet_manager.cpp +++ b/src/core/hle/service/apt/applet_manager.cpp @@ -713,6 +713,7 @@ Result AppletManager::SendDspSleep(AppletId from_applet_id, .signal = SignalType::DspSleep, .object = std::move(object), }); + return ResultSuccess; } auto sys_lib_slot = GetAppletSlotFromPos(AppletPos::SysLibrary); @@ -728,6 +729,7 @@ Result AppletManager::SendDspSleep(AppletId from_applet_id, .signal = SignalType::DspSleep, .object = std::move(object), }); + return ResultSuccess; } return ResultSuccess; diff --git a/src/core/hle/service/boss/online_service.cpp b/src/core/hle/service/boss/online_service.cpp index 2ae967e47..991cd614e 100644 --- a/src/core/hle/service/boss/online_service.cpp +++ b/src/core/hle/service/boss/online_service.cpp @@ -399,8 +399,8 @@ Result OnlineService::GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHead } } -ResultVal OnlineService::ReadNsData(const u32 ns_data_id, const u64 offset, const u32 size, - Kernel::MappedBuffer& buffer) { +ResultVal OnlineService::ReadNsData(const u32 ns_data_id, const u64 offset, + const u32 size, Kernel::MappedBuffer& buffer) { std::optional entry = GetNsDataEntryFromId(ns_data_id); if (!entry.has_value()) { LOG_WARNING(Service_BOSS, "Failed to find NsData entry for ID {:#010X}", ns_data_id); diff --git a/src/core/hle/service/boss/online_service.h b/src/core/hle/service/boss/online_service.h index a80fceede..a79aac955 100644 --- a/src/core/hle/service/boss/online_service.h +++ b/src/core/hle/service/boss/online_service.h @@ -36,11 +36,11 @@ constexpr u32 BOSS_EXTDATA_HEADER_LENGTH = 0x18; constexpr u32 BOSS_S_ENTRY_SIZE = 0xC00; constexpr u32 BOSS_SAVE_HEADER_SIZE = 4; -constexpr size_t TASK_ID_SIZE = 8; -constexpr size_t URL_SIZE = 0x200; -constexpr size_t HEADERS_SIZE = 0x360; -constexpr size_t CERTIDLIST_SIZE = 3; -constexpr size_t TASKIDLIST_SIZE = 0x400; +constexpr std::size_t TASK_ID_SIZE = 8; +constexpr std::size_t URL_SIZE = 0x200; +constexpr std::size_t HEADERS_SIZE = 0x360; +constexpr std::size_t CERTIDLIST_SIZE = 3; +constexpr std::size_t TASKIDLIST_SIZE = 0x400; constexpr std::array boss_system_savedata_id{ 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x01, 0x00, @@ -188,8 +188,8 @@ public: std::optional GetNsDataEntryFromId(const u32 ns_data_id); Result GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHeaderInfoType type, const u32 size, Kernel::MappedBuffer& buffer); - ResultVal ReadNsData(const u32 ns_data_id, const u64 offset, const u32 size, - Kernel::MappedBuffer& buffer); + ResultVal ReadNsData(const u32 ns_data_id, const u64 offset, const u32 size, + Kernel::MappedBuffer& buffer); Result SendProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer); Result ReceiveProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer); diff --git a/src/core/hle/service/cecd/cecd.cpp b/src/core/hle/service/cecd/cecd.cpp index 4d48cd1a6..9e34bf833 100644 --- a/src/core/hle/service/cecd/cecd.cpp +++ b/src/core/hle/service/cecd/cecd.cpp @@ -649,7 +649,7 @@ void Module::Interface::ReadData(Kernel::HLERequestContext& ctx) { buffer = {}; } dest_buffer.Write(buffer.data(), 0, - std::min(static_cast(dest_buffer_size), buffer.size())); + std::min(static_cast(dest_buffer_size), buffer.size())); rb.Push(ResultSuccess); rb.PushMappedBuffer(param_buffer); diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp index f69e5c70f..b93265c6b 100644 --- a/src/core/hle/service/cfg/cfg.cpp +++ b/src/core/hle/service/cfg/cfg.cpp @@ -384,7 +384,7 @@ ResultVal Module::GetConfigBlockPointer(u32 block_id, u32 size, AccessFla "Config block 0x{:X} with flags {} and size {} was not found, creating " "from defaults.", block_id, accesss_flag, size); - auto default_block = GetDefaultConfigBlock(static_cast(block_id)); + const auto& default_block = GetDefaultConfigBlock(static_cast(block_id)); auto result = CreateConfigBlock(block_id, static_cast(default_block.data.size()), default_block.access_flags, default_block.data.data()); if (!result.IsSuccess()) { diff --git a/src/core/hle/service/fs/file.cpp b/src/core/hle/service/fs/file.cpp index fc1c5e14f..702e2018e 100644 --- a/src/core/hle/service/fs/file.cpp +++ b/src/core/hle/service/fs/file.cpp @@ -107,7 +107,7 @@ void File::Read(Kernel::HLERequestContext& ctx) { Result ret{0}; Kernel::MappedBuffer* buffer; std::unique_ptr data; - size_t read_size; + std::size_t read_size; }; auto async_data = std::make_shared(); diff --git a/src/core/hle/service/http/http_c.cpp b/src/core/hle/service/http/http_c.cpp index 3655280ac..7be08a476 100644 --- a/src/core/hle/service/http/http_c.cpp +++ b/src/core/hle/service/http/http_c.cpp @@ -112,9 +112,9 @@ static URLInfo SplitUrl(const std::string& url) { }; } -static size_t WriteHeaders(httplib::Stream& stream, - std::span headers) { - size_t write_len = 0; +static std::size_t WriteHeaders(httplib::Stream& stream, + std::span headers) { + std::size_t write_len = 0; for (const auto& header : headers) { auto len = stream.write_format("%s: %s\r\n", header.name.c_str(), header.value.c_str()); if (len < 0) { @@ -130,8 +130,8 @@ static size_t WriteHeaders(httplib::Stream& stream, return write_len; } -static size_t HandleHeaderWrite(std::vector& pending_headers, - httplib::Stream& strm, httplib::Headers& httplib_headers) { +static std::size_t HandleHeaderWrite(std::vector& pending_headers, + httplib::Stream& strm, httplib::Headers& httplib_headers) { std::vector final_headers; std::vector::iterator it_pending_headers; httplib::Headers::iterator it_httplib_headers; @@ -508,7 +508,7 @@ void HTTP_C::ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout) { } Context& http_context = GetContext(async_data->context_handle); - const size_t remaining_data = + const std::size_t remaining_data = http_context.response.body.size() - http_context.current_copied_data; if (async_data->buffer_size >= remaining_data) { diff --git a/src/core/hle/service/http/http_c.h b/src/core/hle/service/http/http_c.h index 07547d05e..afc788607 100644 --- a/src/core/hle/service/http/http_c.h +++ b/src/core/hle/service/http/http_c.h @@ -217,7 +217,7 @@ public: std::future request_future; std::atomic current_download_size_bytes; std::atomic total_download_size_bytes; - size_t current_copied_data; + std::size_t current_copied_data; bool uses_default_client_cert{}; httplib::Response response; diff --git a/src/core/hle/service/ir/extra_hid.cpp b/src/core/hle/service/ir/extra_hid.cpp index 08af23c42..e159a70fe 100644 --- a/src/core/hle/service/ir/extra_hid.cpp +++ b/src/core/hle/service/ir/extra_hid.cpp @@ -238,7 +238,7 @@ void ExtraHID::SendHIDStatus() { float x, y; std::tie(x, y) = c_stick->GetStatus(); - ExtraHIDResponse response; + ExtraHIDResponse response{}; response.c_stick.header.Assign(static_cast(ResponseID::PollHID)); response.c_stick.c_stick_x.Assign(static_cast(C_STICK_CENTER + C_STICK_RADIUS * x)); response.c_stick.c_stick_y.Assign(static_cast(C_STICK_CENTER + C_STICK_RADIUS * y)); diff --git a/src/core/hle/service/soc/soc_u.cpp b/src/core/hle/service/soc/soc_u.cpp index 386a2ac06..a41f8eb30 100644 --- a/src/core/hle/service/soc/soc_u.cpp +++ b/src/core/hle/service/soc/soc_u.cpp @@ -1102,7 +1102,7 @@ void SOC_U::SendToOther(Kernel::HLERequestContext& ctx) { #endif // _WIN32 std::vector input_buff(len); input_mapped_buff.Read(input_buff.data(), 0, - std::min(input_mapped_buff.GetSize(), static_cast(len))); + std::min(input_mapped_buff.GetSize(), static_cast(len))); s32 ret = -1; if (addr_len > 0) { @@ -1853,7 +1853,7 @@ void SOC_U::GetSockOpt(Kernel::HLERequestContext& ctx) { if (err == SOCKET_ERROR_VALUE) { err = TranslateError(GET_ERRNO); } else { - platform_data.resize(static_cast(platform_data_size)); + platform_data.resize(static_cast(platform_data_size)); TranslateSockOptDataFromPlatform(optval, platform_data, level_opt.first, level_opt.second); } diff --git a/src/core/loader/3dsx.h b/src/core/loader/3dsx.h index 27432e9fd..d7162f4d7 100644 --- a/src/core/loader/3dsx.h +++ b/src/core/loader/3dsx.h @@ -16,7 +16,7 @@ class AppLoader_THREEDSX final : public AppLoader { public: AppLoader_THREEDSX(Core::System& system_, FileUtil::IOFile&& file, const std::string& filename, const std::string& filepath) - : AppLoader(system_, std::move(file)), filename(std::move(filename)), filepath(filepath) {} + : AppLoader(system_, std::move(file)), filename(filename), filepath(filepath) {} /** * Returns the type of the file diff --git a/src/core/savestate.cpp b/src/core/savestate.cpp index e0ed958df..bc1f53684 100644 --- a/src/core/savestate.cpp +++ b/src/core/savestate.cpp @@ -48,8 +48,8 @@ static std::string GetSaveStatePath(u64 program_id, u64 movie_id, u32 slot) { } static bool ValidateSaveState(const CSTHeader& header, SaveStateInfo& info, u64 program_id, - u64 movie_id, u32 slot) { - const auto path = GetSaveStatePath(program_id, movie_id, slot); + u64 movie_id) { + const auto path = GetSaveStatePath(program_id, movie_id, info.slot); if (header.filetype != header_magic_bytes) { LOG_WARNING(Core, "Invalid save state file {}", path); return false; @@ -112,7 +112,7 @@ std::vector ListSaveStates(u64 program_id, u64 movie_id) { LOG_ERROR(Core, "Could not read from file {}", path); continue; } - if (!ValidateSaveState(header, info, program_id, movie_id, slot)) { + if (!ValidateSaveState(header, info, program_id, movie_id)) { continue; } @@ -185,7 +185,8 @@ void System::LoadState(u32 slot) { // validate header SaveStateInfo info; - if (!ValidateSaveState(header, info, title_id, movie_id, slot)) { + info.slot = slot; + if (!ValidateSaveState(header, info, title_id, movie_id)) { throw std::runtime_error("Invalid savestate"); } diff --git a/src/video_core/custom_textures/custom_tex_manager.cpp b/src/video_core/custom_textures/custom_tex_manager.cpp index da05b6e6d..df9720941 100644 --- a/src/video_core/custom_textures/custom_tex_manager.cpp +++ b/src/video_core/custom_textures/custom_tex_manager.cpp @@ -207,7 +207,7 @@ void CustomTexManager::PrepareDumping(u64 title_id) { void CustomTexManager::PreloadTextures(const std::atomic_bool& stop_run, const VideoCore::DiskResourceLoadCallback& callback) { u64 size_sum = 0; - size_t preloaded = 0; + std::size_t preloaded = 0; const u64 sys_mem = Common::GetMemInfo().total_physical_memory; const u64 recommended_min_mem = 2_GiB; @@ -343,7 +343,7 @@ bool CustomTexManager::ReadConfig(u64 title_id, bool options_only) { const auto& textures = json["textures"]; for (const auto& material : textures.items()) { - size_t idx{}; + std::size_t idx{}; const u64 hash = std::stoull(material.key(), &idx, 16); if (!idx) { LOG_ERROR(Render, "Key {} is invalid, skipping", material.key()); diff --git a/src/video_core/gpu_debugger.h b/src/video_core/gpu_debugger.h index c5fb2de47..d6d6ebde9 100644 --- a/src/video_core/gpu_debugger.h +++ b/src/video_core/gpu_debugger.h @@ -7,6 +7,7 @@ #include #include #include +#include "common/logging/log.h" #include "core/hle/service/gsp/gsp_command.h" namespace VideoCore { diff --git a/src/video_core/pica/output_vertex.h b/src/video_core/pica/output_vertex.h index 7213dcf67..d39210327 100644 --- a/src/video_core/pica/output_vertex.h +++ b/src/video_core/pica/output_vertex.h @@ -4,6 +4,7 @@ #pragma once +#include "common/common_funcs.h" #include "common/vector_math.h" #include "video_core/pica_types.h" diff --git a/src/video_core/pica/pica_core.cpp b/src/video_core/pica/pica_core.cpp index 9c3fadde8..53e273833 100644 --- a/src/video_core/pica/pica_core.cpp +++ b/src/video_core/pica/pica_core.cpp @@ -398,7 +398,7 @@ void PicaCore::SubmitImmediate(u32 value) { return; } - constexpr size_t IMMEDIATE_MODE_INDEX = 0xF; + constexpr std::size_t IMMEDIATE_MODE_INDEX = 0xF; auto& setup = regs.internal.pipeline.vs_default_attributes_setup; if (setup.index > IMMEDIATE_MODE_INDEX) { diff --git a/src/video_core/pica/pica_core.h b/src/video_core/pica/pica_core.h index 353945b53..b35ec7b08 100644 --- a/src/video_core/pica/pica_core.h +++ b/src/video_core/pica/pica_core.h @@ -53,7 +53,7 @@ private: public: union Regs { - static constexpr size_t NUM_REGS = 0x732; + static constexpr std::size_t NUM_REGS = 0x732; struct { u32 hardware_id; diff --git a/src/video_core/pica/regs_external.h b/src/video_core/pica/regs_external.h index 1a433a696..a629a11a7 100644 --- a/src/video_core/pica/regs_external.h +++ b/src/video_core/pica/regs_external.h @@ -4,7 +4,12 @@ #pragma once +#include + +#include +#include "common/assert.h" #include "common/bit_field.h" +#include "common/common_funcs.h" namespace Pica { diff --git a/src/video_core/pica/regs_rasterizer.h b/src/video_core/pica/regs_rasterizer.h index 7b88231f9..5b4785da5 100644 --- a/src/video_core/pica/regs_rasterizer.h +++ b/src/video_core/pica/regs_rasterizer.h @@ -5,6 +5,7 @@ #pragma once #include +#include "common/assert.h" #include "common/bit_field.h" #include "common/common_funcs.h" #include "common/math_util.h" diff --git a/src/video_core/pica/shader_setup.cpp b/src/video_core/pica/shader_setup.cpp index 967292c9f..2b4b62002 100644 --- a/src/video_core/pica/shader_setup.cpp +++ b/src/video_core/pica/shader_setup.cpp @@ -2,8 +2,10 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/assert.h" #include "common/bit_set.h" #include "common/hash.h" +#include "common/logging/log.h" #include "video_core/pica/regs_shader.h" #include "video_core/pica/shader_setup.h" diff --git a/src/video_core/pica/shader_setup.h b/src/video_core/pica/shader_setup.h index f26843838..1a240000a 100644 --- a/src/video_core/pica/shader_setup.h +++ b/src/video_core/pica/shader_setup.h @@ -21,15 +21,15 @@ struct Uniforms { std::array b; std::array, 4> i; - static size_t GetFloatUniformOffset(u32 index) { + static std::size_t GetFloatUniformOffset(u32 index) { return offsetof(Uniforms, f) + index * sizeof(Common::Vec4); } - static size_t GetBoolUniformOffset(u32 index) { + static std::size_t GetBoolUniformOffset(u32 index) { return offsetof(Uniforms, b) + index * sizeof(bool); } - static size_t GetIntUniformOffset(u32 index) { + static std::size_t GetIntUniformOffset(u32 index) { return offsetof(Uniforms, i) + index * sizeof(Common::Vec4); } diff --git a/src/video_core/pica/shader_unit.cpp b/src/video_core/pica/shader_unit.cpp index 7cee1131d..5d81f857a 100644 --- a/src/video_core/pica/shader_unit.cpp +++ b/src/video_core/pica/shader_unit.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/assert.h" #include "common/bit_set.h" #include "video_core/pica/regs_shader.h" #include "video_core/pica/shader_unit.h" diff --git a/src/video_core/pica/shader_unit.h b/src/video_core/pica/shader_unit.h index 968b00b90..4fa9a1496 100644 --- a/src/video_core/pica/shader_unit.h +++ b/src/video_core/pica/shader_unit.h @@ -33,15 +33,15 @@ struct ShaderUnit { void WriteOutput(const ShaderRegs& config, AttributeBuffer& output); - static constexpr size_t InputOffset(s32 register_index) { + static constexpr std::size_t InputOffset(s32 register_index) { return offsetof(ShaderUnit, input) + register_index * sizeof(Common::Vec4); } - static constexpr size_t OutputOffset(s32 register_index) { + static constexpr std::size_t OutputOffset(s32 register_index) { return offsetof(ShaderUnit, output) + register_index * sizeof(Common::Vec4); } - static constexpr size_t TemporaryOffset(s32 register_index) { + static constexpr std::size_t TemporaryOffset(s32 register_index) { return offsetof(ShaderUnit, temporary) + register_index * sizeof(Common::Vec4); } diff --git a/src/video_core/rasterizer_accelerated.cpp b/src/video_core/rasterizer_accelerated.cpp index 62047deba..6c97f25ba 100644 --- a/src/video_core/rasterizer_accelerated.cpp +++ b/src/video_core/rasterizer_accelerated.cpp @@ -710,7 +710,7 @@ void RasterizerAccelerated::SyncCombinerColor() { } void RasterizerAccelerated::SyncTevConstColor( - const size_t stage_index, const Pica::TexturingRegs::TevStageConfig& tev_stage) { + const std::size_t stage_index, const Pica::TexturingRegs::TevStageConfig& tev_stage) { const auto const_color = ColorRGBA8(tev_stage.const_color); if (const_color == fs_uniform_block_data.data.const_color[stage_index]) { diff --git a/src/video_core/rasterizer_cache/rasterizer_cache.h b/src/video_core/rasterizer_cache/rasterizer_cache.h index 85eda2c56..b6c4dd4f6 100644 --- a/src/video_core/rasterizer_cache/rasterizer_cache.h +++ b/src/video_core/rasterizer_cache/rasterizer_cache.h @@ -777,7 +777,7 @@ typename RasterizerCache::SurfaceRect_Tuple RasterizerCache::GetTexCopySur template template -void RasterizerCache::ForEachSurfaceInRegion(PAddr addr, size_t size, Func&& func) { +void RasterizerCache::ForEachSurfaceInRegion(PAddr addr, std::size_t size, Func&& func) { using FuncReturn = typename std::invoke_result::type; static constexpr bool BOOL_BREAK = std::is_same_v; boost::container::small_vector surfaces; diff --git a/src/video_core/rasterizer_cache/rasterizer_cache_base.h b/src/video_core/rasterizer_cache/rasterizer_cache_base.h index 8d401370b..13d9682a0 100644 --- a/src/video_core/rasterizer_cache/rasterizer_cache_base.h +++ b/src/video_core/rasterizer_cache/rasterizer_cache_base.h @@ -139,7 +139,7 @@ public: private: /// Iterate over all page indices in a range template - void ForEachPage(PAddr addr, size_t size, Func&& func) { + void ForEachPage(PAddr addr, std::size_t size, Func&& func) { static constexpr bool RETURNS_BOOL = std::is_same_v, bool>; const u64 page_end = (addr + size - 1) >> CITRA_PAGEBITS; for (u64 page = addr >> CITRA_PAGEBITS; page <= page_end; ++page) { @@ -155,7 +155,7 @@ private: /// Iterates over all the surfaces in a region calling func template - void ForEachSurfaceInRegion(PAddr addr, size_t size, Func&& func); + void ForEachSurfaceInRegion(PAddr addr, std::size_t size, Func&& func); /// Get the best surface match (and its match type) for the given flags template diff --git a/src/video_core/rasterizer_cache/surface_base.h b/src/video_core/rasterizer_cache/surface_base.h index e786a82b0..b2ca33e61 100644 --- a/src/video_core/rasterizer_cache/surface_base.h +++ b/src/video_core/rasterizer_cache/surface_base.h @@ -47,7 +47,7 @@ public: /// Returns true if the surface contains a custom material with a normal map. bool HasNormalMap() const noexcept; - bool Overlaps(PAddr overlap_addr, size_t overlap_size) const noexcept { + bool Overlaps(PAddr overlap_addr, std::size_t overlap_size) const noexcept { const PAddr overlap_end = overlap_addr + static_cast(overlap_size); return addr < overlap_end && overlap_addr < end; } diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 341bfdc72..e9423fc6d 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -310,7 +310,7 @@ void RendererOpenGL::InitOpenGLObjects() { glClearColor(Settings::values.bg_red.GetValue(), Settings::values.bg_green.GetValue(), Settings::values.bg_blue.GetValue(), 0.0f); - for (size_t i = 0; i < samplers.size(); i++) { + for (std::size_t i = 0; i < samplers.size(); i++) { samplers[i].Create(); glSamplerParameteri(samplers[i].handle, GL_TEXTURE_MIN_FILTER, i == 0 ? GL_NEAREST : GL_LINEAR); diff --git a/src/video_core/renderer_software/sw_blitter.cpp b/src/video_core/renderer_software/sw_blitter.cpp index 9a8361a34..0a68afd07 100644 --- a/src/video_core/renderer_software/sw_blitter.cpp +++ b/src/video_core/renderer_software/sw_blitter.cpp @@ -78,12 +78,12 @@ void SwBlitter::TextureCopy(const Pica::DisplayTransferConfig& config) { return; } - const size_t contiguous_input_size = + const std::size_t contiguous_input_size = config.texture_copy.size / input_width * (input_width + input_gap); rasterizer->FlushRegion(config.GetPhysicalInputAddress(), static_cast(contiguous_input_size)); - const size_t contiguous_output_size = + const std::size_t contiguous_output_size = config.texture_copy.size / output_width * (output_width + output_gap); // Only need to flush output if it has a gap @@ -329,7 +329,7 @@ void SwBlitter::MemoryFill(const Pica::MemoryFillConfig& config) { // Fill with 32-bit values if (end > start) { const u32 value = config.value_32bit; - const size_t len = (end - start) / sizeof(u32); + const std::size_t len = (end - start) / sizeof(u32); for (std::size_t i = 0; i < len; ++i) { std::memcpy(&start[i * sizeof(u32)], &value, sizeof(u32)); } diff --git a/src/video_core/renderer_software/sw_rasterizer.h b/src/video_core/renderer_software/sw_rasterizer.h index 25ca224d2..026dc8b76 100644 --- a/src/video_core/renderer_software/sw_rasterizer.h +++ b/src/video_core/renderer_software/sw_rasterizer.h @@ -70,7 +70,7 @@ private: Memory::MemorySystem& memory; Pica::PicaCore& pica; Pica::RegsInternal& regs; - size_t num_sw_threads; + std::size_t num_sw_threads; Common::ThreadWorker sw_workers; Framebuffer fb; }; diff --git a/src/video_core/renderer_vulkan/vk_instance.cpp b/src/video_core/renderer_vulkan/vk_instance.cpp index c541af6e5..1168efd70 100644 --- a/src/video_core/renderer_vulkan/vk_instance.cpp +++ b/src/video_core/renderer_vulkan/vk_instance.cpp @@ -691,7 +691,7 @@ void Instance::CollectToolingInfo() { bool Instance::SetMoltenVkConfig() { #ifdef __APPLE__ - size_t mvk_config_size = sizeof(MVKConfiguration); + std::size_t mvk_config_size = sizeof(MVKConfiguration); MVKConfiguration mvk_config{}; const auto _vkGetMoltenVKConfigurationMVK = diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index f689925d6..9668aed69 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -543,7 +543,7 @@ void PipelineCache::BindTexelBuffer(u32 binding, vk::BufferView buffer_view) { } } -void PipelineCache::SetBufferOffset(u32 binding, size_t offset) { +void PipelineCache::SetBufferOffset(u32 binding, std::size_t offset) { if (offsets[binding] != static_cast(offset)) { offsets[binding] = static_cast(offset); set_dirty[0] = true; diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h index 949bb3250..2c57d2d52 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h @@ -79,7 +79,7 @@ public: void BindTexelBuffer(u32 binding, vk::BufferView buffer_view); /// Sets the dynamic offset for the uniform buffer at binding - void SetBufferOffset(u32 binding, size_t offset); + void SetBufferOffset(u32 binding, std::size_t offset); private: /// Builds the rasterizer pipeline layout diff --git a/src/video_core/renderer_vulkan/vk_platform.cpp b/src/video_core/renderer_vulkan/vk_platform.cpp index a6be64257..82a5da8c4 100644 --- a/src/video_core/renderer_vulkan/vk_platform.cpp +++ b/src/video_core/renderer_vulkan/vk_platform.cpp @@ -63,7 +63,7 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL DebugUtilsCallback( static VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, - uint64_t object, size_t location, + uint64_t object, std::size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData) { diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 1d03f0acc..0208c8cde 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -235,7 +235,7 @@ void RasterizerVulkan::SetupVertexArray() { if (aligned_stride == loader.byte_count) { std::memcpy(dst_ptr, src_ptr, data_size); } else { - for (size_t vertex = 0; vertex < vertex_num; vertex++) { + for (std::size_t vertex = 0; vertex < vertex_num; vertex++) { std::memcpy(dst_ptr + vertex * aligned_stride, src_ptr + vertex * loader.byte_count, loader.byte_count); } diff --git a/src/video_core/renderer_vulkan/vk_renderpass_cache.h b/src/video_core/renderer_vulkan/vk_renderpass_cache.h index 64f9931a2..3763d9898 100644 --- a/src/video_core/renderer_vulkan/vk_renderpass_cache.h +++ b/src/video_core/renderer_vulkan/vk_renderpass_cache.h @@ -35,8 +35,8 @@ struct RenderPass { }; class RenderpassCache { - static constexpr size_t MAX_COLOR_FORMATS = 13; - static constexpr size_t MAX_DEPTH_FORMATS = 4; + static constexpr std::size_t MAX_COLOR_FORMATS = 13; + static constexpr std::size_t MAX_DEPTH_FORMATS = 4; public: explicit RenderpassCache(const Instance& instance, Scheduler& scheduler); diff --git a/src/video_core/renderer_vulkan/vk_resource_pool.cpp b/src/video_core/renderer_vulkan/vk_resource_pool.cpp index d74c4edc7..84df8afe7 100644 --- a/src/video_core/renderer_vulkan/vk_resource_pool.cpp +++ b/src/video_core/renderer_vulkan/vk_resource_pool.cpp @@ -10,7 +10,7 @@ namespace Vulkan { -ResourcePool::ResourcePool(MasterSemaphore* master_semaphore_, size_t grow_step_) +ResourcePool::ResourcePool(MasterSemaphore* master_semaphore_, std::size_t grow_step_) : master_semaphore{master_semaphore_}, grow_step{grow_step_} {} std::size_t ResourcePool::CommitResource() { @@ -57,12 +57,12 @@ std::size_t ResourcePool::ManageOverflow() { } void ResourcePool::Grow() { - const size_t old_capacity = ticks.size(); + const std::size_t old_capacity = ticks.size(); ticks.resize(old_capacity + grow_step); Allocate(old_capacity, old_capacity + grow_step); } -constexpr size_t COMMAND_BUFFER_POOL_SIZE = 4; +constexpr std::size_t COMMAND_BUFFER_POOL_SIZE = 4; struct CommandPool::Pool { vk::CommandPool handle; diff --git a/src/video_core/renderer_vulkan/vk_texture_runtime.cpp b/src/video_core/renderer_vulkan/vk_texture_runtime.cpp index 8f2b3b93e..4ba7e6052 100644 --- a/src/video_core/renderer_vulkan/vk_texture_runtime.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_runtime.cpp @@ -119,9 +119,9 @@ u32 UnpackDepthStencil(const VideoCore::StagingData& data, vk::Format dest) { } boost::container::small_vector MakeInitBarriers( - vk::ImageAspectFlags aspect, std::span images, size_t num_images) { + vk::ImageAspectFlags aspect, std::span images, std::size_t num_images) { boost::container::small_vector barriers; - for (size_t i = 0; i < num_images; i++) { + for (std::size_t i = 0; i < num_images; i++) { barriers.push_back(vk::ImageMemoryBarrier{ .srcAccessMask = vk::AccessFlagBits::eNone, .dstAccessMask = vk::AccessFlagBits::eNone, diff --git a/src/video_core/shader/generator/glsl_fs_shader_gen.cpp b/src/video_core/shader/generator/glsl_fs_shader_gen.cpp index c85035abc..45a49e7ff 100644 --- a/src/video_core/shader/generator/glsl_fs_shader_gen.cpp +++ b/src/video_core/shader/generator/glsl_fs_shader_gen.cpp @@ -12,7 +12,7 @@ using ProcTexCombiner = TexturingRegs::ProcTexCombiner; using ProcTexFilter = TexturingRegs::ProcTexFilter; using TextureType = Pica::TexturingRegs::TextureConfig::TextureType; -constexpr static size_t RESERVE_SIZE = 8 * 1024 * 1024; +constexpr static std::size_t RESERVE_SIZE = 8 * 1024 * 1024; enum class Semantic : u32 { Position, diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index a8dd4c1c6..c19519298 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h @@ -4,6 +4,7 @@ #pragma once +#include #include "common/common_types.h" namespace Pica { diff --git a/src/video_core/shader/shader_jit_a64_compiler.cpp b/src/video_core/shader/shader_jit_a64_compiler.cpp index 95027c751..d32421161 100644 --- a/src/video_core/shader/shader_jit_a64_compiler.cpp +++ b/src/video_core/shader/shader_jit_a64_compiler.cpp @@ -968,7 +968,7 @@ void JitShader::Compile(const std::array* program_ protect(); invalidate_all(); - const size_t code_size = + const std::size_t code_size = current_address() - reinterpret_cast(oaknut::CodeBlock::ptr()); ASSERT_MSG(code_size <= MAX_SHADER_SIZE, "Compiled a shader that exceeds the allocated size!");