diff --git a/Utilities/geometry.h b/Utilities/geometry.h index b90286c54c..faace6c77e 100644 --- a/Utilities/geometry.h +++ b/Utilities/geometry.h @@ -777,9 +777,9 @@ struct color4_base }; constexpr color4_base() - : x{} - , y{} - , z{} + : x{ T{0} } + , y{ T{0} } + , z{ T{0} } , w{ T(1) } { } diff --git a/rpcs3/Emu/Cell/Modules/cellCamera.cpp b/rpcs3/Emu/Cell/Modules/cellCamera.cpp index 7ecad36c3e..708f88753c 100644 --- a/rpcs3/Emu/Cell/Modules/cellCamera.cpp +++ b/rpcs3/Emu/Cell/Modules/cellCamera.cpp @@ -1372,7 +1372,7 @@ error_code cellCameraReadEx(s32 dev_num, vm::ptr read) return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND; } - g_camera.bytes_read = bytes_read; + g_camera.bytes_read = ::narrow(bytes_read); cellCamera.trace("cellCameraRead: frame_number=%d, width=%d, height=%d. bytes_read=%d (passed to game: frame=%d, bytesread=%d)", frame_number, width, height, bytes_read, read ? read->frame.get() : 0, read ? read->bytesread.get() : 0); @@ -1385,7 +1385,7 @@ error_code cellCameraReadEx(s32 dev_num, vm::ptr read) if (has_new_frame) { - g_camera.frame_timestamp = (get_guest_system_time() - g_camera.start_timestamp); + g_camera.frame_timestamp = ::narrow(get_guest_system_time() - g_camera.start_timestamp); } if (read) // NULL returns CELL_OK diff --git a/rpcs3/Emu/Cell/Modules/cellHttpUtil.cpp b/rpcs3/Emu/Cell/Modules/cellHttpUtil.cpp index 4308a08bcc..b3a521867f 100644 --- a/rpcs3/Emu/Cell/Modules/cellHttpUtil.cpp +++ b/rpcs3/Emu/Cell/Modules/cellHttpUtil.cpp @@ -248,7 +248,7 @@ error_code cellHttpUtilBuildRequestLine(vm::cptr req, vm::p if (required) { - *required = result.size(); + *required = ::narrow(result.size()); } return CELL_OK; @@ -277,7 +277,7 @@ error_code cellHttpUtilBuildHeader(vm::cptr header, vm::ptr(result.size()); } return CELL_OK; @@ -336,7 +336,7 @@ error_code cellHttpUtilBuildUri(vm::cptr uri, vm::ptr buf, u3 fmt::append(result, "%s", uri->path); } - const u32 size_needed = result.size() + 1; // Including '\0' + const u32 size_needed = ::narrow(result.size() + 1); // Including '\0' if (buf) { diff --git a/rpcs3/Emu/Cell/Modules/cellRtc.cpp b/rpcs3/Emu/Cell/Modules/cellRtc.cpp index 614a20f355..a686f549ca 100644 --- a/rpcs3/Emu/Cell/Modules/cellRtc.cpp +++ b/rpcs3/Emu/Cell/Modules/cellRtc.cpp @@ -846,7 +846,7 @@ error_code cellRtcSetTick(vm::ptr pTime, vm::cptr pTime->second = seconds; pTime->minute = minutes; pTime->hour = hours; - pTime->day = days_tmp + 1; + pTime->day = ::narrow(days_tmp + 1); pTime->month = months; pTime->year = years; @@ -1006,10 +1006,10 @@ error_code cellRtcTickAddMonths(vm::ptr pTick0, vm::cptryear * 12ULL) + date_time->month + iAdd + -1; - s32 total_months_s32 = total_months; + s32 total_months_s32 = ::narrow(total_months); u32 unk_1 = total_months_s32 >> 0x1f; u64 unk_2 = ((total_months_s32 / 6 + unk_1) >> 1) - unk_1; - u32 unk_3 = unk_2; + u32 unk_3 = ::narrow(unk_2); unk_1 = unk_3 & 0xffff; u64 unk_4 = (total_months - ((u64{unk_3} << 4) - (unk_3 << 2))) + 1; if (((unk_2 & 0xffff) == 0) || ((unk_3 = unk_4 & 0xffff, (unk_4 & 0xffff) == 0 || (0xc < unk_3)))) @@ -1036,8 +1036,8 @@ error_code cellRtcTickAddMonths(vm::ptr pTick0, vm::cptrday = month_days; } - date_time->month = unk_4; - date_time->year = unk_2; + date_time->month = ::narrow(unk_4); + date_time->year = ::narrow(unk_2); cellRtcGetTick(date_time, pTick0); return CELL_OK; @@ -1086,7 +1086,7 @@ error_code cellRtcTickAddYears(vm::ptr pTick0, vm::cptrday = month_days; } - date_time->year = total_years; + date_time->year = ::narrow(total_years); cellRtcGetTick(date_time, pTick0); return CELL_OK; diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 5fc5f349f3..82dd8cb4d1 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -3953,7 +3953,7 @@ bool spu_thread::process_mfc_cmd() if (getllar_busy_waiting_switch == umax) { // Evalute its value (shift-right to ensure its randomness with different CPUs) - getllar_busy_waiting_switch = ((perf0.get() >> 8) % 100 < g_cfg.core.spu_getllar_busy_waiting_percentage); + getllar_busy_waiting_switch = ((perf0.get() >> 8) % 100 < g_cfg.core.spu_getllar_busy_waiting_percentage) ? 1 : 0; } return !!getllar_busy_waiting_switch || getllar_spin_count < 3; @@ -3971,7 +3971,7 @@ bool spu_thread::process_mfc_cmd() last_getllar_id = mfc_cmd_id; last_gtsc = perf0.get(); - if (getllar_busy_waiting_switch == true) + if (getllar_busy_waiting_switch == 1) { busy_wait(300); } @@ -4535,7 +4535,7 @@ u32 spu_thread::get_ch_count(u32 ch) case SPU_RdSigNotify1: return ch_snr1.get_count(); case SPU_RdSigNotify2: return ch_snr2.get_count(); case MFC_RdAtomicStat: return ch_atomic_stat.get_count(); - case SPU_RdEventStat: return get_events().count; + case SPU_RdEventStat: return static_cast(get_events().count); case MFC_Cmd: return 16 - mfc_size; // Channels with a constant count of 1: diff --git a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp index 3b675adbc9..9f41f0702e 100644 --- a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp @@ -47,9 +47,9 @@ void fmt_class_string::format(std::string& out, u64 arg) struct UsbLdd { std::string name; - u16 id_vendor; - u16 id_product_min; - u16 id_product_max; + u16 id_vendor{}; + u16 id_product_min{}; + u16 id_product_max{}; }; struct UsbPipe @@ -177,7 +177,7 @@ usb_handler_thread::usb_handler_thread() if (ndev < 0) { - sys_usbd.error("Failed to get device list: %s", libusb_error_name(ndev)); + sys_usbd.error("Failed to get device list: %s", libusb_error_name(static_cast(ndev))); return; } diff --git a/rpcs3/Emu/Io/usb_device.cpp b/rpcs3/Emu/Io/usb_device.cpp index e7074c6a6b..78d1952e3a 100644 --- a/rpcs3/Emu/Io/usb_device.cpp +++ b/rpcs3/Emu/Io/usb_device.cpp @@ -245,7 +245,7 @@ u32 usb_device_emulated::get_descriptor(u8 type, u8 index, u8* buf, u32 buf_size else { const std::u16string u16str = utf8_to_utf16(strings[index - 1]); - const u8 len = std::min(u16str.size() * sizeof(u16) + 2, static_cast(0xFF)); + const u8 len = static_cast(std::min(u16str.size() * sizeof(u16) + 2, static_cast(0xFF))); buf[0] = len; expected_count = std::min(len, ::narrow(buf_size)); memcpy(buf + 2, u16str.data(), expected_count - 2); @@ -269,7 +269,7 @@ u32 usb_device_emulated::get_status(bool self_powered, bool remote_wakeup, u8* b return 0; } - const u16 device_status = self_powered | remote_wakeup << 1; + const u16 device_status = static_cast(self_powered) | static_cast(remote_wakeup) << 1; memcpy(buf, &device_status, expected_count); return expected_count; } diff --git a/rpcs3/Emu/Io/usb_device.h b/rpcs3/Emu/Io/usb_device.h index 36d6aeb580..28f04638b1 100644 --- a/rpcs3/Emu/Io/usb_device.h +++ b/rpcs3/Emu/Io/usb_device.h @@ -92,7 +92,7 @@ struct UsbTransfer s32 result = 0; u32 count = 0; - UsbDeviceIsoRequest iso_request; + UsbDeviceIsoRequest iso_request{}; std::vector setup_buf; libusb_transfer* transfer = nullptr; @@ -111,8 +111,8 @@ struct UsbTransfer // Usb descriptor helper struct UsbDescriptorNode { - u8 bLength; - u8 bDescriptorType; + u8 bLength{}; + u8 bDescriptorType{}; union { @@ -121,7 +121,7 @@ struct UsbDescriptorNode UsbDeviceInterface _interface; UsbDeviceEndpoint _endpoint; UsbDeviceHID _hid; - u8 data[0xFF]; + u8 data[0xFF]{}; }; std::vector subnodes; diff --git a/rpcs3/Emu/system_config.h b/rpcs3/Emu/system_config.h index eed37fba87..d732fa670e 100644 --- a/rpcs3/Emu/system_config.h +++ b/rpcs3/Emu/system_config.h @@ -243,7 +243,7 @@ struct cfg_root : cfg::node cfg::_bool dump_to_file{ this, "Dump to file", false, true }; cfg::_bool convert_to_s16{ this, "Convert to 16 bit", false, true }; cfg::_enum format{ this, "Audio Format", audio_format::stereo, false }; - cfg::uint<0, umax> formats{ this, "Audio Formats", static_cast(audio_format_flag::lpcm_2_48khz), false }; + cfg::uint<0, 0xFF> formats{ this, "Audio Formats", static_cast(audio_format_flag::lpcm_2_48khz), false }; cfg::string audio_device{ this, "Audio Device", "@@@default@@@", true }; cfg::_int<0, 200> volume{ this, "Master Volume", 100, true }; cfg::_bool enable_buffering{ this, "Enable Buffering", true, true }; diff --git a/rpcs3/rpcs3qt/rsx_debugger.cpp b/rpcs3/rpcs3qt/rsx_debugger.cpp index 8369b2ee98..44247de471 100644 --- a/rpcs3/rpcs3qt/rsx_debugger.cpp +++ b/rpcs3/rpcs3qt/rsx_debugger.cpp @@ -743,7 +743,7 @@ void rsx_debugger::GetBuffers() const } // Touch RSX memory to potentially flush GPU memory (must occur in named_thread) - named_thread("RSX Buffer Touch", [&]() + [[maybe_unused]] auto buffer_touch_1 = named_thread("RSX Buffer Touch"sv, [&]() { for (u32 page_start = rsx_buffer_addr & -4096; page_start < rsx_buffer_addr + src_mem_size; page_start += 4096) { @@ -781,7 +781,7 @@ void rsx_debugger::GetBuffers() const { for (u32 y = 0; y < height; y++) { - for (u32 x = pitch - 2; x != -2u; x -= 2) + for (u32 x = 0; x < std::max(pitch, 1u) - 1; x += 2) { const usz line_start = y * pitch; @@ -904,7 +904,7 @@ void rsx_debugger::GetBuffers() const } // Touch RSX memory to potentially flush GPU memory (must occur in named_thread) - named_thread("RSX Buffer Touch", [&]() + [[maybe_unused]] auto buffer_touch_2 = named_thread("RSX Buffer Touch"sv, [&]() { for (u32 page_start = rsx_buffer_addr & -4096; page_start < rsx_buffer_addr + src_mem_size; page_start += 4096) { @@ -1059,7 +1059,7 @@ void rsx_debugger::GetBuffers() const return; } - named_thread("RSX Buffer Touch", [&]() + [[maybe_unused]] auto buffer_touch_3 = named_thread("RSX Buffer Touch"sv, [&]() { // Must touch every page for (u32 i = texture_addr & -4096; i < texture_addr + src_mem_size; i += 4096) diff --git a/rpcs3/util/typeindices.hpp b/rpcs3/util/typeindices.hpp index 4f8e907362..cb9b3b2748 100644 --- a/rpcs3/util/typeindices.hpp +++ b/rpcs3/util/typeindices.hpp @@ -26,7 +26,7 @@ namespace stx u32 size = 1; u32 align = 1; u32 begin = 0; - double order; + double order{}; // Next typeinfo in linked list type_info* next = nullptr;