fix some warnings

This commit is contained in:
Megamouse 2023-12-29 18:33:29 +01:00
parent b1c48e66c9
commit 59c58aa3cf
72 changed files with 263 additions and 203 deletions

View file

@ -198,6 +198,7 @@
<PreprocessorDefinitions>ASMJIT_STATIC;ASMJIT_NO_DEPRECATED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release'">MaxSpeed</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization>
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">TurnOffAllWarnings</WarningLevel>
</ClCompile>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View file

@ -47,7 +47,7 @@
<PreprocessorDefinitions>HAVE_SNI;NDEBUG;BUILDING_LIBCURL;CURL_STATICLIB;USE_WOLFSSL;NO_MD4;WOLFSSL_USER_SETTINGS;USE_IPV6;SIZEOF_LONG=4;SIZEOF_LONG_LONG=8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level4</WarningLevel>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View file

@ -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

View file

@ -66,7 +66,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
</ItemDefinitionGroup>

View file

@ -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);

View file

@ -101,6 +101,8 @@ namespace cfg
// Set multiple values. Implementation-specific, optional.
virtual bool from_list(std::vector<std::string>&&);
bool save(std::string_view cfg_name) const;
};
// Config tree node which contains another nodes

View file

@ -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()
{

View file

@ -495,7 +495,8 @@ namespace fs
{
std::basic_string<T> 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<T> 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;
}

View file

@ -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<int>(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<std::codecvt_utf8<wchar_t>, 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<std::codecvt_utf8_utf16<char16_t>, 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<int>(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<std::codecvt_utf8_utf16<wchar_t>, wchar_t> converter{};

View file

@ -1031,12 +1031,12 @@ static usz apply_modification(std::basic_string<u32>& 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<u32>(p.original_value.size(), 1);
memory_size = utils::add_saturate<u32>(::size32(p.original_value), 1);
break;
}
case patch_type::move_file:

View file

@ -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);

View file

@ -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
}

View file

@ -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] = {};

View file

@ -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<u32>(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<u32>(ppu_frsqrte_mantissas[idx] | exp);
}
}
}

View file

@ -7,6 +7,8 @@
#include "Emu/Cell/lv2/sys_event.h"
#include "Emu/IdManager.h"
#include <cmath>
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<u32>(static_cast<u64>(std::ceil(width * height * bytes_per_pixel)));
}

View file

@ -385,7 +385,7 @@ error_code cellFsGetFreeSize(ppu_thread& ppu, vm::cptr<char> path, vm::ptr<u32>
}
*block_count = *avail / *_block_size;
*block_size = *_block_size;
*block_size = ::narrow<u32>(*_block_size);
}
return CELL_OK;

View file

@ -141,7 +141,7 @@ static u32 ppu_test(const be_t<u32>* ptr, const void* fend, ppu_pattern_array pa
cur++;
}
return (cur - ptr) * sizeof(*ptr);
return ::narrow<u32>((cur - ptr) * sizeof(*ptr));
}
static u32 ppu_test(const be_t<u32>* 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<u32>(funcs.size(), 128);
const bool error = per_instruction_bytes >= 200 && per_instruction_bytes / 4 >= utils::aligned_div<u32>(::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);
}

View file

