From a16d8ba3ead71f98c91a54ab40d884394707d455 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 9 Apr 2021 21:12:47 +0200 Subject: [PATCH] More random changes --- Utilities/CRC.h | 4 +- Utilities/Config.h | 4 +- Utilities/File.cpp | 28 ++++----- Utilities/JIT.cpp | 4 -- Utilities/JIT.h | 1 - Utilities/LUrlParser.cpp | 12 ++-- Utilities/StrUtil.h | 1 - Utilities/Thread.cpp | 3 +- Utilities/Thread.h | 2 - Utilities/Timer.h | 12 ++-- Utilities/address_range.h | 57 +++++-------------- Utilities/bin_patch.cpp | 6 +- Utilities/cfmt.h | 2 +- Utilities/cond.cpp | 3 - Utilities/date_time.h | 4 +- Utilities/rXml.cpp | 4 +- Utilities/sema.h | 1 - Utilities/sync.h | 4 +- rpcs3/Crypto/ec.cpp | 2 +- rpcs3/Crypto/key_vault.cpp | 14 ++--- rpcs3/Crypto/key_vault.h | 2 +- rpcs3/Crypto/lz.cpp | 2 +- rpcs3/Crypto/unedat.cpp | 18 +++--- rpcs3/Crypto/unedat.h | 2 +- rpcs3/Crypto/unpkg.cpp | 2 +- rpcs3/Crypto/unpkg.h | 18 +++--- rpcs3/Crypto/unself.cpp | 20 +++---- rpcs3/Crypto/unself.h | 34 +++++------ rpcs3/Crypto/utils.cpp | 8 +-- rpcs3/Emu/Audio/AL/OpenALBackend.h | 27 +++++---- rpcs3/Emu/Audio/AudioBackend.cpp | 2 +- rpcs3/Emu/Audio/AudioDumper.cpp | 2 +- rpcs3/Emu/Audio/FAudio/FAudioBackend.cpp | 18 +++--- rpcs3/Emu/Audio/FAudio/FAudioBackend.h | 28 ++++----- rpcs3/Emu/Audio/XAudio2/XAudio2Backend.cpp | 18 +++--- rpcs3/Emu/Audio/XAudio2/XAudio2Backend.h | 26 ++++----- rpcs3/Emu/CPU/CPUThread.cpp | 12 ++-- rpcs3/Emu/CPU/CPUThread.h | 5 +- rpcs3/Emu/CPU/CPUTranslator.cpp | 14 ++--- rpcs3/Emu/CPU/CPUTranslator.h | 14 ++--- rpcs3/Emu/Cell/Modules/StaticHLE.cpp | 8 +-- rpcs3/Emu/Cell/Modules/StaticHLE.h | 2 +- rpcs3/Emu/Cell/Modules/cellAdec.cpp | 26 ++++----- rpcs3/Emu/Cell/Modules/cellAudio.cpp | 5 +- rpcs3/Emu/Cell/Modules/cellAudio.h | 2 +- rpcs3/Emu/Cell/Modules/cellAudioOut.h | 2 - rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellCamera.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellFont.cpp | 7 +-- rpcs3/Emu/Cell/Modules/cellFs.cpp | 2 - rpcs3/Emu/Cell/Modules/cellFs.h | 1 - rpcs3/Emu/Cell/Modules/cellGame.cpp | 2 - rpcs3/Emu/Cell/Modules/cellGame.h | 4 +- rpcs3/Emu/Cell/Modules/cellGem.cpp | 6 +- rpcs3/Emu/Cell/Modules/cellGifDec.cpp | 3 + rpcs3/Emu/Cell/Modules/cellHttpUtil.cpp | 1 - rpcs3/Emu/Cell/Modules/cellJpgDec.cpp | 3 + rpcs3/Emu/Cell/Modules/cellL10n.cpp | 20 +++---- rpcs3/Emu/Cell/Modules/cellMic.cpp | 6 +- rpcs3/Emu/Cell/Modules/cellNetCtl.cpp | 5 +- rpcs3/Emu/Cell/Modules/cellOskDialog.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellPamf.cpp | 2 + rpcs3/Emu/Cell/Modules/cellPamf.h | 2 +- rpcs3/Emu/Cell/Modules/cellPngDec.cpp | 4 +- rpcs3/Emu/Cell/Modules/cellPngDec.h | 2 - rpcs3/Emu/Cell/Modules/cellRec.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellRtc.cpp | 4 +- rpcs3/Emu/Cell/Modules/cellSail.cpp | 6 +- rpcs3/Emu/Cell/Modules/cellSearch.cpp | 14 ++--- rpcs3/Emu/Cell/Modules/cellSpurs.h | 2 +- rpcs3/Emu/Cell/Modules/cellSpursJq.cpp | 3 - rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp | 4 -- rpcs3/Emu/Cell/Modules/cellStorage.h | 4 +- rpcs3/Emu/Cell/Modules/cellSubDisplay.cpp | 1 + rpcs3/Emu/Cell/Modules/cellSysCache.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellSysutil.cpp | 1 + rpcs3/Emu/Cell/Modules/cellVdec.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellVpost.cpp | 4 +- rpcs3/Emu/Cell/Modules/libmixer.cpp | 1 - rpcs3/Emu/Cell/Modules/sceNp.cpp | 4 +- rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp | 3 +- rpcs3/Emu/Cell/Modules/sceNpTus.cpp | 15 ++--- rpcs3/Emu/Cell/Modules/sys_libc_.cpp | 6 +- rpcs3/Emu/Cell/Modules/sys_lwcond_.cpp | 9 ++- rpcs3/Emu/Cell/Modules/sys_spu_.cpp | 5 +- rpcs3/Emu/Cell/PPUAnalyser.h | 2 +- rpcs3/Emu/Cell/PPUModule.cpp | 1 + rpcs3/Emu/Cell/PPUTranslator.cpp | 1 + rpcs3/Emu/Cell/RawSPUThread.cpp | 2 +- rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp | 3 +- rpcs3/Emu/Cell/SPUDisAsm.cpp | 2 +- rpcs3/Emu/Cell/SPUDisAsm.h | 3 +- rpcs3/Emu/Cell/SPURecompiler.cpp | 7 +-- rpcs3/Emu/Cell/SPURecompiler.h | 2 +- rpcs3/Emu/Cell/SPUThread.cpp | 8 +-- rpcs3/Emu/Cell/SPUThread.h | 11 ++-- rpcs3/Emu/Cell/lv2/lv2.cpp | 3 +- rpcs3/Emu/Cell/lv2/sys_cond.cpp | 6 +- rpcs3/Emu/Cell/lv2/sys_cond.h | 4 +- rpcs3/Emu/Cell/lv2/sys_config.cpp | 14 ++--- rpcs3/Emu/Cell/lv2/sys_config.h | 12 ++-- rpcs3/Emu/Cell/lv2/sys_event.cpp | 2 +- rpcs3/Emu/Cell/lv2/sys_event_flag.cpp | 2 +- rpcs3/Emu/Cell/lv2/sys_fs.cpp | 5 +- rpcs3/Emu/Cell/lv2/sys_fs.h | 4 +- rpcs3/Emu/Cell/lv2/sys_gamepad.cpp | 11 ---- rpcs3/Emu/Cell/lv2/sys_interrupt.cpp | 4 +- rpcs3/Emu/Cell/lv2/sys_interrupt.h | 4 +- rpcs3/Emu/Cell/lv2/sys_memory.cpp | 4 +- rpcs3/Emu/Cell/lv2/sys_memory.h | 1 - rpcs3/Emu/Cell/lv2/sys_mmapper.cpp | 1 - rpcs3/Emu/Cell/lv2/sys_mmapper.h | 4 +- rpcs3/Emu/Cell/lv2/sys_mutex.cpp | 2 +- rpcs3/Emu/Cell/lv2/sys_net.cpp | 24 ++++---- rpcs3/Emu/Cell/lv2/sys_net.h | 2 +- rpcs3/Emu/Cell/lv2/sys_process.cpp | 1 - rpcs3/Emu/Cell/lv2/sys_prx.cpp | 2 - rpcs3/Emu/Cell/lv2/sys_rsx.h | 2 +- rpcs3/Emu/Cell/lv2/sys_spu.cpp | 5 +- rpcs3/Emu/Cell/lv2/sys_spu.h | 15 ++--- rpcs3/Emu/Cell/lv2/sys_ss.h | 4 +- rpcs3/Emu/Cell/lv2/sys_sync.h | 8 +-- rpcs3/Emu/Cell/lv2/sys_time.cpp | 2 +- rpcs3/Emu/Cell/lv2/sys_usbd.cpp | 1 - rpcs3/Emu/GDB.cpp | 14 ++--- rpcs3/Emu/GDB.h | 8 +-- rpcs3/Emu/Io/KeyboardHandler.h | 4 +- rpcs3/Emu/Io/MouseHandler.h | 3 - rpcs3/Emu/Io/PadHandler.cpp | 2 +- rpcs3/Emu/Io/PadHandler.h | 22 +++---- rpcs3/Emu/Io/interception.h | 1 - rpcs3/Emu/Io/usb_device.h | 2 +- rpcs3/Emu/Memory/vm.cpp | 9 ++- rpcs3/Emu/Memory/vm.h | 8 +-- rpcs3/Emu/Memory/vm_ref.h | 8 +-- rpcs3/Emu/NP/np_handler.cpp | 6 +- rpcs3/Emu/NP/np_handler.h | 3 +- rpcs3/Emu/NP/rpcn_client.cpp | 11 ++-- rpcs3/Emu/NP/rpcn_client.h | 16 ++---- rpcs3/Emu/NP/rpcn_config.cpp | 2 +- rpcs3/Emu/NP/signaling_handler.cpp | 15 +++-- rpcs3/Emu/NP/signaling_handler.h | 19 ++----- rpcs3/Emu/RSX/Capture/rsx_replay.cpp | 3 +- rpcs3/Emu/RSX/Capture/rsx_replay.h | 2 +- rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp | 8 +-- rpcs3/Emu/RSX/CgBinaryProgram.h | 22 +++---- rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp | 8 +-- rpcs3/Emu/RSX/Common/BufferUtils.h | 2 - .../RSX/Common/FragmentProgramDecompiler.cpp | 4 +- .../RSX/Common/FragmentProgramDecompiler.h | 8 +-- rpcs3/Emu/RSX/Common/ProgramStateCache.h | 1 - rpcs3/Emu/RSX/Common/ShaderParam.h | 18 +++--- rpcs3/Emu/RSX/Common/TextGlyphs.h | 1 - rpcs3/Emu/RSX/Common/TextureUtils.cpp | 5 +- .../RSX/Common/VertexProgramDecompiler.cpp | 8 +-- .../Emu/RSX/Common/VertexProgramDecompiler.h | 10 ++-- rpcs3/Emu/RSX/Common/program_state_cache2.hpp | 4 +- rpcs3/Emu/RSX/Common/ring_buffer_helper.h | 2 +- rpcs3/Emu/RSX/Common/surface_store.h | 4 +- rpcs3/Emu/RSX/Common/texture_cache.cpp | 2 +- rpcs3/Emu/RSX/Common/texture_cache.h | 7 ++- rpcs3/Emu/RSX/Common/texture_cache_types.h | 10 ++-- rpcs3/Emu/RSX/Common/texture_cache_utils.h | 11 ++-- rpcs3/Emu/RSX/GSFrameBase.h | 1 - rpcs3/Emu/RSX/GSRender.cpp | 1 + rpcs3/Emu/RSX/GSRender.h | 2 +- rpcs3/Emu/RSX/Overlays/overlay_animation.cpp | 2 - rpcs3/Emu/RSX/Overlays/overlay_animation.h | 2 +- rpcs3/Emu/RSX/Overlays/overlay_controls.h | 2 +- rpcs3/Emu/RSX/Overlays/overlay_fonts.cpp | 2 +- rpcs3/Emu/RSX/Overlays/overlay_fonts.h | 9 ++- rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp | 2 +- rpcs3/Emu/RSX/Overlays/overlay_osk.cpp | 2 +- rpcs3/Emu/RSX/Overlays/overlay_osk.h | 2 +- .../Emu/RSX/Overlays/overlay_perf_metrics.cpp | 2 - .../Emu/RSX/Overlays/overlay_save_dialog.cpp | 6 +- rpcs3/Emu/RSX/Overlays/overlays.cpp | 4 +- rpcs3/Emu/RSX/Overlays/overlays.h | 4 +- rpcs3/Emu/RSX/RSXFIFO.cpp | 4 +- rpcs3/Emu/RSX/RSXFIFO.h | 8 ++- rpcs3/Emu/RSX/RSXOffload.cpp | 12 ++-- rpcs3/Emu/RSX/RSXOffload.h | 14 ++--- rpcs3/Emu/RSX/RSXThread.cpp | 2 +- rpcs3/Emu/RSX/RSXThread.h | 7 +-- rpcs3/Emu/RSX/rsx_cache.h | 9 +-- rpcs3/Emu/RSX/rsx_decode.h | 1 - rpcs3/Emu/RSX/rsx_methods.cpp | 1 + rpcs3/Emu/RSX/rsx_methods.h | 7 +-- rpcs3/Emu/RSX/rsx_utils.cpp | 3 +- rpcs3/Emu/RSX/rsx_utils.h | 10 ++-- rpcs3/Emu/RSX/rsx_vertex_data.h | 4 +- rpcs3/Emu/System.cpp | 8 +-- rpcs3/Emu/System.h | 8 +-- rpcs3/Emu/VFS.cpp | 1 + rpcs3/Emu/perf_meter.cpp | 2 +- rpcs3/Emu/perf_meter.hpp | 5 +- rpcs3/Emu/system_config.cpp | 2 +- rpcs3/Emu/system_config.h | 2 +- rpcs3/Loader/TAR.cpp | 2 - rpcs3/rpcs3_version.h | 1 - rpcs3/util/asm.hpp | 5 +- rpcs3/util/atomic.cpp | 5 +- rpcs3/util/atomic.hpp | 2 +- rpcs3/util/cereal.hpp | 2 +- rpcs3/util/cpu_stats.cpp | 4 +- rpcs3/util/fifo_mutex.hpp | 1 - rpcs3/util/logs.hpp | 1 - rpcs3/util/shared_ptr.hpp | 5 +- rpcs3/util/slow_mutex.hpp | 1 - rpcs3/util/sysinfo.cpp | 2 +- rpcs3/util/vm_native.cpp | 3 +- 211 files changed, 576 insertions(+), 748 deletions(-) diff --git a/Utilities/CRC.h b/Utilities/CRC.h index 9faf9174ef..36333879f7 100644 --- a/Utilities/CRC.h +++ b/Utilities/CRC.h @@ -295,7 +295,7 @@ namespace CRCPP static CRCType Finalize(CRCType remainder, CRCType finalXOR, bool reflectOutput); template - static CRCType UndoFinalize(CRCType remainder, CRCType finalXOR, bool reflectOutput); + static CRCType UndoFinalize(CRCType crc, CRCType finalXOR, bool reflectOutput); template static CRCType CalculateRemainder(const void * data, crcpp_size size, const Parameters & parameters, CRCType remainder); @@ -771,8 +771,6 @@ namespace CRCPP in a function even in a branch will never be executed. This also means we don't need pragmas to get rid of warnings, but it still can be computed at compile-time. Win-win! @param[in] x Compile-time expression to bound - @tparam CRCType Integer type for storing the CRC result - @tparam CRCWidth Number of bits in the CRC @return Non-negative compile-time expression */ template diff --git a/Utilities/Config.h b/Utilities/Config.h index 1cdd2063b2..a9ae3d44d0 100644 --- a/Utilities/Config.h +++ b/Utilities/Config.h @@ -70,10 +70,10 @@ namespace cfg // Get type type get_type() const { return m_type; } - const std::string& get_name() const { return m_name; }; + const std::string& get_name() const { return m_name; } // Get dynamic property for reloading configs during games - bool get_is_dynamic() const { return m_dynamic; }; + bool get_is_dynamic() const { return m_dynamic; } // Reset defaults virtual void from_default() = 0; diff --git a/Utilities/File.cpp b/Utilities/File.cpp index 21ca74c51d..3f58dc112b 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include "util/asm.hpp" @@ -18,11 +17,6 @@ using namespace std::literals::string_literals; #include #include -namespace utils -{ - u64 get_unique_tsc(); -} - static std::unique_ptr to_wchar(const std::string& source) { // String size + null terminator @@ -65,7 +59,7 @@ static void to_utf8(std::string& out, const wchar_t* source) // Resize buffer out.resize(buf_size - 1); - const int result = WideCharToMultiByte(CP_UTF8, 0, source, static_cast(length) + 1, &out.front(), buf_size, NULL, NULL); + const int result = WideCharToMultiByte(CP_UTF8, 0, source, static_cast(length) + 1, &out.front(), buf_size, nullptr, nullptr); // Fix the size out.resize(ensure(result) - 1); @@ -593,7 +587,7 @@ bool fs::create_dir(const std::string& path) } #ifdef _WIN32 - if (!CreateDirectoryW(to_wchar(path).get(), NULL)) + if (!CreateDirectoryW(to_wchar(path).get(), nullptr)) { int res = GetLastError(); @@ -713,7 +707,7 @@ bool fs::rename(const std::string& from, const std::string& to, bool overwrite) } error1 = GetLastError(); - CreateDirectoryW(ws2.get(), NULL); // TODO + CreateDirectoryW(ws2.get(), nullptr); // TODO } else { @@ -882,7 +876,7 @@ bool fs::truncate_file(const std::string& path, u64 length) #ifdef _WIN32 // Open the file - const auto handle = CreateFileW(to_wchar(path).get(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + const auto handle = CreateFileW(to_wchar(path).get(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (handle == INVALID_HANDLE_VALUE) { g_tls_error = to_error(GetLastError()); @@ -921,7 +915,7 @@ bool fs::utime(const std::string& path, s64 atime, s64 mtime) #ifdef _WIN32 // Open the file - const auto handle = CreateFileW(to_wchar(path).get(), FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_ATTRIBUTE_NORMAL, NULL); + const auto handle = CreateFileW(to_wchar(path).get(), FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_ATTRIBUTE_NORMAL, NULL); if (handle == INVALID_HANDLE_VALUE) { g_tls_error = to_error(GetLastError()); @@ -1033,7 +1027,7 @@ fs::file::file(const std::string& path, bs_t mode) share |= FILE_SHARE_WRITE; } - const HANDLE handle = CreateFileW(to_wchar(path).get(), access, share, NULL, disp, FILE_ATTRIBUTE_NORMAL, NULL); + const HANDLE handle = CreateFileW(to_wchar(path).get(), access, share, nullptr, disp, FILE_ATTRIBUTE_NORMAL, NULL); if (handle == INVALID_HANDLE_VALUE) { @@ -1100,7 +1094,7 @@ fs::file::file(const std::string& path, bs_t mode) const int size = narrow(count); DWORD nread; - ensure(ReadFile(m_handle, buffer, size, &nread, NULL)); // "file::read" + ensure(ReadFile(m_handle, buffer, size, &nread, nullptr)); // "file::read" return nread; } @@ -1111,7 +1105,7 @@ fs::file::file(const std::string& path, bs_t mode) const int size = narrow(count); DWORD nwritten; - ensure(WriteFile(m_handle, buffer, size, &nwritten, NULL)); // "file::write" + ensure(WriteFile(m_handle, buffer, size, &nwritten, nullptr)); // "file::write" return nwritten; } @@ -1439,7 +1433,7 @@ bool fs::dir::open(const std::string& path) #ifdef _WIN32 WIN32_FIND_DATAW found; - const auto handle = FindFirstFileExW(to_wchar(path + "/*").get(), FindExInfoBasic, &found, FindExSearchNameMatch, NULL, FIND_FIRST_EX_CASE_SENSITIVE | FIND_FIRST_EX_LARGE_FETCH); + const auto handle = FindFirstFileExW(to_wchar(path + "/*").get(), FindExInfoBasic, &found, FindExSearchNameMatch, nullptr, FIND_FIRST_EX_CASE_SENSITIVE | FIND_FIRST_EX_LARGE_FETCH); if (handle == INVALID_HANDLE_VALUE) { @@ -1594,9 +1588,9 @@ const std::string& fs::get_config_dir() wchar_t buf[32768]; constexpr DWORD size = static_cast(std::size(buf)); if (GetEnvironmentVariable(L"RPCS3_CONFIG_DIR", buf, size) - 1 >= size - 1 && - GetModuleFileName(NULL, buf, size) - 1 >= size - 1) + GetModuleFileName(nullptr, buf, size) - 1 >= size - 1) { - MessageBoxA(0, fmt::format("GetModuleFileName() failed: error %u.", GetLastError()).c_str(), "fs::get_config_dir()", MB_ICONERROR); + MessageBoxA(nullptr, fmt::format("GetModuleFileName() failed: error %u.", GetLastError()).c_str(), "fs::get_config_dir()", MB_ICONERROR); return dir; // empty } diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index 7c2c19c24d..48abef72e1 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -8,7 +8,6 @@ #include "util/vm.hpp" #include "util/asm.hpp" #include -#include #include #ifdef __linux__ @@ -272,10 +271,7 @@ asmjit::Runtime& asmjit::get_global_runtime() #ifdef LLVM_AVAILABLE #include -#include #include -#include -#include #include #ifdef _MSC_VER diff --git a/Utilities/JIT.h b/Utilities/JIT.h index 82f92e206c..53e9c08edd 100644 --- a/Utilities/JIT.h +++ b/Utilities/JIT.h @@ -176,7 +176,6 @@ inline FT build_function_asm(F&& builder) #include #include "util/types.hpp" -#include "mutex.h" #ifdef _MSC_VER #pragma warning(push, 0) diff --git a/Utilities/LUrlParser.cpp b/Utilities/LUrlParser.cpp index ffe345b670..a6be4b5a0f 100644 --- a/Utilities/LUrlParser.cpp +++ b/Utilities/LUrlParser.cpp @@ -29,24 +29,22 @@ #include #include -#include +#include // check if the scheme name is valid static bool IsSchemeValid( const std::string& SchemeName ) { - for ( auto c : SchemeName ) + return std::all_of(SchemeName.cbegin(), SchemeName.cend(), [](const auto& c) { - if ( !isalpha( c ) && c != '+' && c != '-' && c != '.' ) return false; - } - - return true; + return isalpha(c) || c == '+' || c == '-' || c == '.'; + }); } bool LUrlParser::clParseURL::GetPort( int* OutPort ) const { if ( !IsValid() ) { return false; } - int Port = atoi( m_Port.c_str() ); + const int Port = atoi( m_Port.c_str() ); if ( Port <= 0 || Port > 65535 ) { return false; } diff --git a/Utilities/StrUtil.h b/Utilities/StrUtil.h index 9e622d6ae3..561f078757 100644 --- a/Utilities/StrUtil.h +++ b/Utilities/StrUtil.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 79cc8baf48..368bae4d44 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -2,7 +2,6 @@ #include "Emu/System.h" #include "Emu/Cell/SPUThread.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/Cell/RawSPUThread.h" #include "Emu/Cell/lv2/sys_mmapper.h" #include "Emu/Cell/lv2/sys_event.h" #include "Emu/RSX/RSXThread.h" @@ -2760,6 +2759,7 @@ u64 thread_ctrl::get_affinity_mask(thread_class group) // Verified by more than one windows user on 16-thread CPU ppu_mask = spu_mask = rsx_mask = (0b10101010101010101010101010101010 & all_cores_mask); } + break; case 12: // 5600X if (g_cfg.core.thread_scheduler == thread_scheduler_mode::alt) @@ -2772,6 +2772,7 @@ u64 thread_ctrl::get_affinity_mask(thread_class group) { ppu_mask = spu_mask = rsx_mask = all_cores_mask; } + break; default: if (thread_count > 24) { diff --git a/Utilities/Thread.h b/Utilities/Thread.h index b10351d76b..caf9ec1c56 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -5,8 +5,6 @@ #include "util/shared_ptr.hpp" #include -#include -#include #include "mutex.h" #include "lockless.h" diff --git a/Utilities/Timer.h b/Utilities/Timer.h index 58edcda7cb..7d084b2f91 100644 --- a/Utilities/Timer.h +++ b/Utilities/Timer.h @@ -30,31 +30,31 @@ public: double GetElapsedTimeInSec() const { - return double(GetElapsedTimeInMicroSec()) / 1000000.0; + return static_cast(GetElapsedTimeInMicroSec()) / 1000000.0; } double GetElapsedTimeInMilliSec() const { - return double(GetElapsedTimeInMicroSec()) / 1000.0; + return static_cast(GetElapsedTimeInMicroSec()) / 1000.0; } u64 GetElapsedTimeInMicroSec() const { - steady_clock::time_point now = m_stopped ? m_end : steady_clock::now(); + const steady_clock::time_point now = m_stopped ? m_end : steady_clock::now(); return std::chrono::duration_cast(now - m_start).count(); } u64 GetElapsedTimeInNanoSec() const { - steady_clock::time_point now = m_stopped ? m_end : steady_clock::now(); + const steady_clock::time_point now = m_stopped ? m_end : steady_clock::now(); return std::chrono::duration_cast(now - m_start).count(); } - u64 GetMsSince(steady_clock::time_point timestamp) + u64 GetMsSince(steady_clock::time_point timestamp) const { - steady_clock::time_point now = m_stopped ? m_end : steady_clock::now(); + const steady_clock::time_point now = m_stopped ? m_end : steady_clock::now(); return std::chrono::duration_cast(now - timestamp).count(); } diff --git a/Utilities/address_range.h b/Utilities/address_range.h index d0f6410924..e7128c2286 100644 --- a/Utilities/address_range.h +++ b/Utilities/address_range.h @@ -3,6 +3,7 @@ #include "util/types.hpp" #include "StrFmt.h" #include +#include namespace utils @@ -271,10 +272,10 @@ namespace utils class address_range_vector { public: - using vector_type = typename std::vector; - using iterator = typename vector_type::iterator; - using const_iterator = typename vector_type::const_iterator; - using size_type = typename vector_type::size_type; + using vector_type = std::vector; + using iterator = vector_type::iterator; + using const_iterator = vector_type::const_iterator; + using size_type = vector_type::size_type; private: vector_type data; @@ -455,7 +456,7 @@ namespace utils // Will fail if ranges within the vector overlap our touch each-other bool check_consistency() const { - usz _size = data.size(); + const usz _size = data.size(); for (usz i = 0; i < _size; ++i) { @@ -485,20 +486,10 @@ namespace utils // Test for overlap with a given range bool overlaps(const address_range &range) const { - for (const address_range ¤t : data) + return std::any_of(data.cbegin(), data.cend(), [&range](const address_range& cur) { - if (!current.valid()) - { - continue; - } - - if (current.overlaps(range)) - { - return true; - } - } - - return false; + return cur.valid() && cur.overlaps(range); + }); } // Test for overlap with a given address_range vector @@ -530,37 +521,19 @@ namespace utils // Test if a given range is fully contained inside this vector bool contains(const address_range &range) const { - for (const address_range &cur : *this) + return std::any_of(this->begin(), this->end(), [&range](const address_range& cur) { - if (!cur.valid()) - { - continue; - } - - if (range.inside(cur)) - { - return true; - } - } - return false; + return cur.valid() && cur.inside(range); + }); } // Test if all ranges in this vector are full contained inside a specific range bool inside(const address_range &range) const { - for (const address_range &cur : *this) + return std::all_of(this->begin(), this->end(), [&range](const address_range& cur) { - if (!cur.valid()) - { - continue; - } - - if (!cur.inside(range)) - { - return false; - } - } - return true; + return !cur.valid() || cur.inside(range); + }); } }; diff --git a/Utilities/bin_patch.cpp b/Utilities/bin_patch.cpp index 978ab82b2e..a16f72324a 100644 --- a/Utilities/bin_patch.cpp +++ b/Utilities/bin_patch.cpp @@ -650,8 +650,8 @@ std::basic_string patch_engine::apply(const std::string& name, u8* dst, u32 std::basic_string applied_total; const auto& container = m_map.at(name); - const auto serial = Emu.GetTitleID(); - const auto app_version = Emu.GetAppVersion(); + const auto& serial = Emu.GetTitleID(); + const auto& app_version = Emu.GetAppVersion(); // Different containers in order to seperate the patches std::vector patches_for_this_serial_and_this_version; @@ -793,7 +793,7 @@ void patch_engine::save_config(const patch_map& patches_map) } } - if (const auto& enabled_patches = config_map[hash].patch_info_map; enabled_patches.size() > 0) + if (const auto& enabled_patches = config_map[hash].patch_info_map; !enabled_patches.empty()) { out << hash << YAML::BeginMap; diff --git a/Utilities/cfmt.h b/Utilities/cfmt.h index 8bf74fe310..dc74be8fd0 100644 --- a/Utilities/cfmt.h +++ b/Utilities/cfmt.h @@ -610,7 +610,7 @@ usz cfmt_append(Dst& out, const Char* fmt, Src&& src) const u64 arg1 = ctx.args >= 1 ? src.template get(1) : 0; const u64 arg2 = ctx.args >= 2 ? src.template get(2) : 0; - if (const usz _size = std::snprintf(0, 0, _fmt.c_str(), arg0, arg1, arg2)) + if (const usz _size = std::snprintf(nullptr, 0, _fmt.c_str(), arg0, arg1, arg2)) { out.resize(out.size() + _size); std::snprintf(&out.front() + out.size() - _size, _size + 1, _fmt.c_str(), arg0, arg1, arg2); diff --git a/Utilities/cond.cpp b/Utilities/cond.cpp index 3b10d24e60..cb8585f9dd 100644 --- a/Utilities/cond.cpp +++ b/Utilities/cond.cpp @@ -1,8 +1,5 @@ #include "cond.h" #include "sync.h" -#include "lockless.h" - -#include // use constants, increase signal space diff --git a/Utilities/date_time.h b/Utilities/date_time.h index 18d19d82e0..bb7223ccbb 100644 --- a/Utilities/date_time.h +++ b/Utilities/date_time.h @@ -20,7 +20,7 @@ namespace date_time static inline std::string current_time() { char str[80]; - tm now = get_time(0); + tm now = get_time(nullptr); strftime(str, sizeof(str), "%c", &now); return str; } @@ -29,7 +29,7 @@ namespace date_time static inline std::string current_time_narrow() { char str[80]; - tm now = get_time(0); + tm now = get_time(nullptr); std::string parse_buf; diff --git a/Utilities/rXml.cpp b/Utilities/rXml.cpp index 6955d16788..6901945b68 100644 --- a/Utilities/rXml.cpp +++ b/Utilities/rXml.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "Utilities/rXml.h" -rXmlNode::rXmlNode() : handle() +rXmlNode::rXmlNode() { } @@ -55,7 +55,7 @@ std::string rXmlNode::GetNodeContent() return handle.text().get(); } -rXmlDocument::rXmlDocument() : handle() +rXmlDocument::rXmlDocument() { } diff --git a/Utilities/sema.h b/Utilities/sema.h index a67527ea0b..6e067e419f 100644 --- a/Utilities/sema.h +++ b/Utilities/sema.h @@ -1,6 +1,5 @@ #pragma once -#include #include "util/types.hpp" #include "util/atomic.hpp" diff --git a/Utilities/sync.h b/Utilities/sync.h index 96b610ddb2..6e4d87ea38 100644 --- a/Utilities/sync.h +++ b/Utilities/sync.h @@ -3,7 +3,6 @@ /* For internal use. Don't include. */ #include "util/types.hpp" -#include "util/atomic.hpp" #include "util/dyn_lib.hpp" #ifdef _WIN32 @@ -11,7 +10,7 @@ #define NOMINMAX #endif #include -#include +#include #elif __linux__ #include #include @@ -21,7 +20,6 @@ #include #endif #include -#include #include #include #include diff --git a/rpcs3/Crypto/ec.cpp b/rpcs3/Crypto/ec.cpp index 82d8205124..64983cdd59 100644 --- a/rpcs3/Crypto/ec.cpp +++ b/rpcs3/Crypto/ec.cpp @@ -120,7 +120,7 @@ static void bn_mon_muladd_dig(u8* d, u8* a, u8 b, u8* N, u32 n) u32 dig; u32 i; - u8 z = -(d[n - 1] + a[n - 1] * b) * inv256[N[n - 1] / 2]; + const u8 z = -(d[n - 1] + a[n - 1] * b) * inv256[N[n - 1] / 2]; dig = d[n - 1] + a[n - 1] * b + N[n - 1] * z; dig >>= 8; diff --git a/rpcs3/Crypto/key_vault.cpp b/rpcs3/Crypto/key_vault.cpp index 23c9ec2186..ab99514b27 100644 --- a/rpcs3/Crypto/key_vault.cpp +++ b/rpcs3/Crypto/key_vault.cpp @@ -757,7 +757,7 @@ void KeyVault::SetKlicenseeKey(u8* key) memcpy(klicensee_key.get(), key, 0x10); } -u8* KeyVault::GetKlicenseeKey() +u8* KeyVault::GetKlicenseeKey() const { return klicensee_key.get(); } @@ -782,21 +782,21 @@ void rap_to_rif(unsigned char* rap, unsigned char* rif) { for (i = 0; i < 16; ++i) { - int p = RAP_PBOX[i]; + const int p = RAP_PBOX[i]; key[p] ^= RAP_E1[p]; } for (i = 15; i >= 1; --i) { - int p = RAP_PBOX[i]; - int pp = RAP_PBOX[i - 1]; + const int p = RAP_PBOX[i]; + const int pp = RAP_PBOX[i - 1]; key[p] ^= key[pp]; } int o = 0; for (i = 0; i < 16; ++i) { - int p = RAP_PBOX[i]; - unsigned char kc = key[p] - o; - unsigned char ec2 = RAP_E2[p]; + const int p = RAP_PBOX[i]; + const unsigned char kc = key[p] - o; + const unsigned char ec2 = RAP_E2[p]; if (o != 1 || kc != 0xFF) { o = kc < ec2 ? 1 : 0; diff --git a/rpcs3/Crypto/key_vault.h b/rpcs3/Crypto/key_vault.h index e4e2c2afbe..71a3fa6e08 100644 --- a/rpcs3/Crypto/key_vault.h +++ b/rpcs3/Crypto/key_vault.h @@ -196,7 +196,7 @@ public: KeyVault(); SELF_KEY FindSelfKey(u32 type, u16 revision, u64 version); void SetKlicenseeKey(u8* key); - u8* GetKlicenseeKey(); + u8* GetKlicenseeKey() const; private: void LoadSelfLV0Keys(); diff --git a/rpcs3/Crypto/lz.cpp b/rpcs3/Crypto/lz.cpp index 134d7ac75e..d1d98982c3 100644 --- a/rpcs3/Crypto/lz.cpp +++ b/rpcs3/Crypto/lz.cpp @@ -154,7 +154,7 @@ int decompress(unsigned char *out, unsigned char *in, unsigned int size) { // Set up a temporary buffer (sliding window). memset(tmp, 0x80, 0xCA8); - while (1) + while (true) { // Start reading at 0xB68. tmp_sect1 = tmp + offset + 0xB68; diff --git a/rpcs3/Crypto/unedat.cpp b/rpcs3/Crypto/unedat.cpp index 1bd3492194..1cbc953022 100644 --- a/rpcs3/Crypto/unedat.cpp +++ b/rpcs3/Crypto/unedat.cpp @@ -40,7 +40,7 @@ void generate_key(int crypto_mode, int version, unsigned char *key_final, unsign memcpy(key_final, key, 0x10); memcpy(iv_final, iv, 0x10); break; - }; + } } void generate_hash(int hash_mode, int version, unsigned char *hash_final, unsigned char *hash) @@ -662,7 +662,7 @@ bool extract_all_data(const fs::file* input, const fs::file* output, const char* if (memcmp(&NPD.magic, npd_magic, 4)) { edat_log.error("EDAT: %s has invalid NPD header or already decrypted.", input_file_name); - return 1; + return true; } if (verbose) @@ -709,7 +709,7 @@ bool extract_all_data(const fs::file* input, const fs::file* output, const char* if ((EDAT.flags & EDAT_DEBUG_DATA_FLAG) != EDAT_DEBUG_DATA_FLAG) { edat_log.error("EDAT: NPD hash validation failed!"); - return 1; + return true; } } @@ -724,7 +724,7 @@ bool extract_all_data(const fs::file* input, const fs::file* output, const char* if (!key) { edat_log.error("EDAT: A valid RAP file is needed for this EDAT file! (local activation)"); - return 1; + return true; } } else if ((NPD.license & 0x1) == 0x1) // Type 1: Use network activation. @@ -735,7 +735,7 @@ bool extract_all_data(const fs::file* input, const fs::file* output, const char* if (!key) { edat_log.error("EDAT: A valid RAP file is needed for this EDAT file! (network activation)"); - return 1; + return true; } } @@ -759,17 +759,17 @@ bool extract_all_data(const fs::file* input, const fs::file* output, const char* if (check_data(reinterpret_cast(&key), &EDAT, &NPD, input, verbose)) { edat_log.error("EDAT: Data parsing failed!"); - return 1; + return true; } input->seek(0); if (decrypt_data(input, output, &EDAT, &NPD, reinterpret_cast(&key), verbose)) { edat_log.error("EDAT: Data decryption failed!"); - return 1; + return true; } - return 0; + return false; } u128 GetEdatRifKeyFromRapFile(const fs::file& rap_file) @@ -878,7 +878,7 @@ fs::file DecryptEDAT(const fs::file& input, const std::string& input_file_name, // Read the RAP file, if provided. if (!rap_file_name.empty()) { - fs::file rap(rap_file_name); + const fs::file rap(rap_file_name); rifKey = GetEdatRifKeyFromRapFile(rap); } diff --git a/rpcs3/Crypto/unedat.h b/rpcs3/Crypto/unedat.h index d9b903bd8f..2c6a70d63e 100644 --- a/rpcs3/Crypto/unedat.h +++ b/rpcs3/Crypto/unedat.h @@ -103,7 +103,7 @@ public: u64 read(void* buffer, u64 size) override { - u64 bytesRead = ReadData(pos, static_cast(buffer), size); + const u64 bytesRead = ReadData(pos, static_cast(buffer), size); pos += bytesRead; return bytesRead; } diff --git a/rpcs3/Crypto/unpkg.cpp b/rpcs3/Crypto/unpkg.cpp index e1d96a507a..7e1cd31e38 100644 --- a/rpcs3/Crypto/unpkg.cpp +++ b/rpcs3/Crypto/unpkg.cpp @@ -554,7 +554,7 @@ bool package_reader::read_param_sfo() } // TODO: maybe also check if VERSION matches -package_error package_reader::check_target_app_version() +package_error package_reader::check_target_app_version() const { if (!m_is_valid) { diff --git a/rpcs3/Crypto/unpkg.h b/rpcs3/Crypto/unpkg.h index 28eaff4320..8c751b04f4 100644 --- a/rpcs3/Crypto/unpkg.h +++ b/rpcs3/Crypto/unpkg.h @@ -165,7 +165,7 @@ public: make_package_npdrm_ver = to_hex_string(data.make_package_npdrm_ver, sizeof(data.make_package_npdrm_ver)); version = to_hex_string(data.version, sizeof(data.version), 2); } - std::string to_string() + std::string to_string() const { return fmt::format("make package npdrm version: %s, version: %s", make_package_npdrm_ver, version); } @@ -193,7 +193,7 @@ public: version = to_hex_string(data.version, sizeof(data.version), 2); app_version = to_hex_string(data.app_version, sizeof(data.app_version), 2); } - std::string to_string() + std::string to_string() const { return fmt::format("unk: %s, firmware version: %s, version: %s, app version: %s", unk, firmware_version, version, app_version); @@ -211,7 +211,7 @@ public: be_t size{ 0 }; u8 sha256[32]{ 0 }; - std::string to_string() + std::string to_string() const { return fmt::format("offset: 0x%x, size: 0x%x, sha256: 0x%x", offset, size, sha256); } @@ -226,7 +226,7 @@ public: u8 unk_2[8]{ 0 }; u8 param_digest[32]{ 0 }; // SHA256 of param_data. Called ParamDigest: This is sha256 digest of param.sfo. - std::string to_string() + std::string to_string() const { return fmt::format("param_offset: 0x%x, param_size: 0x%x, unk_1: 0x%x, psp2_system_ver: 0x%x, unk_2: 0x%x, param_digest: 0x%x", param_offset, param_size, unk_1, psp2_system_ver, unk_2, param_digest); @@ -240,7 +240,7 @@ public: u8 unk[32]{ 0 }; u8 unknown_data_sha256[32]{ 0 }; - std::string to_string() + std::string to_string() const { return fmt::format("unknown_data_offset: 0x%x, unknown_data_size: 0x%x, unk: 0x%x, unknown_data_sha256: 0x%x", unknown_data_offset, unknown_data_size, unk, unknown_data_sha256); @@ -257,7 +257,7 @@ public: u8 unk_3[8]{ 0 }; u8 entirety_digest[32]{ 0 }; - std::string to_string() + std::string to_string() const { return fmt::format("entirety_data_offset: 0x%x, entirety_data_size: 0x%x, flags: 0x%x, unk_1: 0x%x, unk_2: 0x%x, unk_3: 0x%x, entirety_digest: 0x%x", entirety_data_offset, entirety_data_size, flags, unk_1, unk_2, unk_3, entirety_digest); @@ -270,7 +270,7 @@ public: be_t psf_builder_version{ 0 }; u8 padding[32]{ 0 }; - std::string to_string() + std::string to_string() const { return fmt::format("publishing_tools_version: 0x%x, psf_builder_version: 0x%x, padding: 0x%x", publishing_tools_version, psf_builder_version, padding); @@ -284,7 +284,7 @@ public: u8 unk[16]{ 0 }; u8 self_sha256[32]{ 0 }; - std::string to_string() + std::string to_string() const { return fmt::format("self_info_offset: 0x%x, self_info_size: 0x%x, unk: 0x%x, self_sha256: 0x%x", self_info_offset, self_info_size, unk, self_sha256); @@ -306,7 +306,7 @@ public: ~package_reader(); bool is_valid() const { return m_is_valid; } - package_error check_target_app_version(); + package_error check_target_app_version() const; bool extract_data(atomic_t& sync); psf::registry get_psf() const { return m_psf; } diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index 19ecdaf56d..647e49dd93 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -200,7 +200,7 @@ void AppInfo::Load(const fs::file& f) padding = Read64(f); } -void AppInfo::Show() +void AppInfo::Show() const { self_log.notice("AuthID: 0x%llx", authid); self_log.notice("VendorID: 0x%08x", vendor_id); @@ -218,7 +218,7 @@ void SectionInfo::Load(const fs::file& f) encrypted = Read32(f); } -void SectionInfo::Show() +void SectionInfo::Show() const { self_log.notice("Offset: 0x%llx", offset); self_log.notice("Size: 0x%llx", size); @@ -236,7 +236,7 @@ void SCEVersionInfo::Load(const fs::file& f) unknown = Read32(f); } -void SCEVersionInfo::Show() +void SCEVersionInfo::Show() const { self_log.notice("Sub-header type: 0x%08x", subheader_type); self_log.notice("Present: 0x%08x", present); @@ -290,7 +290,7 @@ void ControlInfo::Load(const fs::file& f) } } -void ControlInfo::Show() +void ControlInfo::Show() const { self_log.notice("Type: 0x%08x", type); self_log.notice("Size: 0x%08x", size); @@ -369,7 +369,7 @@ void MetadataInfo::Load(u8* in) memcpy(iv_pad, in + 0x30, 0x10); } -void MetadataInfo::Show() +void MetadataInfo::Show() const { std::string key_str; std::string key_pad_str; @@ -409,7 +409,7 @@ void MetadataHeader::Load(u8* in) unknown3 = swap32(unknown3); } -void MetadataHeader::Show() +void MetadataHeader::Show() const { self_log.notice("Signature input length: 0x%llx", signature_input_length); self_log.notice("Unknown1: 0x%08x", unknown1); @@ -446,7 +446,7 @@ void MetadataSectionHeader::Load(u8* in) compressed = swap32(compressed); } -void MetadataSectionHeader::Show() +void MetadataSectionHeader::Show() const { self_log.notice("Data offset: 0x%llx", data_offset); self_log.notice("Data size: 0x%llx", data_size); @@ -1395,7 +1395,7 @@ static bool CheckDebugSelf(fs::file& s) // Copy the data. char buf[2048]; - while (u64 size = s.read(buf, 2048)) + while (const u64 size = s.read(buf, 2048)) { e.write(buf, size); } @@ -1426,7 +1426,7 @@ fs::file decrypt_self(fs::file elf_or_self, u8* klic_key, SelfAdditionalInfo* ou if (elf_or_self.size() >= 4 && elf_or_self.read() == "SCE\0"_u32 && !CheckDebugSelf(elf_or_self)) { // Check the ELF file class (32 or 64 bit). - bool isElf32 = IsSelfElf32(elf_or_self); + const bool isElf32 = IsSelfElf32(elf_or_self); // Start the decrypter on this SELF file. SELFDecrypter self_dec(elf_or_self); @@ -1469,7 +1469,7 @@ bool verify_npdrm_self_headers(const fs::file& self, u8* klic_key) if (self.size() >= 4 && self.read() == "SCE\0"_u32) { // Check the ELF file class (32 or 64 bit). - bool isElf32 = IsSelfElf32(self); + const bool isElf32 = IsSelfElf32(self); // Start the decrypter on this SELF file. SELFDecrypter self_dec(self); diff --git a/rpcs3/Crypto/unself.h b/rpcs3/Crypto/unself.h index 6cac321ca2..e3977c1ef7 100644 --- a/rpcs3/Crypto/unself.h +++ b/rpcs3/Crypto/unself.h @@ -18,7 +18,7 @@ struct AppInfo u64 padding; void Load(const fs::file& f); - void Show(); + void Show() const; }; struct SectionInfo @@ -31,7 +31,7 @@ struct SectionInfo u32 encrypted; void Load(const fs::file& f); - void Show(); + void Show() const; }; struct SCEVersionInfo @@ -42,7 +42,7 @@ struct SCEVersionInfo u32 unknown; void Load(const fs::file& f); - void Show(); + void Show() const; }; struct ControlInfo @@ -102,7 +102,7 @@ struct ControlInfo }; void Load(const fs::file& f); - void Show(); + void Show() const; }; @@ -114,7 +114,7 @@ struct MetadataInfo u8 iv_pad[0x10]; void Load(u8* in); - void Show(); + void Show() const; }; struct MetadataHeader @@ -128,7 +128,7 @@ struct MetadataHeader u32 unknown3; void Load(u8* in); - void Show(); + void Show() const; }; struct MetadataSectionHeader @@ -145,7 +145,7 @@ struct MetadataSectionHeader u32 compressed; void Load(u8* in); - void Show(); + void Show() const; }; struct SectionHash @@ -213,7 +213,7 @@ struct Elf32_Ehdr u16 e_shstrndx; void Load(const fs::file& f); - void Show() {} + static void Show() {} bool IsLittleEndian() const { return e_data == 1; } bool CheckMagic() const { return e_magic == 0x7F454C46; } u32 GetEntry() const { return e_entry; } @@ -234,7 +234,7 @@ struct Elf32_Shdr void Load(const fs::file& f); void LoadLE(const fs::file& f); - void Show() {} + static void Show() {} }; struct Elf32_Phdr @@ -250,7 +250,7 @@ struct Elf32_Phdr void Load(const fs::file& f); void LoadLE(const fs::file& f); - void Show() {} + static void Show() {} }; struct Elf64_Ehdr @@ -276,7 +276,7 @@ struct Elf64_Ehdr u16 e_shstrndx; void Load(const fs::file& f); - void Show() {} + static void Show() {} bool CheckMagic() const { return e_magic == 0x7F454C46; } u64 GetEntry() const { return e_entry; } }; @@ -295,7 +295,7 @@ struct Elf64_Shdr u64 sh_entsize; void Load(const fs::file& f); - void Show(){} + static void Show(){} }; struct Elf64_Phdr @@ -310,7 +310,7 @@ struct Elf64_Phdr u64 p_align; void Load(const fs::file& f); - void Show(){} + static void Show(){} }; struct SceHeader @@ -324,7 +324,7 @@ struct SceHeader u64 se_esize; void Load(const fs::file& f); - void Show(){} + static void Show(){} bool CheckMagic() const { return se_magic == 0x53434500; } }; @@ -342,7 +342,7 @@ struct SelfHeader u64 pad; void Load(const fs::file& f); - void Show(){} + static void Show(){} }; struct SelfAdditionalInfo @@ -427,7 +427,7 @@ public: bool LoadMetadata(u8* klic_key); bool DecryptData(); bool DecryptNPDRM(u8 *metadata, u32 metadata_size); - bool GetKeyFromRap(u8 *content_id, u8 *npdrm_key); + static bool GetKeyFromRap(u8 *content_id, u8 *npdrm_key); private: template @@ -466,7 +466,7 @@ private: // Use zlib uncompress on the new buffer. // decomp_buf_length changes inside the call to uncompress - int rv = uncompress(decomp_buf.get(), &decomp_buf_length, zlib_buf.get() + data_buf_offset, data_buf_length); + const int rv = uncompress(decomp_buf.get(), &decomp_buf_length, zlib_buf.get() + data_buf_offset, data_buf_length); // Check for errors (TODO: Probably safe to remove this once these changes have passed testing.) switch (rv) diff --git a/rpcs3/Crypto/utils.cpp b/rpcs3/Crypto/utils.cpp index 7b71c44d78..c2a23f4b57 100644 --- a/rpcs3/Crypto/utils.cpp +++ b/rpcs3/Crypto/utils.cpp @@ -45,7 +45,7 @@ u64 hex_to_u64(const char* hex_str) void hex_to_bytes(unsigned char* data, const char* hex_str, unsigned int str_length) { - auto strn_length = (str_length > 0) ? str_length : std::strlen(hex_str); + const auto strn_length = (str_length > 0) ? str_length : std::strlen(hex_str); auto data_length = strn_length / 2; char tmp_buf[3] = {0, 0, 0}; @@ -93,7 +93,7 @@ void aesecb128_encrypt(unsigned char *key, unsigned char *in, unsigned char *out bool hmac_hash_compare(unsigned char *key, int key_len, unsigned char *in, int in_len, unsigned char *hash, int hash_len) { - std::unique_ptr out(new u8[key_len]); + const std::unique_ptr out(new u8[key_len]); sha1_hmac(key, key_len, in, in_len, out.get()); @@ -107,7 +107,7 @@ void hmac_hash_forge(unsigned char *key, int key_len, unsigned char *in, int in_ bool cmac_hash_compare(unsigned char *key, int key_len, unsigned char *in, int in_len, unsigned char *hash, int hash_len) { - std::unique_ptr out(new u8[key_len]); + const std::unique_ptr out(new u8[key_len]); aes_context ctx; aes_setkey_enc(&ctx, key, 128); @@ -127,7 +127,7 @@ char* extract_file_name(const char* file_path, char real_file_name[CRYPTO_MAX_PA { std::string_view v(file_path); - if (auto pos = v.find_last_of(fs::delim); pos != umax) + if (const auto pos = v.find_last_of(fs::delim); pos != umax) { v.remove_prefix(pos + 1); } diff --git a/rpcs3/Emu/Audio/AL/OpenALBackend.h b/rpcs3/Emu/Audio/AL/OpenALBackend.h index 92ad84c771..ef077f729a 100644 --- a/rpcs3/Emu/Audio/AL/OpenALBackend.h +++ b/rpcs3/Emu/Audio/AL/OpenALBackend.h @@ -2,7 +2,6 @@ #include "Emu/Audio/AudioBackend.h" #include "3rdparty/OpenAL/include/alext.h" -#include class OpenALBackend : public AudioBackend { @@ -19,23 +18,23 @@ private: public: OpenALBackend(); - virtual ~OpenALBackend() override; + ~OpenALBackend() override; - virtual const char* GetName() const override { return "OpenAL"; } + const char* GetName() const override { return "OpenAL"; } static const u32 capabilities = PLAY_PAUSE_FLUSH | IS_PLAYING | GET_NUM_ENQUEUED_SAMPLES | SET_FREQUENCY_RATIO; - virtual u32 GetCapabilities() const override { return capabilities; } + u32 GetCapabilities() const override { return capabilities; } - virtual void Open(u32 num_buffers) override; - virtual void Close() override; + void Open(u32 num_buffers) override; + void Close() override; - virtual void Play() override; - virtual void Pause() override; - virtual bool IsPlaying() override; + void Play() override; + void Pause() override; + bool IsPlaying() override; - virtual bool AddData(const void* src, u32 size) override; - virtual void Flush() override; + bool AddData(const void* src, u32 num_samples) override; + void Flush() override; - virtual u64 GetNumEnqueuedSamples() override; - virtual f32 SetFrequencyRatio(f32 new_ratio) override; -}; \ No newline at end of file + u64 GetNumEnqueuedSamples() override; + f32 SetFrequencyRatio(f32 new_ratio) override; +}; diff --git a/rpcs3/Emu/Audio/AudioBackend.cpp b/rpcs3/Emu/Audio/AudioBackend.cpp index 13aea6dea7..65add4fb22 100644 --- a/rpcs3/Emu/Audio/AudioBackend.cpp +++ b/rpcs3/Emu/Audio/AudioBackend.cpp @@ -73,7 +73,7 @@ bool AudioBackend::has_capability(u32 cap) const void AudioBackend::dump_capabilities(std::string& out) const { u32 count = 0; - u32 capabilities = GetCapabilities(); + const u32 capabilities = GetCapabilities(); if (capabilities & PLAY_PAUSE_FLUSH) { diff --git a/rpcs3/Emu/Audio/AudioDumper.cpp b/rpcs3/Emu/Audio/AudioDumper.cpp index 909892593f..8082bff347 100644 --- a/rpcs3/Emu/Audio/AudioDumper.cpp +++ b/rpcs3/Emu/Audio/AudioDumper.cpp @@ -13,7 +13,7 @@ AudioDumper::AudioDumper(u16 ch) if (const std::string id = Emu.GetTitleID(); !id.empty()) { path += id + "_"; - }; + } path += date_time::current_time_narrow<'_'>() + ".wav"; m_output.open(path, fs::rewrite); m_output.write(m_header); // write initial file header diff --git a/rpcs3/Emu/Audio/FAudio/FAudioBackend.cpp b/rpcs3/Emu/Audio/FAudio/FAudioBackend.cpp index df37dc34d7..bb823b47e8 100644 --- a/rpcs3/Emu/Audio/FAudio/FAudioBackend.cpp +++ b/rpcs3/Emu/Audio/FAudio/FAudioBackend.cpp @@ -12,9 +12,7 @@ LOG_CHANNEL(FAudio_, "FAudio"); FAudioBackend::FAudioBackend() : AudioBackend() { - u32 res; - - res = FAudioCreate(&m_instance, 0, FAUDIO_DEFAULT_PROCESSOR); + u32 res = FAudioCreate(&m_instance, 0, FAUDIO_DEFAULT_PROCESSOR); if (res) { FAudio_.fatal("FAudioCreate() failed(0x%08x)", res); @@ -53,7 +51,7 @@ void FAudioBackend::Play() { AUDIT(m_source_voice != nullptr); - u32 res = FAudioSourceVoice_Start(m_source_voice, 0, FAUDIO_COMMIT_NOW); + const u32 res = FAudioSourceVoice_Start(m_source_voice, 0, FAUDIO_COMMIT_NOW); if (res) { FAudio_.error("FAudioSourceVoice_Start() failed(0x%08x)", res); @@ -65,7 +63,7 @@ void FAudioBackend::Pause() { AUDIT(m_source_voice != nullptr); - u32 res = FAudioSourceVoice_Stop(m_source_voice, 0, FAUDIO_COMMIT_NOW); + const u32 res = FAudioSourceVoice_Stop(m_source_voice, 0, FAUDIO_COMMIT_NOW); if (res) { FAudio_.error("FAudioSourceVoice_Stop() failed(0x%08x)", res); @@ -77,7 +75,7 @@ void FAudioBackend::Flush() { AUDIT(m_source_voice != nullptr); - u32 res = FAudioSourceVoice_FlushSourceBuffers(m_source_voice); + const u32 res = FAudioSourceVoice_FlushSourceBuffers(m_source_voice); if (res) { FAudio_.error("FAudioSourceVoice_FlushSourceBuffers() failed(0x%08x)", res); @@ -112,7 +110,7 @@ void FAudioBackend::Open(u32 /* num_buffers */) waveformatex.wBitsPerSample = m_sample_size * 8; waveformatex.cbSize = 0; - u32 res = FAudio_CreateSourceVoice(m_instance, &m_source_voice, &waveformatex, 0, FAUDIO_DEFAULT_FREQ_RATIO, nullptr, nullptr, nullptr); + const u32 res = FAudio_CreateSourceVoice(m_instance, &m_source_voice, &waveformatex, 0, FAUDIO_DEFAULT_FREQ_RATIO, nullptr, nullptr, nullptr); if (res) { FAudio_.error("FAudio_CreateSourceVoice() failed(0x%08x)", res); @@ -143,11 +141,11 @@ bool FAudioBackend::AddData(const void* src, u32 num_samples) buffer.LoopCount = 0; buffer.LoopLength = 0; buffer.pAudioData = static_cast(src); - buffer.pContext = 0; + buffer.pContext = nullptr; buffer.PlayBegin = 0; buffer.PlayLength = AUDIO_BUFFER_SAMPLES; - u32 res = FAudioSourceVoice_SubmitSourceBuffer(m_source_voice, &buffer, nullptr); + const u32 res = FAudioSourceVoice_SubmitSourceBuffer(m_source_voice, &buffer, nullptr); if (res) { FAudio_.error("FAudioSourceVoice_SubmitSourceBuffer() failed(0x%08x)", res); @@ -171,7 +169,7 @@ f32 FAudioBackend::SetFrequencyRatio(f32 new_ratio) { new_ratio = std::clamp(new_ratio, FAUDIO_MIN_FREQ_RATIO, FAUDIO_DEFAULT_FREQ_RATIO); - u32 res = FAudioSourceVoice_SetFrequencyRatio(m_source_voice, new_ratio, FAUDIO_COMMIT_NOW); + const u32 res = FAudioSourceVoice_SetFrequencyRatio(m_source_voice, new_ratio, FAUDIO_COMMIT_NOW); if (res) { FAudio_.error("FAudioSourceVoice_SetFrequencyRatio() failed(0x%08x)", res); diff --git a/rpcs3/Emu/Audio/FAudio/FAudioBackend.h b/rpcs3/Emu/Audio/FAudio/FAudioBackend.h index 4617559719..81116bb9d7 100644 --- a/rpcs3/Emu/Audio/FAudio/FAudioBackend.h +++ b/rpcs3/Emu/Audio/FAudio/FAudioBackend.h @@ -16,32 +16,32 @@ private: public: FAudioBackend(); - virtual ~FAudioBackend() override; + ~FAudioBackend() override; FAudioBackend(const FAudioBackend&) = delete; FAudioBackend& operator=(const FAudioBackend&) = delete; - virtual const char* GetName() const override + const char* GetName() const override { return "FAudio"; - }; + } static const u32 capabilities = PLAY_PAUSE_FLUSH | IS_PLAYING | GET_NUM_ENQUEUED_SAMPLES | SET_FREQUENCY_RATIO; - virtual u32 GetCapabilities() const override + u32 GetCapabilities() const override { return capabilities; - }; + } - virtual void Open(u32 /* num_buffers */) override; - virtual void Close() override; + void Open(u32 /* num_buffers */) override; + void Close() override; - virtual void Play() override; - virtual void Pause() override; - virtual bool IsPlaying() override; + void Play() override; + void Pause() override; + bool IsPlaying() override; - virtual bool AddData(const void* src, u32 num_samples) override; - virtual void Flush() override; + bool AddData(const void* src, u32 num_samples) override; + void Flush() override; - virtual u64 GetNumEnqueuedSamples() override; - virtual f32 SetFrequencyRatio(f32 new_ratio) override; + u64 GetNumEnqueuedSamples() override; + f32 SetFrequencyRatio(f32 new_ratio) override; }; diff --git a/rpcs3/Emu/Audio/XAudio2/XAudio2Backend.cpp b/rpcs3/Emu/Audio/XAudio2/XAudio2Backend.cpp index f39b3eac3b..f9562b0f1f 100644 --- a/rpcs3/Emu/Audio/XAudio2/XAudio2Backend.cpp +++ b/rpcs3/Emu/Audio/XAudio2/XAudio2Backend.cpp @@ -4,9 +4,7 @@ #include #include "util/logs.hpp" -#include "Utilities/StrFmt.h" #include "Emu/System.h" -#include "Emu/system_config.h" #include "XAudio2Backend.h" #include @@ -23,7 +21,7 @@ XAudio2Backend::XAudio2Backend() // In order to prevent errors on CreateMasteringVoice, apparently we need CoInitializeEx according to: // https://docs.microsoft.com/en-us/windows/win32/api/xaudio2fx/nf-xaudio2fx-xaudio2createvolumemeter - CoInitializeEx(NULL, COINIT_MULTITHREADED); + CoInitializeEx(nullptr, COINIT_MULTITHREADED); HRESULT hr = XAudio2Create(instance.GetAddressOf(), 0, XAUDIO2_DEFAULT_PROCESSOR); if (FAILED(hr)) @@ -66,7 +64,7 @@ void XAudio2Backend::Play() { AUDIT(m_source_voice != nullptr); - HRESULT hr = m_source_voice->Start(); + const HRESULT hr = m_source_voice->Start(); if (FAILED(hr)) { XAudio.error("Start() failed: %s (0x%08x)", std::system_category().message(hr), static_cast(hr)); @@ -84,7 +82,7 @@ void XAudio2Backend::Pause() { AUDIT(m_source_voice != nullptr); - HRESULT hr = m_source_voice->Stop(); + const HRESULT hr = m_source_voice->Stop(); if (FAILED(hr)) { XAudio.error("Stop() failed: %s (0x%08x)", std::system_category().message(hr), static_cast(hr)); @@ -94,8 +92,6 @@ void XAudio2Backend::Pause() void XAudio2Backend::Open(u32 /* num_buffers */) { - HRESULT hr; - WAVEFORMATEX waveformatex; waveformatex.wFormatTag = m_convert_to_u16 ? WAVE_FORMAT_PCM : WAVE_FORMAT_IEEE_FLOAT; waveformatex.nChannels = m_channels; @@ -105,7 +101,7 @@ void XAudio2Backend::Open(u32 /* num_buffers */) waveformatex.wBitsPerSample = m_sample_size * 8; waveformatex.cbSize = 0; - hr = m_xaudio2_instance->CreateSourceVoice(&m_source_voice, &waveformatex, 0, XAUDIO2_DEFAULT_FREQ_RATIO); + const HRESULT hr = m_xaudio2_instance->CreateSourceVoice(&m_source_voice, &waveformatex, 0, XAUDIO2_DEFAULT_FREQ_RATIO); if (FAILED(hr)) { XAudio.error("CreateSourceVoice() failed: %s (0x%08x)", std::system_category().message(hr), static_cast(hr)); @@ -152,7 +148,7 @@ bool XAudio2Backend::AddData(const void* src, u32 num_samples) buffer.PlayBegin = 0; buffer.PlayLength = AUDIO_BUFFER_SAMPLES; - HRESULT hr = m_source_voice->SubmitSourceBuffer(&buffer); + const HRESULT hr = m_source_voice->SubmitSourceBuffer(&buffer); if (FAILED(hr)) { XAudio.error("AddData() failed: %s (0x%08x)", std::system_category().message(hr), static_cast(hr)); @@ -167,7 +163,7 @@ void XAudio2Backend::Flush() { AUDIT(m_source_voice != nullptr); - HRESULT hr = m_source_voice->FlushSourceBuffers(); + const HRESULT hr = m_source_voice->FlushSourceBuffers(); if (FAILED(hr)) { XAudio.error("FlushSourceBuffers() failed: %s (0x%08x)", std::system_category().message(hr), static_cast(hr)); @@ -190,7 +186,7 @@ f32 XAudio2Backend::SetFrequencyRatio(f32 new_ratio) { new_ratio = std::clamp(new_ratio, XAUDIO2_MIN_FREQ_RATIO, XAUDIO2_DEFAULT_FREQ_RATIO); - HRESULT hr = m_source_voice->SetFrequencyRatio(new_ratio); + const HRESULT hr = m_source_voice->SetFrequencyRatio(new_ratio); if (FAILED(hr)) { XAudio.error("SetFrequencyRatio() failed: %s (0x%08x)", std::system_category().message(hr), static_cast(hr)); diff --git a/rpcs3/Emu/Audio/XAudio2/XAudio2Backend.h b/rpcs3/Emu/Audio/XAudio2/XAudio2Backend.h index 8481c10ffb..4c74d520f8 100644 --- a/rpcs3/Emu/Audio/XAudio2/XAudio2Backend.h +++ b/rpcs3/Emu/Audio/XAudio2/XAudio2Backend.h @@ -19,28 +19,28 @@ private: public: XAudio2Backend(); - virtual ~XAudio2Backend() override; + ~XAudio2Backend() override; XAudio2Backend(const XAudio2Backend&) = delete; XAudio2Backend& operator=(const XAudio2Backend&) = delete; - virtual const char* GetName() const override { return "XAudio2"; }; + const char* GetName() const override { return "XAudio2"; } static const u32 capabilities = PLAY_PAUSE_FLUSH | IS_PLAYING | GET_NUM_ENQUEUED_SAMPLES | SET_FREQUENCY_RATIO; - virtual u32 GetCapabilities() const override { return capabilities; }; + u32 GetCapabilities() const override { return capabilities; } - virtual bool Initialized() const override { return m_xaudio2_instance != nullptr; } + bool Initialized() const override { return m_xaudio2_instance != nullptr; } - virtual void Open(u32 /* num_buffers */) override; - virtual void Close() override; + void Open(u32 /* num_buffers */) override; + void Close() override; - virtual void Play() override; - virtual void Pause() override; - virtual bool IsPlaying() override; + void Play() override; + void Pause() override; + bool IsPlaying() override; - virtual bool AddData(const void* src, u32 num_samples) override; - virtual void Flush() override; + bool AddData(const void* src, u32 num_samples) override; + void Flush() override; - virtual u64 GetNumEnqueuedSamples() override; - virtual f32 SetFrequencyRatio(f32 new_ratio) override; + u64 GetNumEnqueuedSamples() override; + f32 SetFrequencyRatio(f32 new_ratio) override; }; diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index 4f8eb19409..bef6eda407 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -17,7 +17,6 @@ #include #include -#include #include DECLARE(cpu_thread::g_threads_created){0}; @@ -875,14 +874,13 @@ std::string cpu_thread::get_name() const { return thread_ctrl::get_name(*static_cast*>(this)); } - else if (id_type() == 2) + + if (id_type() == 2) { return thread_ctrl::get_name(*static_cast*>(this)); } - else - { - fmt::throw_exception("Invalid cpu_thread type"); - } + + fmt::throw_exception("Invalid cpu_thread type"); } u32 cpu_thread::get_pc() const @@ -1181,7 +1179,7 @@ void cpu_thread::flush_profilers() noexcept return; } - if (g_cfg.core.spu_prof || false) + if (g_cfg.core.spu_prof) { g_fxo->get().registered.push(0); } diff --git a/rpcs3/Emu/CPU/CPUThread.h b/rpcs3/Emu/CPU/CPUThread.h index 02fcd7b192..f85b9c13dc 100644 --- a/rpcs3/Emu/CPU/CPUThread.h +++ b/rpcs3/Emu/CPU/CPUThread.h @@ -147,7 +147,7 @@ public: virtual void cpu_return() {} // Callback for thread_ctrl::wait or RSX wait - virtual void cpu_wait(bs_t flags); + virtual void cpu_wait(bs_t old); // Callback for function abortion stats on Emu.Stop() virtual void cpu_on_stop() {} @@ -175,9 +175,6 @@ public: // Internal method bool push(cpu_thread* _this) noexcept; - - // Called after suspend_post - void post() noexcept; }; // Suspend all threads and execute op (may be executed by other thread than caller!) diff --git a/rpcs3/Emu/CPU/CPUTranslator.cpp b/rpcs3/Emu/CPU/CPUTranslator.cpp index 5d49f3af61..6b1ca7817c 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.cpp +++ b/rpcs3/Emu/CPU/CPUTranslator.cpp @@ -71,7 +71,7 @@ void cpu_translator::initialize(llvm::LLVMContext& context, llvm::ExecutionEngin } } -llvm::Value* cpu_translator::bitcast(llvm::Value* val, llvm::Type* type) +llvm::Value* cpu_translator::bitcast(llvm::Value* val, llvm::Type* type) const { uint s1 = type->getScalarSizeInBits(); uint s2 = val->getType()->getScalarSizeInBits(); @@ -110,7 +110,7 @@ std::pair cpu_translator::get_const_vector(llvm::Value* c, u32 { if (const auto ci = llvm::dyn_cast(c); ci && ci->getBitWidth() == 128) { - auto cv = ci->getValue(); + const auto& cv = ci->getValue(); result._u64[0] = cv.extractBitsAsZExtValue(64, 0); result._u64[1] = cv.extractBitsAsZExtValue(64, 64); @@ -213,23 +213,23 @@ llvm::Constant* cpu_translator::make_const_vector(v128 v, llvm::Type* t) { return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef(reinterpret_cast(v._bytes), 16)); } - else if (sct->isIntegerTy(16)) + if (sct->isIntegerTy(16)) { return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef(reinterpret_cast(v._bytes), 8)); } - else if (sct->isIntegerTy(32)) + if (sct->isIntegerTy(32)) { return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef(reinterpret_cast(v._bytes), 4)); } - else if (sct->isIntegerTy(64)) + if (sct->isIntegerTy(64)) { return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef(reinterpret_cast(v._bytes), 2)); } - else if (sct->isFloatTy()) + if (sct->isFloatTy()) { return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef(reinterpret_cast(v._bytes), 4)); } - else if (sct->isDoubleTy()) + if (sct->isDoubleTy()) { return llvm::ConstantDataVector::get(m_context, llvm::makeArrayRef(reinterpret_cast(v._bytes), 2)); } diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index fe6c24c6b5..5ebb38569c 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -29,16 +29,8 @@ #include "util/types.hpp" #include "Utilities/StrFmt.h" #include "Utilities/BitField.h" -#include "util/logs.hpp" #include "Utilities/JIT.h" -#include -#include -#include -#include -#include -#include - #include "util/v128.hpp" enum class i2 : char @@ -846,6 +838,8 @@ struct llvm_neg { return ir->CreateFNeg(v1); } + + // TODO: return value ? } llvm_match_tuple match(llvm::Value*& value) const @@ -2432,7 +2426,7 @@ protected: bool m_use_avx512_icl = false; // IR builder - llvm::IRBuilder<>* m_ir; + llvm::IRBuilder<>* m_ir = nullptr; void initialize(llvm::LLVMContext& context, llvm::ExecutionEngine& engine); @@ -2500,7 +2494,7 @@ public: } // Bitcast with immediate constant folding - llvm::Value* bitcast(llvm::Value* val, llvm::Type* type); + llvm::Value* bitcast(llvm::Value* val, llvm::Type* type) const; template llvm::Value* bitcast(llvm::Value* val) diff --git a/rpcs3/Emu/Cell/Modules/StaticHLE.cpp b/rpcs3/Emu/Cell/Modules/StaticHLE.cpp index 0c7534898e..ed3f00dcda 100644 --- a/rpcs3/Emu/Cell/Modules/StaticHLE.cpp +++ b/rpcs3/Emu/Cell/Modules/StaticHLE.cpp @@ -63,7 +63,6 @@ bool statichle_handler::load_patterns() auto char_to_u8 = [&](u8 char1, u8 char2) -> u16 { - u8 hv, lv; if (char1 == '.' && char2 == '.') return 0xFFFF; @@ -73,8 +72,8 @@ bool statichle_handler::load_patterns() return -1; } - hv = char1 > '9' ? char1 - 'A' + 10 : char1 - '0'; - lv = char2 > '9' ? char2 - 'A' + 10 : char2 - '0'; + const u8 hv = char1 > '9' ? char1 - 'A' + 10 : char1 - '0'; + const u8 lv = char2 > '9' ? char2 - 'A' + 10 : char2 - '0'; return (hv << 4) | lv; }; @@ -101,7 +100,6 @@ bool statichle_handler::load_patterns() u16 statichle_handler::gen_CRC16(const u8* data_p, usz length) { - unsigned char i; unsigned int data; if (length == 0) @@ -110,7 +108,7 @@ u16 statichle_handler::gen_CRC16(const u8* data_p, usz length) do { data = *data_p++; - for (i = 0; i < 8; i++) + for (unsigned char i = 0; i < 8; i++) { if ((crc ^ data) & 1) crc = (crc >> 1) ^ POLY; diff --git a/rpcs3/Emu/Cell/Modules/StaticHLE.h b/rpcs3/Emu/Cell/Modules/StaticHLE.h index b55bcc6102..f2ddd8a961 100644 --- a/rpcs3/Emu/Cell/Modules/StaticHLE.h +++ b/rpcs3/Emu/Cell/Modules/StaticHLE.h @@ -29,7 +29,7 @@ public: bool check_against_patterns(vm::cptr& data, u32 size, u32 addr); protected: - u16 gen_CRC16(const u8* data_p, usz length); + static u16 gen_CRC16(const u8* data_p, usz length); std::vector hle_patterns; }; diff --git a/rpcs3/Emu/Cell/Modules/cellAdec.cpp b/rpcs3/Emu/Cell/Modules/cellAdec.cpp index 75ce35ea37..ad05765e71 100644 --- a/rpcs3/Emu/Cell/Modules/cellAdec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAdec.cpp @@ -30,7 +30,6 @@ extern "C" #include "cellAdec.h" #include -#include extern std::mutex g_mutex_avcodec_open2; @@ -356,7 +355,7 @@ public: fmt::throw_exception("avformat_alloc_context() failed"); } io_buf = static_cast(av_malloc(4096)); - fmt->pb = avio_alloc_context(io_buf, 256, 0, this, adecRead, NULL, NULL); + fmt->pb = avio_alloc_context(io_buf, 256, 0, this, adecRead, nullptr, nullptr); if (!fmt->pb) { fmt::throw_exception("avio_alloc_context() failed"); @@ -466,7 +465,7 @@ public: } else { - data = NULL; + data = nullptr; size = 0; } } @@ -490,7 +489,7 @@ public: { AVDictionary* opts = nullptr; av_dict_set(&opts, "probesize", "96", 0); - err = avformat_open_input(&fmt, NULL, input_format, &opts); + err = avformat_open_input(&fmt, nullptr, input_format, &opts); if (err || opts) { fmt::throw_exception("avformat_open_input() failed (err=0x%x, opts=%d)", err, opts ? 1 : 0); @@ -687,9 +686,8 @@ next: case adecClose: { buf_size = adec.reader.size; + break; } - break; - case adecDecodeAu: { std::memcpy(buf, vm::base(adec.reader.addr), adec.reader.size); @@ -706,9 +704,9 @@ next: adec.reader.size = adec.task.au.size; adec.reader.has_ats = adec.use_ats_headers; //cellAdec.notice("Audio AU: size = 0x%x, pts = 0x%llx", adec.task.au.size, adec.task.au.pts); + break; } - break; - + case adecStartSeq: // TODO ? default: { cellAdec.error("adecRawRead(): unknown task (%d)", +task.type); @@ -728,14 +726,12 @@ next: { return res; } - else - { - std::memcpy(buf, vm::base(adec.reader.addr), buf_size); - adec.reader.addr += buf_size; - adec.reader.size -= buf_size; - return res + buf_size; - } + std::memcpy(buf, vm::base(adec.reader.addr), buf_size); + + adec.reader.addr += buf_size; + adec.reader.size -= buf_size; + return res + buf_size; } bool adecCheckType(s32 type) diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.cpp b/rpcs3/Emu/Cell/Modules/cellAudio.cpp index f7bcd4d833..ecd410ae4b 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAudio.cpp @@ -7,7 +7,6 @@ #include "cellAudio.h" #include "emmintrin.h" -#include "immintrin.h" #include LOG_CHANNEL(cellAudio); @@ -65,7 +64,7 @@ void cell_audio_config::reset() desired_buffer_duration = raw.desired_buffer_duration * 1000llu; - buffering_enabled = raw.buffering_enabled && backend->has_capability(AudioBackend::PLAY_PAUSE_FLUSH | AudioBackend::IS_PLAYING);; + buffering_enabled = raw.buffering_enabled && backend->has_capability(AudioBackend::PLAY_PAUSE_FLUSH | AudioBackend::IS_PLAYING); minimum_block_period = audio_block_period / 2; maximum_block_period = (6 * audio_block_period) / 5; @@ -160,7 +159,7 @@ f32 audio_ringbuffer::set_frequency_ratio(f32 new_ratio) return frequency_ratio; } -u64 audio_ringbuffer::get_timestamp() const +u64 audio_ringbuffer::get_timestamp() { return get_system_time() - Emu.GetPauseTime(); } diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.h b/rpcs3/Emu/Cell/Modules/cellAudio.h index b515151591..8481fdea2f 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.h +++ b/rpcs3/Emu/Cell/Modules/cellAudio.h @@ -307,7 +307,7 @@ public: return buffer[num].get(); } - u64 get_timestamp() const; + static u64 get_timestamp(); float* get_current_buffer() const { diff --git a/rpcs3/Emu/Cell/Modules/cellAudioOut.h b/rpcs3/Emu/Cell/Modules/cellAudioOut.h index 495d1be0f4..22ef3e09e3 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudioOut.h +++ b/rpcs3/Emu/Cell/Modules/cellAudioOut.h @@ -1,7 +1,5 @@ #pragma once -#include "Emu/Memory/vm_ptr.h" - // Error codes enum CellAudioOutError { diff --git a/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp b/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp index db8f5f9c0e..05a6b9d06f 100644 --- a/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp @@ -8,7 +8,6 @@ #include "cellAudioIn.h" #include "cellAudioOut.h" #include "cellVideoOut.h" -#include "cellSysutil.h" LOG_CHANNEL(cellAvconfExt); @@ -108,6 +107,7 @@ avconf_manager::avconf_manager() curindex++; break; + case microphone_handler::null: default: break; } } diff --git a/rpcs3/Emu/Cell/Modules/cellCamera.cpp b/rpcs3/Emu/Cell/Modules/cellCamera.cpp index 0f5b402051..7a3497733f 100644 --- a/rpcs3/Emu/Cell/Modules/cellCamera.cpp +++ b/rpcs3/Emu/Cell/Modules/cellCamera.cpp @@ -547,7 +547,7 @@ error_code cellCameraGetType(s32 dev_num, vm::ptr type) return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND; } - switch (g_cfg.io.camera_type) + switch (g_cfg.io.camera_type.get()) { case fake_camera_type::unknown: *type = CELL_CAMERA_TYPE_UNKNOWN; break; case fake_camera_type::eyetoy: *type = CELL_CAMERA_EYETOY; break; diff --git a/rpcs3/Emu/Cell/Modules/cellFont.cpp b/rpcs3/Emu/Cell/Modules/cellFont.cpp index 612a27e6e0..fc7cb37326 100644 --- a/rpcs3/Emu/Cell/Modules/cellFont.cpp +++ b/rpcs3/Emu/Cell/Modules/cellFont.cpp @@ -354,10 +354,9 @@ error_code cellFontRenderCharGlyphImage(vm::ptr font, u32 code, vm::pt } // Get the baseLineY value - s32 baseLineY; s32 ascent, descent, lineGap; stbtt_GetFontVMetrics(font->stbfont, &ascent, &descent, &lineGap); - baseLineY = static_cast(ascent * scale); // ??? + const s32 baseLineY = static_cast(ascent * scale); // ??? // Move the rendered character to the surface unsigned char* buffer = vm::_ptr(surface->buffer.addr()); @@ -375,7 +374,7 @@ error_code cellFontRenderCharGlyphImage(vm::ptr font, u32 code, vm::pt buffer[(static_cast(y) + ypos + yoff + baseLineY) * surface->width + static_cast(x) + xpos] = box[ypos * width + xpos]; } } - stbtt_FreeBitmap(box, 0); + stbtt_FreeBitmap(box, nullptr); return CELL_OK; } @@ -389,7 +388,7 @@ error_code cellFontSetEffectSlant(vm::ptr font, float slantParam) { cellFont.trace("cellFontSetEffectSlant(font=*0x%x, slantParam=%f)", font, slantParam); - if (slantParam < -1.0 || slantParam > 1.0) + if (slantParam < -1.0f || slantParam > 1.0f) { return CELL_FONT_ERROR_INVALID_PARAMETER; } diff --git a/rpcs3/Emu/Cell/Modules/cellFs.cpp b/rpcs3/Emu/Cell/Modules/cellFs.cpp index 3885cd4ed8..b94c230031 100644 --- a/rpcs3/Emu/Cell/Modules/cellFs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellFs.cpp @@ -7,8 +7,6 @@ #include "Emu/Cell/lv2/sys_sync.h" #include "cellFs.h" -#include "Utilities/StrUtil.h" - #include LOG_CHANNEL(cellFs); diff --git a/rpcs3/Emu/Cell/Modules/cellFs.h b/rpcs3/Emu/Cell/Modules/cellFs.h index 00a3bf7ae1..229c48b865 100644 --- a/rpcs3/Emu/Cell/Modules/cellFs.h +++ b/rpcs3/Emu/Cell/Modules/cellFs.h @@ -1,6 +1,5 @@ #pragma once -#include "Emu/Cell/lv2/sys_fs.h" #include "Emu/Memory/vm_ptr.h" // CellFsRingBuffer.copy diff --git a/rpcs3/Emu/Cell/Modules/cellGame.cpp b/rpcs3/Emu/Cell/Modules/cellGame.cpp index 1d06177a34..1cc08f2391 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGame.cpp @@ -18,8 +18,6 @@ #include "util/init_mutex.hpp" #include "util/asm.hpp" -#include - LOG_CHANNEL(cellGame); template<> diff --git a/rpcs3/Emu/Cell/Modules/cellGame.h b/rpcs3/Emu/Cell/Modules/cellGame.h index d04ea728fc..ed1f64219c 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.h +++ b/rpcs3/Emu/Cell/Modules/cellGame.h @@ -354,7 +354,7 @@ struct CellHddGameStatSet typedef void(CellHddGameStatCallback)(vm::ptr cbResult, vm::ptr get, vm::ptr set); typedef void(CellGameThemeInstallCallback)(u32 fileOffset, u32 readSize, vm::ptr buf); -typedef void(CellGameDiscEjectCallback)(void); +typedef void(CellGameDiscEjectCallback)(); typedef void(CellGameDiscInsertCallback)(u32 discType, vm::ptr titleId); -typedef void(CellDiscGameDiscEjectCallback)(void); +typedef void(CellDiscGameDiscEjectCallback)(); typedef void(CellDiscGameDiscInsertCallback)(u32 discType, vm::ptr titleId); diff --git a/rpcs3/Emu/Cell/Modules/cellGem.cpp b/rpcs3/Emu/Cell/Modules/cellGem.cpp index ba38af1a2e..004ba61717 100644 --- a/rpcs3/Emu/Cell/Modules/cellGem.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGem.cpp @@ -124,7 +124,9 @@ struct gem_config connected_controllers = 1; break; } - default: break; + case move_handler::null: + default: + break; } // Assign status and port number @@ -143,7 +145,7 @@ struct gem_config */ static bool check_gem_num(const u32 gem_num) { - return gem_num >= 0 && gem_num < CELL_GEM_MAX_NUM; + return gem_num < CELL_GEM_MAX_NUM; } /** diff --git a/rpcs3/Emu/Cell/Modules/cellGifDec.cpp b/rpcs3/Emu/Cell/Modules/cellGifDec.cpp index 0135f65cf8..5d00f10749 100644 --- a/rpcs3/Emu/Cell/Modules/cellGifDec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGifDec.cpp @@ -93,6 +93,7 @@ error_code cellGifDecOpen(PMainHandle mainHandle, PPSubHandle subHandle, PSrc sr current_subHandle.fd = idm::make(src->fileName.get_ptr(), std::move(file_s), 0, 0, real_path); break; } + default: break; // TODO } subHandle->set(vm::alloc(sizeof(GifStream), vm::main)); @@ -131,6 +132,7 @@ error_code cellGifDecReadHeader(PMainHandle mainHandle, PSubHandle subHandle, PI file->file.read(buffer, sizeof(buffer)); break; } + default: break; // TODO } if (*utils::bless>(buffer + 0) != 0x47494638u || @@ -217,6 +219,7 @@ error_code cellGifDecDecodeData(PMainHandle mainHandle, PSubHandle subHandle, vm file->file.read(gif.get(), fileSize); break; } + default: break; // TODO } //Decode GIF file. (TODO: Is there any faster alternative? Can we do it without external libraries?) diff --git a/rpcs3/Emu/Cell/Modules/cellHttpUtil.cpp b/rpcs3/Emu/Cell/Modules/cellHttpUtil.cpp index 45f5177903..b1548ad551 100644 --- a/rpcs3/Emu/Cell/Modules/cellHttpUtil.cpp +++ b/rpcs3/Emu/Cell/Modules/cellHttpUtil.cpp @@ -6,7 +6,6 @@ #ifdef _WIN32 #include -#include #include #pragma comment(lib, "Winhttp.lib") #endif diff --git a/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp b/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp index e7a779b510..75e25a82b3 100644 --- a/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp @@ -84,6 +84,7 @@ error_code cellJpgDecOpen(u32 mainHandle, vm::ptr subHandle, vm::ptr(src->fileName.get_ptr(), std::move(file_s), 0, 0, real_path); break; } + default: break; // TODO } // From now, every u32 subHandle argument is a pointer to a CellJpgDecSubHandle struct. @@ -146,6 +147,7 @@ error_code cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptrfile.read(buffer.get(), fileSize); break; } + default: break; // TODO } if (*utils::bless>(buffer.get() + 0) != 0xE0FFD8FF || // Error: Not a valid SOI header @@ -226,6 +228,7 @@ error_code cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr data, file->file.read(jpg.get(), fileSize); break; } + default: break; // TODO } //Decode JPG file. (TODO: Is there any faster alternative? Can we do it without external libraries?) diff --git a/rpcs3/Emu/Cell/Modules/cellL10n.cpp b/rpcs3/Emu/Cell/Modules/cellL10n.cpp index 5cdc6f942e..5de490b1a1 100644 --- a/rpcs3/Emu/Cell/Modules/cellL10n.cpp +++ b/rpcs3/Emu/Cell/Modules/cellL10n.cpp @@ -167,12 +167,11 @@ bool _L10nCodeParse(s32 code, HostCode& retCode) s32 _OEM2Wide(HostCode oem_code, const std::string& src, std::wstring& dst) { //Such length returned should include the '\0' character. - s32 length = MultiByteToWideChar(oem_code, 0, src.c_str(), -1, NULL, 0); + const s32 length = MultiByteToWideChar(oem_code, 0, src.c_str(), -1, nullptr, 0); wchar_t *store = new wchar_t[length](); - MultiByteToWideChar(oem_code, 0, src.c_str(), -1, (LPWSTR)store, length); - std::wstring result(store); - dst = result; + MultiByteToWideChar(oem_code, 0, src.c_str(), -1, static_cast(store), length); + dst = std::wstring(store); delete[] store; store = nullptr; @@ -184,12 +183,11 @@ s32 _OEM2Wide(HostCode oem_code, const std::string& src, std::wstring& dst) s32 _Wide2OEM(HostCode oem_code, const std::wstring& src, std::string& dst) { //Such length returned should include the '\0' character. - s32 length = WideCharToMultiByte(oem_code, 0, src.c_str(), -1, NULL, 0, NULL, NULL); + const s32 length = WideCharToMultiByte(oem_code, 0, src.c_str(), -1, nullptr, 0, nullptr, nullptr); char *store = new char[length](); - WideCharToMultiByte(oem_code, 0, src.c_str(), -1, store, length, NULL, NULL); - std::string result(store); - dst = result; + WideCharToMultiByte(oem_code, 0, src.c_str(), -1, store, length, nullptr, nullptr); + dst = std::string(store); delete[] store; store = nullptr; @@ -219,10 +217,10 @@ s32 _ConvertStr(s32 src_code, const void *src, s32 src_len, s32 dst_code, void * return ConverterUnknown; #ifdef _MSC_VER - std::string wrapped_source = std::string(static_cast(src), src_len); - std::string target = _OemToOem(srcCode, dstCode, wrapped_source); + const std::string wrapped_source = std::string(static_cast(src), src_len); + const std::string target = _OemToOem(srcCode, dstCode, wrapped_source); - if (dst != NULL) + if (dst != nullptr) { if (target.length() > *dst_len) return DSTExhausted; memcpy(dst, target.c_str(), target.length()); diff --git a/rpcs3/Emu/Cell/Modules/cellMic.cpp b/rpcs3/Emu/Cell/Modules/cellMic.cpp index 94dae18537..51c14e83b4 100644 --- a/rpcs3/Emu/Cell/Modules/cellMic.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMic.cpp @@ -155,6 +155,7 @@ void mic_context::load_config_and_init() mic_list.at(0).add_device(device_list[0]); break; } + case microphone_handler::null: default: break; } } @@ -211,6 +212,7 @@ error_code microphone_device::open_microphone(const u8 type, const u32 dsp_r, co } break; case microphone_handler::rocksmith: num_channels = 1; break; + case microphone_handler::null: default: ensure(false); break; } @@ -226,7 +228,7 @@ error_code microphone_device::open_microphone(const u8 type, const u32 dsp_r, co num_al_channels = AL_FORMAT_STEREO16; break; case 4: - if (alcIsExtensionPresent(NULL, "AL_EXT_MCFORMATS") == AL_TRUE) + if (alcIsExtensionPresent(nullptr, "AL_EXT_MCFORMATS") == AL_TRUE) { num_al_channels = AL_FORMAT_QUAD16; } @@ -437,6 +439,7 @@ void microphone_device::get_raw(const u32 num_samples) } break; + case microphone_handler::null: default: ensure(false); break; } @@ -491,6 +494,7 @@ void microphone_device::get_dsp(const u32 num_samples) } break; + case microphone_handler::null: default: ensure(false); break; } diff --git a/rpcs3/Emu/Cell/Modules/cellNetCtl.cpp b/rpcs3/Emu/Cell/Modules/cellNetCtl.cpp index a7186cd804..fc6caa681b 100644 --- a/rpcs3/Emu/Cell/Modules/cellNetCtl.cpp +++ b/rpcs3/Emu/Cell/Modules/cellNetCtl.cpp @@ -9,12 +9,9 @@ #include "cellNetCtl.h" #include "Utilities/StrUtil.h" -#include "Emu/IdManager.h" #include "Emu/NP/np_handler.h" -#include - LOG_CHANNEL(cellNetCtl); template <> @@ -228,7 +225,7 @@ struct netstart_hack { static constexpr std::string_view thread_name = "NetStart Hack"; - void operator()(int) + void operator()(int) const { thread_ctrl::wait_for(500'000); diff --git a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp index edddba9e33..2a8c46c40d 100644 --- a/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellOskDialog.cpp @@ -140,7 +140,7 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr dia atomic_t result = false; - osk->on_osk_close = [maxLength, wptr = std::weak_ptr(osk)](s32 status) + osk->on_osk_close = [wptr = std::weak_ptr(osk)](s32 status) { const auto osk = wptr.lock(); diff --git a/rpcs3/Emu/Cell/Modules/cellPamf.cpp b/rpcs3/Emu/Cell/Modules/cellPamf.cpp index 33e2f496f6..9ce010b3f3 100644 --- a/rpcs3/Emu/Cell/Modules/cellPamf.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPamf.cpp @@ -148,6 +148,7 @@ u8 pamfGetStreamType(vm::ptr pSelf, u32 stream) case 0x80: return CELL_PAMF_STREAM_TYPE_PAMF_LPCM; case 0x81: return CELL_PAMF_STREAM_TYPE_AC3; case 0xdd: return CELL_PAMF_STREAM_TYPE_USER_DATA; + default: break; } cellPamf.todo("pamfGetStreamType(): unsupported stream type found(0x%x)", header.type); @@ -196,6 +197,7 @@ u8 pamfGetStreamChannel(vm::ptr pSelf, u32 stream) ensure((header.fid_minor & 0xf0) == 0x20); return header.fid_minor % 16; } + default: break; } cellPamf.todo("pamfGetStreamChannel(): unsupported stream type found(0x%x)", header.type); diff --git a/rpcs3/Emu/Cell/Modules/cellPamf.h b/rpcs3/Emu/Cell/Modules/cellPamf.h index ffe873da66..abf457e331 100644 --- a/rpcs3/Emu/Cell/Modules/cellPamf.h +++ b/rpcs3/Emu/Cell/Modules/cellPamf.h @@ -446,7 +446,7 @@ public: { } - u32 get_max_size() const + static u32 get_max_size() { return sq_size; } diff --git a/rpcs3/Emu/Cell/Modules/cellPngDec.cpp b/rpcs3/Emu/Cell/Modules/cellPngDec.cpp index 54b79228e8..d792987251 100644 --- a/rpcs3/Emu/Cell/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPngDec.cpp @@ -2,9 +2,9 @@ #include "Emu/VFS.h" #include "Emu/IdManager.h" #include "Emu/Cell/PPUModule.h" - #include "Emu/Cell/lv2/sys_fs.h" #include "png.h" +#include "cellPng.h" #include "cellPngDec.h" #if PNG_LIBPNG_VER_MAJOR >= 1 && (PNG_LIBPNG_VER_MINOR < 5 \ @@ -579,7 +579,7 @@ error_code pngDecSetParameter(PStream stream, PInParam in_param, POutParam out_p } // flag to keep unknown chunks - png_set_keep_unknown_chunks(stream->png_ptr, PNG_HANDLE_CHUNK_IF_SAFE, 0, 0); + png_set_keep_unknown_chunks(stream->png_ptr, PNG_HANDLE_CHUNK_IF_SAFE, nullptr, 0); // Scale 16 bit depth down to 8 bit depth. if (stream->info.bitDepth == 16u && in_param->outputBitDepth == 8u) diff --git a/rpcs3/Emu/Cell/Modules/cellPngDec.h b/rpcs3/Emu/Cell/Modules/cellPngDec.h index 55af2cfe3a..92f2b4c2fd 100644 --- a/rpcs3/Emu/Cell/Modules/cellPngDec.h +++ b/rpcs3/Emu/Cell/Modules/cellPngDec.h @@ -1,7 +1,5 @@ #pragma once -#include "cellPng.h" - #include "Emu/Memory/vm_ptr.h" #include "png.h" diff --git a/rpcs3/Emu/Cell/Modules/cellRec.cpp b/rpcs3/Emu/Cell/Modules/cellRec.cpp index f6e99b1f74..4701f621c3 100644 --- a/rpcs3/Emu/Cell/Modules/cellRec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellRec.cpp @@ -72,7 +72,7 @@ error_code cellRecOpen(vm::cptr pDirName, vm::cptr pFileName, vm::cp rec.cb = cb; rec.cbUserData = cbUserData; - sysutil_register_cb([=, &rec](ppu_thread& ppu) -> s32 + sysutil_register_cb([=](ppu_thread& ppu) -> s32 { cb(ppu, CELL_REC_STATUS_OPEN, CELL_OK, cbUserData); return CELL_OK; diff --git a/rpcs3/Emu/Cell/Modules/cellRtc.cpp b/rpcs3/Emu/Cell/Modules/cellRtc.cpp index 0bccdc9f66..81a7c2c78a 100644 --- a/rpcs3/Emu/Cell/Modules/cellRtc.cpp +++ b/rpcs3/Emu/Cell/Modules/cellRtc.cpp @@ -584,8 +584,8 @@ error_code cellRtcParseRfc3339(vm::ptr pUtc, vm::cptr pszDate char char_1 = pszDateTime[1]; char char_2 = pszDateTime[2]; - char char_3 = pszDateTime[3]; - if (((((((*pszDateTime - 0x30U) < 10) && ('/' < char_1)) && (char_1 < ':')) && (('/' < char_2 && (char_2 < ':')))) && ('/' < char_3)) && (char_3 < ':')) + const char char_3 = pszDateTime[3]; + if (((*pszDateTime - 0x30U) < 10) && ('/' < char_1) && (char_1 < ':') && ('/' < char_2) && (char_2 < ':') && ('/' < char_3) && (char_3 < ':')) { date_time->year = (char_2 << 1) + (char_2 << 3) + *pszDateTime * 1000 + char_1 * 100 + char_3 + 0x2fb0; } diff --git a/rpcs3/Emu/Cell/Modules/cellSail.cpp b/rpcs3/Emu/Cell/Modules/cellSail.cpp index 60c857320b..da3c7c6da5 100644 --- a/rpcs3/Emu/Cell/Modules/cellSail.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSail.cpp @@ -643,7 +643,7 @@ error_code cellSailPlayerInitialize2(ppu_thread& ppu, event.u32x2.major = CELL_SAIL_EVENT_PLAYER_STATE_CHANGED; event.u32x2.minor = 0; pSelf->callback(ppu, pSelf->callbackArg, event, CELL_SAIL_PLAYER_STATE_INITIALIZED, 0); - }; + } return CELL_OK; } @@ -782,7 +782,7 @@ error_code cellSailPlayerBoot(ppu_thread& ppu, vm::ptr pSelf, u6 event.u32x2.major = CELL_SAIL_EVENT_PLAYER_STATE_CHANGED; event.u32x2.minor = 0; pSelf->callback(ppu, pSelf->callbackArg, event, CELL_SAIL_PLAYER_STATE_BOOT_TRANSITION, 0); - }; + } // TODO: Do stuff here pSelf->booted = true; @@ -792,7 +792,7 @@ error_code cellSailPlayerBoot(ppu_thread& ppu, vm::ptr pSelf, u6 event.u32x2.major = CELL_SAIL_EVENT_PLAYER_CALL_COMPLETED; event.u32x2.minor = CELL_SAIL_PLAYER_CALL_BOOT; pSelf->callback(ppu, pSelf->callbackArg, event, 0, 0); - }; + } return CELL_OK; } diff --git a/rpcs3/Emu/Cell/Modules/cellSearch.cpp b/rpcs3/Emu/Cell/Modules/cellSearch.cpp index 197c36931d..e5a7a6f349 100644 --- a/rpcs3/Emu/Cell/Modules/cellSearch.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSearch.cpp @@ -591,7 +591,7 @@ error_code cellSearchStartContentSearchInList(vm::cptr list av_format_ctx = avformat_alloc_context(); // Open input file - if (avformat_open_input(&av_format_ctx, (vfs::get(vpath) + "/" + item.name).c_str(), 0, &av_dict_opts) < 0) + if (avformat_open_input(&av_format_ctx, (vfs::get(vpath) + "/" + item.name).c_str(), nullptr, &av_dict_opts) < 0) { // Failed to open file av_dict_free(&av_dict_opts); @@ -601,7 +601,7 @@ error_code cellSearchStartContentSearchInList(vm::cptr list av_dict_free(&av_dict_opts); // Find stream information - if (avformat_find_stream_info(av_format_ctx, 0) < 0) + if (avformat_find_stream_info(av_format_ctx, nullptr) < 0) { // Failed to load stream information avformat_free_context(av_format_ctx); @@ -671,14 +671,14 @@ error_code cellSearchStartContentSearchInList(vm::cptr list std::string value; info.trackNumber = 0; - tag = av_dict_get(av_format_ctx->metadata, "track", 0, AV_DICT_IGNORE_SUFFIX); + tag = av_dict_get(av_format_ctx->metadata, "track", nullptr, AV_DICT_IGNORE_SUFFIX); if (tag != nullptr) { std::string tmp(tag->value); - info.trackNumber = stoi(tmp.substr(0, tmp.find("/"))); + info.trackNumber = stoi(tmp.substr(0, tmp.find('/'))); } - tag = av_dict_get(av_format_ctx->metadata, "album", 0, AV_DICT_IGNORE_SUFFIX); + tag = av_dict_get(av_format_ctx->metadata, "album", nullptr, AV_DICT_IGNORE_SUFFIX); if (tag != nullptr) { value = tag->value; @@ -718,7 +718,7 @@ error_code cellSearchStartContentSearchInList(vm::cptr list } } - tag = av_dict_get(av_format_ctx->metadata, "artist", 0, AV_DICT_IGNORE_SUFFIX); + tag = av_dict_get(av_format_ctx->metadata, "artist", nullptr, AV_DICT_IGNORE_SUFFIX); if (tag != nullptr) { value = tag->value; @@ -733,7 +733,7 @@ error_code cellSearchStartContentSearchInList(vm::cptr list strcpy_trunc(info.artistName, "Unknown Artist"); } - tag = av_dict_get(av_format_ctx->metadata, "genre", 0, AV_DICT_IGNORE_SUFFIX); + tag = av_dict_get(av_format_ctx->metadata, "genre", nullptr, AV_DICT_IGNORE_SUFFIX); if (tag != nullptr) { value = tag->value; diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.h b/rpcs3/Emu/Cell/Modules/cellSpurs.h index 051042103c..51f059d973 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.h +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.h @@ -772,7 +772,7 @@ struct alignas(128) CellSpurs } } - u8 wklStatus(u32 wid) + u8 wklStatus(u32 wid) const { if (wid & 0x10) { diff --git a/rpcs3/Emu/Cell/Modules/cellSpursJq.cpp b/rpcs3/Emu/Cell/Modules/cellSpursJq.cpp index 1c9a3b9bce..dfbc3e0966 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpursJq.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpursJq.cpp @@ -1,10 +1,7 @@ #include "stdafx.h" #include "Emu/Cell/PPUModule.h" -#include "Emu/Cell/lv2/sys_lwmutex.h" -#include "Emu/Cell/lv2/sys_lwcond.h" #include "Emu/Cell/lv2/sys_spu.h" -#include "cellSpurs.h" #include "cellSpursJq.h" LOG_CHANNEL(cellSpursJq); diff --git a/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp b/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp index aa82423578..aaec2a7464 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "Loader/ELF.h" -#include "Emu/Cell/PPUModule.h" #include "Emu/Memory/vm_reservation.h" #include "Emu/Cell/SPUThread.h" @@ -10,9 +9,6 @@ #include "Emu/Cell/lv2/sys_spu.h" #include "cellSpurs.h" -#include -#include - #include "util/asm.hpp" #include "util/v128.hpp" #include "util/v128sse.hpp" diff --git a/rpcs3/Emu/Cell/Modules/cellStorage.h b/rpcs3/Emu/Cell/Modules/cellStorage.h index afc7d039f9..71e937dea3 100644 --- a/rpcs3/Emu/Cell/Modules/cellStorage.h +++ b/rpcs3/Emu/Cell/Modules/cellStorage.h @@ -24,8 +24,8 @@ enum CellStorageDataParamSize CELL_STORAGEDATA_TITLE_MAX = 256 }; -const char* CELL_STORAGEDATA_IMPORT_FILENAME = "IMPORT.BIN"; -const char* CELL_STORAGEDATA_EXPORT_FILENAME = "EXPORT.BIN"; +inline const char* CELL_STORAGEDATA_IMPORT_FILENAME = "IMPORT.BIN"; +inline const char* CELL_STORAGEDATA_EXPORT_FILENAME = "EXPORT.BIN"; struct CellStorageDataSetParam { diff --git a/rpcs3/Emu/Cell/Modules/cellSubDisplay.cpp b/rpcs3/Emu/Cell/Modules/cellSubDisplay.cpp index b25d5aabf4..b57155053a 100644 --- a/rpcs3/Emu/Cell/Modules/cellSubDisplay.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSubDisplay.cpp @@ -48,6 +48,7 @@ error_code cellSubDisplayGetRequiredMemory(vm::ptr pParam) case CELL_SUBDISPLAY_VERSION_0001: return not_an_error(CELL_SUBDISPLAY_0001_MEMORY_CONTAINER_SIZE); case CELL_SUBDISPLAY_VERSION_0002: return not_an_error(CELL_SUBDISPLAY_0002_MEMORY_CONTAINER_SIZE); case CELL_SUBDISPLAY_VERSION_0003: return not_an_error(CELL_SUBDISPLAY_0003_MEMORY_CONTAINER_SIZE); + default: break; } return CELL_SUBDISPLAY_ERROR_INVALID_VALUE; diff --git a/rpcs3/Emu/Cell/Modules/cellSysCache.cpp b/rpcs3/Emu/Cell/Modules/cellSysCache.cpp index 576805d6b8..7999dc0de1 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysCache.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysCache.cpp @@ -68,7 +68,7 @@ struct syscache_info } } - void clear(bool remove_root) noexcept + void clear(bool remove_root) const noexcept { // Clear cache if (!vfs::host::remove_all(cache_root + cache_id, cache_root, &g_mp_sys_dev_hdd1, remove_root)) diff --git a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp index 187fc2da5e..865627758c 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp @@ -157,6 +157,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case CELL_SYSUTIL_SYSTEMPARAM_ID_x1011: return "ID_x1011"; case CELL_SYSUTIL_SYSTEMPARAM_ID_x1012: return "ID_x1012"; case CELL_SYSUTIL_SYSTEMPARAM_ID_x1024: return "ID_x1024"; + default: break; } return unknown; diff --git a/rpcs3/Emu/Cell/Modules/cellVdec.cpp b/rpcs3/Emu/Cell/Modules/cellVdec.cpp index e8165b382d..27efcc66bb 100644 --- a/rpcs3/Emu/Cell/Modules/cellVdec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVdec.cpp @@ -883,7 +883,7 @@ error_code cellVdecGetPicture(u32 handle, vm::cptr format, vm } } - vdec->sws = sws_getCachedContext(vdec->sws, w, h, in_f, w, h, out_f, SWS_POINT, NULL, NULL, NULL); + vdec->sws = sws_getCachedContext(vdec->sws, w, h, in_f, w, h, out_f, SWS_POINT, nullptr, nullptr, nullptr); u8* in_data[4] = { frame->data[0], frame->data[1], frame->data[2], alpha_plane.get() }; int in_line[4] = { frame->linesize[0], frame->linesize[1], frame->linesize[2], w * 1 }; diff --git a/rpcs3/Emu/Cell/Modules/cellVpost.cpp b/rpcs3/Emu/Cell/Modules/cellVpost.cpp index fa6a48e80e..514aad9f7b 100644 --- a/rpcs3/Emu/Cell/Modules/cellVpost.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVpost.cpp @@ -277,14 +277,14 @@ error_code cellVpostExec(u32 handle, vm::cptr inPicBuff, vm::cptrsws = sws_getCachedContext(vpost->sws, w, h, AV_PIX_FMT_YUVA420P, ow, oh, AV_PIX_FMT_RGBA, SWS_BILINEAR, NULL, NULL, NULL); + vpost->sws = sws_getCachedContext(vpost->sws, w, h, AV_PIX_FMT_YUVA420P, ow, oh, AV_PIX_FMT_RGBA, SWS_BILINEAR, nullptr, nullptr, nullptr); //u64 stamp2 = get_guest_system_time(); const u8* in_data[4] = { &inPicBuff[0], &inPicBuff[w * h], &inPicBuff[w * h * 5 / 4], pA.get() }; int ws = w; int in_line[4] = { ws, ws/2, ws/2, ws }; - u8* out_data[4] = { outPicBuff.get_ptr(), NULL, NULL, NULL }; + u8* out_data[4] = { outPicBuff.get_ptr(), nullptr, nullptr, nullptr }; int out_line[4] = { static_cast(ow * 4), 0, 0, 0 }; sws_scale(vpost->sws, in_data, in_line, 0, h, out_data, out_line); diff --git a/rpcs3/Emu/Cell/Modules/libmixer.cpp b/rpcs3/Emu/Cell/Modules/libmixer.cpp index e9aa8d502a..c9a6f6dca9 100644 --- a/rpcs3/Emu/Cell/Modules/libmixer.cpp +++ b/rpcs3/Emu/Cell/Modules/libmixer.cpp @@ -6,7 +6,6 @@ #include "libmixer.h" #include -#include #include LOG_CHANNEL(libmixer); diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index a3f7c97bd6..6d90a05bd7 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -2875,7 +2875,7 @@ error_code sceNpManagerRequestTicket(vm::cptr npId, vm::cptr serv return SCE_NP_ERROR_INVALID_STATE; } - nph.req_ticket(0x00020001, npId.get_ptr(), serviceId.get_ptr(), reinterpret_cast(cookie.get_ptr()), cookieSize, entitlementId.get_ptr(), consumedCount); + nph.req_ticket(0x00020001, npId.get_ptr(), serviceId.get_ptr(), static_cast(cookie.get_ptr()), cookieSize, entitlementId.get_ptr(), consumedCount); return CELL_OK; } @@ -2908,7 +2908,7 @@ error_code sceNpManagerRequestTicket2(vm::cptr npId, vm::cptr(cookie.get_ptr()), cookieSize, entitlementId.get_ptr(), consumedCount); + nph.req_ticket(0x00020001, npId.get_ptr(), serviceId.get_ptr(), static_cast(cookie.get_ptr()), cookieSize, entitlementId.get_ptr(), consumedCount); return CELL_OK; } diff --git a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp index 1d1c535147..f170e8e0e0 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp @@ -18,7 +18,6 @@ #include "Emu/Cell/lv2/sys_process.h" #include "Emu/Cell/lv2/sys_fs.h" -#include #include #include "util/asm.hpp" @@ -827,6 +826,7 @@ error_code sceNpTrophyGetGameInfo(u32 context, u32 handle, vm::ptrunlockedSilver++; break; case 'G': data->unlockedGold++; break; case 'P': data->unlockedPlatinum++; break; + default: break; } } } @@ -1038,6 +1038,7 @@ static error_code NpTrophyGetTrophyInfo(const trophy_context_t* ctxt, s32 trophy case 'S': tmp_details.trophyGrade = SCE_NP_TROPHY_GRADE_SILVER; break; case 'G': tmp_details.trophyGrade = SCE_NP_TROPHY_GRADE_GOLD; break; case 'P': tmp_details.trophyGrade = SCE_NP_TROPHY_GRADE_PLATINUM; break; + default: break; } for (std::shared_ptr n2 = n->GetChildren(); n2; n2 = n2->GetNext()) diff --git a/rpcs3/Emu/Cell/Modules/sceNpTus.cpp b/rpcs3/Emu/Cell/Modules/sceNpTus.cpp index 24ac02192a..457bdc1119 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTus.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTus.cpp @@ -93,17 +93,10 @@ s32 sce_np_tus_manager::add_transaction_context(s32 titleCtxId) bool sce_np_tus_manager::check_transaction_context_id(s32 transId) { - for (const auto& title_context : title_contexts) + return std::any_of(title_contexts.cbegin(), title_contexts.cend(), [&transId](const auto& c) { - const auto& transactions = title_context.second.transaction_contexts; - - if (transactions.find(transId) != transactions.end()) - { - return true; - } - } - - return false; + return c.second.transaction_contexts.contains(transId); + }); } bool sce_np_tus_manager::remove_transaction_context_id(s32 transId) @@ -202,7 +195,7 @@ error_code sceNpTusCreateTitleCtx(vm::cptr communicationId return SCE_NP_COMMUNITY_ERROR_TOO_MANY_OBJECTS; } - return not_an_error(id);; + return not_an_error(id); } error_code sceNpTusDestroyTitleCtx(s32 titleCtxId) diff --git a/rpcs3/Emu/Cell/Modules/sys_libc_.cpp b/rpcs3/Emu/Cell/Modules/sys_libc_.cpp index 1ed16791ab..d9bd57a3c9 100644 --- a/rpcs3/Emu/Cell/Modules/sys_libc_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_libc_.cpp @@ -2,8 +2,6 @@ #include "Emu/Cell/lv2/sys_tty.h" #include "Emu/Cell/PPUModule.h" #include "Utilities/cfmt.h" -#include -#include LOG_CHANNEL(sysPrxForUser); @@ -16,7 +14,7 @@ struct ps3_fmt_src ppu_thread* ctx; u32 g_count; - bool test(usz) const + static bool test(usz) { return true; } @@ -40,7 +38,7 @@ struct ps3_fmt_src return out.size() - start; } - usz type(usz) const + static usz type(usz) { return 0; } diff --git a/rpcs3/Emu/Cell/Modules/sys_lwcond_.cpp b/rpcs3/Emu/Cell/Modules/sys_lwcond_.cpp index 29b42c61ec..2fe71cb5da 100644 --- a/rpcs3/Emu/Cell/Modules/sys_lwcond_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_lwcond_.cpp @@ -3,7 +3,6 @@ #include "Emu/Cell/lv2/sys_lwmutex.h" #include "Emu/Cell/lv2/sys_lwcond.h" -#include "Emu/Cell/lv2/sys_mutex.h" #include "Emu/Cell/lv2/sys_cond.h" #include "sysPrxForUser.h" @@ -100,7 +99,7 @@ error_code sys_lwcond_signal(ppu_thread& ppu, vm::ptr lwcond) } // if locking succeeded - lwmutex->lock_var.atomic_op([](typename sys_lwmutex_t::sync_var_t& var) + lwmutex->lock_var.atomic_op([](sys_lwmutex_t::sync_var_t& var) { var.waiter++; var.owner = lwmutex_reserved; @@ -114,7 +113,7 @@ error_code sys_lwcond_signal(ppu_thread& ppu, vm::ptr lwcond) return 0; } - lwmutex->lock_var.atomic_op([&](typename sys_lwmutex_t::sync_var_t& var) + lwmutex->lock_var.atomic_op([&](sys_lwmutex_t::sync_var_t& var) { var.waiter--; var.owner = ppu.id; @@ -253,7 +252,7 @@ error_code sys_lwcond_signal_to(ppu_thread& ppu, vm::ptr lwcond, u } // if locking succeeded - lwmutex->lock_var.atomic_op([](typename sys_lwmutex_t::sync_var_t& var) + lwmutex->lock_var.atomic_op([](sys_lwmutex_t::sync_var_t& var) { var.waiter++; var.owner = lwmutex_reserved; @@ -267,7 +266,7 @@ error_code sys_lwcond_signal_to(ppu_thread& ppu, vm::ptr lwcond, u return 0; } - lwmutex->lock_var.atomic_op([&](typename sys_lwmutex_t::sync_var_t& var) + lwmutex->lock_var.atomic_op([&](sys_lwmutex_t::sync_var_t& var) { var.waiter--; var.owner = ppu.id; diff --git a/rpcs3/Emu/Cell/Modules/sys_spu_.cpp b/rpcs3/Emu/Cell/Modules/sys_spu_.cpp index ce3249212e..70d5abf836 100644 --- a/rpcs3/Emu/Cell/Modules/sys_spu_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_spu_.cpp @@ -2,7 +2,6 @@ #include "Emu/VFS.h" #include "Emu/Cell/PPUModule.h" -#include "Emu/Cell/RawSPUThread.h" #include "Emu/Cell/lv2/sys_spu.h" #include "Crypto/unself.h" #include "Loader/ELF.h" @@ -23,7 +22,7 @@ struct spu_elf_ldr be_t ehdr_off; be_t phdr_off; - s32 get_ehdr(vm::ptr> out) + s32 get_ehdr(vm::ptr> out) const { if (!src) { @@ -57,7 +56,7 @@ struct spu_elf_ldr return 0; } - s32 get_phdr(vm::ptr> out, u32 count) + s32 get_phdr(vm::ptr> out, u32 count) const { if (!src) { diff --git a/rpcs3/Emu/Cell/PPUAnalyser.h b/rpcs3/Emu/Cell/PPUAnalyser.h index 366726a1e1..2f2710c69a 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.h +++ b/rpcs3/Emu/Cell/PPUAnalyser.h @@ -1189,7 +1189,7 @@ struct ppu_acontext } // Range XOR - spec_gpr operator ^(const spec_gpr& rhs) + spec_gpr operator ^(const spec_gpr& rhs) const { return (~*this & rhs) | (*this & ~rhs); } diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index 28fbf52b59..377b6f1ff3 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -1063,6 +1063,7 @@ std::shared_ptr ppu_load_prx(const ppu_prx_object& elf, const std::stri break; } + default : break; } } diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index bd6e8b821e..09f5ebc858 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -97,6 +97,7 @@ PPUTranslator::PPUTranslator(LLVMContext& context, Module* _module, const ppu_mo ppu_log.error("Ignoring 64-bit relocation at 0x%x (%u)", rel.addr, rel.type); continue; } + default: break; } // Align relocation address (TODO) diff --git a/rpcs3/Emu/Cell/RawSPUThread.cpp b/rpcs3/Emu/Cell/RawSPUThread.cpp index c07068a188..6572393d94 100644 --- a/rpcs3/Emu/Cell/RawSPUThread.cpp +++ b/rpcs3/Emu/Cell/RawSPUThread.cpp @@ -8,7 +8,7 @@ inline void try_start(spu_thread& spu) { reader_lock lock(spu.run_ctrl_mtx); - if (spu.status_npc.fetch_op([](typename spu_thread::status_npc_sync_var& value) + if (spu.status_npc.fetch_op([](spu_thread::status_npc_sync_var& value) { if (value.status & SPU_STATUS_RUNNING) { diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index 8c6f32d977..e9b361aa92 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -17,7 +17,6 @@ #include "util/sysinfo.hpp" #include -#include #include #define SPU_OFF_128(x, ...) asmjit::x86::oword_ptr(*cpu, offset32(&spu_thread::x, ##__VA_ARGS__)) @@ -1514,6 +1513,7 @@ void spu_recompiler::RDCH(spu_opcode_t op) c->movdqa(SPU_OFF_128(gpr, op.rt), vr); return; } + default: break; } c->lea(addr->r64(), get_pc(m_pos)); @@ -2505,6 +2505,7 @@ void spu_recompiler::WRCH(spu_opcode_t op) { return; } + default: break; } c->lea(addr->r64(), get_pc(m_pos)); diff --git a/rpcs3/Emu/Cell/SPUDisAsm.cpp b/rpcs3/Emu/Cell/SPUDisAsm.cpp index 9b79fb23c6..a54a89d7d1 100644 --- a/rpcs3/Emu/Cell/SPUDisAsm.cpp +++ b/rpcs3/Emu/Cell/SPUDisAsm.cpp @@ -164,7 +164,7 @@ std::pair SPUDisAsm::try_get_const_value(u32 reg, u32 pc) const return {}; } -typename SPUDisAsm::insert_mask_info SPUDisAsm::try_get_insert_mask_info(const v128& mask) +SPUDisAsm::insert_mask_info SPUDisAsm::try_get_insert_mask_info(const v128& mask) { if ((mask & v128::from8p(0xe0)) != v128{}) { diff --git a/rpcs3/Emu/Cell/SPUDisAsm.h b/rpcs3/Emu/Cell/SPUDisAsm.h index f23623afe8..0f2fafe948 100644 --- a/rpcs3/Emu/Cell/SPUDisAsm.h +++ b/rpcs3/Emu/Cell/SPUDisAsm.h @@ -96,8 +96,7 @@ private: } } -private: - std::string& FixOp(std::string& op) + std::string& FixOp(std::string& op) const { if (m_mode != cpu_disasm_mode::normal) { diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 906212caa7..15dae29e83 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -738,7 +738,7 @@ spu_function_t spu_runtime::rebuild_ubertrampoline(u32 id_inst) workload.back().size = size0; workload.back().level = 0; workload.back().from = -1; - workload.back().rel32 = 0; + workload.back().rel32 = nullptr; workload.back().beg = beg; workload.back().end = _end; @@ -1760,6 +1760,7 @@ spu_program spu_recompiler_base::analyse(const be_t* ls, u32 entry_point) m_use_rb[pos / 4] = s_reg_mfc_eal; break; } + default: break; } break; @@ -3226,11 +3227,8 @@ void spu_recompiler_base::dump(const spu_program& result, std::string& out) #include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Verifier.h" #include "llvm/IR/InlineAsm.h" -#include "llvm/Analysis/Lint.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Scalar.h" -#include "llvm/Transforms/IPO.h" -#include "llvm/Transforms/Vectorize.h" #ifdef _MSC_VER #pragma warning(pop) #else @@ -6160,6 +6158,7 @@ public: { return; } + default: break; } update_pc(); diff --git a/rpcs3/Emu/Cell/SPURecompiler.h b/rpcs3/Emu/Cell/SPURecompiler.h index fc33215157..fd35375b11 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.h +++ b/rpcs3/Emu/Cell/SPURecompiler.h @@ -321,7 +321,7 @@ public: static void old_interpreter(spu_thread&, void* ls, u8*); // Get the function data at specified address - spu_program analyse(const be_t* ls, u32 lsa); + spu_program analyse(const be_t* ls, u32 entry_point); // Print analyser internal state void dump(const spu_program& result, std::string& out); diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index ea28fa0608..f770df06b8 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -20,9 +20,7 @@ #include "Emu/Cell/SPUDisAsm.h" #include "Emu/Cell/SPUAnalyser.h" #include "Emu/Cell/SPUThread.h" -#include "Emu/Cell/SPUInterpreter.h" #include "Emu/Cell/SPURecompiler.h" -#include "Emu/Cell/RawSPUThread.h" #include "Emu/Cell/timers.hpp" #include @@ -3106,7 +3104,7 @@ bool spu_thread::is_exec_code(u32 addr) const return true; } -u32 spu_thread::get_mfc_completed() +u32 spu_thread::get_mfc_completed() const { return ch_tag_mask & ~mfc_fence; } @@ -3123,7 +3121,7 @@ bool spu_thread::process_mfc_cmd() return false; } - thread_ctrl::wait_on(state, old);; + thread_ctrl::wait_on(state, old); } spu::scheduler::concurrent_execution_watchdog watchdog(*this); @@ -3487,7 +3485,7 @@ bool spu_thread::process_mfc_cmd() ch_mfc_cmd.cmd, ch_mfc_cmd.lsa, ch_mfc_cmd.eal, ch_mfc_cmd.tag, ch_mfc_cmd.size); } -bool spu_thread::reservation_check(u32 addr, const decltype(rdata)& data) +bool spu_thread::reservation_check(u32 addr, const decltype(rdata)& data) const { if (!addr) { diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index 3622b01a5f..56661827b3 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -5,7 +5,6 @@ #include "Emu/Memory/vm.h" #include "MFC.h" -#include #include "util/v128.hpp" #include "util/logs.hpp" #include "util/to_endian.hpp" @@ -354,12 +353,12 @@ public: data.release(u64{count} << off_count | value); } - u32 get_value() + u32 get_value() const { return static_cast(data); } - u32 get_count() + u32 get_count() const { return static_cast(data >> off_count); } @@ -790,13 +789,13 @@ public: void do_putlluc(const spu_mfc_cmd& args); bool do_putllc(const spu_mfc_cmd& args); void do_mfc(bool wait = true); - u32 get_mfc_completed(); + u32 get_mfc_completed() const; bool process_mfc_cmd(); ch_events_t get_events(u32 mask_hint = -1, bool waiting = false, bool reading = false); void set_events(u32 bits); void set_interrupt_status(bool enable); - bool check_mfc_interrupts(u32 nex_pc); + bool check_mfc_interrupts(u32 next_pc); bool is_exec_code(u32 addr) const; // Only a hint, do not rely on it other than debugging purposes u32 get_ch_count(u32 ch); s64 get_ch_value(u32 ch); @@ -834,7 +833,7 @@ public: // Returns true if reservation existed but was just discovered to be lost // It is safe to use on any address, even if not directly accessed by SPU (so it's slower) - bool reservation_check(u32 addr, const decltype(rdata)& data); + bool reservation_check(u32 addr, const decltype(rdata)& data) const; bool read_reg(const u32 addr, u32& value); bool write_reg(const u32 addr, const u32 value); diff --git a/rpcs3/Emu/Cell/lv2/lv2.cpp b/rpcs3/Emu/Cell/lv2/lv2.cpp index 6b545aca60..3770b612d1 100644 --- a/rpcs3/Emu/Cell/lv2/lv2.cpp +++ b/rpcs3/Emu/Cell/lv2/lv2.cpp @@ -1075,7 +1075,7 @@ extern void ppu_execute_syscall(ppu_thread& ppu, u64 code) { g_fxo->get>().stat[code]++; - if (auto func = g_ppu_syscall_table[code].first) + if (const auto func = g_ppu_syscall_table[code].first) { func(ppu); ppu_log.trace("Syscall '%s' (%llu) finished, r3=0x%llx", ppu_syscall_code(code), code, ppu.gpr[3]); @@ -1263,6 +1263,7 @@ bool lv2_obj::awake_unlocked(cpu_thread* cpu, s32 prio) break; } } + break; } case enqueue_cmd: { diff --git a/rpcs3/Emu/Cell/lv2/sys_cond.cpp b/rpcs3/Emu/Cell/lv2/sys_cond.cpp index 32b16689cc..e6617cc96e 100644 --- a/rpcs3/Emu/Cell/lv2/sys_cond.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_cond.cpp @@ -26,7 +26,7 @@ error_code sys_cond_create(ppu_thread& ppu, vm::ptr cond_id, u32 mutex_id, const auto _attr = *attr; - if (auto error = lv2_obj::create(_attr.pshared, _attr.ipc_key, _attr.flags, [&] + if (const auto error = lv2_obj::create(_attr.pshared, _attr.ipc_key, _attr.flags, [&] { return std::make_shared( _attr.pshared, @@ -59,7 +59,7 @@ error_code sys_cond_destroy(ppu_thread& ppu, u32 cond_id) return CELL_EBUSY; } - cond.mutex->obj_count.atomic_op([](typename lv2_mutex::count_info& info){ info.cond_count--; }); + cond.mutex->obj_count.atomic_op([](lv2_mutex::count_info& info){ info.cond_count--; }); return {}; }); @@ -224,7 +224,7 @@ error_code sys_cond_wait(ppu_thread& ppu, u32 cond_id, u64 timeout) // Unlock the mutex const auto count = cond.mutex->lock_count.exchange(0); - if (auto cpu = cond.mutex->reown()) + if (const auto cpu = cond.mutex->reown()) { cond.mutex->append(cpu); } diff --git a/rpcs3/Emu/Cell/lv2/sys_cond.h b/rpcs3/Emu/Cell/lv2/sys_cond.h index fce60b6741..1b945b1209 100644 --- a/rpcs3/Emu/Cell/lv2/sys_cond.h +++ b/rpcs3/Emu/Cell/lv2/sys_cond.h @@ -42,9 +42,9 @@ struct lv2_cond final : lv2_obj { } - CellError on_id_create() + CellError on_id_create() const { - if (!mutex->obj_count.fetch_op([](typename lv2_mutex::count_info& info) + if (!mutex->obj_count.fetch_op([](lv2_mutex::count_info& info) { if (info.mutex_count) return info.cond_count++, true; diff --git a/rpcs3/Emu/Cell/lv2/sys_config.cpp b/rpcs3/Emu/Cell/lv2/sys_config.cpp index e630ea01cb..f3fa0bbe21 100644 --- a/rpcs3/Emu/Cell/lv2/sys_config.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_config.cpp @@ -115,7 +115,7 @@ void lv2_config::remove_service_event(u32 id) // LV2 Config Service Listener -bool lv2_config_service_listener::check_service(const lv2_config_service& service) +bool lv2_config_service_listener::check_service(const lv2_config_service& service) const { // Filter by type if (type == SYS_CONFIG_SERVICE_LISTENER_ONCE && !service_events.empty()) @@ -152,7 +152,7 @@ bool lv2_config_service_listener::notify(const std::shared_ptris_registered(); + const auto registered = service->is_registered(); dst->service_listener_handle = listener.get_id(); dst->registered = registered; @@ -242,7 +242,7 @@ void lv2_config_service_event::write(sys_config_service_event_t *dst) dst->verbosity = service->verbosity; dst->padding = service->padding; - auto size = service->data.size(); + const auto size = service->data.size(); dst->data_size = static_cast(size); memcpy(dst->data, service->data.data(), size); } @@ -390,7 +390,7 @@ error_code sys_config_register_service(u32 config_hdl, sys_config_service_id ser } // Create service - auto service = lv2_config_service::create(service_id, user_id, verbosity, 0, data_buf.get_ptr(), size); + const auto service = lv2_config_service::create(service_id, user_id, verbosity, 0, data_buf.get_ptr(), size); if (!service) { return CELL_EAGAIN; diff --git a/rpcs3/Emu/Cell/lv2/sys_config.h b/rpcs3/Emu/Cell/lv2/sys_config.h index 658c25c60e..8c3027c4bf 100644 --- a/rpcs3/Emu/Cell/lv2/sys_config.h +++ b/rpcs3/Emu/Cell/lv2/sys_config.h @@ -146,9 +146,9 @@ public: { reader_lock lock(m_mutex); - auto it = events.find(id); + const auto it = events.find(id); - if (it == events.end()) + if (it == events.cend()) return nullptr; if (auto event = it->second.lock()) @@ -270,7 +270,7 @@ public: // Utilities usz get_size() const { return sizeof(sys_config_service_event_t)-1 + data.size(); } - std::shared_ptr get_shared_ptr () const { return wkptr.lock(); }; + std::shared_ptr get_shared_ptr () const { return wkptr.lock(); } u32 get_id() const { return idm_id; } }; @@ -327,7 +327,7 @@ public: } // Check whether service matches - bool check_service(const lv2_config_service& service); + bool check_service(const lv2_config_service& service) const; // Register new event, and notify queue bool notify(const std::shared_ptr& service); @@ -337,7 +337,7 @@ public: // Utilities u32 get_id() const { return idm_id; } - std::shared_ptr get_shared_ptr() const { return wkptr.lock(); }; + std::shared_ptr get_shared_ptr() const { return wkptr.lock(); } }; /* @@ -403,7 +403,7 @@ public: bool notify() const; // Write event to buffer - void write(sys_config_service_event_t *dst); + void write(sys_config_service_event_t *dst) const; // Check if the buffer can fit the current event, return false otherwise bool check_buffer_size(usz size) const { return service->get_size() <= size; } diff --git a/rpcs3/Emu/Cell/lv2/sys_event.cpp b/rpcs3/Emu/Cell/lv2/sys_event.cpp index 79670fdc81..074ea29b75 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_event.cpp @@ -249,7 +249,7 @@ error_code sys_event_queue_tryreceive(ppu_thread& ppu, u32 equeue_id, vm::ptrsq.empty() && count < size && !queue->events.empty()) { auto& dest = event_array[count++]; - auto event = queue->events.front(); + const auto event = queue->events.front(); queue->events.pop_front(); std::tie(dest.source, dest.data1, dest.data2, dest.data3) = event; diff --git a/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp b/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp index 58f79ee81f..aaed5f702d 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp @@ -42,7 +42,7 @@ error_code sys_event_flag_create(ppu_thread& ppu, vm::ptr id, vm::ptr(_attr.pshared, _attr.ipc_key, _attr.flags, [&] + if (const auto error = lv2_obj::create(_attr.pshared, _attr.ipc_key, _attr.flags, [&] { return std::make_shared( _attr.protocol, diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index afd754a6fd..8cc7527f21 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -297,6 +297,7 @@ lv2_file::open_raw_result_t lv2_file::open_raw(const std::string& local_path, s3 case CELL_FS_O_RDONLY: open_mode += fs::read; break; case CELL_FS_O_WRONLY: open_mode += fs::write; break; case CELL_FS_O_RDWR: open_mode += fs::read + fs::write; break; + default: break; } if (mp->flags & lv2_mp_flag::read_only) @@ -777,11 +778,11 @@ error_code sys_fs_opendir(ppu_thread& ppu, vm::cptr path, vm::ptr fd) std::lock_guard lock(mp->mutex); - fs::dir dir(local_path); + const fs::dir dir(local_path); if (!dir) { - switch (auto error = fs::g_tls_error) + switch (const auto error = fs::g_tls_error) { case fs::error::noent: { diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.h b/rpcs3/Emu/Cell/lv2/sys_fs.h index 61058f5734..cc0e12fc98 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.h +++ b/rpcs3/Emu/Cell/lv2/sys_fs.h @@ -258,7 +258,7 @@ struct lv2_file final : lv2_fs_object // File reading with intermediate buffer static u64 op_read(const fs::file& file, vm::ptr buf, u64 size); - u64 op_read(vm::ptr buf, u64 size) + u64 op_read(vm::ptr buf, u64 size) const { return op_read(file, buf, size); } @@ -266,7 +266,7 @@ struct lv2_file final : lv2_fs_object // File writing with intermediate buffer static u64 op_write(const fs::file& file, vm::cptr buf, u64 size); - u64 op_write(vm::cptr buf, u64 size) + u64 op_write(vm::cptr buf, u64 size) const { return op_write(file, buf, size); } diff --git a/rpcs3/Emu/Cell/lv2/sys_gamepad.cpp b/rpcs3/Emu/Cell/lv2/sys_gamepad.cpp index 3a165fff81..26ffbc2696 100644 --- a/rpcs3/Emu/Cell/lv2/sys_gamepad.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_gamepad.cpp @@ -72,35 +72,24 @@ u32 sys_gamepad_ycon_if(u8 packet_id, vm::ptr in, vm::ptr out) { case 0: return sys_gamepad_ycon_initalize(in, out); - break; case 1: return sys_gamepad_ycon_finalize(in, out); - break; case 2: return sys_gamepad_ycon_has_input_ownership(in, out); - break; case 3: return sys_gamepad_ycon_enumerate_device(in, out); - break; case 4: return sys_gamepad_ycon_get_device_info(in, out); - break; case 5: return sys_gamepad_ycon_read_raw_report(in, out); - break; case 6: return sys_gamepad_ycon_write_raw_report(in, out); - break; case 7: return sys_gamepad_ycon_get_feature(in, out); - break; case 8: return sys_gamepad_ycon_set_feature(in, out); - break; case 9: return sys_gamepad_ycon_is_gem(in, out); - break; - default: sys_gamepad.error("sys_gamepad_ycon_if(packet_id=*%d, in=%d, out=%d), unknown packet id", packet_id, in, out); break; diff --git a/rpcs3/Emu/Cell/lv2/sys_interrupt.cpp b/rpcs3/Emu/Cell/lv2/sys_interrupt.cpp index 4e5d7d1218..a44e849415 100644 --- a/rpcs3/Emu/Cell/lv2/sys_interrupt.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_interrupt.cpp @@ -9,7 +9,7 @@ LOG_CHANNEL(sys_interrupt); -void lv2_int_serv::exec() +void lv2_int_serv::exec() const { thread->cmd_list ({ @@ -25,7 +25,7 @@ void lv2_int_serv::exec() bool ppu_thread_exit(ppu_thread& ppu); -void lv2_int_serv::join() +void lv2_int_serv::join() const { thread->cmd_list ({ diff --git a/rpcs3/Emu/Cell/lv2/sys_interrupt.h b/rpcs3/Emu/Cell/lv2/sys_interrupt.h index 2f7fca7180..4472443a18 100644 --- a/rpcs3/Emu/Cell/lv2/sys_interrupt.h +++ b/rpcs3/Emu/Cell/lv2/sys_interrupt.h @@ -28,8 +28,8 @@ struct lv2_int_serv final : lv2_obj { } - void exec(); - void join(); + void exec() const; + void join() const; }; // Syscalls diff --git a/rpcs3/Emu/Cell/lv2/sys_memory.cpp b/rpcs3/Emu/Cell/lv2/sys_memory.cpp index ed0fa6da2b..a1cdc18569 100644 --- a/rpcs3/Emu/Cell/lv2/sys_memory.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_memory.cpp @@ -60,7 +60,7 @@ error_code sys_memory_allocate(cpu_thread& cpu, u32 size, u64 flags, vm::ptralloc(size, nullptr, align)) + if (const u32 addr = area->alloc(size, nullptr, align)) { ensure(!g_fxo->get().addrs[addr >> 16].exchange(&dct)); @@ -131,7 +131,7 @@ error_code sys_memory_allocate_from_container(cpu_thread& cpu, u32 size, u32 cid if (const auto area = vm::reserve_map(align == 0x10000 ? vm::user64k : vm::user1m, 0, utils::align(size, 0x10000000), 0x401)) { - if (u32 addr = area->alloc(size)) + if (const u32 addr = area->alloc(size)) { ensure(!g_fxo->get().addrs[addr >> 16].exchange(ct.ptr.get())); diff --git a/rpcs3/Emu/Cell/lv2/sys_memory.h b/rpcs3/Emu/Cell/lv2/sys_memory.h index f12edf2476..18f96d93ec 100644 --- a/rpcs3/Emu/Cell/lv2/sys_memory.h +++ b/rpcs3/Emu/Cell/lv2/sys_memory.h @@ -1,7 +1,6 @@ #pragma once #include "Emu/Memory/vm_ptr.h" -#include "Emu/IdManager.h" #include "Emu/Cell/ErrorCodes.h" class cpu_thread; diff --git a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp index fc0107798c..9383fb83da 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp @@ -2,7 +2,6 @@ #include "sys_mmapper.h" #include "Emu/Cell/PPUThread.h" -#include "sys_ppu_thread.h" #include "Emu/Cell/lv2/sys_event.h" #include "Emu/Memory/vm_var.h" #include "sys_memory.h" diff --git a/rpcs3/Emu/Cell/lv2/sys_mmapper.h b/rpcs3/Emu/Cell/lv2/sys_mmapper.h index 7a6506e638..44ac477144 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mmapper.h +++ b/rpcs3/Emu/Cell/lv2/sys_mmapper.h @@ -88,8 +88,8 @@ error_code sys_mmapper_allocate_address(ppu_thread&, u64 size, u64 flags, u64 al error_code sys_mmapper_allocate_fixed_address(ppu_thread&); error_code sys_mmapper_allocate_shared_memory(ppu_thread&, u64 ipc_key, u64 size, u64 flags, vm::ptr mem_id); error_code sys_mmapper_allocate_shared_memory_from_container(ppu_thread&, u64 ipc_key, u64 size, u32 cid, u64 flags, vm::ptr mem_id); -error_code sys_mmapper_allocate_shared_memory_ext(ppu_thread&, u64 ipc_key, u64 size, u32 flags, vm::ptr src, s32 count, vm::ptr mem_id); -error_code sys_mmapper_allocate_shared_memory_from_container_ext(ppu_thread&, u64 ipc_key, u64 size, u64 flags, u32 mc_id, vm::ptr entries, s32 entry_count, vm::ptr mem_id); +error_code sys_mmapper_allocate_shared_memory_ext(ppu_thread&, u64 ipc_key, u64 size, u32 flags, vm::ptr entries, s32 entry_count, vm::ptr mem_id); +error_code sys_mmapper_allocate_shared_memory_from_container_ext(ppu_thread&, u64 ipc_key, u64 size, u64 flags, u32 cid, vm::ptr entries, s32 entry_count, vm::ptr mem_id); error_code sys_mmapper_change_address_access_right(ppu_thread&, u32 addr, u64 flags); error_code sys_mmapper_free_address(ppu_thread&, u32 addr); error_code sys_mmapper_free_shared_memory(ppu_thread&, u32 mem_id); diff --git a/rpcs3/Emu/Cell/lv2/sys_mutex.cpp b/rpcs3/Emu/Cell/lv2/sys_mutex.cpp index fac291e8e6..567afbfd2b 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mutex.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_mutex.cpp @@ -88,7 +88,7 @@ error_code sys_mutex_destroy(ppu_thread& ppu, u32 mutex_id) return CELL_EBUSY; } - if (!mutex.obj_count.fetch_op([](typename lv2_mutex::count_info& info) + if (!mutex.obj_count.fetch_op([](lv2_mutex::count_info& info) { if (info.cond_count) { diff --git a/rpcs3/Emu/Cell/lv2/sys_net.cpp b/rpcs3/Emu/Cell/lv2/sys_net.cpp index 56d03c5200..26ccf9528f 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_net.cpp @@ -96,6 +96,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case SYS_NET_SOCK_RAW: return "RAW"; case SYS_NET_SOCK_DGRAM_P2P: return "DGRAM-P2P"; case SYS_NET_SOCK_STREAM_P2P: return "STREAM-P2P"; + default: break; } return unknown; @@ -113,6 +114,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case SYS_NET_AF_LOCAL: return "LOCAL"; case SYS_NET_AF_INET: return "INET"; case SYS_NET_AF_INET6: return "INET6"; + default: break; } return unknown; @@ -571,7 +573,7 @@ struct nt_p2p_port } } - void dump_packet(lv2_socket::p2ps_i::encapsulated_tcp* tcph) + static void dump_packet(lv2_socket::p2ps_i::encapsulated_tcp* tcph) { const std::string result = fmt::format("src_port: %d\ndst_port: %d\nflags: %d\nseq: %d\nack: %d\nlen: %d", tcph->src_port, tcph->dst_port, tcph->flags, tcph->seq, tcph->ack, tcph->length); sys_net.trace("PACKET DUMP:\n%s", result); @@ -1587,7 +1589,6 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr packet; const auto psa_in_p2p = reinterpret_cast(addr_buf.buf); { std::lock_guard lock(sock.mutex); @@ -1646,7 +1647,7 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr packet = nt_p2p_port::generate_u2s_packet(send_hdr, nullptr, 0); name.sin_port = std::bit_cast(psa_in_p2p->sin_vport); // not a bug nt_p2p_port::send_u2s_packet(sock, s, std::move(packet), reinterpret_cast<::sockaddr_in*>(&name), send_hdr.seq); } @@ -2357,11 +2358,11 @@ error_code sys_net_bnet_recvfrom(ppu_thread& ppu, s32 s, vm::ptr buf, u32 return false; } - get_data(reinterpret_cast(buf.get_ptr())); + get_data(static_cast(buf.get_ptr())); return true; } - native_result = ::recvfrom(sock.socket, reinterpret_cast(buf.get_ptr()), len, native_flags, reinterpret_cast(&native_addr), &native_addrlen); + native_result = ::recvfrom(sock.socket, static_cast(buf.get_ptr()), len, native_flags, reinterpret_cast(&native_addr), &native_addrlen); if (native_result >= 0) { @@ -2772,16 +2773,16 @@ error_code sys_net_bnet_setsockopt(ppu_thread& ppu, s32 s, s32 level, s32 optnam switch(optlen) { case 1: - sys_net.warning("optval: 0x%02X", *reinterpret_cast(optval.get_ptr())); + sys_net.warning("optval: 0x%02X", *static_cast(optval.get_ptr())); break; case 2: - sys_net.warning("optval: 0x%04X", *reinterpret_cast *>(optval.get_ptr())); + sys_net.warning("optval: 0x%04X", *static_cast *>(optval.get_ptr())); break; case 4: - sys_net.warning("optval: 0x%08X", *reinterpret_cast *>(optval.get_ptr())); + sys_net.warning("optval: 0x%08X", *static_cast *>(optval.get_ptr())); break; case 8: - sys_net.warning("optval: 0x%016X", *reinterpret_cast *>(optval.get_ptr())); + sys_net.warning("optval: 0x%016X", *static_cast *>(optval.get_ptr())); break; } @@ -2972,7 +2973,7 @@ error_code sys_net_bnet_setsockopt(ppu_thread& ppu, s32 s, s32 level, s32 optnam return SYS_NET_EINVAL; } - if (::setsockopt(sock.socket, native_level, native_opt, reinterpret_cast(native_val), native_len) == 0) + if (::setsockopt(sock.socket, native_level, native_opt, static_cast(native_val), native_len) == 0) { return {}; } @@ -3080,6 +3081,7 @@ error_code sys_net_bnet_socket(ppu_thread& ppu, s32 family, s32 type, s32 protoc protocol == SYS_NET_IPPROTO_UDP ? IPPROTO_UDP : protocol == SYS_NET_IPPROTO_ICMPV6 ? IPPROTO_ICMPV6 : 0; + // TODO: native_domain is always AF_INET if (native_domain == AF_UNSPEC && type == SYS_NET_SOCK_DGRAM) { // Windows gets all errory if you try a unspec socket with protocol 0 @@ -3100,7 +3102,7 @@ error_code sys_net_bnet_socket(ppu_thread& ppu, s32 family, s32 type, s32 protoc sys_net.error("Error setting default SO_SNDBUF on sys_net_bnet_socket socket"); } - auto sock_lv2 = std::make_shared(native_socket, type, family); + const auto sock_lv2 = std::make_shared(native_socket, type, family); if (type == SYS_NET_SOCK_STREAM_P2P) { sock_lv2->p2p.port = 3658; // Default value if unspecified later diff --git a/rpcs3/Emu/Cell/lv2/sys_net.h b/rpcs3/Emu/Cell/lv2/sys_net.h index ecac036bf1..006827d344 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net.h +++ b/rpcs3/Emu/Cell/lv2/sys_net.h @@ -182,7 +182,7 @@ struct sys_net_fd_set { be_t fds_bits[32]; - u32 bit(s32 s) + u32 bit(s32 s) const { return (fds_bits[(s >> 5) & 31] >> (s & 31)) & 1u; } diff --git a/rpcs3/Emu/Cell/lv2/sys_process.cpp b/rpcs3/Emu/Cell/lv2/sys_process.cpp index c8f4dbbea5..42570d9dcc 100644 --- a/rpcs3/Emu/Cell/lv2/sys_process.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_process.cpp @@ -22,7 +22,6 @@ #include "sys_rwlock.h" #include "sys_semaphore.h" #include "sys_timer.h" -#include "sys_trace.h" #include "sys_fs.h" #include "sys_vm.h" #include "sys_spu.h" diff --git a/rpcs3/Emu/Cell/lv2/sys_prx.cpp b/rpcs3/Emu/Cell/lv2/sys_prx.cpp index 2d8e150d5a..095a465d2e 100644 --- a/rpcs3/Emu/Cell/lv2/sys_prx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_prx.cpp @@ -565,8 +565,6 @@ error_code _sys_prx_stop_module(ppu_thread& ppu, u32 id, u64 flags, vm::ptr pOpt) diff --git a/rpcs3/Emu/Cell/lv2/sys_rsx.h b/rpcs3/Emu/Cell/lv2/sys_rsx.h index db44c0e71c..c3d4a8c027 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rsx.h +++ b/rpcs3/Emu/Cell/lv2/sys_rsx.h @@ -151,4 +151,4 @@ error_code sys_rsx_context_iounmap(cpu_thread& cpu, u32 context_id, u32 io, u32 error_code sys_rsx_context_attribute(u32 context_id, u32 package_id, u64 a3, u64 a4, u64 a5, u64 a6); error_code sys_rsx_device_map(cpu_thread& cpu, vm::ptr dev_addr, vm::ptr a2, u32 dev_id); error_code sys_rsx_device_unmap(cpu_thread& cpu, u32 dev_id); -error_code sys_rsx_attribute(cpu_thread& cpu, u32 a1, u32 a2, u32 a3, u32 a4, u32 a5); +error_code sys_rsx_attribute(cpu_thread& cpu, u32 packageId, u32 a2, u32 a3, u32 a4, u32 a5); diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index 16d6e23ff9..88794a2b28 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -12,7 +12,6 @@ #include "Emu/Cell/ErrorCodes.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/Cell/PPUModule.h" #include "Emu/Cell/RawSPUThread.h" #include "Emu/Cell/timers.hpp" #include "sys_interrupt.h" @@ -101,7 +100,7 @@ void sys_spu_image::load(const fs::file& stream) vm::page_protect(segs.addr(), utils::align(mem_size, 4096), 0, 0, vm::page_writable); } -void sys_spu_image::free() +void sys_spu_image::free() const { if (type == SYS_SPU_IMAGE_TYPE_KERNEL) { @@ -1112,7 +1111,7 @@ error_code sys_spu_thread_group_join(ppu_thread& ppu, u32 id, vm::ptr cause thread_ctrl::wait_on(ppu.state, state); } } - while (0); + while (false); if (!cause) { diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.h b/rpcs3/Emu/Cell/lv2/sys_spu.h index b533b5848f..418cc04d93 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.h +++ b/rpcs3/Emu/Cell/lv2/sys_spu.h @@ -222,7 +222,7 @@ struct sys_spu_image } void load(const fs::file& stream); - void free(); + void free() const; static void deploy(u8* loc, sys_spu_segment* segs, u32 nsegs); }; @@ -311,11 +311,12 @@ struct lv2_spu_group , join_state(0) , running(0) , stop_count(0) + // TODO: args() { threads_map.fill(-1); } - void send_run_event(u64 data1, u64 data2, u64 data3) + void send_run_event(u64 data1, u64 data2, u64 data3) const { if (const auto queue = ep_run.lock()) { @@ -323,7 +324,7 @@ struct lv2_spu_group } } - void send_exception_event(u64 data1, u64 data2, u64 data3) + void send_exception_event(u64 data1, u64 data2, u64 data3) const { if (const auto queue = ep_exception.lock()) { @@ -331,7 +332,7 @@ struct lv2_spu_group } } - void send_sysmodule_event(u64 data1, u64 data2, u64 data3) + void send_sysmodule_event(u64 data1, u64 data2, u64 data3) const { if (const auto queue = ep_sysmodule.lock()) { @@ -371,14 +372,14 @@ error_code sys_spu_thread_group_disconnect_event_all_threads(ppu_thread&, u32 id error_code sys_spu_thread_group_set_cooperative_victims(ppu_thread&, u32 id, u32 threads_mask); error_code sys_spu_thread_group_syscall_253(ppu_thread& ppu, u32 id, vm::ptr info); error_code sys_spu_thread_group_log(ppu_thread&, s32 command, vm::ptr stat); -error_code sys_spu_thread_write_ls(ppu_thread&, u32 id, u32 address, u64 value, u32 type); -error_code sys_spu_thread_read_ls(ppu_thread&, u32 id, u32 address, vm::ptr value, u32 type); +error_code sys_spu_thread_write_ls(ppu_thread&, u32 id, u32 lsa, u64 value, u32 type); +error_code sys_spu_thread_read_ls(ppu_thread&, u32 id, u32 lsa, vm::ptr value, u32 type); error_code sys_spu_thread_write_spu_mb(ppu_thread&, u32 id, u32 value); error_code sys_spu_thread_set_spu_cfg(ppu_thread&, u32 id, u64 value); error_code sys_spu_thread_get_spu_cfg(ppu_thread&, u32 id, vm::ptr value); error_code sys_spu_thread_write_snr(ppu_thread&, u32 id, u32 number, u32 value); error_code sys_spu_thread_connect_event(ppu_thread&, u32 id, u32 eq, u32 et, u8 spup); -error_code sys_spu_thread_disconnect_event(ppu_thread&, u32 id, u32 event_type, u8 spup); +error_code sys_spu_thread_disconnect_event(ppu_thread&, u32 id, u32 et, u8 spup); error_code sys_spu_thread_bind_queue(ppu_thread&, u32 id, u32 spuq, u32 spuq_num); error_code sys_spu_thread_unbind_queue(ppu_thread&, u32 id, u32 spuq_num); error_code sys_spu_thread_get_exit_status(ppu_thread&, u32 id, vm::ptr status); diff --git a/rpcs3/Emu/Cell/lv2/sys_ss.h b/rpcs3/Emu/Cell/lv2/sys_ss.h index fb2e21cc46..99fcba19e4 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ss.h +++ b/rpcs3/Emu/Cell/lv2/sys_ss.h @@ -21,7 +21,7 @@ struct CellSsOpenPSID error_code sys_ss_random_number_generator(u64 pkg_id, vm::ptr buf, u64 size); error_code sys_ss_access_control_engine(u64 pkg_id, u64 a2, u64 a3); s32 sys_ss_get_console_id(vm::ptr buf); -s32 sys_ss_get_open_psid(vm::ptr ptr); +s32 sys_ss_get_open_psid(vm::ptr psid); error_code sys_ss_appliance_info_manager(u32 code, vm::ptr buffer); error_code sys_ss_get_cache_of_product_mode(vm::ptr ptr); error_code sys_ss_secure_rtc(u64 cmd, u64 a2, u64 a3, u64 a4); @@ -29,4 +29,4 @@ error_code sys_ss_get_cache_of_flash_ext_flag(vm::ptr flag); error_code sys_ss_get_boot_device(vm::ptr dev); error_code sys_ss_update_manager(u64 pkg_id, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6); error_code sys_ss_virtual_trm_manager(u64 pkg_id, u64 a1, u64 a2, u64 a3, u64 a4); -error_code sys_ss_individual_info_manager(u64 pkg_id, u64 a2, vm::ptr out_size, u64 a4, u64, u64 a5); +error_code sys_ss_individual_info_manager(u64 pkg_id, u64 a2, vm::ptr out_size, u64 a4, u64 a5, u64 a6); diff --git a/rpcs3/Emu/Cell/lv2/sys_sync.h b/rpcs3/Emu/Cell/lv2/sys_sync.h index a0749c0895..e1c82927e5 100644 --- a/rpcs3/Emu/Cell/lv2/sys_sync.h +++ b/rpcs3/Emu/Cell/lv2/sys_sync.h @@ -12,7 +12,6 @@ #include #include -#include // attr_protocol (waiting scheduling policy) enum lv2_protocol : u32 @@ -78,7 +77,7 @@ private: }; // Function executed under IDM mutex, error will make the object creation fail and the error will be returned - CellError on_id_create() + static CellError on_id_create() { return {}; } @@ -95,7 +94,7 @@ public: str.erase(std::remove_if(str.begin(), str.end(), [](uchar c){ return !std::isprint(c); }), str.end()); return str; - }; + } // Find and remove the object from the container (deque or vector) template @@ -306,7 +305,6 @@ public: usec = std::min(usec, max_timeout); u64 passed = 0; - u64 remaining; const u64 start_time = get_system_time(); @@ -327,7 +325,7 @@ public: while (usec >= passed) { - remaining = usec - passed; + u64 remaining = usec - passed; #ifdef __linux__ // NOTE: Assumption that timer initialization has succeeded u64 host_min_quantum = IsUsleep && remaining <= 1000 ? 10 : 50; diff --git a/rpcs3/Emu/Cell/lv2/sys_time.cpp b/rpcs3/Emu/Cell/lv2/sys_time.cpp index 2b3bd1acab..0dd7195843 100644 --- a/rpcs3/Emu/Cell/lv2/sys_time.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_time.cpp @@ -23,7 +23,7 @@ const auto s_time_aux_info = []() -> time_aux_info_t LARGE_INTEGER freq; if (!QueryPerformanceFrequency(&freq)) { - MessageBox(0, L"Your hardware doesn't support a high-resolution performance counter", L"Error", MB_OK | MB_ICONERROR); + MessageBox(nullptr, L"Your hardware doesn't support a high-resolution performance counter", L"Error", MB_OK | MB_ICONERROR); return {}; } diff --git a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp index cbc48fd332..0f480774e8 100644 --- a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp @@ -4,7 +4,6 @@ #include "sys_sync.h" #include -#include #include "Emu/System.h" #include "Emu/Memory/vm.h" #include "Emu/IdManager.h" diff --git a/rpcs3/Emu/GDB.cpp b/rpcs3/Emu/GDB.cpp index e4647c329b..51b0583ed9 100644 --- a/rpcs3/Emu/GDB.cpp +++ b/rpcs3/Emu/GDB.cpp @@ -9,8 +9,6 @@ #include "Emu/IdManager.h" #include "Emu/CPU/CPUThread.h" #include "Emu/Cell/PPUThread.h" -#include "Emu/Cell/RawSPUThread.h" -#include "Emu/Cell/SPUThread.h" #ifdef _WIN32 #include @@ -29,7 +27,6 @@ #include // sockaddr_un #endif -#include #include #include @@ -205,11 +202,11 @@ void gdb_thread::start_server() GDB.notice("Started listening on Unix socket '%s'.", sname); } -int gdb_thread::read(void* buf, int cnt) +int gdb_thread::read(void* buf, int cnt) const { while (thread_ctrl::state() != thread_state::aborting) { - int result = recv(client_socket, reinterpret_cast(buf), cnt, 0); + const int result = recv(client_socket, static_cast(buf), cnt, 0); if (result == -1) { @@ -313,7 +310,7 @@ bool gdb_thread::read_cmd(gdb_cmd& out_cmd) } } -void gdb_thread::send(const char* buf, int cnt) +void gdb_thread::send(const char* buf, int cnt) const { GDB.trace("Sending %s (%d bytes).", buf, cnt); @@ -554,7 +551,7 @@ bool gdb_thread::cmd_thread_info(gdb_cmd&) //todo: this may exceed max command length result = "m" + result + "l"; - return send_cmd_ack(result);; + return send_cmd_ack(result); } bool gdb_thread::cmd_current_thread(gdb_cmd&) @@ -892,7 +889,8 @@ void gdb_thread::operator()() PROCESS_CMD("Z", cmd_set_breakpoint); GDB.trace("Unsupported command received: '%s'.", cmd.cmd); - if (!send_cmd_ack("")) { + if (!send_cmd_ack("")) + { break; } } diff --git a/rpcs3/Emu/GDB.h b/rpcs3/Emu/GDB.h index 6e90119e6e..2e79216600 100644 --- a/rpcs3/Emu/GDB.h +++ b/rpcs3/Emu/GDB.h @@ -23,7 +23,7 @@ class gdb_thread //initialize server socket and start listening void start_server(); //read at most cnt bytes to buf, returns number of bytes actually read - int read(void* buf, int cnt); + int read(void* buf, int cnt) const; //reads one character char read_char(); //reads pairs of hex characters and returns their integer value @@ -39,7 +39,7 @@ class gdb_thread //chance of getting correct command is low bool read_cmd(gdb_cmd& out_cmd); //send cnt bytes from buf to client - void send(const char* buf, int cnt); + void send(const char* buf, int cnt) const; //send character to client void send_char(char c); //acknowledge packet, either as accepted or declined @@ -80,7 +80,7 @@ class gdb_thread bool cmd_write_all_registers(gdb_cmd& cmd); bool cmd_set_thread_ops(gdb_cmd& cmd); bool cmd_attached_to_what(gdb_cmd& cmd); - bool cmd_kill(gdb_cmd& cmd); + static bool cmd_kill(gdb_cmd& cmd); bool cmd_continue_support(gdb_cmd& cmd); bool cmd_vcont(gdb_cmd& cmd); bool cmd_set_breakpoint(gdb_cmd& cmd); @@ -89,7 +89,7 @@ class gdb_thread public: bool from_breakpoint = true; bool paused = false; - u64 pausedBy; + u64 pausedBy = 0; gdb_thread() noexcept; ~gdb_thread(); diff --git a/rpcs3/Emu/Io/KeyboardHandler.h b/rpcs3/Emu/Io/KeyboardHandler.h index 53ff9dfa6c..630dd147e8 100644 --- a/rpcs3/Emu/Io/KeyboardHandler.h +++ b/rpcs3/Emu/Io/KeyboardHandler.h @@ -80,8 +80,6 @@ struct Keyboard std::vector m_buttons; Keyboard() - : m_data() - , m_config() { } }; @@ -102,7 +100,7 @@ public: void Key(u32 code, bool pressed); void SetIntercepted(bool intercepted); - bool IsMetaKey(u32 code); + static bool IsMetaKey(u32 code); KbInfo& GetInfo() { return m_info; } std::vector& GetKeyboards() { return m_keyboards; } diff --git a/rpcs3/Emu/Io/MouseHandler.h b/rpcs3/Emu/Io/MouseHandler.h index e836c8c890..815b5e1fba 100644 --- a/rpcs3/Emu/Io/MouseHandler.h +++ b/rpcs3/Emu/Io/MouseHandler.h @@ -125,9 +125,6 @@ struct Mouse : x_pos(0) , y_pos(0) , buttons(0) - , m_tablet_datalist() - , m_datalist() - , m_rawdata() { } }; diff --git a/rpcs3/Emu/Io/PadHandler.cpp b/rpcs3/Emu/Io/PadHandler.cpp index 9c22f2d857..e3eb3e67af 100644 --- a/rpcs3/Emu/Io/PadHandler.cpp +++ b/rpcs3/Emu/Io/PadHandler.cpp @@ -116,7 +116,7 @@ float PadHandlerBase::ScaledInput2(s32 raw_value, int minimum, int maximum) } // Get normalized trigger value based on the range defined by a threshold -u16 PadHandlerBase::NormalizeTriggerInput(u16 value, int threshold) +u16 PadHandlerBase::NormalizeTriggerInput(u16 value, int threshold) const { if (value <= threshold || threshold >= trigger_max) { diff --git a/rpcs3/Emu/Io/PadHandler.h b/rpcs3/Emu/Io/PadHandler.h index b9dd6d2601..fd8f724fdb 100644 --- a/rpcs3/Emu/Io/PadHandler.h +++ b/rpcs3/Emu/Io/PadHandler.h @@ -104,7 +104,7 @@ protected: static float ScaledInput2(s32 raw_value, int minimum, int maximum); // Get normalized trigger value based on the range defined by a threshold - u16 NormalizeTriggerInput(u16 value, int threshold); + u16 NormalizeTriggerInput(u16 value, int threshold) const; // normalizes a directed input, meaning it will correspond to a single "button" and not an axis with two directions // the input values must lie in 0+ @@ -173,16 +173,16 @@ public: virtual void get_next_button_press(const std::string& padId, const pad_callback& callback, const pad_fail_callback& fail_callback, bool get_blacklist, const std::vector& buttons = {}); private: - virtual std::shared_ptr get_device(const std::string& /*device*/) { return nullptr; }; - virtual bool get_is_left_trigger(u64 /*keyCode*/) { return false; }; - virtual bool get_is_right_trigger(u64 /*keyCode*/) { return false; }; - virtual bool get_is_left_stick(u64 /*keyCode*/) { return false; }; - virtual bool get_is_right_stick(u64 /*keyCode*/) { return false; }; - virtual PadHandlerBase::connection update_connection(const std::shared_ptr& /*device*/) { return connection::disconnected; }; - virtual void get_extended_info(const std::shared_ptr& /*device*/, const std::shared_ptr& /*pad*/) {}; - virtual void apply_pad_data(const std::shared_ptr& /*device*/, const std::shared_ptr& /*pad*/) {}; - virtual std::unordered_map get_button_values(const std::shared_ptr& /*device*/) { return {}; }; - virtual pad_preview_values get_preview_values(const std::unordered_map& /*data*/) { return {}; }; + virtual std::shared_ptr get_device(const std::string& /*device*/) { return nullptr; } + virtual bool get_is_left_trigger(u64 /*keyCode*/) { return false; } + virtual bool get_is_right_trigger(u64 /*keyCode*/) { return false; } + virtual bool get_is_left_stick(u64 /*keyCode*/) { return false; } + virtual bool get_is_right_stick(u64 /*keyCode*/) { return false; } + virtual PadHandlerBase::connection update_connection(const std::shared_ptr& /*device*/) { return connection::disconnected; } + virtual void get_extended_info(const std::shared_ptr& /*device*/, const std::shared_ptr& /*pad*/) {} + virtual void apply_pad_data(const std::shared_ptr& /*device*/, const std::shared_ptr& /*pad*/) {} + virtual std::unordered_map get_button_values(const std::shared_ptr& /*device*/) { return {}; } + virtual pad_preview_values get_preview_values(const std::unordered_map& /*data*/) { return {}; } protected: virtual std::array get_mapped_key_codes(const std::shared_ptr& /*device*/, const pad_config* profile); diff --git a/rpcs3/Emu/Io/interception.h b/rpcs3/Emu/Io/interception.h index d1b211206b..72a88308de 100644 --- a/rpcs3/Emu/Io/interception.h +++ b/rpcs3/Emu/Io/interception.h @@ -1,6 +1,5 @@ #pragma once -#include "util/types.hpp" #include "util/atomic.hpp" namespace input diff --git a/rpcs3/Emu/Io/usb_device.h b/rpcs3/Emu/Io/usb_device.h index c2f22432bf..040d29cccd 100644 --- a/rpcs3/Emu/Io/usb_device.h +++ b/rpcs3/Emu/Io/usb_device.h @@ -122,7 +122,7 @@ struct UsbDescriptorNode std::vector subnodes; - UsbDescriptorNode(){}; + UsbDescriptorNode(){} template UsbDescriptorNode(u8 _bDescriptorType, const T& _data) : bLength(sizeof(T) + 2) diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index 24c6fba5d0..1ba36d53c6 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -3,7 +3,6 @@ #include "vm_ptr.h" #include "vm_ref.h" #include "vm_reservation.h" -#include "vm_var.h" #include "Utilities/mutex.h" #include "Utilities/Thread.h" @@ -1044,7 +1043,7 @@ namespace vm // Mapped regions: addr -> shm handle constexpr auto block_map = &auto_typemap::get>>>; - bool block_t::try_alloc(u32 addr, u8 flags, u32 size, std::shared_ptr&& shm) + bool block_t::try_alloc(u32 addr, u8 flags, u32 size, std::shared_ptr&& shm) const { // Check if memory area is already mapped for (u32 i = addr / 4096; i <= (addr + size - 1) / 4096; i++) @@ -1283,7 +1282,7 @@ namespace vm return addr; } - u32 block_t::dealloc(u32 addr, const std::shared_ptr* src) + u32 block_t::dealloc(u32 addr, const std::shared_ptr* src) const { auto& m_map = (m.*block_map)(); { @@ -1328,7 +1327,7 @@ namespace vm } } - std::pair> block_t::peek(u32 addr, u32 size) + std::pair> block_t::peek(u32 addr, u32 size) const { if (addr < this->addr || addr + u64{size} > this->addr + u64{this->size}) { @@ -1369,7 +1368,7 @@ namespace vm return {found->first, found->second.second}; } - u32 block_t::imp_used(const vm::writer_lock&) + u32 block_t::imp_used(const vm::writer_lock&) const { u32 result = 0; diff --git a/rpcs3/Emu/Memory/vm.h b/rpcs3/Emu/Memory/vm.h index 3ce682354e..af1a4ebb6a 100644 --- a/rpcs3/Emu/Memory/vm.h +++ b/rpcs3/Emu/Memory/vm.h @@ -116,7 +116,7 @@ namespace vm // Common mapped region for special cases std::shared_ptr m_common; - bool try_alloc(u32 addr, u8 flags, u32 size, std::shared_ptr&&); + bool try_alloc(u32 addr, u8 flags, u32 size, std::shared_ptr&&) const; public: block_t(u32 addr, u32 size, u64 flags); @@ -138,16 +138,16 @@ namespace vm u32 falloc(u32 addr, u32 size, const std::shared_ptr* = nullptr, u64 flags = 0); // Unmap memory at specified location previously returned by alloc(), return size - u32 dealloc(u32 addr, const std::shared_ptr* = nullptr); + u32 dealloc(u32 addr, const std::shared_ptr* = nullptr) const; // Get memory at specified address (if size = 0, addr assumed exact) - std::pair> peek(u32 addr, u32 size = 0); + std::pair> peek(u32 addr, u32 size = 0) const; // Get allocated memory count u32 used(); // Internal - u32 imp_used(const vm::writer_lock&); + u32 imp_used(const vm::writer_lock&) const; }; // Create new memory block with specified parameters and return it diff --git a/rpcs3/Emu/Memory/vm_ref.h b/rpcs3/Emu/Memory/vm_ref.h index b60e2584c5..c2b81446d6 100644 --- a/rpcs3/Emu/Memory/vm_ref.h +++ b/rpcs3/Emu/Memory/vm_ref.h @@ -69,22 +69,22 @@ namespace vm return get_ref() = right; } - decltype(auto) operator ++(int) + decltype(auto) operator ++(int) const { return get_ref()++; } - decltype(auto) operator ++() + decltype(auto) operator ++() const { return ++get_ref(); } - decltype(auto) operator --(int) + decltype(auto) operator --(int) const { return get_ref()--; } - decltype(auto) operator --() + decltype(auto) operator --() const { return --get_ref(); } diff --git a/rpcs3/Emu/NP/np_handler.cpp b/rpcs3/Emu/NP/np_handler.cpp index 14bab182e2..5ab0334c3d 100644 --- a/rpcs3/Emu/NP/np_handler.cpp +++ b/rpcs3/Emu/NP/np_handler.cpp @@ -1,5 +1,4 @@ #include "stdafx.h" -#include #include "Emu/system_config.h" #include "np_handler.h" #include "Emu/Cell/PPUModule.h" @@ -276,13 +275,10 @@ const SceNpAvatarUrl& np_handler::get_avatar_url() const std::string np_handler::ip_to_string(u32 ip_addr) { - std::string result; in_addr addr; addr.s_addr = ip_addr; - result = inet_ntoa(addr); - - return result; + return inet_ntoa(addr); } std::string np_handler::ether_to_string(std::array& ether) diff --git a/rpcs3/Emu/NP/np_handler.h b/rpcs3/Emu/NP/np_handler.h index ee54977a44..370bb113e8 100644 --- a/rpcs3/Emu/NP/np_handler.h +++ b/rpcs3/Emu/NP/np_handler.h @@ -7,7 +7,6 @@ #include "Emu/Memory/vm_ptr.h" #include "Emu/Cell/Modules/sceNp.h" #include "Emu/Cell/Modules/sceNp2.h" -#include "Emu/Cell/Modules/sceNpCommerce2.h" #include "Emu/NP/rpcn_client.h" #include "generated/np2_structs_generated.h" @@ -109,7 +108,7 @@ public: // Misc stuff void req_ticket(u32 version, const SceNpId *npid, const char *service_id, const u8 *cookie, u32 cookie_size, const char *entitlement_id, u32 consumed_count); - const std::vector& get_ticket() { return current_ticket; } + const std::vector& get_ticket() const { return current_ticket; } u32 add_players_to_history(vm::cptr npids, u32 count); // For signaling diff --git a/rpcs3/Emu/NP/rpcn_client.cpp b/rpcs3/Emu/NP/rpcn_client.cpp index 43ac4e7b70..f937fc1a86 100644 --- a/rpcs3/Emu/NP/rpcn_client.cpp +++ b/rpcs3/Emu/NP/rpcn_client.cpp @@ -52,10 +52,10 @@ rpcn_client::~rpcn_client() disconnect(); } -std::string rpcn_client::get_wolfssl_error(int error) +std::string rpcn_client::get_wolfssl_error(int error) const { char error_string[80]{}; - auto wssl_err = wolfSSL_get_error(wssl, error); + const auto wssl_err = wolfSSL_get_error(wssl, error); wolfSSL_ERR_error_string(wssl_err, &error_string[0]); return std::string(error_string); } @@ -220,7 +220,7 @@ bool rpcn_client::connect(const std::string& host) return false; } - wolfSSL_CTX_set_verify(wssl_ctx, SSL_VERIFY_NONE, 0); + wolfSSL_CTX_set_verify(wssl_ctx, SSL_VERIFY_NONE, nullptr); if ((wssl = wolfSSL_new(wssl_ctx)) == nullptr) { @@ -505,7 +505,7 @@ bool rpcn_client::manage_connection() case PacketType::Notification: { std::lock_guard lock(mutex_notifs); - notifications.push_back(std::make_pair(command, std::move(data))); + notifications.emplace_back(std::make_pair(command, std::move(data))); break; } case PacketType::ServerInfo: @@ -1130,6 +1130,7 @@ bool rpcn_client::is_error(ErrorType err) const case ErrorLogin: rpcn_log.error("Sent password/token was incorrect!"); break; case ErrorCreate: rpcn_log.error("Error creating an account!"); break; case AlreadyLoggedIn: rpcn_log.error("User is already logged in!"); break; + case AlreadyJoined: rpcn_log.error("User has already joined!"); break; case DbFail: rpcn_log.error("A db query failed on the server!"); break; case NotFound: rpcn_log.error("A request replied not found!"); return false; case Unsupported: rpcn_log.error("An unsupported operation was attempted!"); return false; @@ -1146,7 +1147,7 @@ bool rpcn_client::error_and_disconnect(const std::string& error_msg) return false; } -bool rpcn_client::is_abort() +bool rpcn_client::is_abort() const { if (in_config) { diff --git a/rpcs3/Emu/NP/rpcn_client.h b/rpcs3/Emu/NP/rpcn_client.h index a7c7382bf1..87d5881c23 100644 --- a/rpcs3/Emu/NP/rpcn_client.h +++ b/rpcs3/Emu/NP/rpcn_client.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include "Utilities/mutex.h" @@ -9,15 +8,12 @@ #ifdef _WIN32 #include -#include #else #include #include #include #endif -#include "Emu/Memory/vm.h" -#include "Emu/Memory/vm_ptr.h" #include "Emu/Cell/Modules/sceNp.h" #include "Emu/Cell/Modules/sceNp2.h" @@ -31,7 +27,7 @@ public: vec_stream() = delete; vec_stream(std::vector& _vec, usz initial_index = 0) : vec(_vec) - , i(initial_index){}; + , i(initial_index){} bool is_error() const { return error; @@ -61,7 +57,7 @@ public: } i++; - if (!empty && res.size() == 0) + if (!empty && res.empty()) { error = true; } @@ -93,7 +89,7 @@ public: vec.push_back(*(reinterpret_cast(&value) + index)); } } - void insert_string(const std::string& str) + void insert_string(const std::string& str) const { std::copy(str.begin(), str.end(), std::back_inserter(vec)); vec.push_back(0); @@ -188,7 +184,7 @@ public: const std::string& get_avatar_url() const { return avatar_url; - }; + } u32 get_addr_sig() const { @@ -220,9 +216,9 @@ protected: bool is_error(ErrorType err) const; bool error_and_disconnect(const std::string& error_mgs); - bool is_abort(); + bool is_abort() const; - std::string get_wolfssl_error(int error); + std::string get_wolfssl_error(int error) const; protected: atomic_t connected = false; diff --git a/rpcs3/Emu/NP/rpcn_config.cpp b/rpcs3/Emu/NP/rpcn_config.cpp index de836628cd..5588209e43 100644 --- a/rpcs3/Emu/NP/rpcn_config.cpp +++ b/rpcs3/Emu/NP/rpcn_config.cpp @@ -70,7 +70,7 @@ std::string cfg_rpcn::get_host() const std::string cfg_rpcn::get_npid() { std::string final_npid = npid.to_string(); - if (final_npid == "") + if (final_npid.empty()) { final_npid = cfg_rpcn::generate_npid(); save(); diff --git a/rpcs3/Emu/NP/signaling_handler.cpp b/rpcs3/Emu/NP/signaling_handler.cpp index 7a289d6d74..85c6bca4fc 100644 --- a/rpcs3/Emu/NP/signaling_handler.cpp +++ b/rpcs3/Emu/NP/signaling_handler.cpp @@ -2,10 +2,8 @@ #include "Emu/Cell/PPUModule.h" #include "signaling_handler.h" #include "Emu/IdManager.h" -#include "Emu/System.h" #include "Emu/Cell/Modules/cellSysutil.h" #include "np_handler.h" -#include #ifdef _WIN32 #include @@ -32,6 +30,7 @@ void fmt_class_string::format(std::string& out, u64 arg) case signal_confirm: return "CONFIRM"; case signal_finished: return "FINISHED"; case signal_finished_ack: return "FINISHED_ACK"; + default: break; } return unknown; @@ -82,7 +81,7 @@ void signaling_handler::signal_sig_callback(u32 conn_id, int event) signal_ext_sig_callback(conn_id, event); } -void signaling_handler::signal_ext_sig_callback(u32 conn_id, int event) +void signaling_handler::signal_ext_sig_callback(u32 conn_id, int event) const { if (sig_ext_cb) { @@ -95,7 +94,7 @@ void signaling_handler::signal_ext_sig_callback(u32 conn_id, int event) } } -void signaling_handler::signal_sig2_callback(u64 room_id, u16 member_id, SceNpMatching2Event event) +void signaling_handler::signal_sig2_callback(u64 room_id, u16 member_id, SceNpMatching2Event event) const { // Signal the callback if (sig2_cb) @@ -317,7 +316,7 @@ void signaling_handler::operator()() while (thread_ctrl::state() != thread_state::aborting) { std::unique_lock lock(data_mutex); - if (qpackets.size()) + if (!qpackets.empty()) wakey.wait_until(lock, qpackets.begin()->first); else wakey.wait(lock); @@ -444,10 +443,10 @@ void signaling_handler::set_self_sig2_info(u64 room_id, u16 member_id) sig2_packet.V2.member_id = member_id; } -void signaling_handler::send_signaling_packet(signaling_packet& sp, u32 addr, u16 port) +void signaling_handler::send_signaling_packet(signaling_packet& sp, u32 addr, u16 port) const { std::vector packet(sizeof(signaling_packet) + sizeof(u16)); - reinterpret_cast&>(packet.data()[0]) = 65535; + reinterpret_cast&>(packet[0]) = 65535; memcpy(packet.data() + sizeof(u16), &sp, sizeof(signaling_packet)); sockaddr_in dest; @@ -467,7 +466,7 @@ void signaling_handler::send_signaling_packet(signaling_packet& sp, u32 addr, u1 void signaling_handler::queue_signaling_packet(signaling_packet& sp, std::shared_ptr si, steady_clock::time_point wakeup_time) { queued_packet qp; - qp.sig_info = si; + qp.sig_info = std::move(si); qp.packet = sp; qpackets.emplace(wakeup_time, std::move(qp)); } diff --git a/rpcs3/Emu/NP/signaling_handler.h b/rpcs3/Emu/NP/signaling_handler.h index e05740c0f9..95515d0d9b 100644 --- a/rpcs3/Emu/NP/signaling_handler.h +++ b/rpcs3/Emu/NP/signaling_handler.h @@ -61,7 +61,7 @@ public: signaling_info get_sig2_infos(u64 room_id, u16 member_id); void set_sig_cb(u32 sig_cb_ctx, vm::ptr sig_cb, vm::ptr sig_cb_arg); - void set_ext_sig_cb(u32 sig_cb_ctx, vm::ptr sig_ext_cb, vm::ptr sig_ext_cb_arg); + void set_ext_sig_cb(u32 sig_ext_cb_ctx, vm::ptr sig_ext_cb, vm::ptr sig_ext_cb_arg); void set_sig2_cb(u16 sig2_cb_ctx, vm::ptr sig2_cb, vm::ptr sig2_cb_arg); void start_sig(u32 conn_id, u32 addr, u16 port); @@ -69,7 +69,6 @@ public: void start_sig2(u64 room_id, u16 member_id); void disconnect_sig2_users(u64 room_id); -public: static constexpr auto thread_name = "Signaling Manager Thread"sv; private: @@ -102,7 +101,6 @@ private: std::shared_ptr sig_info; }; -private: u32 sig_cb_ctx = 0; vm::ptr sig_cb{}; vm::ptr sig_cb_arg{}; @@ -115,24 +113,20 @@ private: vm::ptr sig2_cb{}; vm::ptr sig2_cb_arg{}; -private: u32 create_sig_infos(const SceNpId* npid); - void update_si_addr(std::shared_ptr& si, u32 new_addr, u16 new_port); + static void update_si_addr(std::shared_ptr& si, u32 new_addr, u16 new_port); void update_si_status(std::shared_ptr& si, s32 new_status, bool confirm_packet = false); void signal_sig_callback(u32 conn_id, int event); - void signal_ext_sig_callback(u32 conn_id, int event); - void signal_sig2_callback(u64 room_id, u16 member_id, SceNpMatching2Event event); + void signal_ext_sig_callback(u32 conn_id, int event) const; + void signal_sig2_callback(u64 room_id, u16 member_id, SceNpMatching2Event event) const; -private: void start_sig_nl(u32 conn_id, u32 addr, u16 port); -private: - bool validate_signaling_packet(const signaling_packet* sp); + static bool validate_signaling_packet(const signaling_packet* sp); void reschedule_packet(std::shared_ptr& si, SignalingCommand cmd, steady_clock::time_point new_timepoint); void retire_packet(std::shared_ptr& si, SignalingCommand cmd); void retire_all_packets(std::shared_ptr& si); -private: std::mutex data_mutex; std::condition_variable wakey; @@ -146,9 +140,8 @@ private: std::unordered_map> sig1_peers; // (conn_id, sig_info) std::unordered_map>> sig2_peers; // (room (member_id, sig_info)) -private: void process_incoming_messages(); std::shared_ptr get_signaling_ptr(const signaling_packet* sp); - void send_signaling_packet(signaling_packet& sp, u32 addr, u16 port); + void send_signaling_packet(signaling_packet& sp, u32 addr, u16 port) const; void queue_signaling_packet(signaling_packet& sp, std::shared_ptr si, steady_clock::time_point wakeup_time); }; diff --git a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp index db04b407fa..7bac9f64c4 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp +++ b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp @@ -6,7 +6,6 @@ #include "Emu/Cell/lv2/sys_memory.h" #include "Emu/RSX/RSXThread.h" -#include #include "util/asm.hpp" namespace rsx @@ -54,7 +53,7 @@ namespace rsx return contextInfo->context_id; } - std::vector rsx_replay_thread::alloc_write_fifo(be_t /*context_id*/) + std::vector rsx_replay_thread::alloc_write_fifo(be_t /*context_id*/) const { // copy commands into fifo buffer // todo: could change rsx_command to just be values to avoid this loop, diff --git a/rpcs3/Emu/RSX/Capture/rsx_replay.h b/rpcs3/Emu/RSX/Capture/rsx_replay.h index 951388fbb7..2fc3d3d177 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_replay.h +++ b/rpcs3/Emu/RSX/Capture/rsx_replay.h @@ -213,7 +213,7 @@ namespace rsx void cpu_task() override; private: be_t allocate_context(); - std::vector alloc_write_fifo(be_t context_id); + std::vector alloc_write_fifo(be_t context_id) const; void apply_frame_state(be_t context_id, const frame_capture_data::replay_command& replay_cmd); }; } diff --git a/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp b/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp index 3d4914cbf9..46c7647c2f 100644 --- a/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/CgBinaryFragmentProgram.cpp @@ -44,7 +44,7 @@ void CgBinaryDisasm::AddCodeAsm(const std::string& code) m_arb_shader += (op_name + " " + m_dst_reg_name + FormatDisAsm(code) + ";" + "\n"); } -std::string CgBinaryDisasm::GetMask() +std::string CgBinaryDisasm::GetMask() const { std::string ret; ret.reserve(5); @@ -60,7 +60,7 @@ std::string CgBinaryDisasm::GetMask() return ret == "."sv || ret == ".xyzw"sv ? "" : (ret); } -std::string CgBinaryDisasm::AddRegDisAsm(u32 index, int fp16) +std::string CgBinaryDisasm::AddRegDisAsm(u32 index, int fp16) const { return std::string(fp16 ? "H" : "R") + std::to_string(index); } @@ -78,12 +78,12 @@ std::string CgBinaryDisasm::AddConstDisAsm() return fmt::format("{0x%08x(%g), 0x%08x(%g), 0x%08x(%g), 0x%08x(%g)}", x, std::bit_cast(x), y, std::bit_cast(y), z, std::bit_cast(z), w, std::bit_cast(w)); } -std::string CgBinaryDisasm::AddTexDisAsm() +std::string CgBinaryDisasm::AddTexDisAsm() const { return (std::string("TEX") + std::to_string(dst.tex_num)); } -std::string CgBinaryDisasm::GetCondDisAsm() +std::string CgBinaryDisasm::GetCondDisAsm() const { static constexpr std::string_view f = "xyzw"; diff --git a/rpcs3/Emu/RSX/CgBinaryProgram.h b/rpcs3/Emu/RSX/CgBinaryProgram.h index 52abbdd323..0c6554b89c 100644 --- a/rpcs3/Emu/RSX/CgBinaryProgram.h +++ b/rpcs3/Emu/RSX/CgBinaryProgram.h @@ -148,26 +148,26 @@ public: std::string GetGlslShader() const { return m_glsl_shader; } // FP functions - std::string GetMask(); + std::string GetMask() const; void AddCodeAsm(const std::string& code); - std::string AddRegDisAsm(u32 index, int fp16); + std::string AddRegDisAsm(u32 index, int fp16) const; std::string AddConstDisAsm(); - std::string AddTexDisAsm(); + std::string AddTexDisAsm() const; std::string FormatDisAsm(const std::string& code); - std::string GetCondDisAsm(); + std::string GetCondDisAsm() const; template std::string GetSrcDisAsm(T src); // VP functions - std::string GetMaskDisasm(bool is_sca); + std::string GetMaskDisasm(bool is_sca) const; std::string GetVecMaskDisasm(); std::string GetScaMaskDisasm(); std::string GetDSTDisasm(bool is_sca = false); std::string GetSRCDisasm(u32 n); - std::string GetTexDisasm(); - std::string GetCondDisasm(); - std::string AddAddrMaskDisasm(); + static std::string GetTexDisasm(); + std::string GetCondDisasm() const; + std::string AddAddrMaskDisasm() const; std::string AddAddrRegDisasm(); - u32 GetAddrDisasm(); + u32 GetAddrDisasm() const; std::string FormatDisasm(const std::string& code); void AddScaCodeDisasm(const std::string& code = ""); void AddVecCodeDisasm(const std::string& code = ""); @@ -195,7 +195,7 @@ public: delete[] m_buffer; } - std::string GetCgParamType(u32 type) const + static std::string GetCgParamType(u32 type) { switch (type) { @@ -367,7 +367,7 @@ public: } } - u32 GetData(const u32 d) const { return d << 16 | d >> 16; } + static u32 GetData(const u32 d) { return d << 16 | d >> 16; } void TaskFP(); void TaskVP(); }; diff --git a/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp b/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp index 85328bfeec..b82726dd30 100644 --- a/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp +++ b/rpcs3/Emu/RSX/CgBinaryVertexProgram.cpp @@ -16,7 +16,7 @@ void CgBinaryDisasm::AddVecCodeDisasm(const std::string& code) m_arb_shader += rsx_vp_vec_op_names[m_vec_opcode] + code + " "; } -std::string CgBinaryDisasm::GetMaskDisasm(bool is_sca) +std::string CgBinaryDisasm::GetMaskDisasm(bool is_sca) const { std::string ret; ret.reserve(5); @@ -207,7 +207,7 @@ std::string CgBinaryDisasm::FormatDisasm(const std::string& code) return fmt::replace_all(code, repl_list); } -std::string CgBinaryDisasm::GetCondDisasm() +std::string CgBinaryDisasm::GetCondDisasm() const { enum { @@ -304,7 +304,7 @@ void CgBinaryDisasm::AddCodeCondDisasm(const std::string& dst, const std::string } -std::string CgBinaryDisasm::AddAddrMaskDisasm() +std::string CgBinaryDisasm::AddAddrMaskDisasm() const { static constexpr std::string_view f = "xyzw"; return std::string(".") + f[d0.addr_swz]; @@ -316,7 +316,7 @@ std::string CgBinaryDisasm::AddAddrRegDisasm() return fmt::format("A%d", d0.addr_reg_sel_1) + AddAddrMaskDisasm(); } -u32 CgBinaryDisasm::GetAddrDisasm() +u32 CgBinaryDisasm::GetAddrDisasm() const { return (d2.iaddrh << 3) | d3.iaddrl; } diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.h b/rpcs3/Emu/RSX/Common/BufferUtils.h index 47013d3a4d..3524b44384 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.h +++ b/rpcs3/Emu/RSX/Common/BufferUtils.h @@ -1,7 +1,5 @@ #pragma once -#include - #include "Utilities/span.h" #include "../gcm_enums.h" diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp index b6b013c266..e0fd69f5f0 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp @@ -170,7 +170,7 @@ void FragmentProgramDecompiler::AddCode(const std::string& code) main.append(m_code_level, '\t') += Format(code) + "\n"; } -std::string FragmentProgramDecompiler::GetMask() +std::string FragmentProgramDecompiler::GetMask() const { std::string ret; ret.reserve(5); @@ -299,7 +299,7 @@ std::string FragmentProgramDecompiler::ClampValue(const std::string& code, u32 p return code; } -bool FragmentProgramDecompiler::DstExpectsSca() +bool FragmentProgramDecompiler::DstExpectsSca() const { int writes = 0; diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h index 8be95625a7..1d02a8326a 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h +++ b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h @@ -93,7 +93,7 @@ struct temp_register return false; } - std::string gather_r() + std::string gather_r() const { std::string h0 = "h" + std::to_string(real_index << 1); std::string h1 = "h" + std::to_string(real_index << 1 | 1); @@ -157,7 +157,7 @@ class FragmentProgramDecompiler std::array temp_registers; - std::string GetMask(); + std::string GetMask() const; void SetDst(std::string code, u32 flags = 0); void AddCode(const std::string& code); @@ -181,7 +181,7 @@ class FragmentProgramDecompiler /** * Returns true if the dst set is not a vector (i.e only a single component) */ - bool DstExpectsSca(); + bool DstExpectsSca() const; void AddCodeCond(const std::string& lhs, const std::string& rhs); std::string GetRawCond(); @@ -189,7 +189,7 @@ class FragmentProgramDecompiler template std::string GetSRC(T src); std::string BuildCode(); - u32 GetData(const u32 d) const { return d << 16 | d >> 16; } + static u32 GetData(const u32 d) { return d << 16 | d >> 16; } /** * Emits code if opcode is an SCT/SCB one and returns true, diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.h b/rpcs3/Emu/RSX/Common/ProgramStateCache.h index 6620a890d5..02bffe509b 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.h +++ b/rpcs3/Emu/RSX/Common/ProgramStateCache.h @@ -8,7 +8,6 @@ #include "Utilities/span.h" #include "util/fnv_hash.hpp" -#include #include enum class SHADER_TYPE diff --git a/rpcs3/Emu/RSX/Common/ShaderParam.h b/rpcs3/Emu/RSX/Common/ShaderParam.h index cdf98bb2b4..9814a11c50 100644 --- a/rpcs3/Emu/RSX/Common/ShaderParam.h +++ b/rpcs3/Emu/RSX/Common/ShaderParam.h @@ -99,12 +99,10 @@ struct ParamType bool SearchName(const std::string& name) const { - for (const auto& item : items) + return std::any_of(items.cbegin(), items.cend(), [&name](const auto& item) { - if (item.name == name) return true; - } - - return false; + return item.name == name; + }); } }; @@ -125,13 +123,11 @@ struct ParamArray bool HasParamTypeless(const ParamFlag flag, const std::string& name) { - for (const auto& param : params[flag]) + const auto& p = params[flag]; + return std::any_of(p.cbegin(), p.cend(), [&name](const auto& param) { - if (param.SearchName(name)) - return true; - } - - return false; + return param.SearchName(name); + }); } bool HasParam(const ParamFlag flag, const std::string& type, const std::string& name) diff --git a/rpcs3/Emu/RSX/Common/TextGlyphs.h b/rpcs3/Emu/RSX/Common/TextGlyphs.h index 4926808c04..7b7cbc890c 100644 --- a/rpcs3/Emu/RSX/Common/TextGlyphs.h +++ b/rpcs3/Emu/RSX/Common/TextGlyphs.h @@ -2,7 +2,6 @@ #include #include -#include #include #include diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index b79ceb9143..faabd301b3 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -370,10 +370,9 @@ namespace std::vector result; usz offset_in_src = 0; - u8 border_size = border ? (padded_row ? 1 : 4) : 0; + const u8 border_size = border ? (padded_row ? 1 : 4) : 0; u32 src_pitch_in_block; u32 full_height_in_block; - u32 slice_sz; for (unsigned layer = 0; layer < layer_count; layer++) { @@ -417,7 +416,7 @@ namespace full_height_in_block = rsx::next_pow2(current_subresource_layout.height_in_block + border_size + border_size); } - slice_sz = src_pitch_in_block * block_size_in_bytes * full_height_in_block * depth; + const u32 slice_sz = src_pitch_in_block * block_size_in_bytes * full_height_in_block * depth; current_subresource_layout.pitch_in_block = src_pitch_in_block; current_subresource_layout.data = gsl::span(texture_data_pointer + offset_in_src, slice_sz); diff --git a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp index 8f215c5510..66670cf9c4 100644 --- a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp @@ -3,9 +3,9 @@ #include "VertexProgramDecompiler.h" -#include +#include -std::string VertexProgramDecompiler::GetMask(bool is_sca) +std::string VertexProgramDecompiler::GetMask(bool is_sca) const { std::string ret; @@ -280,7 +280,7 @@ std::string VertexProgramDecompiler::GetCond() return "any(" + GetRawCond() + ")"; } -std::string VertexProgramDecompiler::GetOptionalBranchCond() +std::string VertexProgramDecompiler::GetOptionalBranchCond() const { std::string cond_operator = d3.brb_cond_true ? " != " : " == "; std::string cond = "(transform_branch_bits & (1u << " + std::to_string(d3.branch_index) + "))" + cond_operator + "0"; @@ -328,7 +328,7 @@ std::string VertexProgramDecompiler::AddCondReg() return m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "cc" + std::to_string(d0.cond_reg_sel_1), getFloatTypeName(4) + "(0.)"); } -u32 VertexProgramDecompiler::GetAddr() +u32 VertexProgramDecompiler::GetAddr() const { return (d2.iaddrh << 3) | d3.iaddrl; } diff --git a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h index 50b4b705bf..7e50d88df8 100644 --- a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h +++ b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.h @@ -1,9 +1,7 @@ #pragma once #include "Emu/RSX/RSXVertexProgram.h" #include -#include #include -#include #include "ShaderParam.h" /** @@ -66,8 +64,8 @@ struct VertexProgramDecompiler const RSXVertexProgram& m_prog; ParamArray m_parr; - std::string NotZeroPositive(const std::string& code); - std::string GetMask(bool is_sca); + static std::string NotZeroPositive(const std::string& code); + std::string GetMask(bool is_sca) const; std::string GetVecMask(); std::string GetScaMask(); std::string GetDST(bool is_sca = false); @@ -75,10 +73,10 @@ struct VertexProgramDecompiler std::string GetTex(); std::string GetRawCond(); std::string GetCond(); - std::string GetOptionalBranchCond(); //Conditional branch expression modified externally at runtime + std::string GetOptionalBranchCond() const; //Conditional branch expression modified externally at runtime std::string AddAddrReg(); std::string AddCondReg(); - u32 GetAddr(); + u32 GetAddr() const; std::string Format(const std::string& code); void AddCodeCond(const std::string& lhs, const std::string& rhs); diff --git a/rpcs3/Emu/RSX/Common/program_state_cache2.hpp b/rpcs3/Emu/RSX/Common/program_state_cache2.hpp index f433a61328..88606c5da0 100644 --- a/rpcs3/Emu/RSX/Common/program_state_cache2.hpp +++ b/rpcs3/Emu/RSX/Common/program_state_cache2.hpp @@ -3,7 +3,6 @@ #include "ProgramStateCache.h" #include "emmintrin.h" -#include "immintrin.h" #include "util/asm.hpp" template @@ -26,11 +25,10 @@ void program_state_cache::fill_fragment_constants_buffer(gsl::span if (!patch_table.is_empty()) { _mm_store_ps(tmp, _mm_castsi128_ps(shuffled_vector)); - bool patched; for (int i = 0; i < 4; ++i) { - patched = false; + bool patched = false; for (auto& e : patch_table.db) { //TODO: Use fp comparison with fabsf without hurting performance diff --git a/rpcs3/Emu/RSX/Common/ring_buffer_helper.h b/rpcs3/Emu/RSX/Common/ring_buffer_helper.h index b06b75c89f..a2ccbb0008 100644 --- a/rpcs3/Emu/RSX/Common/ring_buffer_helper.h +++ b/rpcs3/Emu/RSX/Common/ring_buffer_helper.h @@ -1,6 +1,6 @@ #pragma once -#include "util/logs.hpp" +#include "Utilities/StrFmt.h" #include "util/asm.hpp" /** diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index 9e1dbd6eb5..285451dfc4 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -21,12 +21,12 @@ namespace rsx template struct surface_store { - constexpr u32 get_aa_factor_u(surface_antialiasing aa_mode) + static constexpr u32 get_aa_factor_u(surface_antialiasing aa_mode) { return (aa_mode == surface_antialiasing::center_1_sample)? 1 : 2; } - constexpr u32 get_aa_factor_v(surface_antialiasing aa_mode) + static constexpr u32 get_aa_factor_v(surface_antialiasing aa_mode) { switch (aa_mode) { diff --git a/rpcs3/Emu/RSX/Common/texture_cache.cpp b/rpcs3/Emu/RSX/Common/texture_cache.cpp index 4a91f70784..95a396f941 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.cpp +++ b/rpcs3/Emu/RSX/Common/texture_cache.cpp @@ -201,7 +201,7 @@ namespace rsx return (protection_strat == section_protection_strategy::lock); } - bool buffered_section::sync() + bool buffered_section::sync() const { if (protection_strat == section_protection_strategy::lock || !locked) { diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 11cea58805..32234b4581 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -1947,6 +1947,7 @@ namespace rsx required_surface_height = tex_size / attributes.pitch; attributes.slice_h = required_surface_height / attributes.depth; break; + default: break; // TODO } if (options.is_compressed_format) @@ -3078,17 +3079,17 @@ namespace rsx return (num_flushes == 0u) ? 0.f : static_cast(m_misses_this_frame.load()) / num_flushes; } - u32 get_texture_upload_calls_this_frame() + u32 get_texture_upload_calls_this_frame() const { return m_texture_upload_calls_this_frame; } - u32 get_texture_upload_misses_this_frame() + u32 get_texture_upload_misses_this_frame() const { return m_texture_upload_misses_this_frame; } - u32 get_texture_upload_miss_percentage() + u32 get_texture_upload_miss_percentage() const { return (m_texture_upload_calls_this_frame)? (m_texture_upload_misses_this_frame * 100 / m_texture_upload_calls_this_frame) : 0; } diff --git a/rpcs3/Emu/RSX/Common/texture_cache_types.h b/rpcs3/Emu/RSX/Common/texture_cache_types.h index 17452fa874..36d1877f99 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache_types.h +++ b/rpcs3/Emu/RSX/Common/texture_cache_types.h @@ -95,10 +95,9 @@ namespace rsx AUDIT(deferred_flush()); if (cause == deferred_read) return read; - else if (cause == deferred_write) + if (cause == deferred_write) return write; - else - fmt::throw_exception("Unreachable"); + fmt::throw_exception("Unreachable"); } constexpr invalidation_cause defer() const @@ -106,10 +105,9 @@ namespace rsx AUDIT(!deferred_flush()); if (cause == read) return deferred_read; - else if (cause == write) + if (cause == write) return deferred_write; - else - fmt::throw_exception("Unreachable"); + fmt::throw_exception("Unreachable"); } constexpr invalidation_cause() : cause(invalid) {} diff --git a/rpcs3/Emu/RSX/Common/texture_cache_utils.h b/rpcs3/Emu/RSX/Common/texture_cache_utils.h index b1af0447a9..c73744b3bc 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache_utils.h +++ b/rpcs3/Emu/RSX/Common/texture_cache_utils.h @@ -5,6 +5,8 @@ #include "texture_cache_predictor.h" #include "TextureUtils.h" +#include "Emu/Memory/vm.h" + #include #include @@ -47,8 +49,8 @@ namespace rsx public: using value_type = section_storage_type; - using array_type = typename std::array; - using list_type = typename std::list; + using array_type = std::array; + using list_type = std::list; using size_type = u32; // Iterator @@ -133,7 +135,8 @@ namespace rsx // Constructor, Destructor ranged_storage_block_list() : m_data_it(m_data.end()), - m_array_idx(UINT32_MAX) + m_array_idx(UINT32_MAX), + m_capacity(0) {} // Iterator @@ -927,7 +930,7 @@ namespace rsx void protect(utils::protection new_prot, bool force = false); void protect(utils::protection prot, const std::pair& new_confirm); void unprotect(); - bool sync(); + bool sync() const; void discard(); const address_range& get_bounds(section_bounds bounds) const; diff --git a/rpcs3/Emu/RSX/GSFrameBase.h b/rpcs3/Emu/RSX/GSFrameBase.h index cc2d4ab2f9..8eb0c3ebbf 100644 --- a/rpcs3/Emu/RSX/GSFrameBase.h +++ b/rpcs3/Emu/RSX/GSFrameBase.h @@ -2,7 +2,6 @@ #include "util/types.hpp" #include "util/atomic.hpp" -#include #include #include "display.h" diff --git a/rpcs3/Emu/RSX/GSRender.cpp b/rpcs3/Emu/RSX/GSRender.cpp index 43e3122f62..1ee2c5ad2d 100644 --- a/rpcs3/Emu/RSX/GSRender.cpp +++ b/rpcs3/Emu/RSX/GSRender.cpp @@ -3,6 +3,7 @@ #include "GSRender.h" GSRender::GSRender() + : m_context(nullptr) { if (auto gs_frame = Emu.GetCallbacks().get_gs_frame()) { diff --git a/rpcs3/Emu/RSX/GSRender.h b/rpcs3/Emu/RSX/GSRender.h index 53322369e4..0d99decabd 100644 --- a/rpcs3/Emu/RSX/GSRender.h +++ b/rpcs3/Emu/RSX/GSRender.h @@ -31,5 +31,5 @@ public: void flip(const rsx::display_flip_info_t& info) override; - GSFrameBase* get_frame() { return m_frame; } + GSFrameBase* get_frame() const { return m_frame; } }; diff --git a/rpcs3/Emu/RSX/Overlays/overlay_animation.cpp b/rpcs3/Emu/RSX/Overlays/overlay_animation.cpp index 55c21f959f..d1055f433f 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_animation.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_animation.cpp @@ -3,8 +3,6 @@ #include "overlay_controls.h" #include "Emu/system_config.h" -#include - namespace rsx { namespace overlays diff --git a/rpcs3/Emu/RSX/Overlays/overlay_animation.h b/rpcs3/Emu/RSX/Overlays/overlay_animation.h index 547b2ce599..7f3b541e31 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_animation.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_animation.h @@ -30,7 +30,7 @@ namespace rsx f32 get_progress_ratio(u64 frame) const; template - T lerp(const T& a, const T& b, f32 t) const + static T lerp(const T& a, const T& b, f32 t) { return (a * (1.f - t)) + (b * t); } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_controls.h b/rpcs3/Emu/RSX/Overlays/overlay_controls.h index d518b6d9c0..1885d99040 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_controls.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_controls.h @@ -1072,7 +1072,7 @@ namespace rsx void add_entry(std::unique_ptr& entry); - int get_selected_index(); + int get_selected_index() const; std::u32string get_selected_item(); diff --git a/rpcs3/Emu/RSX/Overlays/overlay_fonts.cpp b/rpcs3/Emu/RSX/Overlays/overlay_fonts.cpp index ec6fa96e60..e1c1a19bf3 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_fonts.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_fonts.cpp @@ -92,7 +92,7 @@ namespace rsx } } - glyph_load_setup font::get_glyph_files(language_class class_) + glyph_load_setup font::get_glyph_files(language_class class_) const { glyph_load_setup result; result.font_names.push_back(font_name); diff --git a/rpcs3/Emu/RSX/Overlays/overlay_fonts.h b/rpcs3/Emu/RSX/Overlays/overlay_fonts.h index fcaea4c37e..0f1fd243f5 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_fonts.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_fonts.h @@ -4,7 +4,6 @@ #include "overlay_utils.h" #include -#include // STB_IMAGE_IMPLEMENTATION and STB_TRUETYPE_IMPLEMENTATION defined externally #include @@ -64,9 +63,9 @@ namespace rsx } codepage_cache; - language_class classify(char32_t page); - glyph_load_setup get_glyph_files(language_class class_); - codepage* initialize_codepage(char32_t page); + static language_class classify(char32_t codepage_id); + glyph_load_setup get_glyph_files(language_class class_) const; + codepage* initialize_codepage(char32_t codepage_id); public: font(const char* ttf_name, f32 size); @@ -80,7 +79,7 @@ namespace rsx std::pair get_char_offset(const char32_t* text, u16 max_length, u16 max_width = UINT16_MAX, bool wrap = false); bool matches(const char* name, int size) const { return font_name == name && static_cast(size_pt) == size; } - std::string_view get_name() const { return font_name; }; + std::string_view get_name() const { return font_name; } f32 get_size_pt() const { return size_pt; } f32 get_size_px() const { return size_px; } f32 get_em_size() const { return em_size; } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp b/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp index e18071b87b..52b46b5f0f 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp @@ -152,7 +152,7 @@ namespace rsx update_selection(); } - int list_view::get_selected_index() + int list_view::get_selected_index() const { return m_selected_entry; } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp index 8093808539..c4cc86b66c 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp @@ -662,7 +662,7 @@ namespace rsx } } - std::u32string osk_dialog::get_placeholder() + std::u32string osk_dialog::get_placeholder() const { const localized_string_id id = m_password_mode ? localized_string_id::RSX_OVERLAYS_OSK_DIALOG_ENTER_PASSWORD diff --git a/rpcs3/Emu/RSX/Overlays/overlay_osk.h b/rpcs3/Emu/RSX/Overlays/overlay_osk.h index a66c4072db..231026abcf 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_osk.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_osk.h @@ -104,7 +104,7 @@ namespace rsx void on_backspace(const std::u32string&); void on_enter(const std::u32string&); - std::u32string get_placeholder(); + std::u32string get_placeholder() const; std::pair get_cell_geometry(u32 index); diff --git a/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp b/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp index 7a711fc67f..4359a04540 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp @@ -2,14 +2,12 @@ #include "overlay_perf_metrics.h" #include "Emu/RSX/RSXThread.h" #include "Emu/Cell/SPUThread.h" -#include "Emu/Cell/RawSPUThread.h" #include "Emu/Cell/PPUThread.h" #include #include #include -#include "util/sysinfo.hpp" #include "util/cpu_stats.hpp" namespace rsx diff --git a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp index 644aa274ad..a3b39def6e 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp @@ -208,13 +208,11 @@ namespace rsx if (listSet && listSet->newData) { - std::unique_ptr new_stub; - const char* title = "Create New"; int id = resource_config::standard_image_resource::new_entry; - if (auto picon = +listSet->newData->icon) + if (const auto picon = +listSet->newData->icon) { if (picon->title) title = picon->title.get_ptr(); @@ -232,7 +230,7 @@ namespace rsx id = image_resource_id::raw_image; } - new_stub = std::make_unique(title, "Select to create a new entry", "", id, icon); + std::unique_ptr new_stub = std::make_unique(title, "Select to create a new entry", "", id, icon); m_list->add_entry(new_stub); } diff --git a/rpcs3/Emu/RSX/Overlays/overlays.cpp b/rpcs3/Emu/RSX/Overlays/overlays.cpp index 9379e95fd2..12c95e43d5 100644 --- a/rpcs3/Emu/RSX/Overlays/overlays.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlays.cpp @@ -113,6 +113,7 @@ namespace rsx case CELL_PAD_CTRL_START: button_id = pad_button::start; break; + default: break; } } else if (button.m_offset == CELL_PAD_BTN_OFFSET_DIGITAL2) @@ -143,6 +144,7 @@ namespace rsx case CELL_PAD_CTRL_R2: button_id = pad_button::R2; break; + default: break; } } @@ -222,7 +224,7 @@ namespace rsx } } - void overlay::refresh() + void overlay::refresh() const { if (auto rsxthr = rsx::get_current_renderer()) { diff --git a/rpcs3/Emu/RSX/Overlays/overlays.h b/rpcs3/Emu/RSX/Overlays/overlays.h index d47f785864..71877c740a 100644 --- a/rpcs3/Emu/RSX/Overlays/overlays.h +++ b/rpcs3/Emu/RSX/Overlays/overlays.h @@ -3,12 +3,10 @@ #include "overlay_controls.h" #include "Emu/IdManager.h" -#include "Emu/Cell/timers.hpp" #include "Utilities/mutex.h" #include "Utilities/Timer.h" -#include #include @@ -34,7 +32,7 @@ namespace rsx virtual void update() {} virtual compiled_resource get_compiled() = 0; - void refresh(); + void refresh() const; }; // Interactable UI element diff --git a/rpcs3/Emu/RSX/RSXFIFO.cpp b/rpcs3/Emu/RSX/RSXFIFO.cpp index 31b7423213..3bae392e03 100644 --- a/rpcs3/Emu/RSX/RSXFIFO.cpp +++ b/rpcs3/Emu/RSX/RSXFIFO.cpp @@ -15,7 +15,7 @@ namespace rsx m_iotable = &pctrl->iomap_table; } - void FIFO_control::sync_get() + void FIFO_control::sync_get() const { m_ctrl->get.release(m_internal_get); } @@ -38,7 +38,7 @@ namespace rsx } template - inline u32 FIFO_control::read_put() + inline u32 FIFO_control::read_put() const { if constexpr (!full) { diff --git a/rpcs3/Emu/RSX/RSXFIFO.h b/rpcs3/Emu/RSX/RSXFIFO.h index 522896270e..dc00ac1446 100644 --- a/rpcs3/Emu/RSX/RSXFIFO.h +++ b/rpcs3/Emu/RSX/RSXFIFO.h @@ -130,13 +130,15 @@ namespace rsx u32 get_pos() const { return m_internal_get; } u32 last_cmd() const { return m_cmd; } - void sync_get(); - u32 get_current_arg_ptr() const { return m_args_ptr; }; + void sync_get() const; + u32 get_current_arg_ptr() const { return m_args_ptr; } u32 get_remaining_args_count() const { return m_remaining_commands; } void inc_get(bool wait); void set_get(u32 get); void abort(); - template u32 read_put(); + + template + u32 read_put() const; void read(register_pair& data); inline bool read_unsafe(register_pair& data); diff --git a/rpcs3/Emu/RSX/RSXOffload.cpp b/rpcs3/Emu/RSX/RSXOffload.cpp index 0db638343e..ed911aa9c3 100644 --- a/rpcs3/Emu/RSX/RSXOffload.cpp +++ b/rpcs3/Emu/RSX/RSXOffload.cpp @@ -95,7 +95,7 @@ namespace rsx } // General transport - void dma_manager::copy(void *dst, std::vector& src, u32 length) + void dma_manager::copy(void *dst, std::vector& src, u32 length) const { if (length <= max_immediate_transfer_size || !g_cfg.video.multithreaded_rsx) { @@ -108,7 +108,7 @@ namespace rsx } } - void dma_manager::copy(void *dst, void *src, u32 length) + void dma_manager::copy(void *dst, void *src, u32 length) const { if (length <= max_immediate_transfer_size || !g_cfg.video.multithreaded_rsx) { @@ -127,7 +127,7 @@ namespace rsx if (!g_cfg.video.multithreaded_rsx) { write_index_array_for_non_indexed_non_native_primitive_to_buffer( - reinterpret_cast(dst), primitive, count); + static_cast(dst), primitive, count); } else { @@ -146,12 +146,12 @@ namespace rsx } // Synchronization - bool dma_manager::is_current_thread() const + bool dma_manager::is_current_thread() { return std::this_thread::get_id() == g_fxo->get().m_thread_id; } - bool dma_manager::sync() + bool dma_manager::sync() const { auto& _thr = g_fxo->get(); @@ -203,7 +203,7 @@ namespace rsx } // Fault recovery - utils::address_range dma_manager::get_fault_range(bool writing) const + utils::address_range dma_manager::get_fault_range(bool writing) { const auto m_current_job = ensure(g_fxo->get().m_current_job); diff --git a/rpcs3/Emu/RSX/RSXOffload.h b/rpcs3/Emu/RSX/RSXOffload.h index 0f9231b541..986c29bbd2 100644 --- a/rpcs3/Emu/RSX/RSXOffload.h +++ b/rpcs3/Emu/RSX/RSXOffload.h @@ -57,24 +57,24 @@ namespace rsx void init(); // General tranport - void copy(void *dst, std::vector& src, u32 length); - void copy(void *dst, void *src, u32 length); + void copy(void *dst, std::vector& src, u32 length) const; + void copy(void *dst, void *src, u32 length) const; // Vertex utilities - void emulate_as_indexed(void *dst, rsx::primitive_type primitive, u32 count); + static void emulate_as_indexed(void *dst, rsx::primitive_type primitive, u32 count); // Renderer callback - void backend_ctrl(u32 request_code, void* args); + static void backend_ctrl(u32 request_code, void* args); // Synchronization - bool is_current_thread() const; - bool sync(); + static bool is_current_thread(); + bool sync() const; void join(); void set_mem_fault_flag(); void clear_mem_fault_flag(); // Fault recovery - utils::address_range get_fault_range(bool writing) const; + static utils::address_range get_fault_range(bool writing); struct offload_thread; }; diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 048bee237f..c90bb05466 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -1159,7 +1159,7 @@ namespace rsx case rsx::surface_raster_type::swizzle: packed_render = true; break; - }; + } if (!packed_render) { diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index 240b5b4907..216ecaa467 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -9,7 +10,6 @@ #include "GCM.h" #include "rsx_cache.h" #include "RSXFIFO.h" -#include "RSXTexture.h" #include "RSXOffload.h" #include "RSXVertexProgram.h" #include "RSXFragmentProgram.h" @@ -22,7 +22,6 @@ #include "Capture/rsx_replay.h" #include "Emu/Cell/lv2/sys_rsx.h" -#include "Emu/Cell/timers.hpp" #include "Emu/IdManager.h" #include "Emu/system_config.h" @@ -426,7 +425,7 @@ namespace rsx std::unordered_map m_statistics_map; // Enables/disables the ZCULL unit - void set_active(class ::rsx::thread* ptimer, bool active, bool flush_queue); + void set_active(class ::rsx::thread* ptimer, bool state, bool flush_queue); // Checks current state of the unit and applies changes void check_state(class ::rsx::thread* ptimer, bool flush_queue); @@ -805,7 +804,7 @@ namespace rsx void run_FIFO(); public: - virtual void clear_surface(u32 /*arg*/) {}; + virtual void clear_surface(u32 /*arg*/) {} virtual void begin(); virtual void end(); virtual void execute_nop_draw(); diff --git a/rpcs3/Emu/RSX/rsx_cache.h b/rpcs3/Emu/RSX/rsx_cache.h index 6e1253807a..a65012ed0d 100644 --- a/rpcs3/Emu/RSX/rsx_cache.h +++ b/rpcs3/Emu/RSX/rsx_cache.h @@ -2,15 +2,12 @@ #include "Utilities/File.h" #include "Utilities/lockless.h" #include "Utilities/Thread.h" -#include "Emu/Memory/vm.h" -#include "gcm_enums.h" #include "Common/ProgramStateCache.h" #include "Emu/System.h" #include "Common/texture_cache_checker.h" #include "Overlays/Shaders/shader_loading_dialog.h" #include "rsx_utils.h" -#include #include #include @@ -61,10 +58,10 @@ namespace rsx backend_storage& m_storage; - std::string get_message(u32 index, u32 processed, u32 entry_count) + static std::string get_message(u32 index, u32 processed, u32 entry_count) { return fmt::format("%s pipeline object %u of %u", index == 0 ? "Loading" : "Compiling", processed, entry_count); - }; + } void load_shaders(uint nb_workers, unpacked_type& unpacked, std::string& directory_path, std::vector& entries, u32 entry_count, shader_loading_dialog* dlg) @@ -319,7 +316,7 @@ namespace rsx fs::write_file(pipeline_path, fs::rewrite, &data, sizeof(data)); } - RSXVertexProgram load_vp_raw(u64 program_hash) + RSXVertexProgram load_vp_raw(u64 program_hash) const { RSXVertexProgram vp = {}; diff --git a/rpcs3/Emu/RSX/rsx_decode.h b/rpcs3/Emu/RSX/rsx_decode.h index b61ca242d0..19820dba79 100644 --- a/rpcs3/Emu/RSX/rsx_decode.h +++ b/rpcs3/Emu/RSX/rsx_decode.h @@ -4,7 +4,6 @@ #include "Utilities/BitField.h" #include "Utilities/StrFmt.h" #include -#include #include #include "gcm_enums.h" #include "rsx_utils.h" diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index a51fe90af2..29a8fc0952 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -2717,6 +2717,7 @@ namespace rsx } // TODO: implement this as virtual function: rsx::thread::init_methods() or something + // TODO: this is unused static const bool s_methods_init = []() -> bool { using namespace method_detail; diff --git a/rpcs3/Emu/RSX/rsx_methods.h b/rpcs3/Emu/RSX/rsx_methods.h index 70da4d9e98..37b1fcdb51 100644 --- a/rpcs3/Emu/RSX/rsx_methods.h +++ b/rpcs3/Emu/RSX/rsx_methods.h @@ -1,17 +1,12 @@ #pragma once #include -#include #include -#include -#include -#include "GCM.h" #include "rsx_decode.h" #include "RSXTexture.h" #include "rsx_vertex_data.h" #include "rsx_utils.h" -#include "Utilities/geometry.h" #include "Emu/Cell/timers.hpp" namespace rsx @@ -1604,7 +1599,7 @@ namespace rsx return decode().output_offset(); } - u32 nv0039_output_location() + u32 nv0039_output_location() const { return decode().output_dma(); } diff --git a/rpcs3/Emu/RSX/rsx_utils.cpp b/rpcs3/Emu/RSX/rsx_utils.cpp index cdaeb189fd..27e780be4a 100644 --- a/rpcs3/Emu/RSX/rsx_utils.cpp +++ b/rpcs3/Emu/RSX/rsx_utils.cpp @@ -2,7 +2,6 @@ #include "rsx_utils.h" #include "rsx_methods.h" #include "Emu/RSX/GCM.h" -#include "Common/BufferUtils.h" #include "Overlays/overlays.h" #ifdef _MSC_VER @@ -34,7 +33,7 @@ namespace rsx const u8 *src, AVPixelFormat src_format, int src_width, int src_height, int src_pitch, int src_slice_h, bool bilinear) { std::unique_ptr sws(sws_getContext(src_width, src_height, src_format, - dst_width, dst_height, dst_format, bilinear ? SWS_FAST_BILINEAR : SWS_POINT, NULL, NULL, NULL), sws_freeContext); + dst_width, dst_height, dst_format, bilinear ? SWS_FAST_BILINEAR : SWS_POINT, nullptr, nullptr, nullptr), sws_freeContext); sws_scale(sws.get(), &src, &src_pitch, 0, src_slice_h, &dst, &dst_pitch); } diff --git a/rpcs3/Emu/RSX/rsx_utils.h b/rpcs3/Emu/RSX/rsx_utils.h index 01acca7d07..4675ff810f 100644 --- a/rpcs3/Emu/RSX/rsx_utils.h +++ b/rpcs3/Emu/RSX/rsx_utils.h @@ -51,16 +51,16 @@ namespace rsx public: void add_ref() { - ref_count++; + ++ref_count; idle_time = 0; } void release() { - ref_count--; + --ref_count; } - bool has_refs() + bool has_refs() const { return (ref_count > 0); } @@ -161,7 +161,7 @@ namespace rsx u32 resolution_y = 720; // Y RES atomic_t state = 0; // 1 after cellVideoOutConfigure was called - u32 get_compatible_gcm_format() + u32 get_compatible_gcm_format() const { switch (format) { @@ -176,7 +176,7 @@ namespace rsx } } - u8 get_bpp() + u8 get_bpp() const { switch (format) { diff --git a/rpcs3/Emu/RSX/rsx_vertex_data.h b/rpcs3/Emu/RSX/rsx_vertex_data.h index fc10eabe13..76acf24e71 100644 --- a/rpcs3/Emu/RSX/rsx_vertex_data.h +++ b/rpcs3/Emu/RSX/rsx_vertex_data.h @@ -16,7 +16,7 @@ private: auto decode_reg() const { - const typename rsx::registers_decoder::decoded_type + const rsx::registers_decoder::decoded_type decoded_value(registers[NV4097_SET_VERTEX_DATA_ARRAY_FORMAT + index]); return decoded_value; } @@ -74,7 +74,7 @@ struct push_buffer_vertex_info } } - u8 get_vertex_size_in_dwords(vertex_base_type type) + u8 get_vertex_size_in_dwords(vertex_base_type type) const { //NOTE: Types are always provided to fit into 32-bits //i.e no less than 4 8-bit values and no less than 2 16-bit values diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index e16af25925..2b7f1c2057 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -592,7 +592,7 @@ std::string Emulator::GetBackgroundPicturePath() const return path; } -std::string Emulator::PPUCache() const +std::string Emulator::PPUCache() { auto& _main = g_fxo->get(); @@ -865,8 +865,8 @@ std::string Emulator::GetExeDir() wchar_t buffer[32767]; GetModuleFileNameW(nullptr, buffer, sizeof(buffer)/2); - std::string path_to_exe = wchar_to_utf8(buffer); - usz last = path_to_exe.find_last_of("\\"); + const std::string path_to_exe = wchar_to_utf8(buffer); + const usz last = path_to_exe.find_last_of('\\'); return last == std::string::npos ? std::string("") : path_to_exe.substr(0, last+1); } #endif @@ -2222,7 +2222,7 @@ void Emulator::ConfigureLogs() was_silenced = silenced; } -void Emulator::ConfigurePPUCache() +void Emulator::ConfigurePPUCache() const { auto& _main = g_fxo->get(); diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index dc3927523f..c3ce87e6ce 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -211,12 +211,12 @@ public: std::string GetBackgroundPicturePath() const; - u64 GetPauseTime() + u64 GetPauseTime() const { return m_pause_amend_time; } - std::string PPUCache() const; + static std::string PPUCache(); game_boot_result BootGame(const std::string& path, const std::string& title_id = "", bool direct = false, bool add_only = false, bool force_global_config = false); bool BootRsxCapture(const std::string& path); @@ -247,7 +247,7 @@ public: void Stop(bool restart = false); void Restart() { Stop(true); } bool Quit(bool force_quit); - void CleanUp(); + static void CleanUp(); bool IsRunning() const { return m_state == system_state::running; } bool IsPaused() const { return m_state >= system_state::paused; } // ready is also considered paused by this function @@ -267,7 +267,7 @@ public: static u32 GetMaxThreads(); static void ConfigureLogs(); - void ConfigurePPUCache(); + void ConfigurePPUCache() const; std::set GetGameDirs() const; diff --git a/rpcs3/Emu/VFS.cpp b/rpcs3/Emu/VFS.cpp index 3547958723..575427e37e 100644 --- a/rpcs3/Emu/VFS.cpp +++ b/rpcs3/Emu/VFS.cpp @@ -493,6 +493,7 @@ std::string vfs::escape(std::string_view name, bool escape_slash) break; } + default: break; } result += c; diff --git a/rpcs3/Emu/perf_meter.cpp b/rpcs3/Emu/perf_meter.cpp index f07ff0ac0b..d570394066 100644 --- a/rpcs3/Emu/perf_meter.cpp +++ b/rpcs3/Emu/perf_meter.cpp @@ -20,7 +20,7 @@ void perf_stat_base::push(u64 ns[66]) noexcept } } -void perf_stat_base::print(const char* name) noexcept +void perf_stat_base::print(const char* name) const noexcept { if (u64 num_total = m_log[0].load()) { diff --git a/rpcs3/Emu/perf_meter.hpp b/rpcs3/Emu/perf_meter.hpp index 99ffce1d9a..a936e13994 100644 --- a/rpcs3/Emu/perf_meter.hpp +++ b/rpcs3/Emu/perf_meter.hpp @@ -3,7 +3,6 @@ #include "util/types.hpp" #include "util/logs.hpp" #include "system_config.h" -#include "IdManager.h" #include #include @@ -39,13 +38,13 @@ class perf_stat_base protected: // Print accumulated values - void print(const char* name) noexcept; + void print(const char* name) const noexcept; // Accumulate values from a thread void push(u64 ns[66]) noexcept; // Get end time; accumulate value to the TLS - static void push(u64 ns[66], u64 start_time, const char* name) noexcept; + static void push(u64 data[66], u64 start_time, const char* name) noexcept; // Register TLS storage for stats static void add(u64 ns[66], const char* name) noexcept; diff --git a/rpcs3/Emu/system_config.cpp b/rpcs3/Emu/system_config.cpp index bf79ffbf60..d608f0ac60 100644 --- a/rpcs3/Emu/system_config.cpp +++ b/rpcs3/Emu/system_config.cpp @@ -7,7 +7,7 @@ cfg_root g_cfg{}; -bool cfg_root::node_core::has_rtm() const +bool cfg_root::node_core::has_rtm() { return utils::has_rtm(); } diff --git a/rpcs3/Emu/system_config.h b/rpcs3/Emu/system_config.h index cbeb5eaa34..a407cdb9a1 100644 --- a/rpcs3/Emu/system_config.h +++ b/rpcs3/Emu/system_config.h @@ -14,7 +14,7 @@ struct cfg_root : cfg::node { private: /** We don't wanna include the sysinfo header here */ - bool has_rtm() const; + static bool has_rtm(); public: node_core(cfg::node* _this) : cfg::node(_this, "Core") {} diff --git a/rpcs3/Loader/TAR.cpp b/rpcs3/Loader/TAR.cpp index 966e6b9283..254bad0e96 100644 --- a/rpcs3/Loader/TAR.cpp +++ b/rpcs3/Loader/TAR.cpp @@ -9,8 +9,6 @@ #include "util/asm.hpp" -#include -#include #include LOG_CHANNEL(tar_log, "TAR"); diff --git a/rpcs3/rpcs3_version.h b/rpcs3/rpcs3_version.h index 729c962288..bd22fc0943 100644 --- a/rpcs3/rpcs3_version.h +++ b/rpcs3/rpcs3_version.h @@ -1,6 +1,5 @@ #pragma once #include -#include #include namespace rpcs3 diff --git a/rpcs3/util/asm.hpp b/rpcs3/util/asm.hpp index ab4170061e..77244dab84 100644 --- a/rpcs3/util/asm.hpp +++ b/rpcs3/util/asm.hpp @@ -1,6 +1,7 @@ #pragma once #include "util/types.hpp" +#include extern bool g_use_rtm; extern u64 g_rtm_tx_limit1; @@ -113,7 +114,7 @@ namespace utils const void* ptr = reinterpret_cast(value); #ifdef _MSC_VER - return _mm_prefetch(reinterpret_cast(ptr), 2); + return _mm_prefetch(static_cast(ptr), 2); #else return __builtin_prefetch(ptr, 0, 2); #endif @@ -128,7 +129,7 @@ namespace utils } #ifdef _MSC_VER - return _mm_prefetch(reinterpret_cast(ptr), 3); + return _mm_prefetch(static_cast(ptr), 3); #else return __builtin_prefetch(ptr, 0, 3); #endif diff --git a/rpcs3/util/atomic.cpp b/rpcs3/util/atomic.cpp index b47c575e68..e5da5a17e3 100644 --- a/rpcs3/util/atomic.cpp +++ b/rpcs3/util/atomic.cpp @@ -29,10 +29,6 @@ namespace utils #include "Utilities/StrFmt.h" #include -#include -#include -#include -#include #include #include #include @@ -126,6 +122,7 @@ static NEVER_INLINE bool ptr_cmp(const void* data, u32 _size, u128 old128, u128 new_value = stx::se_storage::swap(new_value); old_value = stx::se_storage::swap(old_value); mask = stx::se_storage::swap(mask); + break; } default: { diff --git a/rpcs3/util/atomic.hpp b/rpcs3/util/atomic.hpp index 1eeddab5ee..27242ec3a7 100644 --- a/rpcs3/util/atomic.hpp +++ b/rpcs3/util/atomic.hpp @@ -312,7 +312,7 @@ private: template friend class atomic_wait::list; - static void wait(const void* data, u32 size, u128 old128, u64 timeout, u128 mask128, atomic_wait::info* extension = nullptr); + static void wait(const void* data, u32 size, u128 old_value, u64 timeout, u128 mask, atomic_wait::info* ext = nullptr); static void notify_one(const void* data, u32 size, u128 mask128); static void notify_all(const void* data, u32 size, u128 mask128); diff --git a/rpcs3/util/cereal.hpp b/rpcs3/util/cereal.hpp index 28329f72ec..378a119150 100644 --- a/rpcs3/util/cereal.hpp +++ b/rpcs3/util/cereal.hpp @@ -6,4 +6,4 @@ template std::string cereal_serialize(const T&); template -void cereal_deserialize(T& out, const std::string& data); +void cereal_deserialize(T& data, const std::string& src); diff --git a/rpcs3/util/cpu_stats.cpp b/rpcs3/util/cpu_stats.cpp index 8cda87a141..fdfb8f999f 100644 --- a/rpcs3/util/cpu_stats.cpp +++ b/rpcs3/util/cpu_stats.cpp @@ -127,10 +127,10 @@ namespace utils { #ifdef _WIN32 // first determine the id of the current process - DWORD const id = GetCurrentProcessId(); + const DWORD id = GetCurrentProcessId(); // then get a process list snapshot. - HANDLE const snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + const HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); // initialize the process entry structure. PROCESSENTRY32 entry = {0}; diff --git a/rpcs3/util/fifo_mutex.hpp b/rpcs3/util/fifo_mutex.hpp index 37a18004c5..cf2d9b0d0e 100644 --- a/rpcs3/util/fifo_mutex.hpp +++ b/rpcs3/util/fifo_mutex.hpp @@ -2,7 +2,6 @@ #include "util/types.hpp" #include "util/atomic.hpp" -#include // Mutex that tries to maintain the order of acquisition class fifo_mutex diff --git a/rpcs3/util/logs.hpp b/rpcs3/util/logs.hpp index 1c21872b47..51feee506a 100644 --- a/rpcs3/util/logs.hpp +++ b/rpcs3/util/logs.hpp @@ -1,6 +1,5 @@ #pragma once // No BOM and only basic ASCII in this header, or a neko will die -#include #include #include #include diff --git a/rpcs3/util/shared_ptr.hpp b/rpcs3/util/shared_ptr.hpp index 8d1b3f47cd..0b420c8faf 100644 --- a/rpcs3/util/shared_ptr.hpp +++ b/rpcs3/util/shared_ptr.hpp @@ -119,8 +119,7 @@ namespace stx template explicit constexpr shared_data(Args&&... args) noexcept - : m_ctr{} - , m_data(std::forward(args)...) + : m_data(std::forward(args)...) { } }; @@ -1197,7 +1196,7 @@ namespace stx template void wait(const volatile void* value, atomic_wait_timeout timeout = atomic_wait_timeout::inf) { - m_val.template wait(reinterpret_cast(value) << c_ref_size, c_ptr_mask, timeout); + m_val.wait(reinterpret_cast(value) << c_ref_size, c_ptr_mask, timeout); } void notify_one() diff --git a/rpcs3/util/slow_mutex.hpp b/rpcs3/util/slow_mutex.hpp index 1dfdabd2ee..c93639e64b 100644 --- a/rpcs3/util/slow_mutex.hpp +++ b/rpcs3/util/slow_mutex.hpp @@ -3,7 +3,6 @@ #include "util/types.hpp" #include "util/atomic.hpp" #include "Utilities/StrFmt.h" -#include // Pessimistic mutex for slow operation, does not spin wait, occupies only one byte class slow_mutex diff --git a/rpcs3/util/sysinfo.cpp b/rpcs3/util/sysinfo.cpp index bd5487c716..6bda0f3513 100755 --- a/rpcs3/util/sysinfo.cpp +++ b/rpcs3/util/sysinfo.cpp @@ -294,7 +294,7 @@ std::string utils::get_OS_version() if (has_sp) { WideCharToMultiByte(CP_UTF8, NULL, service_pack.Buffer, service_pack.Length, - (LPSTR) holder.data(), static_cast(holder.size()), NULL, NULL); + (LPSTR) holder.data(), static_cast(holder.size()), nullptr, nullptr); } fmt::append(output, diff --git a/rpcs3/util/vm_native.cpp b/rpcs3/util/vm_native.cpp index 13fe2548e1..c9369e7aca 100644 --- a/rpcs3/util/vm_native.cpp +++ b/rpcs3/util/vm_native.cpp @@ -259,10 +259,9 @@ namespace utils shm::shm(u32 size, u32 flags) : m_size(utils::align(size, 0x10000)) , m_flags(flags) - , m_ptr(nullptr) { #ifdef _WIN32 - m_handle = ::CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_EXECUTE_READWRITE, 0, m_size, NULL); + m_handle = ::CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_EXECUTE_READWRITE, 0, m_size, nullptr); ensure(m_handle != INVALID_HANDLE_VALUE); #elif __linux__ m_file = -1;