diff --git a/3rdparty/asmjit/asmjit.vcxproj b/3rdparty/asmjit/asmjit.vcxproj
index e6ada4aaf3..7165eaef97 100644
--- a/3rdparty/asmjit/asmjit.vcxproj
+++ b/3rdparty/asmjit/asmjit.vcxproj
@@ -198,6 +198,7 @@
ASMJIT_STATIC;ASMJIT_NO_DEPRECATED;%(PreprocessorDefinitions)
MaxSpeed
MaxSpeed
+ TurnOffAllWarnings
diff --git a/3rdparty/curl/libcurl.vcxproj b/3rdparty/curl/libcurl.vcxproj
index 5056136351..503a4d1347 100644
--- a/3rdparty/curl/libcurl.vcxproj
+++ b/3rdparty/curl/libcurl.vcxproj
@@ -47,7 +47,7 @@
HAVE_SNI;NDEBUG;BUILDING_LIBCURL;CURL_STATICLIB;USE_WOLFSSL;NO_MD4;WOLFSSL_USER_SETTINGS;USE_IPV6;SIZEOF_LONG=4;SIZEOF_LONG_LONG=8;%(PreprocessorDefinitions)
true
true
- Level4
+ TurnOffAllWarnings
NDEBUG;%(PreprocessorDefinitions)
diff --git a/3rdparty/wolfssl/extra/win32/user_settings.h b/3rdparty/wolfssl/extra/win32/user_settings.h
index 016a7f20c6..eb81754c35 100644
--- a/3rdparty/wolfssl/extra/win32/user_settings.h
+++ b/3rdparty/wolfssl/extra/win32/user_settings.h
@@ -25,9 +25,13 @@
#define HAVE_ONE_TIME_AUTH
#define HAVE_CHACHA
#define HAVE_HASHDRBG
+#ifndef HAVE_SNI
#define HAVE_SNI
+#endif
#define HAVE_ENCRYPT_THEN_MAC
+#ifndef NO_MD4
#define NO_MD4
+#endif
#define WC_NO_ASYNC_THREADING
#define WC_NO_HARDEN
#define HAVE_WRITE_DUP
diff --git a/3rdparty/wolfssl/wolfssl.vcxproj b/3rdparty/wolfssl/wolfssl.vcxproj
index 2538183e51..629dc1e687 100644
--- a/3rdparty/wolfssl/wolfssl.vcxproj
+++ b/3rdparty/wolfssl/wolfssl.vcxproj
@@ -66,7 +66,7 @@
true
- Level3
+ TurnOffAllWarnings
ProgramDatabase
diff --git a/Utilities/Config.cpp b/Utilities/Config.cpp
index d28b019786..19f2e7577b 100644
--- a/Utilities/Config.cpp
+++ b/Utilities/Config.cpp
@@ -50,6 +50,17 @@ namespace cfg
return false;
}
+ bool _base::save(std::string_view cfg_name) const
+ {
+ if (fs::pending_file cfg_file(cfg_name); !!cfg_file.file)
+ {
+ cfg_file.file.write(to_string());
+ return cfg_file.commit();
+ }
+
+ return false;
+ }
+
// Emit YAML
static void encode(YAML::Emitter& out, const class _base& rhs);
diff --git a/Utilities/Config.h b/Utilities/Config.h
index ee22a20d96..84b1f02e80 100644
--- a/Utilities/Config.h
+++ b/Utilities/Config.h
@@ -101,6 +101,8 @@ namespace cfg
// Set multiple values. Implementation-specific, optional.
virtual bool from_list(std::vector&&);
+
+ bool save(std::string_view cfg_name) const;
};
// Config tree node which contains another nodes
diff --git a/Utilities/File.cpp b/Utilities/File.cpp
index 2e21d0e9fd..a766156e8a 100644
--- a/Utilities/File.cpp
+++ b/Utilities/File.cpp
@@ -227,10 +227,17 @@ namespace fs
{
}
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4646)
+#endif
[[noreturn]] stat_t file_base::get_stat()
{
fmt::throw_exception("fs::file::get_stat() not supported.");
}
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
void file_base::sync()
{
diff --git a/Utilities/File.h b/Utilities/File.h
index b3ac96698f..4718236f12 100644
--- a/Utilities/File.h
+++ b/Utilities/File.h
@@ -495,7 +495,8 @@ namespace fs
{
std::basic_string result;
result.resize(size() / sizeof(T));
- if (seek(0), !read(result, result.size(), file, func, line, col)) xfail({line, col, file, func});
+ seek(0);
+ if (!read(result, result.size(), file, func, line, col)) xfail({line, col, file, func});
return result;
}
@@ -509,7 +510,8 @@ namespace fs
{
std::vector result;
result.resize(size() / sizeof(T));
- if (seek(0), !read(result, result.size(), file, func, line, col)) xfail({line, col, file, func});
+ seek(0);
+ if (!read(result, result.size(), file, func, line, col)) xfail({line, col, file, func});
return result;
}
diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp
index 84df804cbf..da1cc732b3 100644
--- a/Utilities/StrFmt.cpp
+++ b/Utilities/StrFmt.cpp
@@ -21,9 +21,10 @@ std::string wchar_to_utf8(std::wstring_view src)
{
#ifdef _WIN32
std::string utf8_string;
- const auto tmp_size = WideCharToMultiByte(CP_UTF8, 0, src.data(), src.size(), nullptr, 0, nullptr, nullptr);
+ const int size = ::narrow(src.size());
+ const auto tmp_size = WideCharToMultiByte(CP_UTF8, 0, src.data(), size, nullptr, 0, nullptr, nullptr);
utf8_string.resize(tmp_size);
- WideCharToMultiByte(CP_UTF8, 0, src.data(), src.size(), utf8_string.data(), tmp_size, nullptr, nullptr);
+ WideCharToMultiByte(CP_UTF8, 0, src.data(), size, utf8_string.data(), tmp_size, nullptr, nullptr);
return utf8_string;
#else
std::wstring_convert, wchar_t> converter{};
@@ -31,7 +32,10 @@ std::string wchar_to_utf8(std::wstring_view src)
#endif
}
-#ifndef _MSC_VER
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4996)
+#else
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
@@ -46,7 +50,9 @@ std::u16string utf8_to_utf16(std::string_view src)
std::wstring_convert, char16_t> converter{};
return converter.from_bytes(src.data());
}
-#ifndef _MSC_VER
+#ifdef _MSC_VER
+#pragma warning(pop)
+#else
#pragma GCC diagnostic pop
#endif
@@ -54,9 +60,10 @@ std::wstring utf8_to_wchar(std::string_view src)
{
#ifdef _WIN32
std::wstring wchar_string;
- const auto tmp_size = MultiByteToWideChar(CP_UTF8, 0, src.data(), src.size(), nullptr, 0);
+ const int size = ::narrow(src.size());
+ const auto tmp_size = MultiByteToWideChar(CP_UTF8, 0, src.data(), size, nullptr, 0);
wchar_string.resize(tmp_size);
- MultiByteToWideChar(CP_UTF8, 0, src.data(), src.size(), wchar_string.data(), tmp_size);
+ MultiByteToWideChar(CP_UTF8, 0, src.data(), size, wchar_string.data(), tmp_size);
return wchar_string;
#else
std::wstring_convert, wchar_t> converter{};
diff --git a/Utilities/bin_patch.cpp b/Utilities/bin_patch.cpp
index 3162e0687a..1e61a57734 100644
--- a/Utilities/bin_patch.cpp
+++ b/Utilities/bin_patch.cpp
@@ -1031,12 +1031,12 @@ static usz apply_modification(std::basic_string& applied, patch_engine::pat
}
case patch_type::utf8:
{
- memory_size = p.original_value.size();
+ memory_size = ::size32(p.original_value);
break;
}
case patch_type::c_utf8:
{
- memory_size = utils::add_saturate(p.original_value.size(), 1);
+ memory_size = utils::add_saturate(::size32(p.original_value), 1);
break;
}
case patch_type::move_file:
diff --git a/rpcs3/Crypto/aes.cpp b/rpcs3/Crypto/aes.cpp
index 2294ccfa57..034e192e2c 100644
--- a/rpcs3/Crypto/aes.cpp
+++ b/rpcs3/Crypto/aes.cpp
@@ -942,10 +942,9 @@ void generate_subkey(aes_context *ctx, unsigned char *K1, unsigned char *K2)
}
}
-void padding (unsigned char *lastb, unsigned char *pad, int length)
+void padding(unsigned char *lastb, unsigned char *pad, size_t length)
{
- int i;
- for (i = 0; i < 16; i++)
+ for (unsigned int i = 0; i < 16; i++)
{
if (i < length)
pad[i] = lastb[i];
@@ -956,14 +955,14 @@ void padding (unsigned char *lastb, unsigned char *pad, int length)
}
}
-void aes_cmac(aes_context *ctx, int length, unsigned char *input, unsigned char *output)
+void aes_cmac(aes_context *ctx, size_t length, unsigned char *input, unsigned char *output)
{
unsigned char X[16], Y[16], M_last[16], padded[16];
unsigned char K1[16], K2[16];
- int n, i, flag;
+ int i, flag;
generate_subkey(ctx, K1, K2);
- n = (length + 15) / 16;
+ size_t n = (length + 15) / 16;
if (n == 0)
{
n = 1;
@@ -984,7 +983,7 @@ void aes_cmac(aes_context *ctx, int length, unsigned char *input, unsigned char
}
for (i = 0; i < 16; i++) X[i] = 0;
- for (i = 0; i < n - 1; i++)
+ for (size_t i = 0; i < n - 1; i++)
{
xor_128(X, &input[16*i], Y);
aes_crypt_ecb(ctx, AES_ENCRYPT, Y, X);
diff --git a/rpcs3/Crypto/aes.h b/rpcs3/Crypto/aes.h
index 807a50cbc4..42e20e664d 100644
--- a/rpcs3/Crypto/aes.h
+++ b/rpcs3/Crypto/aes.h
@@ -172,7 +172,7 @@ int aes_crypt_ctr( aes_context *ctx,
const unsigned char *input,
unsigned char *output );
-void aes_cmac(aes_context *ctx, int length, unsigned char *input, unsigned char *output);
+void aes_cmac(aes_context *ctx, size_t length, unsigned char *input, unsigned char *output);
#ifdef __cplusplus
}
diff --git a/rpcs3/Crypto/unedat.cpp b/rpcs3/Crypto/unedat.cpp
index e8a3b3cff5..d7aaf37f06 100644
--- a/rpcs3/Crypto/unedat.cpp
+++ b/rpcs3/Crypto/unedat.cpp
@@ -66,7 +66,7 @@ void generate_hash(int hash_mode, int version, unsigned char *hash_final, unsign
};
}
-bool decrypt(int hash_mode, int crypto_mode, int version, unsigned char *in, unsigned char *out, int length, unsigned char *key, unsigned char *iv, unsigned char *hash, unsigned char *test_hash)
+bool decrypt(int hash_mode, int crypto_mode, int version, unsigned char *in, unsigned char *out, usz length, unsigned char *key, unsigned char *iv, unsigned char *hash, unsigned char *test_hash)
{
// Setup buffers for key, iv and hash.
unsigned char key_final[0x10] = {};
diff --git a/rpcs3/Emu/Cell/Common.h b/rpcs3/Emu/Cell/Common.h
index 14fd22550f..19e6433fb9 100644
--- a/rpcs3/Emu/Cell/Common.h
+++ b/rpcs3/Emu/Cell/Common.h
@@ -176,7 +176,7 @@ inline struct ppu_frsqrte_lut_t
if (expv == 0) // ±INF on zero/denormal, not accurate
{
- data[i] = 0x7ff0'0000 | (sign << 31);
+ data[i] = static_cast(0x7ff0'0000 | (sign << 31));
}
else if (expv == 0x7ff)
{
@@ -194,7 +194,7 @@ inline struct ppu_frsqrte_lut_t
// ((MAN_BITS(b) >> 49) & 7ull) + (!(EXP_BITS(b) & 1) << 3)
const u64 idx = 8 ^ (i & 0xf);
- data[i] = ppu_frsqrte_mantissas[idx] | exp;
+ data[i] = static_cast(ppu_frsqrte_mantissas[idx] | exp);
}
}
}
diff --git a/rpcs3/Emu/Cell/Modules/cellCamera.cpp b/rpcs3/Emu/Cell/Modules/cellCamera.cpp
index 76a59c11c4..020878e933 100644
--- a/rpcs3/Emu/Cell/Modules/cellCamera.cpp
+++ b/rpcs3/Emu/Cell/Modules/cellCamera.cpp
@@ -7,6 +7,8 @@
#include "Emu/Cell/lv2/sys_event.h"
#include "Emu/IdManager.h"
+#include
+
LOG_CHANNEL(cellCamera);
template <>
@@ -326,7 +328,7 @@ u32 get_buffer_size_by_format(s32 format, s32 width, s32 height)
break;
}
- return width * height * bytes_per_pixel;
+ return ::narrow(static_cast(std::ceil(width * height * bytes_per_pixel)));
}
diff --git a/rpcs3/Emu/Cell/Modules/cellFs.cpp b/rpcs3/Emu/Cell/Modules/cellFs.cpp
index b94c230031..fcc0810b3e 100644
--- a/rpcs3/Emu/Cell/Modules/cellFs.cpp
+++ b/rpcs3/Emu/Cell/Modules/cellFs.cpp
@@ -385,7 +385,7 @@ error_code cellFsGetFreeSize(ppu_thread& ppu, vm::cptr path, vm::ptr
}
*block_count = *avail / *_block_size;
- *block_size = *_block_size;
+ *block_size = ::narrow(*_block_size);
}
return CELL_OK;
diff --git a/rpcs3/Emu/Cell/PPUAnalyser.cpp b/rpcs3/Emu/Cell/PPUAnalyser.cpp
index d3ba3e142f..9e6ae11906 100644
--- a/rpcs3/Emu/Cell/PPUAnalyser.cpp
+++ b/rpcs3/Emu/Cell/PPUAnalyser.cpp
@@ -141,7 +141,7 @@ static u32 ppu_test(const be_t* ptr, const void* fend, ppu_pattern_array pa
cur++;
}
- return (cur - ptr) * sizeof(*ptr);
+ return ::narrow((cur - ptr) * sizeof(*ptr));
}
static u32 ppu_test(const be_t* ptr, const void* fend, ppu_pattern_matrix pats)
@@ -2041,7 +2041,7 @@ bool ppu_module::analyse(u32 lib_toc, u32 entry, const u32 sec_end, const std::b
if (per_instruction_bytes)
{
- const bool error = per_instruction_bytes >= 200 && per_instruction_bytes / 4 >= utils::aligned_div(funcs.size(), 128);
+ const bool error = per_instruction_bytes >= 200 && per_instruction_bytes / 4 >= utils::aligned_div(::size32(funcs), 128);
(error ? ppu_log.error : ppu_log.notice)("%d instructions will be compiled on per-instruction basis in total", per_instruction_bytes / 4);
}
diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp
index 736de83f15..bebe793ab1 100644
--- a/rpcs3/Emu/Cell/PPUModule.cpp
+++ b/rpcs3/Emu/Cell/PPUModule.cpp
@@ -1148,7 +1148,7 @@ static void ppu_check_patch_spu_images(const ppu_module& mod, const ppu_segment&
for (usz addr_last = 0, valid_count = 0, invalid_count = 0;;)
{
- usz instruction = ls_segment.find("\x24\0\x40\x80"sv, addr_last);
+ const usz instruction = ls_segment.find("\x24\0\x40\x80"sv, addr_last);
if (instruction != umax)
{
@@ -1161,7 +1161,7 @@ static void ppu_check_patch_spu_images(const ppu_module& mod, const ppu_segment&
// FIXME: This seems to terminate SPU code prematurely in some cases
// Likely due to absolute branches
- if (spu_thread::is_exec_code(instruction, {reinterpret_cast(ls_segment.data()), ls_segment.size()}, 0))
+ if (spu_thread::is_exec_code(::narrow(instruction), {reinterpret_cast(ls_segment.data()), ls_segment.size()}, 0))
{
addr_last = instruction + 4;
valid_count++;
@@ -1183,7 +1183,7 @@ static void ppu_check_patch_spu_images(const ppu_module& mod, const ppu_segment&
if (addr_last >= 0x80 && valid_count >= 2)
{
const u32 begin = i & -128;
- u32 end = std::min(seg.size, utils::align(i + addr_last + 256, 128));
+ u32 end = std::min(seg.size, utils::align(::narrow(i + addr_last + 256), 128));
u32 guessed_ls_addr = 0;
@@ -1738,7 +1738,7 @@ std::shared_ptr ppu_load_prx(const ppu_prx_object& elf, bool virtual_lo
};
// Access library information (TODO)
- const auto lib_info = ensure(prx->get_ptr(prx->segs[0].addr + elf.progs[0].p_paddr - elf.progs[0].p_offset));
+ const auto lib_info = ensure(prx->get_ptr(::narrow(prx->segs[0].addr + elf.progs[0].p_paddr - elf.progs[0].p_offset)));
const std::string lib_name = lib_info->name;
strcpy_trunc(prx->module_info_name, lib_name);
@@ -1749,7 +1749,7 @@ std::shared_ptr ppu_load_prx(const ppu_prx_object& elf, bool virtual_lo
prx->exports_start = lib_info->exports_start;
prx->exports_end = lib_info->exports_end;
- for (usz start = prx->exports_start, size = 0;; size++)
+ for (u32 start = prx->exports_start, size = 0;; size++)
{
if (start >= prx->exports_end)
{
@@ -2612,7 +2612,7 @@ bool ppu_load_exec(const ppu_exec_object& elf, bool virtual_load, const std::str
ensure(ppu->stack_size > stack_alloc_size);
- vm::ptr args = vm::cast(static_cast(ppu->stack_addr + ppu->stack_size - stack_alloc_size - utils::align(Emu.data.size(), 0x10)));
+ vm::ptr args = vm::cast(static_cast(ppu->stack_addr + ppu->stack_size - stack_alloc_size - utils::align(::size32(Emu.data), 0x10)));
vm::ptr args_data = vm::cast(args.addr() + pointers_storage_size);
const vm::ptr argv = args;
diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp
index c8284f0310..62094955b1 100644
--- a/rpcs3/Emu/Cell/PPUThread.cpp
+++ b/rpcs3/Emu/Cell/PPUThread.cpp
@@ -1342,12 +1342,12 @@ void ppu_thread::dump_regs(std::string& ret, std::any& custom_data) const
}
}
}
- else if (is_exec_code(reg))
+ else if (is_exec_code(static_cast(reg)))
{
is_function = true;
}
- const auto gpr_buf = vm::get_super_ptr(reg);
+ const auto gpr_buf = vm::get_super_ptr(static_cast(reg));
std::string buf_tmp(gpr_buf, gpr_buf + max_str_len);
@@ -1361,7 +1361,7 @@ void ppu_thread::dump_regs(std::string& ret, std::any& custom_data) const
}
else
{
- dis_asm.disasm(reg);
+ dis_asm.disasm(static_cast(reg));
fmt::append(ret, " -> %s", dis_asm.last_opcode);
}
}
diff --git a/rpcs3/Emu/Cell/RawSPUThread.cpp b/rpcs3/Emu/Cell/RawSPUThread.cpp
index b322ab017f..ec571a1505 100644
--- a/rpcs3/Emu/Cell/RawSPUThread.cpp
+++ b/rpcs3/Emu/Cell/RawSPUThread.cpp
@@ -404,7 +404,7 @@ void spu_load_rel_exec(const spu_rel_object& elf)
ensure(vm::get(vm::spu)->falloc(spu->vm_offset(), SPU_LS_SIZE, &spu->shm, vm::page_size_64k));
spu->map_ls(*spu->shm, spu->ls);
- u64 total_memsize = 0;
+ u32 total_memsize = 0;
// Compute executable data size
for (const auto& shdr : elf.shdrs)
diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp
index 3e9d3cb9cd..7453e7763e 100644
--- a/rpcs3/Emu/Cell/SPURecompiler.cpp
+++ b/rpcs3/Emu/Cell/SPURecompiler.cpp
@@ -707,7 +707,7 @@ void spu_cache::initialize(bool build_existing_cache)
auto data_list = g_fxo->get().precompile_funcs.pop_all();
g_fxo->get().collect_funcs_to_precompile = false;
- u32 total_precompile = 0;
+ usz total_precompile = 0;
for (auto& sec : data_list)
{
@@ -763,14 +763,14 @@ void spu_cache::initialize(bool build_existing_cache)
if (g_cfg.core.spu_decoder == spu_decoder_type::asmjit || g_cfg.core.spu_decoder == spu_decoder_type::llvm)
{
- const u32 add_count = ::size32(func_list) + total_precompile;
+ const usz add_count = func_list.size() + total_precompile;
if (add_count)
{
- total_funcs = build_existing_cache ? add_count : 0;
+ total_funcs = build_existing_cache ? ::narrow(add_count) : 0;
}
- worker_count = std::min(rpcs3::utils::get_max_threads(), add_count);
+ worker_count = std::min(rpcs3::utils::get_max_threads(), ::narrow(add_count));
}
atomic_t pending_progress = 0;
@@ -898,7 +898,7 @@ void spu_cache::initialize(bool build_existing_cache)
for (func_i = data_indexer++;; func_i = data_indexer++, (showing_progress ? g_progr_pdone : pending_progress) += build_existing_cache ? 1 : 0)
{
- u32 passed_count = 0;
+ usz passed_count = 0;
u32 func_addr = 0;
u32 next_func = 0;
u32 sec_addr = umax;
@@ -910,11 +910,11 @@ void spu_cache::initialize(bool build_existing_cache)
{
if (func_i < passed_count + sec.funcs.size())
{
- const u32 func_idx = func_i - passed_count;
+ const usz func_idx = func_i - passed_count;
sec_addr = sec.vaddr;
func_addr = ::at32(sec.funcs, func_idx);
inst_data = sec.inst_data;
- next_func = sec.funcs.size() >= func_idx ? sec_addr + inst_data.size() * 4 : sec.funcs[func_idx];
+ next_func = sec.funcs.size() >= func_idx ? ::narrow(sec_addr + inst_data.size() * 4) : sec.funcs[func_idx];
break;
}
@@ -961,7 +961,7 @@ void spu_cache::initialize(bool build_existing_cache)
while (!func2.data.empty())
{
const u32 last_inst = std::bit_cast>(func2.data.back());
- const u32 prog_size = func2.data.size();
+ const u32 prog_size = ::size32(func2.data);
if (!compiler->compile(std::move(func2)))
{
@@ -2247,7 +2247,7 @@ std::vector spu_thread::discover_functions(u32 base_addr, std::span(base_addr, 0x10); i < std::min(base_addr + ls.size(), 0x3FFF0); i += 0x10)
+ for (u32 i = utils::align(base_addr, 0x10); i < std::min(base_addr + ::size32(ls), 0x3FFF0); i += 0x10)
{
// Search for BRSL LR and BRASL LR or BR
// TODO: BISL
@@ -2323,7 +2323,7 @@ std::vector spu_thread::discover_functions(u32 base_addr, std::span= base_addr && back < std::min(base_addr + ls.size(), 0x3FFF0); it--, back -= 4)
+ for (u32 back = addr - 4, it = 10; it && back >= base_addr && back < std::min(base_addr + ::size32(ls), 0x3FFF0); it--, back -= 4)
{
const spu_opcode_t test_op{read_from_ptr>(ls, back - base_addr)};
const auto type = g_spu_itype.decode(test_op.opcode);
diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp
index 6aa2e79e69..e347b7635d 100644
--- a/rpcs3/Emu/Cell/SPUThread.cpp
+++ b/rpcs3/Emu/Cell/SPUThread.cpp
@@ -3481,7 +3481,7 @@ bool spu_thread::do_list_transfer(spu_mfc_cmd& args)
ch_stall_stat.set_value(utils::rol32(1, args.tag) | ch_stall_stat.get_value());
args.tag |= 0x80; // Set stalled status
- args.eal = reinterpret_cast(item_ptr) - this->ls;
+ args.eal = ::narrow(reinterpret_cast(item_ptr) - this->ls);
args.lsa = arg_lsa;
args.size = arg_size;
return false;
@@ -4750,7 +4750,7 @@ std::pair spu_thread::read_dec() const
return {static_cast(res), static_cast(res >> 32)};
}
-spu_thread::ch_events_t spu_thread::get_events(u32 mask_hint, bool waiting, bool reading)
+spu_thread::ch_events_t spu_thread::get_events(u64 mask_hint, bool waiting, bool reading)
{
if (auto mask1 = ch_events.load().mask; mask1 & ~SPU_EVENT_IMPLEMENTED)
{
diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h
index 80567a9745..f6ae828e07 100644
--- a/rpcs3/Emu/Cell/SPUThread.h
+++ b/rpcs3/Emu/Cell/SPUThread.h
@@ -513,7 +513,7 @@ enum FPSCR_EX
class SPU_FPSCR
{
public:
- u32 _u32[4];
+ u32 _u32[4]{};
SPU_FPSCR() {}
@@ -526,6 +526,7 @@ public:
{
memset(this, 0, sizeof(*this));
}
+
//slice -> 0 - 1 (double-precision slice index)
//NOTE: slices follow v128 indexing, i.e. slice 0 is RIGHT end of register!
//roundTo -> FPSCR_RN_*
@@ -535,6 +536,7 @@ public:
//rounding is located in the left end of the FPSCR
this->_u32[3] = (this->_u32[3] & ~(3 << shift)) | (roundTo << shift);
}
+
//Slice 0 or 1
u8 checkSliceRounding(u8 slice) const
{
@@ -571,11 +573,11 @@ public:
//exception: FPSCR_D* bitmask
void setDoublePrecisionExceptionFlags(u8 slice, u32 exceptions)
{
- _u32[1+slice] |= exceptions;
+ _u32[1 + slice] |= exceptions;
}
// Write the FPSCR
- void Write(const v128 & r)
+ void Write(const v128& r)
{
_u32[3] = r._u32[3] & 0x00000F07;
_u32[2] = r._u32[2] & 0x00003F07;
@@ -584,7 +586,7 @@ public:
}
// Read the FPSCR
- void Read(v128 & r)
+ void Read(v128& r) const
{
r._u32[3] = _u32[3];
r._u32[2] = _u32[2];
@@ -823,7 +825,7 @@ public:
u32 get_mfc_completed() const;
bool process_mfc_cmd();
- ch_events_t get_events(u32 mask_hint = -1, bool waiting = false, bool reading = false);
+ ch_events_t get_events(u64 mask_hint = umax, bool waiting = false, bool reading = false);
void set_events(u32 bits);
void set_interrupt_status(bool enable);
bool check_mfc_interrupts(u32 next_pc);
diff --git a/rpcs3/Emu/Cell/lv2/lv2.cpp b/rpcs3/Emu/Cell/lv2/lv2.cpp
index f49e070d03..1cb800c802 100644
--- a/rpcs3/Emu/Cell/lv2/lv2.cpp
+++ b/rpcs3/Emu/Cell/lv2/lv2.cpp
@@ -1536,7 +1536,7 @@ bool lv2_obj::awake_unlocked(cpu_thread* cpu, s32 prio)
});
};
- const s32 old_prio = static_cast(cpu)->prio.load().prio;
+ const s64 old_prio = static_cast(cpu)->prio.load().prio;
// If priority is the same, push ONPROC/RUNNABLE thread to the back of the priority list if it is not the current thread
if (old_prio == prio && cpu == cpu_thread::get_current())
@@ -2067,7 +2067,7 @@ bool lv2_obj::wait_timeout(u64 usec, ppu_thread* cpu, bool scale, bool is_usleep
#if defined(ARCH_X64)
else if (utils::has_appropriate_um_wait())
{
- u32 us_in_tsc_clocks = remaining * (utils::get_tsc_freq() / 1000000);
+ const u32 us_in_tsc_clocks = ::narrow(remaining * (utils::get_tsc_freq() / 1000000ULL));
if (utils::has_waitpkg())
{
diff --git a/rpcs3/Emu/Cell/lv2/sys_game.cpp b/rpcs3/Emu/Cell/lv2/sys_game.cpp
index d734546c10..e4f48af141 100644
--- a/rpcs3/Emu/Cell/lv2/sys_game.cpp
+++ b/rpcs3/Emu/Cell/lv2/sys_game.cpp
@@ -19,9 +19,9 @@ struct system_sw_version
system_sw_version()
{
f64 version_f = 0;
- if (!try_to_float(&version_f, utils::get_firmware_version(), 0, 99.9999))
+ if (!try_to_float(&version_f, utils::get_firmware_version(), 0.0f, 99.9999f))
sys_game.error("Error parsing firmware version");
- version = version_f * 10000;
+ version = static_cast(version_f * 10000);
}
system_sw_version(const system_sw_version&) = delete;
diff --git a/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_native.cpp b/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_native.cpp
index fa9aeff6bb..6a38674506 100644
--- a/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_native.cpp
+++ b/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_native.cpp
@@ -968,7 +968,7 @@ std::optional lv2_socket_native::sendto(s32 flags, const std::vector& b
if (dnshook.is_dns(lv2_id))
{
- const s32 ret_analyzer = dnshook.analyze_dns_packet(lv2_id, reinterpret_cast(buf.data()), buf.size());
+ const s32 ret_analyzer = dnshook.analyze_dns_packet(lv2_id, reinterpret_cast(buf.data()), ::size32(buf));
// Check if the packet is intercepted
if (ret_analyzer >= 0)
@@ -977,7 +977,7 @@ std::optional lv2_socket_native::sendto(s32 flags, const std::vector& b
}
}
- native_result = ::sendto(socket, reinterpret_cast(buf.data()), buf.size(), native_flags, native_addr ? reinterpret_cast(&native_addr.value()) : nullptr, native_addr ? sizeof(sockaddr_in) : 0);
+ native_result = ::sendto(socket, reinterpret_cast(buf.data()), ::narrow(buf.size()), native_flags, native_addr ? reinterpret_cast(&native_addr.value()) : nullptr, native_addr ? sizeof(sockaddr_in) : 0);
if (native_result >= 0)
{
@@ -1025,7 +1025,7 @@ std::optional lv2_socket_native::sendmsg(s32 flags, const sys_net_msghdr& m
const u32 len = msg.msg_iov[i].iov_len;
const std::vector buf_copy(vm::_ptr(iov_base.addr()), vm::_ptr(iov_base.addr()) + len);
- native_result = ::send(socket, reinterpret_cast(buf_copy.data()), buf_copy.size(), native_flags);
+ native_result = ::send(socket, reinterpret_cast(buf_copy.data()), ::narrow(buf_copy.size()), native_flags);
if (native_result >= 0)
{
diff --git a/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_p2p.cpp b/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_p2p.cpp
index 9e2e5e8221..4c02b89cdd 100644
--- a/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_p2p.cpp
+++ b/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_p2p.cpp
@@ -222,7 +222,7 @@ s32 lv2_socket_p2p::setsockopt(s32 level, s32 optname, const std::vector& op
const u64 key = (static_cast(level) << 32) | static_cast(optname);
sockopt_cache cache{};
memcpy(&cache.data._int, optval.data(), optval.size());
- cache.len = optval.size();
+ cache.len = ::size32(optval);
sockopts[key] = std::move(cache);
@@ -296,7 +296,7 @@ std::optional lv2_socket_p2p::sendto(s32 flags, const std::vector& buf,
native_flags |= MSG_WAITALL;
}
- auto native_result = ::sendto(socket, reinterpret_cast(p2p_data.data()), p2p_data.size(), native_flags, reinterpret_cast(&native_addr), sizeof(native_addr));
+ auto native_result = ::sendto(socket, reinterpret_cast(p2p_data.data()), ::size32(p2p_data), native_flags, reinterpret_cast(&native_addr), sizeof(native_addr));
if (native_result >= 0)
{
diff --git a/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_p2ps.cpp b/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_p2ps.cpp
index bd826ff362..4474164ed5 100644
--- a/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_p2ps.cpp
+++ b/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_p2ps.cpp
@@ -129,7 +129,7 @@ public:
ensure(sock.get_type() == SYS_NET_SOCK_STREAM_P2P);
auto& sock_p2ps = reinterpret_cast(sock);
- if (::sendto(sock_p2ps.get_socket(), reinterpret_cast(msg.data.data()), msg.data.size(), 0, reinterpret_cast(&msg.dst_addr), sizeof(msg.dst_addr)) == -1)
+ if (::sendto(sock_p2ps.get_socket(), reinterpret_cast(msg.data.data()), ::size32(msg.data), 0, reinterpret_cast(&msg.dst_addr), sizeof(msg.dst_addr)) == -1)
{
sys_net.error("[P2PS] Resending the packet failed(%s), closing the socket", get_last_error(false));
@@ -284,7 +284,7 @@ bool lv2_socket_p2ps::handle_connected(p2ps_encapsulated_tcp* tcp_header, u8* da
nt_p2p_port::dump_packet(tcp_header);
- if (tcp_header->flags == p2ps_tcp_flags::ACK)
+ if (tcp_header->flags == static_cast(p2ps_tcp_flags::ACK))
{
auto& tcpm = g_fxo->get>();
tcpm.confirm_data_received(lv2_id, tcp_header->ack);
@@ -400,7 +400,7 @@ bool lv2_socket_p2ps::handle_listening(p2ps_encapsulated_tcp* tcp_header, [[mayb
}
// Only valid packet
- if (tcp_header->flags == p2ps_tcp_flags::SYN)
+ if (tcp_header->flags == static_cast(p2ps_tcp_flags::SYN))
{
if (backlog.size() >= max_backlog)
{
@@ -475,12 +475,12 @@ bool lv2_socket_p2ps::handle_listening(p2ps_encapsulated_tcp* tcp_header, [[mayb
return true;
}
-void lv2_socket_p2ps::send_u2s_packet(std::vector data, const ::sockaddr_in* dst, u32 seq, bool require_ack)
+void lv2_socket_p2ps::send_u2s_packet(std::vector data, const ::sockaddr_in* dst, u64 seq, bool require_ack)
{
char ip_str[16];
inet_ntop(AF_INET, &dst->sin_addr, ip_str, sizeof(ip_str));
sys_net.trace("[P2PS] Sending U2S packet on socket %d(id:%d): data(%d, seq %d, require_ack %d) to %s:%d", socket, lv2_id, data.size(), seq, require_ack, ip_str, std::bit_cast>(dst->sin_port));
- if (::sendto(socket, reinterpret_cast(data.data()), data.size(), 0, reinterpret_cast(dst), sizeof(sockaddr_in)) == -1)
+ if (::sendto(socket, reinterpret_cast(data.data()), ::size32(data), 0, reinterpret_cast(dst), sizeof(sockaddr_in)) == -1)
{
sys_net.error("[P2PS] Attempting to send a u2s packet failed(%s), closing socket!", get_last_error(false));
status = p2ps_stream_status::stream_closed;
@@ -753,7 +753,7 @@ std::optional, sys_net_sockaddr>> lv2_socket_p2p
return std::nullopt;
}
- const u32 to_give = std::min(data_available, len);
+ const u32 to_give = static_cast(std::min(data_available, len));
sys_net_sockaddr addr{};
std::vector dest_buf(to_give);
@@ -819,7 +819,7 @@ std::optional lv2_socket_p2ps::sendto([[maybe_unused]] s32 flags, const std
tcp_header.dst_port = op_vport;
// chop it up
std::vector> stream_packets;
- u32 cur_total_len = buf.size();
+ u32 cur_total_len = ::size32(buf);
while (cur_total_len > 0)
{
u32 cur_data_len = std::min(cur_total_len, max_data_len);
@@ -834,7 +834,7 @@ std::optional lv2_socket_p2ps::sendto([[maybe_unused]] s32 flags, const std
cur_seq += cur_data_len;
}
- return {buf.size()};
+ return {::size32(buf)};
}
std::optional lv2_socket_p2ps::sendmsg([[maybe_unused]] s32 flags, [[maybe_unused]] const sys_net_msghdr& msg, [[maybe_unused]] bool is_lock)
diff --git a/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_p2ps.h b/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_p2ps.h
index e06b16aa97..05129df9a8 100644
--- a/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_p2ps.h
+++ b/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_p2ps.h
@@ -65,7 +65,7 @@ public:
void set_status(p2ps_stream_status new_status);
bool handle_connected(p2ps_encapsulated_tcp* tcp_header, u8* data, ::sockaddr_storage* op_addr);
bool handle_listening(p2ps_encapsulated_tcp* tcp_header, u8* data, ::sockaddr_storage* op_addr);
- void send_u2s_packet(std::vector data, const ::sockaddr_in* dst, u32 seq, bool require_ack);
+ void send_u2s_packet(std::vector data, const ::sockaddr_in* dst, u64 seq, bool require_ack);
std::tuple, sys_net_sockaddr> accept(bool is_lock = true) override;
s32 bind(const sys_net_sockaddr& addr) override;
diff --git a/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_raw.cpp b/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_raw.cpp
index fa9b86c25e..aee50f5c58 100644
--- a/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_raw.cpp
+++ b/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket_raw.cpp
@@ -97,7 +97,7 @@ std::optional, sys_net_sockaddr>> lv2_socket_raw
std::optional lv2_socket_raw::sendto([[maybe_unused]] s32 flags, [[maybe_unused]] const std::vector& buf, [[maybe_unused]] std::optional opt_sn_addr, [[maybe_unused]] bool is_lock)
{
sys_net.todo("lv2_socket_raw::sendto");
- return buf.size();
+ return ::size32(buf);
}
std::optional lv2_socket_raw::sendmsg([[maybe_unused]] s32 flags, [[maybe_unused]] const sys_net_msghdr& msg, [[maybe_unused]] bool is_lock)
diff --git a/rpcs3/Emu/Cell/lv2/sys_net/network_context.cpp b/rpcs3/Emu/Cell/lv2/sys_net/network_context.cpp
index 15b27b49b8..e3d5cdda4a 100644
--- a/rpcs3/Emu/Cell/lv2/sys_net/network_context.cpp
+++ b/rpcs3/Emu/Cell/lv2/sys_net/network_context.cpp
@@ -18,7 +18,7 @@ s32 send_packet_from_p2p_port(const std::vector& data, const sockaddr_in& ad
if (nc.list_p2p_ports.contains(SCE_NP_PORT))
{
auto& def_port = ::at32(nc.list_p2p_ports, SCE_NP_PORT);
- res = ::sendto(def_port.p2p_socket, reinterpret_cast(data.data()), data.size(), 0, reinterpret_cast(&addr), sizeof(sockaddr_in));
+ res = ::sendto(def_port.p2p_socket, reinterpret_cast(data.data()), ::size32(data), 0, reinterpret_cast(&addr), sizeof(sockaddr_in));
}
else
{
@@ -114,7 +114,7 @@ void network_thread::operator()()
// Wait with 1ms timeout
#ifdef _WIN32
- windows_poll(fds, socklist.size(), 1, connecting);
+ windows_poll(fds, ::size32(socklist), 1, connecting);
#else
::poll(fds.data(), socklist.size(), 1);
#endif
diff --git a/rpcs3/Emu/Cell/lv2/sys_net/nt_p2p_port.cpp b/rpcs3/Emu/Cell/lv2/sys_net/nt_p2p_port.cpp
index a4c66b0dfe..024106623b 100644
--- a/rpcs3/Emu/Cell/lv2/sys_net/nt_p2p_port.cpp
+++ b/rpcs3/Emu/Cell/lv2/sys_net/nt_p2p_port.cpp
@@ -134,9 +134,9 @@ bool nt_p2p_port::handle_listening(s32 sock_id, p2ps_encapsulated_tcp* tcp_heade
bool nt_p2p_port::recv_data()
{
- ::sockaddr_storage native_addr;
+ ::sockaddr_storage native_addr{};
::socklen_t native_addrlen = sizeof(native_addr);
- const auto recv_res = ::recvfrom(p2p_socket, reinterpret_cast(p2p_recv_data.data()), p2p_recv_data.size(), 0, reinterpret_cast(&native_addr), &native_addrlen);
+ const auto recv_res = ::recvfrom(p2p_socket, reinterpret_cast(p2p_recv_data.data()), ::size32(p2p_recv_data), 0, reinterpret_cast(&native_addr), &native_addrlen);
if (recv_res == -1)
{
diff --git a/rpcs3/Emu/Cell/lv2/sys_overlay.h b/rpcs3/Emu/Cell/lv2/sys_overlay.h
index 103321b9e0..9b3278a848 100644
--- a/rpcs3/Emu/Cell/lv2/sys_overlay.h
+++ b/rpcs3/Emu/Cell/lv2/sys_overlay.h
@@ -7,7 +7,7 @@ struct lv2_overlay final : lv2_obj, ppu_module
{
static const u32 id_base = 0x25000000;
- u32 entry;
+ u32 entry{};
u32 seg0_code_end{};
std::basic_string applied_patches;
diff --git a/rpcs3/Emu/Cell/lv2/sys_prx.cpp b/rpcs3/Emu/Cell/lv2/sys_prx.cpp
index 35bd37d4f5..84c9279dfa 100644
--- a/rpcs3/Emu/Cell/lv2/sys_prx.cpp
+++ b/rpcs3/Emu/Cell/lv2/sys_prx.cpp
@@ -756,7 +756,7 @@ void lv2_prx::restore_exports()
std::basic_string loaded_flags_empty;
- for (usz start = exports_start, i = 0; start < exports_end; i++, start += vm::read8(start) ? vm::read8(start) : sizeof_export_data)
+ for (u32 start = exports_start, i = 0; start < exports_end; i++, start += vm::read8(start) ? vm::read8(start) : sizeof_export_data)
{
if (::at32(m_external_loaded_flags, i) || (!m_loaded_flags.empty() && ::at32(m_loaded_flags, i)))
{
diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.h b/rpcs3/Emu/Cell/lv2/sys_spu.h
index e2b233ac5d..cfeed37c53 100644
--- a/rpcs3/Emu/Cell/lv2/sys_spu.h
+++ b/rpcs3/Emu/Cell/lv2/sys_spu.h
@@ -316,7 +316,7 @@ struct lv2_spu_group
, run_state(SPU_THREAD_GROUP_STATUS_NOT_INITIALIZED)
, exit_status(0)
, join_state(0)
- // TODO: args()
+ , args({})
{
threads_map.fill(-1);
prio.raw().prio = _prio;
diff --git a/rpcs3/Emu/Cell/lv2/sys_storage.cpp b/rpcs3/Emu/Cell/lv2/sys_storage.cpp
index d420e3aa80..e5e1aec24e 100644
--- a/rpcs3/Emu/Cell/lv2/sys_storage.cpp
+++ b/rpcs3/Emu/Cell/lv2/sys_storage.cpp
@@ -77,7 +77,7 @@ error_code sys_storage_read(u32 fd, u32 mode, u32 start_sector, u32 num_sectors,
handle->file.seek(start_sector * 0x200ull);
const u64 size = num_sectors * 0x200ull;
const u64 result = lv2_file::op_read(handle->file, bounce_buf, size);
- num_sectors = result / 0x200;
+ num_sectors = ::narrow(result / 0x200ull);
}
*sectors_read = num_sectors;
diff --git a/rpcs3/Emu/IPC_config.cpp b/rpcs3/Emu/IPC_config.cpp
index 7eedad9246..5aa95f4c34 100644
--- a/rpcs3/Emu/IPC_config.cpp
+++ b/rpcs3/Emu/IPC_config.cpp
@@ -32,11 +32,11 @@ void cfg_ipc::save() const
}
#endif
- fs::pending_file cfg_file(cfg_ipc::get_path());
+ const std::string path = cfg_ipc::get_path();
- if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
+ if (!cfg::node::save(path))
{
- IPC.error("Could not save config: %s (error=%s)", cfg_ipc::get_path(), fs::g_tls_error);
+ IPC.error("Could not save config: %s (error=%s)", path, fs::g_tls_error);
}
}
diff --git a/rpcs3/Emu/Io/PadHandler.cpp b/rpcs3/Emu/Io/PadHandler.cpp
index 0afdc2305a..3ec2e113eb 100644
--- a/rpcs3/Emu/Io/PadHandler.cpp
+++ b/rpcs3/Emu/Io/PadHandler.cpp
@@ -82,14 +82,14 @@ f32 PadHandlerBase::ScaledAxisInput(f32 raw_value, f32 minimum, f32 maximum, f32
}
// Get normalized trigger value based on the range defined by a threshold
-u16 PadHandlerBase::NormalizeTriggerInput(u16 value, int threshold) const
+u16 PadHandlerBase::NormalizeTriggerInput(u16 value, s32 threshold) const
{
if (value <= threshold || threshold >= trigger_max)
{
return static_cast(0);
}
- return static_cast(ScaledInput(value, trigger_min, trigger_max, threshold));
+ return static_cast(ScaledInput(static_cast(value), static_cast(trigger_min), static_cast(trigger_max), static_cast(threshold)));
}
// normalizes a directed input, meaning it will correspond to a single "button" and not an axis with two directions
@@ -101,10 +101,10 @@ u16 PadHandlerBase::NormalizeDirectedInput(s32 raw_value, s32 threshold, s32 max
return static_cast(0);
}
- return static_cast(ScaledInput(raw_value, 0, maximum, threshold));
+ return static_cast(ScaledInput(static_cast(raw_value), 0.0f, static_cast(maximum), static_cast(threshold)));
}
-u16 PadHandlerBase::NormalizeStickInput(u16 raw_value, int threshold, int multiplier, bool ignore_threshold) const
+u16 PadHandlerBase::NormalizeStickInput(u16 raw_value, s32 threshold, s32 multiplier, bool ignore_threshold) const
{
const s32 scaled_value = MultipliedInput(raw_value, multiplier);
@@ -113,7 +113,7 @@ u16 PadHandlerBase::NormalizeStickInput(u16 raw_value, int threshold, int multip
threshold = 0;
}
- return static_cast(ScaledInput(scaled_value, 0, thumb_max, threshold));
+ return static_cast(ScaledInput(static_cast(scaled_value), 0.0f, static_cast(thumb_max), static_cast(threshold)));
}
// This function normalizes stick deadzone based on the DS3's deadzone, which is ~13%
diff --git a/rpcs3/Emu/Io/PadHandler.h b/rpcs3/Emu/Io/PadHandler.h
index 217661e91a..4028ea7100 100644
--- a/rpcs3/Emu/Io/PadHandler.h
+++ b/rpcs3/Emu/Io/PadHandler.h
@@ -214,7 +214,7 @@ protected:
static f32 ScaledAxisInput(f32 raw_value, f32 minimum, f32 maximum, f32 deadzone, f32 range = 255.0f);
// Get normalized trigger value based on the range defined by a threshold
- u16 NormalizeTriggerInput(u16 value, int threshold) const;
+ u16 NormalizeTriggerInput(u16 value, s32 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+
@@ -261,7 +261,7 @@ public:
bool has_battery() const;
bool has_pressure_intensity_button() const;
- u16 NormalizeStickInput(u16 raw_value, int threshold, int multiplier, bool ignore_threshold = false) const;
+ u16 NormalizeStickInput(u16 raw_value, s32 threshold, s32 multiplier, bool ignore_threshold = false) const;
void convert_stick_values(u16& x_out, u16& y_out, const s32& x_in, const s32& y_in, const s32& deadzone, const s32& padsquircling) const;
virtual bool Init() { return true; }
diff --git a/rpcs3/Emu/Io/camera_config.cpp b/rpcs3/Emu/Io/camera_config.cpp
index dce03e8cd7..9767405646 100644
--- a/rpcs3/Emu/Io/camera_config.cpp
+++ b/rpcs3/Emu/Io/camera_config.cpp
@@ -34,9 +34,7 @@ void cfg_camera::save() const
{
camera_log.notice("Saving camera config to '%s'", path);
- fs::pending_file cfg_file(path);
-
- if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
+ if (!cfg::node::save(path))
{
camera_log.error("Failed to save camera config to '%s' (error=%s)", path, fs::g_tls_error);
}
diff --git a/rpcs3/Emu/Io/emulated_pad_config.h b/rpcs3/Emu/Io/emulated_pad_config.h
index 0659743949..3dcc1f05ac 100644
--- a/rpcs3/Emu/Io/emulated_pad_config.h
+++ b/rpcs3/Emu/Io/emulated_pad_config.h
@@ -250,9 +250,7 @@ struct emulated_pads_config : cfg::node
cfg_log.fatal("Failed to create path: %s (%s)", cfg_name, fs::g_tls_error);
}
- fs::pending_file cfg_file(cfg_name);
-
- if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
+ if (!cfg::node::save(cfg_name))
{
cfg_log.error("Failed to save %s config to '%s' (error=%s)", cfg_id, cfg_name, fs::g_tls_error);
}
diff --git a/rpcs3/Emu/Io/pad_config.cpp b/rpcs3/Emu/Io/pad_config.cpp
index fc08baff2f..83ac998ecd 100644
--- a/rpcs3/Emu/Io/pad_config.cpp
+++ b/rpcs3/Emu/Io/pad_config.cpp
@@ -103,9 +103,7 @@ void cfg_input::save(const std::string& title_id, const std::string& config_file
input_log.fatal("Failed to create path: %s (%s)", cfg_name, fs::g_tls_error);
}
- fs::pending_file cfg_file(cfg_name);
-
- if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
+ if (!cfg::node::save(cfg_name))
{
input_log.error("Failed to save pad config to '%s' (error=%s)", cfg_name, fs::g_tls_error);
}
@@ -131,9 +129,7 @@ void cfg_input_configurations::save() const
{
input_log.notice("Saving input configurations config to '%s'", path);
- fs::pending_file cfg_file(path);
-
- if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
+ if (!cfg::node::save(path))
{
input_log.error("Failed to save input configurations config to '%s' (error=%s)", path, fs::g_tls_error);
}
diff --git a/rpcs3/Emu/Io/recording_config.cpp b/rpcs3/Emu/Io/recording_config.cpp
index 5092c9c152..0457317d80 100644
--- a/rpcs3/Emu/Io/recording_config.cpp
+++ b/rpcs3/Emu/Io/recording_config.cpp
@@ -35,9 +35,7 @@ void cfg_recording::save() const
{
cfg_log.notice("Saving recording config to '%s'", path);
- fs::pending_file cfg_file(path);
-
- if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
+ if (!cfg::node::save(path))
{
cfg_log.error("Failed to save recording config to '%s' (error=%s)", path, fs::g_tls_error);
}
diff --git a/rpcs3/Emu/Io/usb_device.cpp b/rpcs3/Emu/Io/usb_device.cpp
index 753f830164..ace244fa21 100644
--- a/rpcs3/Emu/Io/usb_device.cpp
+++ b/rpcs3/Emu/Io/usb_device.cpp
@@ -200,11 +200,16 @@ bool usb_device_emulated::open_device()
u32 usb_device_emulated::get_descriptor(u8 type, u8 index, u8* buf, u32 buf_size)
{
- std::array header;
- header = {header.size(), type};
+ if (!buf)
+ {
+ return 0;
+ }
- u32 expected_count = buf ? std::min(header.size(), buf_size) : 0;
- memcpy(buf, header.data(), expected_count);
+ std::array header;
+ header = {static_cast(header.size()), type};
+
+ u32 expected_count = std::min(static_cast(header.size()), buf_size);
+ std::memcpy(buf, header.data(), expected_count);
if (expected_count < header.size())
return expected_count;
@@ -215,7 +220,7 @@ u32 usb_device_emulated::get_descriptor(u8 type, u8 index, u8* buf, u32 buf_size
{
buf[0] = device.bLength;
expected_count = std::min(device.bLength, ::narrow(buf_size));
- memcpy(buf + header.size(), device.data, expected_count - header.size());
+ std::memcpy(buf + header.size(), device.data, expected_count - header.size());
break;
}
case USB_DESCRIPTOR_CONFIG:
@@ -224,7 +229,7 @@ u32 usb_device_emulated::get_descriptor(u8 type, u8 index, u8* buf, u32 buf_size
{
buf[0] = device.subnodes[index].bLength;
expected_count = std::min(device.subnodes[index].bLength, ::narrow(buf_size));
- memcpy(buf + header.size(), device.subnodes[index].data, expected_count - header.size());
+ std::memcpy(buf + header.size(), device.subnodes[index].data, expected_count - header.size());
}
break;
}
@@ -234,11 +239,11 @@ u32 usb_device_emulated::get_descriptor(u8 type, u8 index, u8* buf, u32 buf_size
{
if (index == 0)
{
- constexpr u8 len = sizeof(u16) + header.size();
+ constexpr u8 len = static_cast(sizeof(u16) + header.size());
buf[0] = len;
expected_count = std::min(len, ::narrow(buf_size));
constexpr le_t langid = 0x0409; // English (United States)
- memcpy(buf + header.size(), &langid, expected_count - header.size());
+ std::memcpy(buf + header.size(), &langid, expected_count - header.size());
}
else
{
@@ -246,7 +251,7 @@ u32 usb_device_emulated::get_descriptor(u8 type, u8 index, u8* buf, u32 buf_size
const u8 len = static_cast(std::min(u16str.size() * sizeof(u16) + header.size(), static_cast(0xFF)));
buf[0] = len;
expected_count = std::min(len, ::narrow(std::min(255, buf_size)));
- memcpy(buf + header.size(), u16str.data(), expected_count - header.size());
+ std::memcpy(buf + header.size(), u16str.data(), expected_count - header.size());
}
}
break;
@@ -261,7 +266,7 @@ u32 usb_device_emulated::get_status(bool self_powered, bool remote_wakeup, u8* b
{
const u32 expected_count = buf ? std::min(sizeof(u16), buf_size) : 0;
const u16 device_status = static_cast(self_powered) | static_cast(remote_wakeup) << 1;
- memcpy(buf, &device_status, expected_count);
+ std::memcpy(buf, &device_status, expected_count);
return expected_count;
}
diff --git a/rpcs3/Emu/NP/fb_helpers.cpp b/rpcs3/Emu/NP/fb_helpers.cpp
index 07798c353d..823fadef2d 100644
--- a/rpcs3/Emu/NP/fb_helpers.cpp
+++ b/rpcs3/Emu/NP/fb_helpers.cpp
@@ -315,7 +315,7 @@ namespace np
if (update_info->optData())
{
sce_update_info->optData.length = update_info->optData()->data()->size();
- for (usz i = 0; i < 16; i++)
+ for (flatbuffers::uoffset_t i = 0; i < 16; i++)
{
sce_update_info->optData.data[i] = update_info->optData()->data()->Get(i);
}
@@ -338,7 +338,7 @@ namespace np
if (update_info->optData())
{
sce_update_info->optData.length = update_info->optData()->data()->size();
- for (usz i = 0; i < 16; i++)
+ for (flatbuffers::uoffset_t i = 0; i < 16; i++)
{
sce_update_info->optData.data[i] = update_info->optData()->data()->Get(i);
}
@@ -477,7 +477,7 @@ namespace np
}
break;
}
- case SCE_NP_MATCHING2_CASTTYPE_MULTICAST_TEAM: sce_mi->dst->multicastTargetTeamId = mi->dst()->Get(0); break;
+ case SCE_NP_MATCHING2_CASTTYPE_MULTICAST_TEAM: sce_mi->dst->multicastTargetTeamId = ::narrow(mi->dst()->Get(0)); break;
default: ensure(false);
}
diff --git a/rpcs3/Emu/NP/np_cache.cpp b/rpcs3/Emu/NP/np_cache.cpp
index 743147feb6..0a782eeff2 100644
--- a/rpcs3/Emu/NP/np_cache.cpp
+++ b/rpcs3/Emu/NP/np_cache.cpp
@@ -129,14 +129,14 @@ namespace np
const auto& room = rooms[room_id];
- SceNpMatching2RoomSlotInfo slots;
+ SceNpMatching2RoomSlotInfo slots{};
slots.roomId = room_id;
SceNpMatching2RoomJoinedSlotMask join_mask = 0;
for (const auto& member : room.members)
{
- join_mask |= (1 << ((member.first >> 4) - 1));
+ join_mask |= (1ull << ((member.first >> 4) - 1));
}
slots.joinedSlotMask = join_mask;
slots.passwordSlotMask = room.mask_password;
@@ -253,7 +253,7 @@ namespace np
{
if (member.bins.contains(binattrs_list[i]))
{
- needed_data_size += (sizeof(SceNpMatching2RoomMemberBinAttrInternal) + ::at32(member.bins, binattrs_list[i]).data.size());
+ needed_data_size += ::narrow(sizeof(SceNpMatching2RoomMemberBinAttrInternal) + ::at32(member.bins, binattrs_list[i]).data.size());
}
}
@@ -311,9 +311,9 @@ namespace np
const auto& bin = ::at32(member.bins, binattrs_list[i]);
bin_ptr[actual_cnt].updateDate.tick = bin.updateDate.tick;
bin_ptr[actual_cnt].data.id = bin.id;
- bin_ptr[actual_cnt].data.size = bin.data.size();
- bin_ptr[actual_cnt].data.ptr.set(mem.allocate(bin.data.size()));
- memcpy(bin_ptr[actual_cnt].data.ptr.get_ptr(), bin.data.data(), bin.data.size());
+ bin_ptr[actual_cnt].data.size = ::size32(bin.data);
+ bin_ptr[actual_cnt].data.ptr.set(mem.allocate(::size32(bin.data)));
+ std::memcpy(bin_ptr[actual_cnt].data.ptr.get_ptr(), bin.data.data(), bin.data.size());
actual_cnt++;
}
}
diff --git a/rpcs3/Emu/NP/np_cache.h b/rpcs3/Emu/NP/np_cache.h
index 976c3b5838..df114a9640 100644
--- a/rpcs3/Emu/NP/np_cache.h
+++ b/rpcs3/Emu/NP/np_cache.h
@@ -12,7 +12,7 @@ namespace np
{
struct userinfo_cache
{
- SceNpId npId;
+ SceNpId npId{};
std::optional onlineName;
std::optional avatarUrl;
};
diff --git a/rpcs3/Emu/NP/np_requests.cpp b/rpcs3/Emu/NP/np_requests.cpp
index ed7c7e82d2..d0ef7be69b 100644
--- a/rpcs3/Emu/NP/np_requests.cpp
+++ b/rpcs3/Emu/NP/np_requests.cpp
@@ -138,11 +138,11 @@ namespace np
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_GetWorldInfoList, sizeof(SceNpMatching2GetWorldInfoListResponse));
auto* world_info = reinterpret_cast(edata.data());
- world_info->worldNum = world_list.size();
+ world_info->worldNum = ::size32(world_list);
if (!world_list.empty())
{
- auto* worlds = edata.allocate(sizeof(SceNpMatching2World) * world_list.size(), world_info->world);
+ auto* worlds = edata.allocate(::narrow(sizeof(SceNpMatching2World) * world_list.size()), world_info->world);
for (usz i = 0; i < world_list.size(); i++)
{
worlds[i].worldId = world_list[i];
@@ -736,13 +736,13 @@ namespace np
if (reply.is_error())
return error_and_disconnect("Malformed reply to GetBoardInfos command");
- SceNpScoreBoardInfo board_info;
-
- board_info.rankLimit = resp->rankLimit();
- board_info.updateMode = resp->updateMode();
- board_info.sortMode = resp->sortMode();
- board_info.uploadNumLimit = resp->uploadNumLimit();
- board_info.uploadSizeLimit = resp->uploadSizeLimit();
+ const SceNpScoreBoardInfo board_info{
+ .rankLimit = resp->rankLimit(),
+ .updateMode = resp->updateMode(),
+ .sortMode = resp->sortMode(),
+ .uploadNumLimit = resp->uploadNumLimit(),
+ .uploadSizeLimit = resp->uploadSizeLimit()
+ };
std::lock_guard lock_trans(mutex_async_transactions);
if (!async_transactions.count(req_id))
@@ -962,7 +962,7 @@ namespace np
return false;
}
- tdata->game_data_size = tdata->game_data.size();
+ tdata->game_data_size = ::size32(tdata->game_data);
usz to_copy = std::min(tdata->game_data.size(), static_cast(tdata->recvSize));
std::memcpy(tdata->score_data.get_ptr(), tdata->game_data.data(), to_copy);
@@ -1396,7 +1396,7 @@ namespace np
cur_status->lastChangedDate.tick = cur_fb_status->lastChangedDate();
string_to_npid(cur_fb_status->lastChangedAuthorId()->string_view(), cur_status->lastChangedAuthorId);
cur_status->info.infoSize = cur_fb_status->info() ? cur_fb_status->info()->size() : 0;
- for (usz i = 0; i < static_cast(cur_status->info.infoSize); i++)
+ for (flatbuffers::uoffset_t i = 0; i < cur_status->info.infoSize; i++)
{
cur_status->info.data[i] = cur_fb_status->info()->Get(i);
}
@@ -1631,6 +1631,7 @@ namespace np
const auto* fb_status = fb_data->status();
ensure(fb_status && fb_status->ownerId());
+ if (!fb_status) return false; // Sanity check to make compiler happy
auto* data_status = tdata->dataStatus.get_ptr();
auto* data = static_cast(tdata->data.get_ptr());
@@ -1638,8 +1639,6 @@ namespace np
memset(data_status, 0, sizeof(SceNpTusDataStatus));
string_to_npid(fb_status->ownerId()->string_view(), data_status->ownerId);
- usz to_copy = 0;
-
if (fb_status->hasData())
{
data_status->hasData = 1;
@@ -1649,19 +1648,19 @@ namespace np
data_status->dataSize = fb_data->data() ? fb_data->data()->size() : 0;
data_status->info.infoSize = fb_status->info() ? fb_status->info()->size() : 0;
- to_copy = std::min(static_cast(data_status->dataSize), static_cast(tdata->recvSize));
- for (usz i = 0; i < to_copy; i++)
+ const u32 to_copy = std::min(data_status->dataSize, tdata->recvSize);
+ for (flatbuffers::uoffset_t i = 0; i < to_copy; i++)
{
data[i] = fb_data->data()->Get(i);
}
- const usz bytes_left = data_status->dataSize - to_copy;
+ const u32 bytes_left = data_status->dataSize - to_copy;
tdata->tus_data.reserve(bytes_left);
- for (usz i = to_copy; i < bytes_left; i++)
+ for (flatbuffers::uoffset_t i = to_copy; i < bytes_left; i++)
{
tdata->tus_data.push_back(fb_data->data()->Get(i));
}
- for (usz i = 0; i < data_status->info.infoSize; i++)
+ for (flatbuffers::uoffset_t i = 0; i < data_status->info.infoSize; i++)
{
fb_status->info()->Get(i);
}
diff --git a/rpcs3/Emu/NP/rpcn_client.cpp b/rpcs3/Emu/NP/rpcn_client.cpp
index f8f1c7a35d..fdd6bb0db0 100644
--- a/rpcs3/Emu/NP/rpcn_client.cpp
+++ b/rpcs3/Emu/NP/rpcn_client.cpp
@@ -496,7 +496,7 @@ namespace rpcn
if (terminate)
return recvn_result::recvn_terminate;
- int res = wolfSSL_read(read_wssl, reinterpret_cast(buf) + n_recv, n - n_recv);
+ int res = wolfSSL_read(read_wssl, reinterpret_cast(buf) + n_recv, ::narrow(n - n_recv));
if (res <= 0)
{
if (wolfSSL_want_read(read_wssl))
@@ -577,7 +577,7 @@ namespace rpcn
if (!connected)
return false;
- int res = wolfSSL_write(write_wssl, reinterpret_cast(packet.data() + n_sent), packet.size() - n_sent);
+ int res = wolfSSL_write(write_wssl, reinterpret_cast(packet.data() + n_sent), ::narrow(packet.size() - n_sent));
if (res <= 0)
{
if (wolfSSL_want_write(write_wssl))
@@ -713,7 +713,7 @@ namespace rpcn
if (splithost.size() == 2)
{
- port = std::stoul(splithost[1]);
+ port = ::narrow(std::stoul(splithost[1]));
if (port == 0)
{
rpcn_log.error("connect: RPCN port is invalid!");
@@ -759,7 +759,14 @@ namespace rpcn
addr_rpcn.sin_port = std::bit_cast>(port); // htons
addr_rpcn.sin_family = AF_INET;
+#ifdef WIN32
+#pragma warning(push)
+#pragma warning(disable : 4996)
+#endif
hostent* host_addr = gethostbyname(splithost[0].c_str());
+#ifdef WIN32
+#pragma warning(pop)
+#endif
if (!host_addr)
{
rpcn_log.error("connect: Failed to resolve %s", host);
@@ -810,7 +817,7 @@ namespace rpcn
update_local_addr(client_addr.sin_addr.s_addr);
// rpcn_log.notice("Updated local address to %s", np::ip_to_string(std::bit_cast>(local_addr_sig.load())));
- if (wolfSSL_set_fd(read_wssl, sockfd) != WOLFSSL_SUCCESS)
+ if (wolfSSL_set_fd(read_wssl, ::narrow(sockfd)) != WOLFSSL_SUCCESS)
{
rpcn_log.error("connect: Failed to associate wolfssl to the socket");
state = rpcn_state::failure_wolfssl;
@@ -1797,7 +1804,7 @@ namespace rpcn
std::vector data;
std::copy(service_id.begin(), service_id.end(), std::back_inserter(data));
data.push_back(0);
- const le_t size = cookie.size();
+ const le_t size = ::size32(cookie);
std::copy(reinterpret_cast(&size), reinterpret_cast(&size) + sizeof(le_t), std::back_inserter(data));
std::copy(cookie.begin(), cookie.end(), std::back_inserter(data));
@@ -2280,12 +2287,12 @@ namespace rpcn
std::vector rpcn_client::forge_request(u16 command, u64 packet_id, const std::vector& data) const
{
- u32 packet_size = data.size() + RPCN_HEADER_SIZE;
+ const usz packet_size = data.size() + RPCN_HEADER_SIZE;
std::vector packet(packet_size);
packet[0] = PacketType::Request;
reinterpret_cast&>(packet[1]) = command;
- reinterpret_cast&>(packet[3]) = packet_size;
+ reinterpret_cast&>(packet[3]) = ::narrow(packet_size);
reinterpret_cast&>(packet[7]) = packet_id;
memcpy(packet.data() + RPCN_HEADER_SIZE, data.data(), data.size());
@@ -2572,14 +2579,14 @@ namespace rpcn
{
std::lock_guard lock(mutex_friends);
- return friend_infos.friends.size();
+ return ::size32(friend_infos.friends);
}
u32 rpcn_client::get_num_blocks()
{
std::lock_guard lock(mutex_friends);
- return friend_infos.blocked.size();
+ return ::size32(friend_infos.blocked);
}
std::optional rpcn_client::get_friend_by_index(u32 index)
diff --git a/rpcs3/Emu/NP/rpcn_config.cpp b/rpcs3/Emu/NP/rpcn_config.cpp
index decdbb54e2..ff802e554e 100644
--- a/rpcs3/Emu/NP/rpcn_config.cpp
+++ b/rpcs3/Emu/NP/rpcn_config.cpp
@@ -41,11 +41,11 @@ void cfg_rpcn::save() const
}
#endif
- fs::pending_file cfg_file(cfg_rpcn::get_path());
+ const std::string path = cfg_rpcn::get_path();
- if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
+ if (!cfg::node::save(path))
{
- rpcn_log.error("Could not save config: %s (error=%s)", cfg_rpcn::get_path(), fs::g_tls_error);
+ rpcn_log.error("Could not save config: %s (error=%s)", path, fs::g_tls_error);
}
}
diff --git a/rpcs3/Emu/NP/signaling_handler.cpp b/rpcs3/Emu/NP/signaling_handler.cpp
index 85f5558443..cfb4aa153d 100644
--- a/rpcs3/Emu/NP/signaling_handler.cpp
+++ b/rpcs3/Emu/NP/signaling_handler.cpp
@@ -264,14 +264,14 @@ void signaling_handler::process_incoming_messages()
si->last_rtts[(si->rtt_counters % 6)] = rtt;
si->rtt_counters++;
- std::size_t num_rtts = std::min(static_cast(6), si->rtt_counters);
+ usz num_rtts = std::min(static_cast(6), si->rtt_counters);
u64 sum = 0;
- for (std::size_t index = 0; index < num_rtts; index++)
+ for (usz index = 0; index < num_rtts; index++)
{
sum += si->last_rtts[index];
}
- si->rtt = (sum / num_rtts);
+ si->rtt = ::narrow(sum / num_rtts);
};
switch (sp->command)
diff --git a/rpcs3/Emu/NP/signaling_handler.h b/rpcs3/Emu/NP/signaling_handler.h
index 2b92c0772b..6b55af8bc5 100644
--- a/rpcs3/Emu/NP/signaling_handler.h
+++ b/rpcs3/Emu/NP/signaling_handler.h
@@ -33,7 +33,7 @@ struct signaling_info
// Stats
u64 last_rtts[6] = {};
- std::size_t rtt_counters = 0;
+ usz rtt_counters = 0;
u32 rtt = 0;
u32 pings_sent = 1, lost_pings = 0;
u32 packet_loss = 0;
diff --git a/rpcs3/Emu/NP/upnp_config.cpp b/rpcs3/Emu/NP/upnp_config.cpp
index aae1b92e51..13a4f72698 100644
--- a/rpcs3/Emu/NP/upnp_config.cpp
+++ b/rpcs3/Emu/NP/upnp_config.cpp
@@ -31,11 +31,11 @@ void cfg_upnp::save() const
}
#endif
- fs::pending_file cfg_file(cfg_upnp::get_path());
+ const std::string path = cfg_upnp::get_path();
- if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit()))
+ if (!cfg::node::save(path))
{
- upnp_cfg_log.error("Could not save config: %s (error=%s)", cfg_upnp::get_path(), fs::g_tls_error);
+ upnp_cfg_log.error("Could not save config: %s (error=%s)", path, fs::g_tls_error);
}
}
diff --git a/rpcs3/Emu/RSX/Common/expected.hpp b/rpcs3/Emu/RSX/Common/expected.hpp
index 3349c15eb4..39254c3f34 100644
--- a/rpcs3/Emu/RSX/Common/expected.hpp
+++ b/rpcs3/Emu/RSX/Common/expected.hpp
@@ -69,11 +69,18 @@ namespace rsx
: value(value_)
{}
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 26495) // disable warning for uninitialized value member (performance reasons)
+#endif
[[ nodiscard ]] expected(const E& error_)
: error(error_)
{
ensure(!error.empty());
}
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
operator T() const
{
diff --git a/rpcs3/Emu/RSX/Common/tiled_dma_copy.hpp b/rpcs3/Emu/RSX/Common/tiled_dma_copy.hpp
index ab78bfa004..bdfe113feb 100644
--- a/rpcs3/Emu/RSX/Common/tiled_dma_copy.hpp
+++ b/rpcs3/Emu/RSX/Common/tiled_dma_copy.hpp
@@ -185,10 +185,10 @@ namespace rsx
}
}
- static auto tile_texel_data16 = tile_texel_data;
- static auto tile_texel_data32 = tile_texel_data;
- static auto detile_texel_data16 = tile_texel_data;
- static auto detile_texel_data32 = tile_texel_data;
+ [[maybe_unused]] static auto tile_texel_data16 = tile_texel_data;
+ [[maybe_unused]] static auto tile_texel_data32 = tile_texel_data;
+ [[maybe_unused]] static auto detile_texel_data16 = tile_texel_data;
+ [[maybe_unused]] static auto detile_texel_data32 = tile_texel_data;
#undef RSX_TILE_WIDTH
#undef RSX_TILE_HEIGHT
diff --git a/rpcs3/Emu/RSX/GCM.h b/rpcs3/Emu/RSX/GCM.h
index 80633e1651..695b0a7611 100644
--- a/rpcs3/Emu/RSX/GCM.h
+++ b/rpcs3/Emu/RSX/GCM.h
@@ -115,14 +115,15 @@ struct GcmZcullInfo
CellGcmZcullInfo pack() const
{
- CellGcmZcullInfo ret;
-
- ret.region = (1<<0) | (zFormat<<4) | (aaFormat<<8);
- ret.size = ((width>>6)<<22) | ((height>>6)<<6);
- ret.start = cullStart&(~0xFFF);
- ret.offset = offset;
- ret.status0 = (zcullDir<<1) | (zcullFormat<<2) | ((sFunc&0xF)<<12) | (sRef<<16) | (sMask<<24);
- ret.status1 = (0x2000<<0) | (0x20<<16);
+ CellGcmZcullInfo ret
+ {
+ .region = (1<<0) | (zFormat<<4) | (aaFormat<<8),
+ .size = ((width>>6)<<22) | ((height>>6)<<6),
+ .start = cullStart&(~0xFFF),
+ .offset = offset,
+ .status0 = (zcullDir<<1) | (zcullFormat<<2) | ((sFunc&0xF)<<12) | (sRef<<16) | (sMask<<24),
+ .status1 = (0x2000<<0) | (0x20<<16)
+ };
return ret;
}
@@ -143,12 +144,13 @@ struct GcmTileInfo
CellGcmTileInfo pack() const
{
- CellGcmTileInfo ret;
-
- ret.tile = (location + 1) | (bank << 4) | ((offset / 0x10000) << 16) | (location << 31);
- ret.limit = ((offset + size - 1) / 0x10000) << 16 | (location << 31);
- ret.pitch = (pitch / 0x100) << 8;
- ret.format = base | ((base + ((size - 1) / 0x10000)) << 13) | (comp << 26) | (1 << 30);
+ CellGcmTileInfo ret
+ {
+ .tile = (location + 1) | (bank << 4) | ((offset / 0x10000) << 16) | (location << 31),
+ .limit = ((offset + size - 1) / 0x10000) << 16 | (location << 31),
+ .pitch = (pitch / 0x100) << 8,
+ .format = base | ((base + ((size - 1) / 0x10000)) << 13) | (comp << 26) | (1 << 30)
+ };
return ret;
}
diff --git a/rpcs3/Emu/RSX/Program/ProgramStateCache.h b/rpcs3/Emu/RSX/Program/ProgramStateCache.h
index 664c37b000..6f13ab20db 100644
--- a/rpcs3/Emu/RSX/Program/ProgramStateCache.h
+++ b/rpcs3/Emu/RSX/Program/ProgramStateCache.h
@@ -178,7 +178,7 @@ protected:
return std::forward_as_tuple(__null_vertex_program, false);
}
- rsx_log.notice("VP not found in buffer!");
+ rsx_log.trace("VP not found in buffer!");
lock.upgrade();
auto [it, inserted] = m_vertex_shader_cache.try_emplace(rsx_vp);
@@ -215,7 +215,7 @@ protected:
return std::forward_as_tuple(__null_fragment_program, false);
}
- rsx_log.notice("FP not found in buffer!");
+ rsx_log.trace("FP not found in buffer!");
lock.upgrade();
std::tie(it, recompile) = m_fragment_shader_cache.try_emplace(rsx_fp);
diff --git a/rpcs3/Emu/RSX/Program/RSXFragmentProgram.h b/rpcs3/Emu/RSX/Program/RSXFragmentProgram.h
index c0de8bf023..3b3f9273a9 100644
--- a/rpcs3/Emu/RSX/Program/RSXFragmentProgram.h
+++ b/rpcs3/Emu/RSX/Program/RSXFragmentProgram.h
@@ -248,7 +248,7 @@ struct RSXFragmentProgram
this->operator=(other);
}
- data_storage_helper(data_storage_helper&& other)
+ data_storage_helper(data_storage_helper&& other) noexcept
: data_ptr(other.data_ptr)
, local_storage(std::move(other.local_storage))
{
@@ -273,7 +273,7 @@ struct RSXFragmentProgram
return *this;
}
- data_storage_helper& operator=(data_storage_helper&& other)
+ data_storage_helper& operator=(data_storage_helper&& other) noexcept
{
if (this == &other) return *this;
diff --git a/rpcs3/Emu/RSX/RSXTexture.cpp b/rpcs3/Emu/RSX/RSXTexture.cpp
index fd182e3b34..3af6c4c395 100644
--- a/rpcs3/Emu/RSX/RSXTexture.cpp
+++ b/rpcs3/Emu/RSX/RSXTexture.cpp
@@ -237,7 +237,7 @@ namespace rsx
f32 fragment_texture::bias() const
{
const f32 bias = rsx::decode_fxp<4, 8>((registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)]) & 0x1fff);
- return std::clamp(bias + g_cfg.video.texture_lod_bias, -16.f, 16.f - 1.f / 256);
+ return std::clamp(bias + static_cast(g_cfg.video.texture_lod_bias.get()), -16.f, 16.f - 1.f / 256);
}
rsx::texture_minify_filter fragment_texture::min_filter() const
@@ -392,7 +392,7 @@ namespace rsx
f32 vertex_texture::bias() const
{
const f32 bias = rsx::decode_fxp<4, 8>((registers[NV4097_SET_VERTEX_TEXTURE_FILTER + (m_index * 8)]) & 0x1fff);
- return std::clamp(bias + g_cfg.video.texture_lod_bias, -16.f, 16.f - 1.f / 256);
+ return std::clamp(bias + static_cast(g_cfg.video.texture_lod_bias.get()), -16.f, 16.f - 1.f / 256);
}
rsx::texture_minify_filter vertex_texture::min_filter() const
diff --git a/rpcs3/Emu/RSX/VK/VKDMA.cpp b/rpcs3/Emu/RSX/VK/VKDMA.cpp
index f4ce1ef175..d1119bdd56 100644
--- a/rpcs3/Emu/RSX/VK/VKDMA.cpp
+++ b/rpcs3/Emu/RSX/VK/VKDMA.cpp
@@ -413,7 +413,7 @@ namespace vk
std::lock_guard lock(g_dma_mutex);
const u32 start = (local_address & s_dma_block_mask);
- const u32 end = utils::align(local_address + length, s_dma_block_length);
+ const u32 end = utils::align(local_address + length, static_cast(s_dma_block_length));
for (u32 block = start; block < end;)
{
diff --git a/rpcs3/Emu/RSX/rsx_methods.h b/rpcs3/Emu/RSX/rsx_methods.h
index 6896fca2eb..7347c24b81 100644
--- a/rpcs3/Emu/RSX/rsx_methods.h
+++ b/rpcs3/Emu/RSX/rsx_methods.h
@@ -469,7 +469,7 @@ namespace rsx
return *this;
}
- rsx_state& operator=(rsx_state&& in)
+ rsx_state& operator=(rsx_state&& in) noexcept
{
registers = std::move(in.registers);
transform_program = std::move(in.transform_program);
@@ -528,7 +528,7 @@ namespace rsx
this->operator=(other);
}
- rsx_state(rsx_state&& other)
+ rsx_state(rsx_state&& other) noexcept
: rsx_state()
{
this->operator=(std::move(other));
diff --git a/rpcs3/Input/keyboard_pad_handler.cpp b/rpcs3/Input/keyboard_pad_handler.cpp
index ece364f1f1..ca14c31b47 100644
--- a/rpcs3/Input/keyboard_pad_handler.cpp
+++ b/rpcs3/Input/keyboard_pad_handler.cpp
@@ -260,6 +260,11 @@ void keyboard_pad_handler::release_all_keys()
for (usz i = 0; i < pad.m_sticks.size(); i++)
{
+ if (i >= max_sticks)
+ {
+ input_log.fatal("Too many sticks (%d vs %d)", pad.m_sticks.size(), max_sticks);
+ break;
+ }
m_stick_min[i] = 0;
m_stick_max[i] = 128;
m_stick_val[i] = 128;
diff --git a/rpcs3/Input/keyboard_pad_handler.h b/rpcs3/Input/keyboard_pad_handler.h
index 3fa69286e2..f5199a3edf 100644
--- a/rpcs3/Input/keyboard_pad_handler.h
+++ b/rpcs3/Input/keyboard_pad_handler.h
@@ -125,9 +125,11 @@ private:
f32 m_r_stick_lerp_factor = 1.0f;
u32 m_l_stick_multiplier = 100;
u32 m_r_stick_multiplier = 100;
- std::array m_stick_min{ 0, 0, 0, 0 };
- std::array m_stick_max{ 128, 128, 128, 128 };
- std::array m_stick_val{ 128, 128, 128, 128 };
+
+ static constexpr usz max_sticks = 4;
+ std::array m_stick_min{ 0, 0, 0, 0 };
+ std::array m_stick_max{ 128, 128, 128, 128 };
+ std::array m_stick_val{ 128, 128, 128, 128 };
// Mouse Movements
steady_clock::time_point m_last_mouse_move_left;
diff --git a/rpcs3/Input/mm_joystick_handler.cpp b/rpcs3/Input/mm_joystick_handler.cpp
index 206b08b764..929717f99b 100644
--- a/rpcs3/Input/mm_joystick_handler.cpp
+++ b/rpcs3/Input/mm_joystick_handler.cpp
@@ -420,8 +420,8 @@ std::unordered_map mm_joystick_handler::GetButtonValues(const JOYINFOE
auto add_axis_value = [&](DWORD axis, UINT min, UINT max, u64 pos, u64 neg)
{
- constexpr int deadzone = 0;
- const float val = ScaledAxisInput(axis, min, max, deadzone);
+ constexpr f32 deadzone = 0.0f;
+ const float val = ScaledAxisInput(static_cast(axis), static_cast(min), static_cast(max), deadzone);
if (val < 0)
{
button_values.emplace(pos, 0);
diff --git a/rpcs3/Loader/ELF.h b/rpcs3/Loader/ELF.h
index 34bb06c267..82dfed01cd 100644
--- a/rpcs3/Loader/ELF.h
+++ b/rpcs3/Loader/ELF.h
@@ -463,7 +463,7 @@ public:
// Rely on previous sh_offset value!
if (hdr.p_offset <= shdr.sh_offset && shdr.sh_offset + shdr.sh_size - 1 <= hdr.p_offset + hdr.p_filesz - 1)
{
- out.sh_offset = data_base + shdr.sh_offset - hdr.p_offset;
+ out.sh_offset = ::narrow