@ -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<const u8*>(ls_segment.data()), ls_segment.size()}, 0))
if (spu_thread::is_exec_code(::narrow<u32>(instruction), {reinterpret_cast<const u8*>(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<u32>(seg.size, utils::align<u32>(i + addr_last + 256, 128));
u32 end = std::min<u32>(seg.size, utils::align<u32>(::narrow<u32>(i + addr_last + 256), 128));
u32 guessed_ls_addr = 0;
@ -1738,7 +1738,7 @@ std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, bool virtual_lo
};
// Access library information (TODO)
const auto lib_info = ensure(prx->get_ptr<const ppu_prx_library_info>(prx->segs[0].addr + elf.progs[0].p_paddr - elf.progs[0].p_offset));
const auto lib_info = ensure(prx->get_ptr<const ppu_prx_library_info>(::narrow<u32>(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<lv2_prx> 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<u64> args = vm::cast(static_cast<u32>(ppu->stack_addr + ppu->stack_size - stack_alloc_size - utils::align<u32>(Emu.data.size(), 0x10)));
vm::ptr<u64> args = vm::cast(static_cast<u32>(ppu->stack_addr + ppu->stack_size - stack_alloc_size - utils::align<u32>(::size32(Emu.data), 0x10)));
vm::ptr<u8> args_data = vm::cast(args.addr() + pointers_storage_size);
const vm::ptr<u64> argv = args;

View file

@ -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<u32>(reg)))
{
is_function = true;
}
const auto gpr_buf = vm::get_super_ptr<u8>(reg);
const auto gpr_buf = vm::get_super_ptr<u8>(static_cast<u32>(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<u32>(reg));
fmt::append(ret, " -> %s", dis_asm.last_opcode);
}
}

View file

@ -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)

View file

@ -707,7 +707,7 @@ void spu_cache::initialize(bool build_existing_cache)
auto data_list = g_fxo->get<spu_cache>().precompile_funcs.pop_all();
g_fxo->get<spu_cache>().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<u32>(add_count) : 0;
}
worker_count = std::min<u32>(rpcs3::utils::get_max_threads(), add_count);
worker_count = std::min<u32>(rpcs3::utils::get_max_threads(), ::narrow<u32>(add_count));
}
atomic_t<u32> 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<u32>(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<be_t<u32>>(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<u32> spu_thread::discover_functions(u32 base_addr, std::span<const u
// TODO: Does not detect jumptables or fixed-addr indirect calls
const v128 brasl_mask = is_known_addr ? v128::from32p(0x62u << 23) : v128::from32p(umax);
for (u32 i = utils::align<u32>(base_addr, 0x10); i < std::min<u32>(base_addr + ls.size(), 0x3FFF0); i += 0x10)
for (u32 i = utils::align<u32>(base_addr, 0x10); i < std::min<u32>(base_addr + ::size32(ls), 0x3FFF0); i += 0x10)
{
// Search for BRSL LR and BRASL LR or BR
// TODO: BISL
@ -2323,7 +2323,7 @@ std::vector<u32> spu_thread::discover_functions(u32 base_addr, std::span<const u
// Search for AI R1, +x or OR R3/4, Rx, 0
// Reasoning: AI R1, +x means stack pointer restoration, branch after that is likely a tail call
// R3 and R4 are common function arguments because they are the first two
for (u32 back = addr - 4, it = 10; it && back >= base_addr && back < std::min<u32>(base_addr + ls.size(), 0x3FFF0); it--, back -= 4)
for (u32 back = addr - 4, it = 10; it && back >= base_addr && back < std::min<u32>(base_addr + ::size32(ls), 0x3FFF0); it--, back -= 4)
{
const spu_opcode_t test_op{read_from_ptr<be_t<u32>>(ls, back - base_addr)};
const auto type = g_spu_itype.decode(test_op.opcode);

View file

@ -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<const u8*>(item_ptr) - this->ls;
args.eal = ::narrow<u32>(reinterpret_cast<const u8*>(item_ptr) - this->ls);
args.lsa = arg_lsa;
args.size = arg_size;
return false;
@ -4750,7 +4750,7 @@ std::pair<u32, u32> spu_thread::read_dec() const
return {static_cast<u32>(res), static_cast<u32>(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)
{

View file

@ -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);

View file

@ -1536,7 +1536,7 @@ bool lv2_obj::awake_unlocked(cpu_thread* cpu, s32 prio)
});
};
const s32 old_prio = static_cast<ppu_thread*>(cpu)->prio.load().prio;
const s64 old_prio = static_cast<ppu_thread*>(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<u32>(remaining * (utils::get_tsc_freq() / 1000000ULL));
if (utils::has_waitpkg())
{

View file

@ -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<usz>(version_f * 10000);
}
system_sw_version(const system_sw_version&) = delete;

View file

@ -968,7 +968,7 @@ std::optional<s32> lv2_socket_native::sendto(s32 flags, const std::vector<u8>& b
if (dnshook.is_dns(lv2_id))
{
const s32 ret_analyzer = dnshook.analyze_dns_packet(lv2_id, reinterpret_cast<const u8*>(buf.data()), buf.size());
const s32 ret_analyzer = dnshook.analyze_dns_packet(lv2_id, reinterpret_cast<const u8*>(buf.data()), ::size32(buf));
// Check if the packet is intercepted
if (ret_analyzer >= 0)
@ -977,7 +977,7 @@ std::optional<s32> lv2_socket_native::sendto(s32 flags, const std::vector<u8>& b
}
}
native_result = ::sendto(socket, reinterpret_cast<const char*>(buf.data()), buf.size(), native_flags, native_addr ? reinterpret_cast<struct sockaddr*>(&native_addr.value()) : nullptr, native_addr ? sizeof(sockaddr_in) : 0);
native_result = ::sendto(socket, reinterpret_cast<const char*>(buf.data()), ::narrow<int>(buf.size()), native_flags, native_addr ? reinterpret_cast<struct sockaddr*>(&native_addr.value()) : nullptr, native_addr ? sizeof(sockaddr_in) : 0);
if (native_result >= 0)
{
@ -1025,7 +1025,7 @@ std::optional<s32> lv2_socket_native::sendmsg(s32 flags, const sys_net_msghdr& m
const u32 len = msg.msg_iov[i].iov_len;
const std::vector<u8> buf_copy(vm::_ptr<const char>(iov_base.addr()), vm::_ptr<const char>(iov_base.addr()) + len);
native_result = ::send(socket, reinterpret_cast<const char*>(buf_copy.data()), buf_copy.size(), native_flags);
native_result = ::send(socket, reinterpret_cast<const char*>(buf_copy.data()), ::narrow<int>(buf_copy.size()), native_flags);
if (native_result >= 0)
{

View file

@ -222,7 +222,7 @@ s32 lv2_socket_p2p::setsockopt(s32 level, s32 optname, const std::vector<u8>& op
const u64 key = (static_cast<u64>(level) << 32) | static_cast<u64>(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<s32> lv2_socket_p2p::sendto(s32 flags, const std::vector<u8>& buf,
native_flags |= MSG_WAITALL;
}
auto native_result = ::sendto(socket, reinterpret_cast<const char*>(p2p_data.data()), p2p_data.size(), native_flags, reinterpret_cast<struct sockaddr*>(&native_addr), sizeof(native_addr));
auto native_result = ::sendto(socket, reinterpret_cast<const char*>(p2p_data.data()), ::size32(p2p_data), native_flags, reinterpret_cast<struct sockaddr*>(&native_addr), sizeof(native_addr));
if (native_result >= 0)
{

View file

@ -129,7 +129,7 @@ public:
ensure(sock.get_type() == SYS_NET_SOCK_STREAM_P2P);
auto& sock_p2ps = reinterpret_cast<lv2_socket_p2ps&>(sock);
if (::sendto(sock_p2ps.get_socket(), reinterpret_cast<const char*>(msg.data.data()), msg.data.size(), 0, reinterpret_cast<const sockaddr*>(&msg.dst_addr), sizeof(msg.dst_addr)) == -1)
if (::sendto(sock_p2ps.get_socket(), reinterpret_cast<const char*>(msg.data.data()), ::size32(msg.data), 0, reinterpret_cast<const sockaddr*>(&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<u8>(p2ps_tcp_flags::ACK))
{
auto& tcpm = g_fxo->get<named_thread<tcp_timeout_monitor>>();
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<u8>(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<u8> data, const ::sockaddr_in* dst, u32 seq, bool require_ack)
void lv2_socket_p2ps::send_u2s_packet(std::vector<u8> 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<u16, be_t<u16>>(dst->sin_port));
if (::sendto(socket, reinterpret_cast<char*>(data.data()), data.size(), 0, reinterpret_cast<const sockaddr*>(dst), sizeof(sockaddr_in)) == -1)
if (::sendto(socket, reinterpret_cast<char*>(data.data()), ::size32(data), 0, reinterpret_cast<const sockaddr*>(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<std::tuple<s32, std::vector<u8>, sys_net_sockaddr>> lv2_socket_p2p
return std::nullopt;
}
const u32 to_give = std::min<u32>(data_available, len);
const u32 to_give = static_cast<u32>(std::min<u64>(data_available, len));
sys_net_sockaddr addr{};
std::vector<u8> dest_buf(to_give);
@ -819,7 +819,7 @@ std::optional<s32> lv2_socket_p2ps::sendto([[maybe_unused]] s32 flags, const std
tcp_header.dst_port = op_vport;
// chop it up
std::vector<std::vector<u8>> 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<s32> lv2_socket_p2ps::sendto([[maybe_unused]] s32 flags, const std
cur_seq += cur_data_len;
}
return {buf.size()};
return {::size32(buf)};
}
std::optional<s32> lv2_socket_p2ps::sendmsg([[maybe_unused]] s32 flags, [[maybe_unused]] const sys_net_msghdr& msg, [[maybe_unused]] bool is_lock)

View file

@ -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<u8> data, const ::sockaddr_in* dst, u32 seq, bool require_ack);
void send_u2s_packet(std::vector<u8> data, const ::sockaddr_in* dst, u64 seq, bool require_ack);
std::tuple<bool, s32, std::shared_ptr<lv2_socket>, sys_net_sockaddr> accept(bool is_lock = true) override;
s32 bind(const sys_net_sockaddr& addr) override;

View file

@ -97,7 +97,7 @@ std::optional<std::tuple<s32, std::vector<u8>, sys_net_sockaddr>> lv2_socket_raw
std::optional<s32> lv2_socket_raw::sendto([[maybe_unused]] s32 flags, [[maybe_unused]] const std::vector<u8>& buf, [[maybe_unused]] std::optional<sys_net_sockaddr> opt_sn_addr, [[maybe_unused]] bool is_lock)
{
sys_net.todo("lv2_socket_raw::sendto");
return buf.size();
return ::size32(buf);
}
std::optional<s32> lv2_socket_raw::sendmsg([[maybe_unused]] s32 flags, [[maybe_unused]] const sys_net_msghdr& msg, [[maybe_unused]] bool is_lock)

View file

@ -18,7 +18,7 @@ s32 send_packet_from_p2p_port(const std::vector<u8>& 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<const char*>(data.data()), data.size(), 0, reinterpret_cast<const sockaddr*>(&addr), sizeof(sockaddr_in));
res = ::sendto(def_port.p2p_socket, reinterpret_cast<const char*>(data.data()), ::size32(data), 0, reinterpret_cast<const sockaddr*>(&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

View file

@ -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<char*>(p2p_recv_data.data()), p2p_recv_data.size(), 0, reinterpret_cast<struct sockaddr*>(&native_addr), &native_addrlen);
const auto recv_res = ::recvfrom(p2p_socket, reinterpret_cast<char*>(p2p_recv_data.data()), ::size32(p2p_recv_data), 0, reinterpret_cast<struct sockaddr*>(&native_addr), &native_addrlen);
if (recv_res == -1)
{

View file

@ -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<u32> applied_patches;

View file

@ -756,7 +756,7 @@ void lv2_prx::restore_exports()
std::basic_string<bool> 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)))
{

View file

@ -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;

View file

@ -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<u32>(result / 0x200ull);
}
*sectors_read = num_sectors;

View file

@ -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);
}
}

View file

@ -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<u16>(0);
}
return static_cast<u16>(ScaledInput(value, trigger_min, trigger_max, threshold));
return static_cast<u16>(ScaledInput(static_cast<f32>(value), static_cast<f32>(trigger_min), static_cast<f32>(trigger_max), static_cast<f32>(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<u16>(0);
}
return static_cast<u16>(ScaledInput(raw_value, 0, maximum, threshold));
return static_cast<u16>(ScaledInput(static_cast<f32>(raw_value), 0.0f, static_cast<f32>(maximum), static_cast<f32>(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<u16>(ScaledInput(scaled_value, 0, thumb_max, threshold));
return static_cast<u16>(ScaledInput(static_cast<f32>(scaled_value), 0.0f, static_cast<f32>(thumb_max), static_cast<f32>(threshold)));
}
// This function normalizes stick deadzone based on the DS3's deadzone, which is ~13%

View file

@ -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; }

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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<u8, 2> header;
header = {header.size(), type};
if (!buf)
{
return 0;
}
u32 expected_count = buf ? std::min<u32>(header.size(), buf_size) : 0;
memcpy(buf, header.data(), expected_count);
std::array<u8, 2> header;
header = {static_cast<u8>(header.size()), type};
u32 expected_count = std::min<u32>(static_cast<u32>(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<u8>(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<u8>(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<u8>(sizeof(u16) + header.size());
buf[0] = len;
expected_count = std::min(len, ::narrow<u8>(buf_size));
constexpr le_t<u16> 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<u8>(std::min(u16str.size() * sizeof(u16) + header.size(), static_cast<usz>(0xFF)));
buf[0] = len;
expected_count = std::min(len, ::narrow<u8>(std::min<u32>(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<u32>(sizeof(u16), buf_size) : 0;
const u16 device_status = static_cast<int>(self_powered) | static_cast<int>(remote_wakeup) << 1;
memcpy(buf, &device_status, expected_count);
std::memcpy(buf, &device_status, expected_count);
return expected_count;
}

View file

@ -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<SceNpMatching2TeamId>(mi->dst()->Get(0)); break;
default: ensure(false);
}

View file

@ -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<u32>(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++;
}
}

View file

@ -12,7 +12,7 @@ namespace np
{
struct userinfo_cache
{
SceNpId npId;
SceNpId npId{};
std::optional<SceNpOnlineName> onlineName;
std::optional<SceNpAvatarUrl> avatarUrl;
};

View file

@ -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<SceNpMatching2GetWorldInfoListResponse*>(edata.data());
world_info->worldNum = world_list.size();
world_info->worldNum = ::size32(world_list);
if (!world_list.empty())
{
auto* worlds = edata.allocate<SceNpMatching2World>(sizeof(SceNpMatching2World) * world_list.size(), world_info->world);
auto* worlds = edata.allocate<SceNpMatching2World>(::narrow<u32>(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<usz>(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<usz>(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<u8 *>(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<usz>(data_status->dataSize), static_cast<usz>(tdata->recvSize));
for (usz i = 0; i < to_copy; i++)
const u32 to_copy = std::min<u32>(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);
}

View file

@ -496,7 +496,7 @@ namespace rpcn
if (terminate)
return recvn_result::recvn_terminate;
int res = wolfSSL_read(read_wssl, reinterpret_cast<char*>(buf) + n_recv, n - n_recv);
int res = wolfSSL_read(read_wssl, reinterpret_cast<char*>(buf) + n_recv, ::narrow<s32>(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<const char*>(packet.data() + n_sent), packet.size() - n_sent);
int res = wolfSSL_write(write_wssl, reinterpret_cast<const char*>(packet.data() + n_sent), ::narrow<s32>(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<u16>(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<u16, be_t<u16>>(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<u32, be_t<u32>>(local_addr_sig.load())));
if (wolfSSL_set_fd(read_wssl, sockfd) != WOLFSSL_SUCCESS)
if (wolfSSL_set_fd(read_wssl, ::narrow<int>(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<u8> data;
std::copy(service_id.begin(), service_id.end(), std::back_inserter(data));
data.push_back(0);
const le_t<u32> size = cookie.size();
const le_t<u32> size = ::size32(cookie);
std::copy(reinterpret_cast<const u8*>(&size), reinterpret_cast<const u8*>(&size) + sizeof(le_t<u32>), std::back_inserter(data));
std::copy(cookie.begin(), cookie.end(), std::back_inserter(data));
@ -2280,12 +2287,12 @@ namespace rpcn
std::vector<u8> rpcn_client::forge_request(u16 command, u64 packet_id, const std::vector<u8>& data) const
{
u32 packet_size = data.size() + RPCN_HEADER_SIZE;
const usz packet_size = data.size() + RPCN_HEADER_SIZE;
std::vector<u8> packet(packet_size);
packet[0] = PacketType::Request;
reinterpret_cast<le_t<u16>&>(packet[1]) = command;
reinterpret_cast<le_t<u32>&>(packet[3]) = packet_size;
reinterpret_cast<le_t<u32>&>(packet[3]) = ::narrow<u32>(packet_size);
reinterpret_cast<le_t<u64>&>(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<std::string> rpcn_client::get_friend_by_index(u32 index)

View file

@ -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);
}
}

View file

@ -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<std::size_t>(6), si->rtt_counters);
usz num_rtts = std::min(static_cast<std::size_t>(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<u32>(sum / num_rtts);
};
switch (sp->command)

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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
{

View file

@ -185,10 +185,10 @@ namespace rsx
}
}
static auto tile_texel_data16 = tile_texel_data<u16, false>;
static auto tile_texel_data32 = tile_texel_data<u32, false>;
static auto detile_texel_data16 = tile_texel_data<u16, true>;
static auto detile_texel_data32 = tile_texel_data<u32, true>;
[[maybe_unused]] static auto tile_texel_data16 = tile_texel_data<u16, false>;
[[maybe_unused]] static auto tile_texel_data32 = tile_texel_data<u32, false>;
[[maybe_unused]] static auto detile_texel_data16 = tile_texel_data<u16, true>;
[[maybe_unused]] static auto detile_texel_data32 = tile_texel_data<u32, true>;
#undef RSX_TILE_WIDTH
#undef RSX_TILE_HEIGHT

View file

@ -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;
}

View file

@ -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);

View file

@ -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;

View file

@ -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<f32>(bias + g_cfg.video.texture_lod_bias, -16.f, 16.f - 1.f / 256);
return std::clamp<f32>(bias + static_cast<f32>(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<f32>(bias + g_cfg.video.texture_lod_bias, -16.f, 16.f - 1.f / 256);
return std::clamp<f32>(bias + static_cast<f32>(g_cfg.video.texture_lod_bias.get()), -16.f, 16.f - 1.f / 256);
}
rsx::texture_minify_filter vertex_texture::min_filter() const

View file

@ -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<u32>(s_dma_block_length));
for (u32 block = start; block < end;)
{

View file

@ -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));

View file

@ -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;

View file

@ -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<u8, 4> m_stick_min{ 0, 0, 0, 0 };
std::array<u8, 4> m_stick_max{ 128, 128, 128, 128 };
std::array<u8, 4> m_stick_val{ 128, 128, 128, 128 };
static constexpr usz max_sticks = 4;
std::array<u8, max_sticks> m_stick_min{ 0, 0, 0, 0 };
std::array<u8, max_sticks> m_stick_max{ 128, 128, 128, 128 };
std::array<u8, max_sticks> m_stick_val{ 128, 128, 128, 128 };
// Mouse Movements
steady_clock::time_point m_last_mouse_move_left;

View file

@ -420,8 +420,8 @@ std::unordered_map<u64, u16> 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<f32>(axis), static_cast<f32>(min), static_cast<f32>(max), deadzone);
if (val < 0)
{
button_values.emplace(pos, 0);

View file

@ -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<sz_t>(data_base + static_cast<usz>(shdr.sh_offset - hdr.p_offset));
result = true;
break;
}

View file

@ -1049,7 +1049,7 @@ int main(int argc, char** argv)
}
// Check nonsensical archive locations
for (const std::string& expr : { "/Rar$" })
for (const std::string_view& expr : { "/Rar$"sv })
{
if (emu_dir.find(expr) != umax)
{

View file

@ -147,12 +147,12 @@ namespace gui
// Convert an arbitrary count of bytes to a readable format using global units (KB, MB...)
QString format_byte_size(usz size);
static Qt::ColorScheme color_scheme()
static inline Qt::ColorScheme color_scheme()
{
return QGuiApplication::styleHints()->colorScheme();
}
static bool dark_mode_active()
static inline bool dark_mode_active()
{
return color_scheme() == Qt::ColorScheme::Dark;
}

View file

@ -1694,7 +1694,7 @@ public:
atomic_wait::info ext[2]{};
ext[0].data = reinterpret_cast<const char*>(&m_data) + 4;
ext[0].old = std::bit_cast<u64>(old_value) >> 32;
atomic_wait_engine::wait(&m_data, std::bit_cast<u64>(old_value), static_cast<u64>(timeout), ext);
atomic_wait_engine::wait(&m_data, ::narrow<u32>(std::bit_cast<u64>(old_value)), static_cast<u64>(timeout), ext);
}
void notify_one()

View file

@ -331,7 +331,7 @@ namespace utils
}
else
{
percent = (sys.QuadPart - m_sys_cpu) + (usr.QuadPart - m_usr_cpu);
percent = static_cast<double>((sys.QuadPart - m_sys_cpu) + (usr.QuadPart - m_usr_cpu));
percent /= (now.QuadPart - m_last_cpu);
percent /= utils::get_thread_count(); // Let's assume this is at least 1
percent *= 100;

View file

@ -130,7 +130,8 @@ namespace stx
template <typename T>
static void call_dtor(void* ptr) noexcept
{
std::launder(static_cast<T*>(ptr))->~T();
auto* obj = std::launder(static_cast<T*>(ptr));
obj->~T();
std::memset(ptr, 0xCC, sizeof(T)); // Set to trap values
}

View file

@ -33,7 +33,7 @@ LOG_CHANNEL(media_log, "Media");
namespace utils
{
template <typename T>
static inline void write_byteswapped(const u8* src, u8* dst)
static inline void write_byteswapped(const void* src, void* dst)
{
*reinterpret_cast<T*>(dst) = *reinterpret_cast<const be_t<T>*>(src);
}

View file

@ -163,11 +163,16 @@ union alignas(16) v128
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
#elif _MSC_VER
#pragma warning(push)
#pragma warning(disable : 6001)
#endif
v128 ret;
return ret;
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#elif _MSC_VER
#pragma warning(pop)
#endif
}