From f3ed26e9dbbb5aa31c7ddb5fb1f252f22bfb78a0 Mon Sep 17 00:00:00 2001 From: MSuih Date: Fri, 25 Oct 2019 13:32:21 +0300 Subject: [PATCH] Small warnings cleanup (#6671) * Ignore more warnings These are intentional * Signed/unsigned mismatch when comparing * Explictly cast values * Intentionally discard a nodiscard value * Change ppu_tid to u32 * Do not use POSIX function name on Windows * Qt: Use horizontalAdvance instead of width * Change progress variables to u32 --- Utilities/Log.cpp | 2 +- Utilities/Thread.cpp | 6 +++--- rpcs3/Crypto/lz.cpp | 8 ++++---- rpcs3/Emu/Cell/Modules/cellGcmSys.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellL10n.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellPngDec.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellSaveData.cpp | 4 ++-- rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp | 12 ++++++------ rpcs3/Emu/Cell/Modules/cellVdec.cpp | 6 +++--- rpcs3/Emu/Cell/PPUThread.cpp | 4 ++-- rpcs3/Emu/Cell/SPURecompiler.cpp | 4 ++-- rpcs3/Emu/Cell/SPUThread.cpp | 4 ++-- rpcs3/Emu/Io/usb_device.cpp | 2 +- rpcs3/Emu/System.cpp | 18 +++++++++--------- rpcs3/cmake_modules/ConfigureCompiler.cmake | 2 ++ rpcs3/rpcs3qt/qt_utils.cpp | 2 +- rpcs3/rpcs3qt/update_manager.cpp | 4 ++++ 17 files changed, 45 insertions(+), 39 deletions(-) diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index b5b755cb6b..7730575b6f 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -527,7 +527,7 @@ bool logs::file_writer::flush(u64 bufv) // Write compressed if (m_fout2 && st < m_max_size) { - m_zs.avail_in = size; + m_zs.avail_in = static_cast(size); m_zs.next_in = m_fptr + st % s_log_size; do diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 02adb603a7..cc8a1126d6 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1276,7 +1276,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) return true; } - if (vm::check_addr(addr, std::max(1, d_size), is_writing ? vm::page_writable : vm::page_readable)) + if (vm::check_addr(addr, std::max(1u, ::narrow(d_size)), is_writing ? vm::page_writable : vm::page_readable)) { if (cpu && cpu->test_stopped()) { @@ -1331,12 +1331,12 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) u64 data3; { vm::reader_lock rlock; - if (vm::check_addr(addr, std::max(1, d_size), is_writing ? vm::page_writable : vm::page_readable)) + if (vm::check_addr(addr, std::max(1u, ::narrow(d_size)), is_writing ? vm::page_writable : vm::page_readable)) { // Memory was allocated inbetween, retry return true; } - else if (vm::check_addr(addr, std::max(1, d_size))) + else if (vm::check_addr(addr, std::max(1u, ::narrow(d_size)))) { data3 = SYS_MEMORY_PAGE_FAULT_CAUSE_READ_ONLY; // TODO } diff --git a/rpcs3/Crypto/lz.cpp b/rpcs3/Crypto/lz.cpp index 3dcc9b6726..bf706eea92 100644 --- a/rpcs3/Crypto/lz.cpp +++ b/rpcs3/Crypto/lz.cpp @@ -147,7 +147,7 @@ int decompress(unsigned char *out, unsigned char *in, unsigned int size) if (code <= size) { memcpy(out, (const void *)(in + 5), code); - result = (start - out); + result = static_cast(start - out); } } else @@ -162,7 +162,7 @@ int decompress(unsigned char *out, unsigned char *in, unsigned int size) { // Adjust offset and check for stream end. if (offset > 0) offset--; - if (start == end) return (start - out); + if (start == end) return static_cast(start - out); // Locate first section. int sect = (((((((int)(start - out)) & 7) << 8) + prev) >> head) & 7) * 0xFF - 1; @@ -203,7 +203,7 @@ int decompress(unsigned char *out, unsigned char *in, unsigned int size) // Decode the data length (8 bit fields). data_length = decode_number(tmp_sect1, index, &bit_flag, &range, &code, &in); - if (data_length == 0xFF) return (start - out); // End of stream. + if (data_length == 0xFF) return static_cast(start - out); // End of stream. } else { @@ -276,7 +276,7 @@ int decompress(unsigned char *out, unsigned char *in, unsigned int size) } prev = *(start - 1); } - result = (start - out); + result = static_cast(start - out); } delete[] tmp; return result; diff --git a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp index a3525a1add..75a6b6e683 100644 --- a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp @@ -423,7 +423,7 @@ s32 _cellGcmInitBody(ppu_thread& ppu, vm::pptr context, u32 vm::var _tid; vm::var _name = vm::make_str("_gcm_intr_thread"); ppu_execute<&sys_ppu_thread_create>(ppu, +_tid, 0x10000, 0, 1, 0x4000, SYS_PPU_THREAD_CREATE_INTERRUPT, +_name); - render->intr_thread = idm::get>(*_tid); + render->intr_thread = idm::get>(static_cast(*_tid)); render->intr_thread->state -= cpu_flag::stop; render->isHLE = true; render->label_addr = gcm_cfg->gcm_info.label_addr; diff --git a/rpcs3/Emu/Cell/Modules/cellL10n.cpp b/rpcs3/Emu/Cell/Modules/cellL10n.cpp index 50d3726cf8..ea794530d5 100644 --- a/rpcs3/Emu/Cell/Modules/cellL10n.cpp +++ b/rpcs3/Emu/Cell/Modules/cellL10n.cpp @@ -1260,7 +1260,7 @@ s32 UTF16stoUTF8s(vm::cptr utf16, vm::ref utf16_len, vm::ptr utf8, const u32 max_len = utf8_len; utf8_len = 0; - for (u32 i = 0, len = 0; i < utf16_len; i++, utf8_len = len) + for (u32 i = 0, len = 0; i < static_cast(utf16_len); i++, utf8_len = len) { const u16 ch = utf16[i]; diff --git a/rpcs3/Emu/Cell/Modules/cellPngDec.cpp b/rpcs3/Emu/Cell/Modules/cellPngDec.cpp index 98e8ae905d..bce724de80 100644 --- a/rpcs3/Emu/Cell/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPngDec.cpp @@ -680,7 +680,7 @@ s32 pngDecodeData(ppu_thread& ppu, PHandle handle, PStream stream, vm::ptr d // Indicate, that the PNG decoding is stopped/failed. This is incase, we return an error code in the middle of decoding data_out_info->status = CELL_PNGDEC_DEC_STATUS_STOP; - const u32 bytes_per_line = data_control_param->outputBytesPerLine; + const u32 bytes_per_line = ::narrow(data_control_param->outputBytesPerLine); // Log this for now if (bytes_per_line < stream->out_param.outputWidthByte) diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 8da5824438..2604767043 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -909,7 +909,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v { statGet->fileNum++; - size_kbytes += (entry.size + 1023) / 1024; // firmware rounds this value up + size_kbytes += ::narrow((entry.size + 1023) / 1024); // firmware rounds this value up if (statGet->fileListNum >= setBuf->fileListMax) continue; @@ -1423,7 +1423,7 @@ static NEVER_INLINE error_code savedata_get_list_item(vm::cptr dirName, vm for (const auto& entry : fs::dir(save_path)) { - size_kbytes += (entry.size + 1023) / 1024; // firmware rounds this value up + size_kbytes += ::narrow((entry.size + 1023) / 1024); // firmware rounds this value up } *sizeKB = size_kbytes; diff --git a/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp b/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp index 133de86a44..90244bfa70 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp @@ -133,7 +133,7 @@ bool spursDma(spu_thread& spu, u32 cmd, u64 ea, u32 lsa, u32 size, u32 tag) if (cmd == MFC_GETLLAR_CMD || cmd == MFC_PUTLLC_CMD || cmd == MFC_PUTLLUC_CMD) { - const u32 rv = spu.get_ch_value(MFC_RdAtomicStat); + const u32 rv = static_cast(spu.get_ch_value(MFC_RdAtomicStat)); return cmd == MFC_PUTLLC_CMD ? !rv : true; } @@ -145,7 +145,7 @@ u32 spursDmaGetCompletionStatus(spu_thread& spu, u32 tagMask) { spu.set_ch_value(MFC_WrTagMask, tagMask); spu.set_ch_value(MFC_WrTagUpdate, MFC_TAG_UPDATE_IMMEDIATE); - return spu.get_ch_value(MFC_RdTagStat); + return static_cast(spu.get_ch_value(MFC_RdTagStat)); } // Wait for DMA operations to complete @@ -153,7 +153,7 @@ u32 spursDmaWaitForCompletion(spu_thread& spu, u32 tagMask, bool waitForAll) { spu.set_ch_value(MFC_WrTagMask, tagMask); spu.set_ch_value(MFC_WrTagUpdate, waitForAll ? MFC_TAG_UPDATE_ALL : MFC_TAG_UPDATE_ANY); - return spu.get_ch_value(MFC_RdTagStat); + return static_cast(spu.get_ch_value(MFC_RdTagStat)); } // Halt the SPU @@ -234,7 +234,7 @@ s32 sys_spu_thread_switch_system_module(spu_thread& spu, u32 status) { spu.set_ch_value(SPU_WrOutMbox, status); spu.stop_and_signal(0x120); - result = spu.get_ch_value(SPU_RdInMbox); + result = static_cast(spu.get_ch_value(SPU_RdInMbox)); } while (result == CELL_EBUSY); @@ -1709,8 +1709,8 @@ s32 spursTasketSaveTaskContext(spu_thread& spu) v128 r; spu.fpscr.Read(r); ctxt->savedContextFpscr = r; - ctxt->savedSpuWriteEventMask = spu.get_ch_value(SPU_RdEventMask); - ctxt->savedWriteTagGroupQueryMask = spu.get_ch_value(MFC_RdTagMask); + ctxt->savedSpuWriteEventMask = static_cast(spu.get_ch_value(SPU_RdEventMask)); + ctxt->savedWriteTagGroupQueryMask = static_cast(spu.get_ch_value(MFC_RdTagMask)); // Store the processor context const u32 contextSaveStorage = vm::cast(taskInfo->context_save_storage_and_alloc_ls_blocks & -0x80, HERE); diff --git a/rpcs3/Emu/Cell/Modules/cellVdec.cpp b/rpcs3/Emu/Cell/Modules/cellVdec.cpp index c871e999c5..ac9b226039 100644 --- a/rpcs3/Emu/Cell/Modules/cellVdec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVdec.cpp @@ -103,7 +103,7 @@ struct vdec_context final u32 frc_set{}; // Frame Rate Override u64 next_pts{}; u64 next_dts{}; - u64 ppu_tid{}; + u32 ppu_tid{}; std::deque out; atomic_t out_max = 60; @@ -472,7 +472,7 @@ static error_code vdecOpen(ppu_thread& ppu, T type, U res, vm::cptr ppu_execute<&sys_ppu_thread_create>(ppu, +_tid, 0x10000, vid, +res->ppuThreadPriority, +res->ppuThreadStackSize, SYS_PPU_THREAD_CREATE_INTERRUPT, +_name); *handle = vid; - const auto thrd = idm::get>(*_tid); + const auto thrd = idm::get>(static_cast(*_tid)); thrd->cmd_list ({ @@ -515,7 +515,7 @@ error_code cellVdecClose(ppu_thread& ppu, u32 handle) vdec->out_max = 0; vdec->in_cmd.push(vdec_close); - while (!atomic_storage::load(vdec->ppu_tid)) + while (!atomic_storage::load(vdec->ppu_tid)) { thread_ctrl::wait_for(1000); } diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index a14d75b2a4..7bce8f7446 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -67,8 +67,8 @@ const bool s_use_ssse3 = extern u64 get_guest_system_time(); extern atomic_t g_progr; -extern atomic_t g_progr_ptotal; -extern atomic_t g_progr_pdone; +extern atomic_t g_progr_ptotal; +extern atomic_t g_progr_pdone; enum class join_status : u32 { diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 9fd37a896f..7d61b3f451 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -17,8 +17,8 @@ #include extern atomic_t g_progr; -extern atomic_t g_progr_ptotal; -extern atomic_t g_progr_pdone; +extern atomic_t g_progr_ptotal; +extern atomic_t g_progr_pdone; const spu_decoder s_spu_itype; const spu_decoder s_spu_iname; diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 33ce476e3f..290dee4734 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -1680,7 +1680,7 @@ void spu_thread::do_mfc(bool wait) u32 fence = 0; // Process enqueued commands - std::remove_if(mfc_queue + 0, mfc_queue + mfc_size, [&](spu_mfc_cmd& args) + static_cast(std::remove_if(mfc_queue + 0, mfc_queue + mfc_size, [&](spu_mfc_cmd& args) { // Select tag bit in the tag mask or the stall mask const u32 mask = utils::rol32(1, args.tag); @@ -1753,7 +1753,7 @@ void spu_thread::do_mfc(bool wait) removed++; return true; - }); + })); mfc_size -= removed; mfc_barrier = barrier; diff --git a/rpcs3/Emu/Io/usb_device.cpp b/rpcs3/Emu/Io/usb_device.cpp index d08494e228..760418dc61 100644 --- a/rpcs3/Emu/Io/usb_device.cpp +++ b/rpcs3/Emu/Io/usb_device.cpp @@ -189,7 +189,7 @@ void usb_device_emulated::control_transfer(u8 bmRequestType, u8 bRequest, u16 wV case 0: switch (bRequest) { - case 0x09: usb_device::set_configuration(wValue); break; + case 0x09: usb_device::set_configuration(::narrow(wValue)); break; default: sys_usbd.fatal("Unhandled control transfer(0): 0x%x", bRequest); break; } break; diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 82b3b198cd..cd5ee2cbbb 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -67,10 +67,10 @@ std::mutex g_tty_mutex; // Progress display server synchronization variables atomic_t g_progr{nullptr}; -atomic_t g_progr_ftotal{0}; -atomic_t g_progr_fdone{0}; -atomic_t g_progr_ptotal{0}; -atomic_t g_progr_pdone{0}; +atomic_t g_progr_ftotal{0}; +atomic_t g_progr_fdone{0}; +atomic_t g_progr_ptotal{0}; +atomic_t g_progr_pdone{0}; template <> void fmt_class_string::format(std::string& out, u64 arg) @@ -457,10 +457,10 @@ void Emulator::Init() }); } - u64 ftotal = 0; - u64 fdone = 0; - u64 ptotal = 0; - u64 pdone = 0; + u32 ftotal = 0; + u32 fdone = 0; + u32 ptotal = 0; + u32 pdone = 0; u32 value = 0; // Update progress @@ -476,7 +476,7 @@ void Emulator::Init() // Compute new progress in percents const u32 total = ftotal + ptotal; const u32 done = fdone + pdone; - const u32 new_value = double(done) * 100. / double(total ? total : 1); + const u32 new_value = static_cast(double(done) * 100. / double(total ? total : 1)); // Compute the difference const u32 delta = new_value > value ? new_value - value : 0; diff --git a/rpcs3/cmake_modules/ConfigureCompiler.cmake b/rpcs3/cmake_modules/ConfigureCompiler.cmake index cf16248aae..e1a3ada342 100644 --- a/rpcs3/cmake_modules/ConfigureCompiler.cmake +++ b/rpcs3/cmake_modules/ConfigureCompiler.cmake @@ -9,6 +9,8 @@ if(MSVC) #TODO: Some of these could be cleaned up add_compile_options(/wd4805) # Comparing boolean and int add_compile_options(/wd4804) # Using integer operators with booleans + add_compile_options(/wd4200) # Zero-sized array in struct/union + add_link_options(/ignore:4281) # Undesirable base address 0x10000 # MSVC 2017 uses iterator as base class internally, causing a lot of warning spam set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1") diff --git a/rpcs3/rpcs3qt/qt_utils.cpp b/rpcs3/rpcs3qt/qt_utils.cpp index 5650baa23a..2fe568725b 100644 --- a/rpcs3/rpcs3qt/qt_utils.cpp +++ b/rpcs3/rpcs3qt/qt_utils.cpp @@ -171,7 +171,7 @@ namespace gui for (int i = 0; i < combo->count(); ++i) { - max_width = std::max(max_width, font_metrics.width(combo->itemText(i))); + max_width = std::max(max_width, font_metrics.horizontalAdvance(combo->itemText(i))); } if (combo->view()->minimumWidth() < max_width) diff --git a/rpcs3/rpcs3qt/update_manager.cpp b/rpcs3/rpcs3qt/update_manager.cpp index 2c9e110caf..66c0524c82 100644 --- a/rpcs3/rpcs3qt/update_manager.cpp +++ b/rpcs3/rpcs3qt/update_manager.cpp @@ -552,7 +552,11 @@ bool update_manager::handle_rpcs3(const QByteArray& rpcs3_data, bool automatic) m_progress_dialog->close(); QMessageBox::information(m_parent, tr("Auto-updater"), tr("Update successful!")); +#ifdef _WIN32 + int ret = _execl(replace_path.c_str(), replace_path.c_str(), nullptr); +#else int ret = execl(replace_path.c_str(), replace_path.c_str(), nullptr); +#endif if (ret == -1) { LOG_ERROR(GENERAL, "[Auto-updater] Relaunching failed with result: %d(%s)", ret, strerror(errno));